wxMaxima
Classes | Public Member Functions | Static Public Member Functions | List of all members
EditorCell Class Referencefinal

#include <EditorCell.h>

Inheritance diagram for EditorCell:
Inheritance graph
[legend]
Collaboration diagram for EditorCell:
Collaboration graph
[legend]

Public Member Functions

 EditorCell (GroupCell *group, Configuration **config, const wxString &text={})
 The constructor.
 
 EditorCell (GroupCell *group, const EditorCell &cell)
 
const CellTypeInfoGetInfo () override
 Returns the information about this cell's type.
 
std::unique_ptr< CellCopy (GroupCell *group) const override
 
EditorCellGetPrevious () const
 Get the previous EditorCell in the list.
 
EditorCellGetNext () const
 Get the next EditorCell in the list.
 
void InsertEscCommand (const wxString &txt)
 Insert the symbol that corresponds to the ESC command txt.
 
wxString GetFullCommandUnderCursor ()
 Get the whole maxima command that is currently under the cursor (including all arguments)
 
void AddDrawParameter (wxString param)
 Add a new parameter to a draw- or similar command including the comma, if needed.
 
void AutoAnswer (bool autoAnswer)
 May this Editor Cell contain the answer to a question?
 
void SearchStartedHere (int index) const
 
void SearchStartedHere () const
 Remember that this is the cell the search was started in.
 
void MouseSelectionStartedHere () const
 Remember that this is the cell the mouse selection was started in.
 
void KeyboardSelectionStartedHere () const
 Remember that this is the cell the keyboard selection was started in.
 
const auto & GetWordList () const
 A list of words that might be applicable to the autocomplete function.
 
void Recalculate (AFontSize fontsize) override
 
virtual void Draw (wxPoint point) override
 
wxString ToHTML () const
 Convert the current cell to HTML code.
 
wxString ToMatlab () const override
 Convert this cell to its Matlab representation.
 
wxString ToMatlab (bool dontLimitToSelection) const
 Convert the current cell to Matlab code. More...
 
wxString ToRTF () const override
 Convert the current cell to RTF code.
 
wxString ToString () const override
 Returns the cell's representation as a string.
 
wxString ToString (bool dontLimitToSelection) const
 
wxString ToTeX () const override
 Convert the current cell to LaTeX code.
 
wxString ToXML () const override
 Convert the current cell to XML code for inclusion in a .wxmx file.
 
void SetFont ()
 Set the currently used font to the one that matches this cell's formatting.
 
void SetForeground ()
 Sets the current color to this cell's foreground color.
 
void SetValue (const wxString &text) override
 
const wxString & GetValue () const override
 
void StyleText ()
 
void StyleTextCode ()
 
void StyleTextTexts ()
 
void Reset ()
 
void ProcessEvent (wxKeyEvent &event) override
 Decide what to do if the user pressed a key when this cell was selected.
 
void ActivateCursor ()
 
void DeactivateCursor ()
 Deactivate the blinking cursor in the EditorCell it is in.
 
size_t BeginningOfLine (long pos) const
 Return the index of the 1st char of the line containing the letter pos.
 
size_t EndOfLine (long pos)
 Return the index of the last char of the line containing the letter #pos,.
 
bool AddEnding () override
 Adds a ";" to the end of the last command in this cell in case that it doesn't end in $ or ;.
 
void PositionToXY (int position, unsigned int *x, unsigned int *y)
 Determines which line and column the pos'th char is at.
 
int XYToPosition (int x, int y)
 Determines which index the char at the position "x chars left, y chars down" is at.
 
wxPoint PositionToPoint (int pos=-1) override
 The screen coordinates of the cursor.
 
void SelectPointText (wxPoint point) override
 Sets the cursor to the screen coordinate point.
 
void SelectRectText (wxPoint one, wxPoint two) override
 Selects the text between the screen coordinates one and two.
 
wxString SelectWordUnderCaret (bool selectParens=true, bool toRight=true, bool includeDoubleQuotes=false)
 Selects the word the cursor is currently at.
 
bool IsPointInSelection (wxPoint point)
 Is the point point inside the currently selected text?
 
bool CopyToClipboard () const override
 
bool CutToClipboard () override
 
void PasteFromClipboard (bool primary=false) override
 
int GetSelectionStart () const
 Get the character position the selection has been started with.
 
int GetSelectionEnd () const
 Get the character position the selection has been ended with.
 
void SelectAll () override
 Select the whole text contained in this Cell.
 
bool AllSelected () const
 Does the selection currently span the whole cell?
 
void SelectNone ()
 Unselect everything.
 
bool SelectionActive () const
 Is there any text selected right now?
 
bool CanCopy () const override
 
bool FindMatchingQuotes ()
 
void FindMatchingParens ()
 
int GetLineWidth (unsigned int line, int pos)
 
bool IsDirty () const override
 true, if this cell's width has to be recalculated.
 
void SwitchCaretDisplay () override
 Toggles the visibility of the cursor which is used to make it blink.
 
void SetFocus (bool focus) override
 
void SetFirstLineOnly (bool show=true)
 
bool IsActive () const override
 
bool CaretAtStart () const
 Is the cursor at the start of this cell?
 
void CaretToStart ()
 Move the cursor to the start of this cell.
 
bool CaretAtEnd () const
 Is the cursor at the end of this cell?
 
void CaretToEnd ()
 Move the cursor to the end of this cell.
 
void CaretToPosition (int pos)
 Move the cursor to a certain position in the cell.
 
bool CanUndo () const
 True, if there is undo information for this cell.
 
void Undo ()
 Issue an undo command.
 
bool CanRedo () const
 True, if a redo can be done for this cell.
 
void Redo ()
 Issu a redo command.
 
void SaveValue ()
 Save the current contents of this cell in the undo buffer.
 
wxString DivideAtCaret ()
 
void CommentSelection ()
 
void ClearUndo ()
 
bool ContainsChanges () const
 Query if this cell needs to be re-evaluated by maxima.
 
void ContainsChanges (bool changes)
 Set the information if this cell needs to be re-evaluated by maxima.
 
bool CheckChanges ()
 
int ReplaceAll (wxString oldString, const wxString &newString, bool ignoreCase)
 
bool FindNext (wxString str, const bool &down, const bool &ignoreCase)
 
bool IsSelectionChanged () const
 
void SetSelection (int start, int end)
 
void GetSelection (int *start, int *end) const
 
bool ReplaceSelection (const wxString &oldStr, const wxString &newString, bool keepSelected=false, bool ignoreCase=false, bool replaceMaximaString=false)
 
wxString GetSelectionString () const
 Convert the current selection to a string.
 
wxString GetWordUnderCaret ()
 The word the cursor currently is at.
 
wxString GetCurrentCommand ()
 Get the command the cursor is in the arguments for.
 
void ClearSelection ()
 Unselect everything.
 
void SetErrorIndex (int index)
 Sets the index the error is at.
 
bool ErrorIndexSet () const
 
void GotoError ()
 
void ProcessNewline (bool keepCursorAtStartOfLine=true)
 Start a new line and optionally auto-indent it.
 
int GetCaretPosition () const
 Get the cursor's current position inside the cell.
 
void ConvertNumToUNicodeChar ()
 Convert a number to unicode chars.
 
void SetCaretPosition (int pos)
 Set the cursor's current position inside the cell.
 
bool FindNextTemplate (bool left=false)
 
void InsertText (wxString text)
 
wxString TextInFrontOfSelection () const
 
void ReturnToSelectionFromTop ()
 Return to the selection after the cell has been left upwards.
 
void SetType (CellType type) override
 Sets the text style according to the type.
 
void SetStyle (TextStyle style) override
 Sets the TextStyle of this cell.
 
bool NeedsRecalculation (AFontSize fontSize) const override
 True, if something that affects the cell size has changed.
 
void ReturnToSelectionFromBot ()
 Return to the selection after the cell has been left downwards.
 
const MaximaTokenizer::TokenList & GetTokens () const
 Get the list of commands, parenthesis, strings and whitespaces in a code cell.
 
- Public Member Functions inherited from Cell
 Cell (GroupCell *group, Configuration **config)
 
int Scale_Px (double px) const
 
AFontSize Scale_Px (AFontSize size) const
 
virtual const wxString & GetToolTip (wxPoint point) const
 
virtual ~Cell ()
 Delete this list of cells.
 
int CellsInListRecursive () const
 How many cells does this cell contain? More...
 
wxRect CropToUpdateRegion (wxRect rect) const
 The part of the rectangle rect that is in the region that is currently drawn.
 
bool InUpdateRegion () const
 Is this cell inside the region that is currently drawn?
 
bool SoftLineBreak (bool breakLine=true)
 Do we want this cell to start with a linebreak?
 
bool BreakLineHere () const
 Are we allowed to break a line here?
 
bool HasHardLineBreak () const
 Does this cell begin with a manual linebreak?
 
virtual bool BreakUp ()
 
bool ContainsRect (const wxRect &sm, bool all=true) const
 
bool ContainsPoint (wxPoint point) const
 
virtual void ClearCache ()
 
void ClearCacheList ()
 
void SetConfigurationList (Configuration **config)
 
virtual void SetConfiguration (Configuration **config)
 
ConfigurationGetConfiguration ()
 
void Draw ()
 
void DrawList (wxPoint point)
 
void DrawList ()
 
virtual void DrawBoundingBox (wxDC &WXUNUSED(dc), bool all=false)
 
bool DrawThisCell (wxPoint point)
 
bool DrawThisCell ()
 
void ForceBreakLine (bool force=true)
 
int GetHeight () const
 
int GetWidth () const
 
int GetCenter () const
 
bool HasValidSize () const
 Is the size valid and not pending a recalculation?
 
bool HasStaleSize () const
 Is the size valid, whether a recalculation is pending or not?
 
bool HasValidPosition () const
 Is the position valid?
 
int GetDrop () const
 
CellType GetType () const
 
int GetMaxDrop () const
 
int GetCenterList () const
 
int GetHeightList () const
 
int GetFullWidth () const
 How many pixels is this list of cells wide, if we don't break it into lines?
 
int GetLineWidth () const
 
int GetCurrentX () const
 
int GetCurrentY () const
 
virtual wxRect GetRect (bool all=false) const
 
virtual wxString GetDiffPart () const
 
void RecalculateList (AFontSize fontsize)
 
void FontsChangedList ()
 Tell a whole list of cells that their fonts have changed.
 
void ClearNeedsToRecalculateWidths ()
 
void ResetData ()
 Mark all cached size information as "to be calculated". More...
 
void ResetDataList ()
 
void ResetSize ()
 Mark the cached height and width information as "to be calculated".
 
void ResetCellListSizes ()
 Mark the line and cell list widths and heights as "to be calculated".
 
void ResetCellListSizesList ()
 Mark the line and cell list widths and heights as "to be calculated".
 
void SetZeroSize ()
 
void ResetSizeList ()
 Mark the cached height information of the whole list of cells as "to be calculated".
 
void SetBigSkip (bool skip)
 
bool HasBigSkip () const
 
TextStyle GetStyle () const
 
void SetPen (double lineWidth=1.0) const
 Sets the drawing pen to the cell's default foreground color.
 
void SetBrush () const
 Sets the fill brush to the cell's default foreground color.
 
wxColour GetForegroundColor () const
 
void SetHighlight (bool highlight)
 Mark this cell as highlighted (e.G. being in a maxima box)
 
bool GetHighlight () const
 Is this cell highlighted (e.G. inside a maxima box)
 
virtual void SetExponentFlag ()
 
virtual void SetValue (const wxString &WXUNUSED(text))
 
Cellfirst () const
 Get the first cell in this list of cells.
 
Celllast () const
 Get the last cell in this list of cells.
 
Range GetCellsInRect (const wxRect &rect) const
 
Range GetListCellsInRect (const wxRect &rect) const
 
virtual Range GetInnerCellsInRect (const wxRect &rect) const
 Select the cells inside this cell described by the rectangle rect.
 
virtual bool IsOperator () const
 Is this cell an operator?
 
bool IsCompound () const
 Do we have an operator in this line - draw () in frac...
 
virtual bool IsShortNum () const
 
GroupCellGetGroup () const
 Returns the group cell this cell belongs to.
 
virtual wxString ListToString () const
 Returns the list's representation as a string.
 
wxString VariablesAndFunctionsList () const
 
virtual wxString ListToMatlab () const
 Convert this list to its LaTeX representation.
 
virtual wxString ListToTeX () const
 Convert this list to its LaTeX representation.
 
virtual wxString ListToXML () const
 Convert this list to a representation fit for saving in a .wxmx file.
 
virtual wxString ListToMathML (bool startofline=false) const
 Convert this list to a MathML representation.
 
virtual wxString ListToOMML (bool startofline=false) const
 Convert this list to an OMML representation.
 
virtual wxString ListToRTF (bool startofline=false) const
 Convert this list to an RTF representation.
 
virtual wxString ToOMML () const
 
virtual wxString ToMathML () const
 Convert this cell to a representation fit for saving in a .wxmx file.
 
virtual void Unbreak ()
 
virtual void UnbreakList ()
 
CellGetPrevious () const
 
CellGetNext () const
 Get the next cell in the list.
 
CellGetNextToDraw () const
 
virtual void SetNextToDraw (Cell *next)
 
template<typename T , typename Del , typename std::enable_if< std::is_base_of< Cell, T >::value, bool >::type = true>
void SetNextToDraw (const std::unique_ptr< T, Del > &ptr)
 
bool IsComment () const
 
bool IsHidden () const
 
virtual void Hide (bool hide=true)
 
bool IsEditable (bool input=false) const
 
virtual bool CanPopOut () const
 Can this cell be popped out interactively in gnuplot?
 
virtual wxString GnuplotSource () const
 
virtual void ProcessEvent (wxKeyEvent &WXUNUSED(event))
 Processes a key event.
 
virtual wxPoint PositionToPoint (int WXUNUSED(pos)=-1)
 
virtual void SetFocus (bool WXUNUSED(focus))
 
void SetForeground ()
 Sets the foreground color.
 
bool IsMath () const
 Is this cell possibly output of maxima?
 
virtual int GetImageBorderWidth () const
 0 for ordinary cells, 1 for slide shows and diagrams displayed with a 1-pixel border
 
void CopyCommonData (const Cell &cell)
 Copy common data (used when copying a cell)
 
std::unique_ptr< CellCopyList (GroupCell *group) const
 Return a copy of the list of cells beginning with this one.
 
void ClearToolTip ()
 Remove this cell's tooltip.
 
void SetToolTip (wxString &&toolTip)
 Set the tooltip to a given temporary string - the cell will move from it.
 
void SetToolTip (const wxString *tooltip)
 
void AddToolTip (const wxString &tip)
 Add another tooltip to this cell.
 
virtual void SetCurrentPoint (wxPoint point)
 Tells this cell where it is placed on the worksheet.
 
void SetCurrentPoint (int x, int y)
 Tells this cell where it is placed on the worksheet.
 
wxPoint GetCurrentPoint () const
 Where is this cell placed on the worksheet?
 
bool IsBrokenIntoLines () const
 
bool GetSuppressMultiplicationDot () const
 
void SetSuppressMultiplicationDot (bool val)
 
bool GetHidableMultSign () const
 Whether this is a hidable multiplication sign.
 
void SetHidableMultSign (bool val)
 
virtual void SetAltCopyText (const wxString &text)
 
virtual const wxString & GetAltCopyText () const
 Get the text set using SetAltCopyText - may be empty.
 
const wxString & GetLocalToolTip () const
 
- Public Member Functions inherited from Observed
bool IsNull () const
 
bool HasControlBlock () const
 
bool HasOneCellPtr () const
 

Static Public Member Functions

static wxString TabExpand (const wxString &input, long posInLine)
 
static wxString EscapeHTMLChars (wxString input)
 Escape all chars that cannot be used in HTML otherwise.
 
static wxString PrependNBSP (wxString input)
 Convert all but the first of a row of multiple spaces to non-breakable.
 
- Static Public Member Functions inherited from Cell
static wxString OMML2RTF (wxXmlNode *node)
 Converts an OMML tag to the corresponding RTF snippet.
 
static wxString OMML2RTF (wxString ommltext)
 Converts OMML math to RTF math.
 
static wxString RTFescape (wxString, bool MarkDown=false)
 Escape a string for RTF.
 
static wxString XMLescape (wxString)
 Escape a string for XML.
 
static std::unique_ptr< CellCopyList (GroupCell *group, const Cell *cell)
 Return a copy of the given list of cells.
 
static std::unique_ptr< CellMakeVisiblyInvalidCell (GroupCell *group, Configuration **config)
 
- Static Public Member Functions inherited from Observed
static size_t GetLiveInstanceCount ()
 
static size_t GetLiveControlBlockInstanceCount ()
 

Additional Inherited Members

- Protected Member Functions inherited from Cell
void BreakUpAndMark ()
 Break up the internal cells of this cell, and mark it as broken up.
 
std::unique_ptr< CellMakeVisiblyInvalidCell () const
 
virtual int GetInnerCellCount () const
 The number of inner cells - for use by the iterators.
 
virtual CellGetInnerCell (int index) const
 
WorksheetGetWorksheet () const
 
CellPointersGetCellPointers () const
 
void InvalidateMaxDrop ()
 
- Protected Attributes inherited from Cell
wxPoint m_currentPoint {-1, -1}
 
CellPtr< GroupCellm_group
 
CellPtr< Cellm_nextToDraw
 
Configuration ** m_configuration
 
const wxString * m_toolTip
 
int m_height = -1
 The height of this cell.
 
int m_width = -1
 The width of this cell; is recalculated by RecalculateHeight.
 
int m_center = -1
 
AFontSize m_fontSize_Scaled = {}
 The font size is smaller in super- and subscripts.
 
CellType m_type = MC_TYPE_DEFAULT
 
TextStyle m_textStyle = TS_DEFAULT
 

Detailed Description

This class defines what the user sees as input cell

This class handles input cells including:

Since Unicode doesn't provide us with a "soft linebreak" letter we use \r as a marker that this line has to be broken here if we don't want it to extend beyond the right margin of the screen.

In a few places we use wxString::const_iterator instead of accessing individual letters within the string using the [] operator. This might look overly complicated. But in UTF-8 all non-standard-ASCII-characters use more than one byte making iterating over every single char of the string the only way of determining which address char n is at. An iterator is the only way of not having to determine the address of every single char independently.

Todo:
Draw only tokens that are in the redraw region.

Member Function Documentation

◆ ActivateCursor()

void EditorCell::ActivateCursor ( )

Activate the blinking cursor in this cell

Automatically calls DeactivateCursor on an eventual cell the cursor currently is in. Normally Mathctrl::SetActiveCell() is used in order to get this function called.

◆ Copy()

std::unique_ptr<Cell> EditorCell::Copy ( GroupCell group) const
overridevirtual

Create a copy of this cell

This method is purely virtual, which means every child class has to define its own Copy() method.

Implements Cell.

◆ DivideAtCaret()

wxString EditorCell::DivideAtCaret ( )

DivideAtCaret Returns the string from caret to end and modifies the m_text so it contains only the string from beginning to caret Used for 'Divide Cell', called from MathCtrl

◆ Draw()

void EditorCell::Draw ( wxPoint  point)
overridevirtual

Draw this cell

Parameters
pointThe x and y position this cell is drawn at: All top-level cells get their position during recalculation. But for the cells within them the position needs a second step after determining the dimension of the contents of the top-level cell.

Example: The position of the denominator of a fraction can only be determined after the height of denominator and numerator are known.

Draw this cell to dc

To make this work each derived class must draw the content of the cell and then call MathCall::Draw(...).

Reimplemented from Cell.

◆ FindMatchingQuotes()

bool EditorCell::FindMatchingQuotes ( )

For a given quotation mark ("), find a matching quote. Since there are no nested quotes, an odd-numbered, non-escaped quote is an opening quote, and an even-numbered non-escaped quote is a closing quote.

Returns
true if matching quotation marks were found; false otherwise

◆ FindNext()

bool EditorCell::FindNext ( wxString  str,
const bool &  down,
const bool &  ignoreCase 
)

Finds the next occurrences of a string

Parameters
strThe string to search for
down
  • true: search downwards
  • false: search upwards
ignoreCase
  • true: Case-insensitive search
  • false: Case-sensitive search

◆ GetValue()

const wxString& EditorCell::GetValue ( ) const
inlineoverridevirtual

Returns the text contained in this cell

Naturally all soft line breaks are converted back to spaces beforehand.

Reimplemented from Cell.

◆ Recalculate()

void EditorCell::Recalculate ( AFontSize  fontsize)
overridevirtual

Recalculate the size of the cell and the difference between top and center

Must set: m_height, m_width, m_center.

Parameters
fontsizeIn exponents, super- and subscripts the font size is reduced. This cell therefore needs to know which font size it has to be drawn at.

Reimplemented from Cell.

◆ ReplaceAll()

int EditorCell::ReplaceAll ( wxString  oldString,
const wxString &  newString,
bool  ignoreCase 
)

Replaces all occurrences of a given string

◆ ReplaceSelection()

bool EditorCell::ReplaceSelection ( const wxString &  oldStr,
const wxString &  newString,
bool  keepSelected = false,
bool  ignoreCase = false,
bool  replaceMaximaString = false 
)

Replace the current selection with a string

Parameters
oldStrThe old string in the selection. If this string doesn't match the selection this function doesn't replace it.
newStringThe new string oldStr has to be replaced by
keepSelected
  • true = we want the new string to be selected afterwards
  • false = the selection is cleared after replacing the string and moving the cursor to its end.
ignoreCasetrue = ignore the case of the string to replace
replaceMaximaStringtrue = replace strings including the double quotes.

◆ SearchStartedHere()

void EditorCell::SearchStartedHere ( int  index) const

Remember that this is the cell the search was started in.

Parameters
indexThe index of the character the search was started at.

◆ SetValue()

void EditorCell::SetValue ( const wxString &  text)
override

Sets the text that is to be displayed.

Automatically calls StyleText().

◆ StyleText()

void EditorCell::StyleText ( )

Converts m_text to a list of styled text snippets that will later be displayed by draw().

This function also generates a wordlist for this EditorCell so Autocompletion can learn about variable names contained in lists or cells that still haven't been evaluated.

For cells containing text instead of code this function adds a \r as a marker that this line is to be broken here until the window's width changes.

◆ StyleTextCode()

void EditorCell::StyleTextCode ( )

Is Called by StyleText() if this is a code cell

◆ TabExpand()

wxString EditorCell::TabExpand ( const wxString &  input,
long  posInLine 
)
static

Expand all tabulators.

Parameters
inputThe string the tabulators should be expanded in
posInLineThe number of characters that come before the input in the same line
Todo:
Implement the actual TAB expansion

◆ ToMatlab()

wxString EditorCell::ToMatlab ( bool  dontLimitToSelection) const

Convert the current cell to Matlab code.

Convert the current cell to a string

Parameters
dontLimitToSelection
  • false: If text is selected return only the selected text
  • true: Always return all text in this text cell

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