On Sun, May 28, 2000 at 02:44:32PM -0600, Martin D. Muggli wrote:
> 
> I'd like some comments on possible user interfaces for this.
> 
> In the initial stages, only a text interface will be available.  A user
> will type an expression exactly the way the would into MuPAD.  Then they
> will somehow tell LyX to evaluate it, and then they will be able to
> include MuPAD's results in their document.

Even if you do this in first stage, I think that you can still use the mathed
for entering the text.

> 1.  The types the expression.  Selects the expression.  Uses the copy to
> clipboard function.  Tells LyX to evaluate the clipboard.  Then when they
> use the paste from clipboard function, they would instead be pasting
> MuPAD's results instead of the expression they copied.
>
> Here are my thoughts on these:  Number 1 would probably be easier to
> implement.   Also, spawning the evalutation as a separate thread is
> planned for later stages of the development so the user can continue
> typing while MuPAD is number crunching.  It seems easier to put the
> results back into the clipboard in the background than into the buffer
> while the user is working on it. 

I think that the following suggestion would be a better UI:
The user types the formula in the mathed (1-d at first stage).
When the user invokes the 'evaluate' command, LyX will read the contents of the
formula inset, send the appropriate commands to MuPAD, and append the result
at the end of the formula inset, adding '=' before it.
(for example the inset x+x becomes x+x=2x. Furthermore, if the inset contains
'(x+y)+(x-y)=x+x' then LyX should send only 'x+x' to MuPAD, and the result
should be '(x+y)+(x-y)=x+x=2x').
Here is the general scheme for implementing this: (I'm not sure if it really
works)
To read the contents of the formula macro do
  std::ostringstream ost;
  the_inset->Ascii(ost);
  string S = ost.str();
The string S now contains the latex representation of the formula
(if the user entered the formula as 1-d then this string contains just the
concatenation of his keystrokes). Now we send "generate::TeX(" + S +");" to
MuPAD and get a result string R. The string R is a latex representation of
the result, but it may need some work to make it readable by the mathed parser
(for example, x^2 should be converted to x^{2}).
To put the result back into the inset, call to
 this_inset->READ(S+"="+T);
where READ is a new method:

void InsetFormula::READ(string const & s)
{
 std::istringstream ist(s);
 delete par; // Delete old contents of the inset
 par = new MathParInset;
 mathed_parser_file(ist, 0);
 ...
}

If you do the computation in the background, than all you need to do is make
the inset uneditable until the computation is done.
When the computation finishes, LyX should update the inset, make it editable
again, and update the display.
If the user delete the formula inset during the computation,
then the computation should be stopped.

> 2.  The user inserts a text inset of some kind (similar to a
> footnote).  Enters their expression into the inset.  Tells LyX to evaluate
> the inset.  Then LyX adds a paragraph after the inset containing the
> results.
> 
> Number 2 might be a little bit more along the lines of WYSIWYM because the
> user doesn't have to think about where they want the results in the
> document, they simply appear right after the expression.  I don't know if

The inset you should use is perhaps more similar to a tabular inset with
one column, where the odd rows contains user expressions, and the even rows
contain the result from MuPAD.

Reply via email to