wxMaxima
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions
Maxima Class Reference

Interface to the Maxima process. More...

#include <Maxima.h>

Inheritance diagram for Maxima:
[legend]
Collaboration diagram for Maxima:
[legend]

Public Types

enum  EventCause {
  READ_PENDING , READ_MISC_TEXT , XML_PROMPT , XML_SUPPRESSOUTPUT ,
  XML_WXXMLSYMBOLS , XML_VARIABLES , XML_WATCH_VARIABLES_ADD , XML_STATUSBAR ,
  XML_WORKSHEET_EXPORT , XML_HTML_MANUAL_KEYWORDS , XML_MATHS , XML_TOOLONGMATHS ,
  XML_WXXML_KEY , XML_ASCIIMATH , XML_ASYNC_OUTPUT , DISCONNECTED ,
  WRITE_PENDING , WRITE_ERROR , STRING_FOR_XMLINSPECTOR , DATA_AVAILABLE
}
 

Public Member Functions

 Maxima (wxSocketBase *socket, Configuration *config)
 Construct this object when a connection is received from Maxima. The argument should be socketServer.Accept();.
 
wxSocketBase * Socket () const
 
bool IsConnected () const
 Are we connected to Maxima?
 
bool Write (const void *buffer, std::size_t length)
 Write more data to be sent to maxima.
 
bool TakeItem (MaximaItemQueue::Item &item)
 Takes the next item Maxima sent.
 
void ClearFirstPrompt ()
 Clear the first prompt state, based on what was read from maxima. This is called from prompt recognizer code in the wxMaxima class.
 
void XmlInspectorActive (bool active)
 

Static Public Member Functions

static wxString EscapeVarnameForMaxima (wxString var)
 Convert a human-readable maxima variable name to one maxima understands.
 
static wxString InvertCase (const wxString &var)
 Invert case of chars that have inverted case in lisp.
 
static wxString MaximaVarnameToLisp (const wxString &var)
 Convert a human-readable maxima variable name to one lisp understands.
 
static void SetPipeToStdErr (bool pipe)
 Tells us if the user wants all data to maxima to be copied to StdErr.
 
static void GetPipeToStdErr (bool pipe)
 Tells if the user wants all data to maxima to be copied to StdErr.
 
static bool GetPipeToStdErr ()
 

Detailed Description

Interface to the Maxima process.

Eventually this class will be the entire stand-alone Maxima interface, factored out from wxMaxima. For now, it only provides socket I/O.

It is a source of EVT_MAXIMA events, used to asynchronously decouple the I/O from the front-end. In the future, more of this class could run on a worker thread perhaps.

What it already does do is that on incoming data it creates a worker thread that splits the incoming data into known XML tags maxima sends and misc text. These items wait in a MaximaItemQueue the GUI thread takes them from (TakeItem()); a DATA_AVAILABLE event tells it when there is something to take. Errors and the end of the connection still arrive as EVT_MAXIMA events of their own.

Member Enumeration Documentation

◆ EventCause

Enumerator
READ_PENDING 

There's still pending data coming from Maxima. The Data member is empty at the moment.

READ_MISC_TEXT 

Maxima has sent non-XML text.

XML_ASCIIMATH 

Maxima has sent one complete block of ASCII-art 2D display output.

XML_ASYNC_OUTPUT 

Output from a background job, naming the cell it belongs to.

Everything else in this protocol is associated with a cell purely by when* it arrives – whichever cell is being evaluated at that moment. A background job's output arrives long after that, so it carries its own cell id instead; see Doxygen/AsyncMaximaOutput.md.

DISCONNECTED 

Maxima has disconnected (possibly because the process had died).

WRITE_PENDING 

A write to Maxima is still ongoing. We use this event to keep the traffic indicator alive.

WRITE_ERROR 

The transmission has failed - this is an unrecoverable error, most likely.

DATA_AVAILABLE 

There are items to take with TakeItem().

Only sent when the GUI has found the queue empty before; see MaximaItemQueue.

Member Function Documentation

◆ EscapeVarnameForMaxima()

wxString Maxima::EscapeVarnameForMaxima ( wxString  var)
static

Convert a human-readable maxima variable name to one maxima understands.

  • Escapes strange characters
  • but keeps a "?" at the beginning of the variable name that indicates a lisp variable.

◆ TakeItem()

bool Maxima::TakeItem ( MaximaItemQueue::Item &  item)
inline

Takes the next item Maxima sent.

GUI thread only.

Returns
false if there is none; the next item to arrive is then announced by a DATA_AVAILABLE event. Until this has returned false, no such event comes: the caller has to come back by itself. See MaximaItemQueue for why it works that way.

◆ Write()

bool Maxima::Write ( const void *  buffer,
std::size_t  length 
)

Write more data to be sent to maxima.

Parameters
bufferis the data's location, can be null if length is zero
lengthis number of bytes to be written, can be zero to resume sending any data still in the transmit buffer but unsent. This is done from the event handler and doesn't have to be cared for by the user.
Returns
true if writing was attempted, false if there's nothing else left to send.

The documentation for this class was generated from the following files: