wxMaxima
EditorCell.h
Go to the documentation of this file.
1 // -*- mode: c++; c-file-style: "linux"; c-basic-offset: 2; indent-tabs-mode: nil -*-
2 //
3 // Copyright (C) 2006-2015 Andrej Vodopivec <andrej.vodopivec@gmail.com>
4 // (C) 2012 Doug Ilijev <doug.ilijev@gmail.com>
5 // (C) 2014-2015 Gunter Königsmann <wxMaxima@physikbuch.de>
6 //
7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 //
22 // SPDX-License-Identifier: GPL-2.0+
23 
24 #ifndef EDITORCELL_H
25 #define EDITORCELL_H
26 
27 #include "Cell.h"
28 #include "FontAttribs.h"
29 #include "MaximaTokenizer.h"
30 #include <vector>
31 #include <list>
32 #include <unordered_map>
33 
58 class EditorCell final : public Cell
59 {
60 private:
61 #if wxUSE_ACCESSIBILITY
62  wxAccStatus GetDescription(int childId, wxString *description) const override;
63  wxAccStatus GetFocus (int *childId, Cell **child) const override;
64  wxAccStatus GetDefaultAction(int childId, wxString *actionName) const override;
65  wxAccStatus GetValue (int childId, wxString *strValue) const override;
66  wxAccStatus GetRole (int childId, wxAccRole *role) const override;
67 #endif
68 
69 public:
71  EditorCell(GroupCell *group, Configuration *config, wxString text = {});
72  EditorCell(GroupCell *group, const EditorCell &cell);
73  void UpdateSelectionString();
74  void SetSelection(size_t start, size_t end){m_selectionStart = start; m_selectionEnd = end;UpdateSelectionString();}
75  bool SelectionActive() const {return m_selectionStart != m_selectionEnd;}
76  void ClearSelection() {SelectionEnd(SelectionEnd());}
77  void SelectionStart(size_t start) {m_selectionStart = start; UpdateSelectionString();}
78  void SelectionEnd(size_t end) {m_selectionEnd = end; UpdateSelectionString();}
79  size_t SelectionStart() const {return std::min(m_selectionStart, m_text.Length());}
80  size_t SelectionEnd() const {return std::min(m_selectionEnd, m_text.Length());}
81  size_t SelectionLeft() const {return std::min(SelectionStart(), SelectionEnd());}
82  size_t SelectionRight() const {return std::max(SelectionStart(), SelectionEnd());}
83  size_t SelectionLength() const {return(SelectionEnd()-SelectionStart());}
84  void SelectionLength(size_t length) {SelectionEnd(SelectionStart() + length); UpdateSelectionString();}
85  void CursorMove(long long increment) {m_selectionEnd += increment;
86  m_selectionStart = m_selectionEnd; UpdateSelectionString();}
87  size_t CursorPosition() const {return std::min(m_selectionEnd, m_text.Length());}
88  void CursorPosition(size_t pos) {m_selectionStart = pos;
89  m_selectionEnd = pos; UpdateSelectionString();}
90  const CellTypeInfo &GetInfo() override;
91  std::unique_ptr<Cell> Copy(GroupCell *group) const override;
92 
94  // cppcheck-suppress duplInheritedMember
95  EditorCell *GetPrevious() const { return dynamic_cast<EditorCell*>(Cell::GetPrevious()); }
97  // cppcheck-suppress duplInheritedMember
98  EditorCell *GetNext() const { return dynamic_cast<EditorCell*>(Cell::GetNext()); }
99 
101  void InsertEscCommand(const wxString &txt) {
102  InsertText(InterpretEscapeString(txt));
103  }
104 
106  wxString GetFullCommandUnderCursor();
107 
109  void AddDrawParameter(wxString param);
110 
112  void AutoAnswer(bool autoAnswer){m_autoAnswer = autoAnswer;}
113 
118  void SearchStartedHere(size_t index) const;
120  void SearchStartedHere() const;
122  void MouseSelectionStartedHere() const;
124  void KeyboardSelectionStartedHere() const;
125 
127  const auto &GetWordList() const { return m_wordList; }
128 
135  static wxString TabExpand(const wxString &input_, size_t posInLine);
136 
138  static wxString EscapeHTMLChars(wxString input);
139 
141  static wxString PrependNBSP(wxString input);
142 
143  void Recalculate(AFontSize fontsize) override;
144 
145  virtual void Draw(wxPoint point, wxDC *dc, wxDC *antialiassingDC) override;
146 
148  wxString ToHTML() const;
149  wxString ToMatlab() const override;
157  wxString ToMatlab(bool dontLimitToSelection) const;
159  wxString ToRTF() const override;
160  wxString ToString() const override;
161  wxString ToString(bool dontLimitToSelection) const;
163  wxString ToTeX() const override;
165  wxString ToXML() const override;
166 
168  const wxFont &GetFont() const {
170  }
172  void SetFont(wxDC *dc) const;
173 
175  void SetForeground(wxDC *dc);
176 
181  void SetValue(const wxString &text) override;
182 
187  const wxString &GetValue() const override { return m_text; }
188 
197  void StyleText();
199  void StyleTextCode();
200  void StyleTextTexts();
201 
202  void Reset();
203 
205  void ProcessEvent(wxKeyEvent &event) override;
206 
214  bool ActivateCursor();
215 
217  void DeactivateCursor();
218 
220  size_t BeginningOfLine(size_t pos) const;
221 
223  size_t EndOfLine(size_t pos);
224 
226  bool AddEnding() override;
227 
229  void PositionToXY(size_t position, size_t *x, size_t *y);
230 
232  size_t XYToPosition(size_t x, size_t y);
233 
235  wxPoint PositionToPoint(size_t pos) override;
236  wxPoint PositionToPoint() override {return PositionToPoint(CursorPosition());}
237 
239  void SelectPointText(wxPoint point) override;
240 
242  void SelectRectText(wxPoint one, wxPoint two) override;
243 
245  wxString SelectWordUnderCaret(bool selectParens = true, bool toRight = true,
246  bool includeDoubleQuotes = false);
247 
249  bool IsPointInSelection(wxPoint point);
250 
251  bool CopyToClipboard() const override;
252 
253  bool CutToClipboard() override;
254 
255  void PasteFromClipboard(bool primary = false) override;
256 
258  size_t GetSelectionStart() const
259  { return SelectionStart(); }
260 
262  long GetSelectionEnd() const
263  { return SelectionEnd(); }
264 
266  void SelectAll() override
267  {
268  SetSelection(0, m_text.Length());
269  }
270 
272  bool AllSelected() const
273  {
274  return (SelectionStart() == 0) && (SelectionEnd() == m_text.Length());
275  }
276 
278  void SelectNone()
279  {
280  ClearSelection();
281  }
282 
283 
284  bool CanCopy() const override
285  {
286  return SelectionActive();
287  }
288 
289  bool FindMatchingQuotes();
290 
291  void FindMatchingParens();
292 
293  wxCoord GetLineWidth(size_t line, size_t pos);
294 
297  bool IsDirty() const override
298  {
299  return m_isDirty;
300  }
301 
303  void SwitchCaretDisplay() override
304  {
305  m_displayCaret = !m_displayCaret;
306  }
307 
308  void SetFocus(bool focus) override
309  {
310  m_hasFocus = focus;
311  }
312 
313  bool IsActive() const override;
314 
316  bool CaretAtStart() const
317  { return CursorPosition() == 0; }
318 
320  void CaretToStart();
321 
323  bool CaretAtEnd() const
324  { return CursorPosition() == m_text.Length(); }
325 
327  void CaretToEnd();
328 
330  void CaretToPosition(size_t pos);
331 
333  bool CanUndo() const {return m_history.CanUndo();}
334 
336  void Undo();
337 
339  bool CanRedo() const {return m_history.CanRedo();}
340 
342  void Redo();
343 
345  class History
346  {
347  public:
348  enum Action : uintptr_t {
349  any = 0,
350  removeChar = 1,
351  addChar = 2
352  };
353 
355  class HistoryEntry // 64 bytes
356  {
357  public:
358  HistoryEntry(){};
359  HistoryEntry(const wxString &text, long long selStart, long long selEnd) :
360  m_text(text), m_selStart(selStart), m_selEnd(selEnd) {}
361  long long SelectionStart() const {return m_selStart;}
362  long long SelectionEnd() const {return m_selEnd;}
363  wxString GetText() const {return m_text;}
364  private:
365  wxString m_text;
366  long long m_selStart = -1;
367  long long m_selEnd = -1;
368  };
369  bool AddState(HistoryEntry entry, Action action = any);
370  bool AddState(const wxString &text, long long selStart, long long selEnd, Action action = any);
371  bool Undo();
372  bool Redo();
373  bool CanUndo() const;
374  bool CanRedo() const;
375  void ClearUndoBuffer();
376  HistoryEntry GetState() const;
377  private:
378  std::vector<HistoryEntry> m_history;
380  size_t m_historyPosition = 0;
381  Action m_lastAction = any;
382  };
383 
385  void SaveValue(History::Action action = History::Action::any);
386 
393  wxString DivideAtCaret();
394 
395  void CommentSelection();
396 
398  bool ContainsChanges() const
399  { return m_containsChanges; }
400 
402  void ContainsChanges(bool changes)
403  { m_containsChanges = m_containsChangesCheck = changes; }
404 
405  bool CheckChanges();
406 
409  size_t ReplaceAll(wxString oldString, const wxString &newString, bool ignoreCase);
410  size_t ReplaceAll_RegEx(const wxString &oldString, const wxString &newString);
411 
422  bool FindNext(wxString str, const bool &down, const bool &ignoreCase);
423  bool FindNext_RegEx(wxString str, const bool &down);
424 
425  bool IsSelectionChanged() const { return m_selectionChanged; }
426 
427  void GetSelection(size_t *start, size_t *end) const
428  {
429  *start = SelectionStart();
430  *end = SelectionEnd();
431  }
432 
445  bool ReplaceSelection(const wxString &oldStr, const wxString &newString,
446  bool keepSelected = false, bool ignoreCase = false,
447  bool replaceMaximaString = false);
448  bool ReplaceSelection_RegEx(const wxString &oldStr, const wxString &newString);
449 
451  wxString GetSelectionString() const;
452 
455 
457  wxString GetWordUnderCaret();
458 
460  wxString GetCurrentCommand() const;
461 
463  void SetErrorIndex(size_t index){m_errorIndex = index; m_errorIndexSet = true;}
465  void ClearErrorIndex(){m_errorIndexSet = false;}
466 
467  bool ErrorIndexSet() const {return m_errorIndexSet;}
468 
469  void GotoError(){SetCaretPosition(m_errorIndex); ActivateCursor(); ClearErrorIndex();}
470 
472  void ProcessNewline(bool keepCursorAtStartOfLine = true);
473 
475  size_t GetCaretPosition() const
476  { return CursorPosition(); }
477 
480 
482  void SetCaretPosition(size_t pos){CursorPosition(pos);}
483 
484  bool FindNextTemplate(bool left = false);
485 
486  void InsertText(wxString text);
487 
488  wxString TextInFrontOfSelection() const
489  {
490  return GetValue().Mid(1, SelectionLeft());
491  }
492 
495  {
496  SetSelection(m_lastSelectionStart, 0);
497  }
498 
499  void SetType(CellType type) override;
500  void SetStyle(TextStyle style) override;
501 
502  bool NeedsRecalculation(AFontSize fontSize) const override;
503 
506  {
507  SetSelection(m_lastSelectionStart, m_text.Length());
508  }
509 
511  const MaximaTokenizer::TokenList &GetDisplayedTokens();
513  const MaximaTokenizer::TokenList &GetAllTokens();
514 
515 private:
516  size_t m_selectionStart = 0;
517  size_t m_selectionEnd = 0;
518  size_t m_lastSelectionStart = 0;
529  class StyledText
530  {
531  private:
534  wxString m_text;
536  wxString m_indentChar;
538  wxCoord m_width = -1;
540  wxCoord m_indentPixels = 0;
542  TextStyle m_style = TS_CODE_DEFAULT;
544  bool m_styleThisText = false;
545  public:
547  StyledText(TextStyle style, const wxString &text)
548  : m_text(text), m_style(style), m_styleThisText(true) {}
549 
551  explicit StyledText(const wxString &text, wxCoord indentPixels = 0,
552  const wxString &indentChar = {})
553  : m_text(text), m_indentChar(indentChar), m_indentPixels(indentPixels) {}
554 
555  void SetWidth(wxCoord width){m_width = width;}
556  void ResetSize(){SetWidth(-1);}
557  wxCoord GetWidth() const {return m_width;}
558  bool SizeKnown() const {return GetWidth() >= 0;}
560  const wxString &GetText() const { return m_text; }
562  void SetText(const wxString &text) { m_text = text; }
564  void SetIndentation(wxCoord indentPixels, const wxString &indentString = {})
565  {
566  m_indentPixels = indentPixels;
567  m_indentChar = indentString;
568  }
570  wxCoord GetIndentPixels() const { return m_indentPixels; }
571  const wxString &GetIndentChar() const { return m_indentChar; }
574  TextStyle GetTextStyle() const { return m_style; }
575  // Has an individual text style been set for this text portion?
576  bool IsStyleSet() const { return m_styleThisText; }
577  };
578 
579 #if defined __WXOSX__
580  bool HandleCtrlCommand(wxKeyEvent &ev);
581 #endif
582  bool HandleSpecialKey(wxKeyEvent &event);
583  bool HandleOrdinaryKey(wxKeyEvent &event);
584 
585  void FontsChanged() override
586  {
587  m_widths.clear();
588  }
589 
596  void HandleSoftLineBreaks_Code(StyledText *&lastSpace, wxCoord &lineWidth, const wxString &token, size_t charInCell,
597  wxString &text, const size_t &lastSpacePos, wxCoord &indentationPixels);
598 
604  size_t GetIndentDepth(wxString text, size_t positionOfCaret);
605 
612  static wxString InterpretEscapeString(const wxString &txt);
613 
615  void MarkSelection(wxDC *dc, size_t start, size_t end, TextStyle style);
616 
618  wxSize GetTextSize(const wxString &text);
619 
621  History m_history;
623  void SetState(const History::HistoryEntry &state);
625  std::vector<StyledText> &GetStyledText();
626 
627 //** Large fields
628 //**
629  typedef std::unordered_map <wxString, wxSize, wxStringHash> StringHash;
631  StringHash m_widths;
632 
634  std::vector<wxString> m_wordList;
635 
637  MaximaTokenizer::TokenList m_tokens;
639  MaximaTokenizer::TokenList m_tokens_including_hidden;
640 
643  wxString m_text;
644  std::vector<StyledText> m_styledText;
645 
646 //** 8/4 bytes
647 //**
648  CellPointers *const m_cellPointers = GetCellPointers();
649 
650 //** 4 bytes
651 //**
652  size_t m_errorIndex = 1;
653  size_t m_numberOfLines = 1;
654  wxCoord m_charHeight = 12;
655  long m_paren1 = -1, m_paren2 = -1;
656 
657 //** 2 bytes
658 //**
659  AFontStyle m_fontStyle;
660  AFontWeight m_fontWeight;
661 
662 
664  bool m_tokens_including_hidden_valid = false;
666  bool m_tokens_valid = false;
667 
668 
669 //** Bitfield objects (2 bytes)
670 //**
671  void InitBitFields_EditorCell()
672  { // Keep the initialization order below same as the order
673  // of bit fields in this class!
674  m_autoAnswer = false;
675  m_containsChanges = false;
676  m_containsChangesCheck = false;
677  m_displayCaret = false;
678  m_hasFocus = false;
679  m_isDirty = false;
680  m_selectionChanged = false;
681  m_underlined = false;
682  m_errorIndexSet = false;
683  }
684 
686  bool m_autoAnswer : 1 /* InitBitFields_EditorCell */;
688  bool m_containsChanges : 1 /* InitBitFields_EditorCell */;
689  bool m_containsChangesCheck : 1 /* InitBitFields_EditorCell */;
690  bool m_displayCaret : 1 /* InitBitFields_EditorCell */;
691  bool m_hasFocus : 1 /* InitBitFields_EditorCell */;
692  bool m_isDirty : 1 /* InitBitFields_EditorCell */;
693  bool m_errorIndexSet : 1 /* InitBitFields_EditorCell */;
695  bool m_selectionChanged : 1 /* InitBitFields_EditorCell */;
697  bool m_underlined : 1 /* InitBitFields_EditorCell */;
698 };
699 
700 #endif // EDITORCELL_H
The definition of the base class of all cells the worksheet consists of.
CellType
The supported types of math cells.
Definition: Cell.h:64
This file declares the class Maximatokenizer.
TextStyle
All text styles known to wxMaxima.
Definition: TextStyle.h:231
A Type-Safe Fixed-Point Font Size.
Definition: FontAttribs.h:98
The storage for pointers to cells.
Definition: CellPointers.h:45
A class that carries information about the type of a cell.
Definition: Cell.h:93
The base class all cell types the worksheet can consist of are derived from.
Definition: Cell.h:142
Cell * GetPrevious() const
Returns a pointer to the previous cell in the current cell list.
Definition: Cell.h:688
const TextStyle & GetTextStyle() const
Get the text style.
Definition: Cell.h:521
void ResetSize()
Mark the cached height and width information as "to be calculated".
Definition: Cell.cpp:1045
wxCoord GetLineWidth() const
How many pixels is the current line of this list of cells wide?
Definition: Cell.cpp:285
Configuration * m_configuration
A pointer to the configuration responsible for this worksheet.
Definition: Cell.h:975
int GetWidth() const
Get the width of this cell.
Definition: Cell.h:371
wxCoord m_width
The width of this cell; is recalculated by RecalculateHeight.
Definition: Cell.h:994
Cell * GetNext() const
Get the next cell in the list.
Definition: Cell.h:691
AFontSize m_fontSize_Scaled
The font size is smaller in super- and subscripts.
Definition: Cell.h:1006
The configuration storage for the current worksheet.
Definition: Configuration.h:95
const Style * GetStyle(TextStyle textStyle) const
Get the text Style for a given text style identifier.
Definition: Configuration.h:883
How an entry to the undo history looks like.
Definition: EditorCell.h:356
The undo history of this cell.
Definition: EditorCell.h:346
This class defines what the user sees as input cell.
Definition: EditorCell.h:59
void SetValue(const wxString &text) override
Sets the text that is to be displayed.
Definition: EditorCell.cpp:3293
size_t ReplaceAll(wxString oldString, const wxString &newString, bool ignoreCase)
Replaces all occurrences of a given string.
Definition: EditorCell.cpp:3348
EditorCell * GetPrevious() const
Get the previous EditorCell in the list.
Definition: EditorCell.h:95
void CaretToStart()
Move the cursor to the start of this cell.
Definition: EditorCell.cpp:3788
EditorCell(GroupCell *group, Configuration *config, wxString text={})
The constructor.
Definition: EditorCell.cpp:45
bool IsActive() const override
Is this editor cell focused?
Definition: EditorCell.cpp:2848
size_t XYToPosition(size_t x, size_t y)
Determines which index the char at the position "x chars left, y chars down" is at.
Definition: EditorCell.cpp:2271
size_t GetSelectionStart() const
Get the character position the selection has been started with.
Definition: EditorCell.h:258
void ContainsChanges(bool changes)
Set the information if this cell needs to be re-evaluated by maxima.
Definition: EditorCell.h:402
wxString ToXML() const override
Convert the current cell to XML code for inclusion in a .wxmx file.
Definition: EditorCell.cpp:491
void DeactivateCursor()
Deactivate the blinking cursor in the EditorCell it is in.
Definition: EditorCell.cpp:2178
bool NeedsRecalculation(AFontSize fontSize) const override
True, if something that affects the cell size has changed.
Definition: EditorCell.cpp:568
void CaretToEnd()
Move the cursor to the end of this cell.
Definition: EditorCell.cpp:3782
const MaximaTokenizer::TokenList & GetDisplayedTokens()
Get the list of commands, parenthesis, strings and whitespaces in a code cell.
size_t GetCaretPosition() const
Get the cursor's current position inside the cell.
Definition: EditorCell.h:475
bool CopyToClipboard() const override
Copy this cell's editable contents to the clipboard.
Definition: EditorCell.cpp:2613
wxString ToRTF() const override
Convert the current cell to RTF code.
Definition: EditorCell.cpp:306
void ClearErrorIndex()
Clears the index the error is at.
Definition: EditorCell.h:465
virtual void Draw(wxPoint point, wxDC *dc, wxDC *antialiassingDC) override
Draw this cell.
Definition: EditorCell.cpp:739
wxString DivideAtCaret()
DivideAtCaret Returns the string from caret to end and modifies the m_text so it contains only the st...
Definition: EditorCell.cpp:2479
wxString ToString() const override
Returns the cell's representation as a string.
Definition: EditorCell.cpp:254
size_t BeginningOfLine(size_t pos) const
Return the index of the 1st char of the line containing the letter pos.
Definition: EditorCell.cpp:1057
const CellTypeInfo & GetInfo() override
Returns the information about this cell's type.
wxString GetCurrentCommand() const
Get the command the cursor is in the arguments for.
Definition: EditorCell.cpp:946
bool IsDirty() const override
true, if this cell's width has to be recalculated.
Definition: EditorCell.h:297
const auto & GetWordList() const
A list of words that might be applicable to the autocomplete function.
Definition: EditorCell.h:127
void ProcessEvent(wxKeyEvent &event) override
Decide what to do if the user pressed a key when this cell was selected.
Definition: EditorCell.cpp:1137
EditorCell * GetNext() const
Get the next EditorCell in the list.
Definition: EditorCell.h:98
bool CanRedo() const
True, if a redo can be done for this cell.
Definition: EditorCell.h:339
wxString GetSelectionString() const
Convert the current selection to a string.
Definition: EditorCell.cpp:3692
static wxString TabExpand(const wxString &input_, size_t posInLine)
Expand all tabulators.
Definition: EditorCell.cpp:1011
long GetSelectionEnd() const
Get the character position the selection has been ended with.
Definition: EditorCell.h:262
void Redo()
Issu a redo command.
Definition: EditorCell.cpp:2867
void SetCaretPosition(size_t pos)
Set the cursor's current position inside the cell.
Definition: EditorCell.h:482
size_t EndOfLine(size_t pos)
Return the index of the last char of the line containing the letter #pos,.
Definition: EditorCell.cpp:1074
void SearchStartedHere() const
Remember that this is the cell the search was started in.
Definition: EditorCell.cpp:174
bool CaretAtStart() const
Is the cursor at the start of this cell?
Definition: EditorCell.h:316
void KeyboardSelectionStartedHere() const
Remember that this is the cell the keyboard selection was started in.
Definition: EditorCell.cpp:184
std::unique_ptr< Cell > Copy(GroupCell *group) const override
Create a copy of this cell.
bool ReplaceSelection(const wxString &oldStr, const wxString &newString, bool keepSelected=false, bool ignoreCase=false, bool replaceMaximaString=false)
Replace the current selection with a string.
Definition: EditorCell.cpp:3598
void SwitchCaretDisplay() override
Toggles the visibility of the cursor which is used to make it blink.
Definition: EditorCell.h:303
wxString SelectWordUnderCaret(bool selectParens=true, bool toRight=true, bool includeDoubleQuotes=false)
Selects the word the cursor is currently at.
Definition: EditorCell.cpp:2579
wxString ToTeX() const override
Convert the current cell to LaTeX code.
Definition: EditorCell.cpp:360
void SelectAll() override
Select the whole text contained in this Cell.
Definition: EditorCell.h:266
const MaximaTokenizer::TokenList & GetAllTokens()
Get the list of commands, parenthesis, strings and whitespaces including hidden ones.
Definition: EditorCell.cpp:3245
void ReturnToSelectionFromBot()
Return to the selection after the cell has been left downwards.
Definition: EditorCell.h:505
bool CanCopy() const override
Select Can we copy the editable text of this cell?
Definition: EditorCell.h:284
void SelectNone()
Unselect everything.
Definition: EditorCell.h:278
bool FindMatchingQuotes()
For a given quotation mark ("), find a matching quote.
Definition: EditorCell.cpp:2074
void AddDrawParameter(wxString param)
Add a new parameter to a draw- or similar command including the comma, if needed.
Definition: EditorCell.cpp:91
void AutoAnswer(bool autoAnswer)
May this Editor Cell contain the answer to a question?
Definition: EditorCell.h:112
const wxFont & GetFont() const
Get the font that matches this cell's formatting.
Definition: EditorCell.h:168
wxString GetWordUnderCaret()
The word the cursor currently is at.
Definition: EditorCell.cpp:2540
const wxString & GetValue() const override
Returns the text contained in this cell.
Definition: EditorCell.h:187
wxString GetFullCommandUnderCursor()
Get the whole maxima command that is currently under the cursor (including all arguments)
Definition: EditorCell.cpp:189
wxPoint PositionToPoint() override
Locates the cursor in the editable text of this cell.
Definition: EditorCell.h:236
void StyleText()
Converts m_text to a list of styled text snippets that will later be displayed by draw().
Definition: EditorCell.cpp:3264
void SelectRectText(wxPoint one, wxPoint two) override
Selects the text between the screen coordinates one and two.
Definition: EditorCell.cpp:2416
void SetErrorIndex(size_t index)
Sets the index the error is at.
Definition: EditorCell.h:463
bool AllSelected() const
Does the selection currently span the whole cell?
Definition: EditorCell.h:272
TextStyle GetSelectionStyle() const
Try to determine the selection's text style.
Definition: EditorCell.cpp:3696
void SaveValue(History::Action action=History::Action::any)
Save the current contents of this cell in the undo buffer.
Definition: EditorCell.cpp:2873
void PositionToXY(size_t position, size_t *x, size_t *y)
Determines which line and column the pos'th char is at.
Definition: EditorCell.cpp:2251
void Recalculate(AFontSize fontsize) override
Recalculate the size of the cell and the difference between top and center.
Definition: EditorCell.cpp:572
bool IsPointInSelection(wxPoint point)
Is the point point inside the currently selected text?
Definition: EditorCell.cpp:2427
void PasteFromClipboard(bool primary=false) override
Paste from the clipboard into this cell.
Definition: EditorCell.cpp:2692
void Undo()
Issue an undo command.
Definition: EditorCell.cpp:2852
void SetFont(wxDC *dc) const
Set the currently used font to the one that matches this cell's formatting.
Definition: EditorCell.cpp:920
wxString ToMatlab() const override
Convert this cell to its Matlab representation.
Definition: EditorCell.cpp:280
bool CutToClipboard() override
Cut this cell's editable contents to the clipboard.
Definition: EditorCell.cpp:2647
bool CanUndo() const
True, if there is undo information for this cell.
Definition: EditorCell.h:333
bool ActivateCursor()
Activate the blinking cursor in this cell.
Definition: EditorCell.cpp:2188
void SetStyle(TextStyle style) override
Sets the TextStyle of this cell.
Definition: EditorCell.cpp:915
void InsertEscCommand(const wxString &txt)
Insert the symbol that corresponds to the ESC command txt.
Definition: EditorCell.h:101
bool FindNext(wxString str, const bool &down, const bool &ignoreCase)
Finds the next occurrences of a string.
Definition: EditorCell.cpp:3427
void CaretToPosition(size_t pos)
Move the cursor to a certain position in the cell.
Definition: EditorCell.cpp:3794
bool ContainsChanges() const
Query if this cell needs to be re-evaluated by maxima.
Definition: EditorCell.h:398
bool AddEnding() override
Adds a ";" to the end of the last command in this cell in case that it doesn't end in $ or ;.
Definition: EditorCell.cpp:2212
void SetForeground(wxDC *dc)
Sets the current color to this cell's foreground color.
Definition: EditorCell.cpp:942
bool CaretAtEnd() const
Is the cursor at the end of this cell?
Definition: EditorCell.h:323
void SelectPointText(wxPoint point) override
Sets the cursor to the screen coordinate point.
Definition: EditorCell.cpp:2315
void StyleTextCode()
Is Called by StyleText() if this is a code cell.
Definition: EditorCell.cpp:2913
void MouseSelectionStartedHere() const
Remember that this is the cell the mouse selection was started in.
Definition: EditorCell.cpp:179
wxString ToHTML() const
Convert the current cell to HTML code.
Definition: EditorCell.cpp:638
void ProcessNewline(bool keepCursorAtStartOfLine=true)
Start a new line and optionally auto-indent it.
Definition: EditorCell.cpp:1305
void ConvertNumToUNicodeChar()
Convert a number to unicode chars.
Definition: EditorCell.cpp:533
static wxString PrependNBSP(wxString input)
Convert all but the first of a row of multiple spaces to non-breakable.
Definition: EditorCell.cpp:223
static wxString EscapeHTMLChars(wxString input)
Escape all chars that cannot be used in HTML otherwise.
Definition: EditorCell.cpp:79
void ReturnToSelectionFromTop()
Return to the selection after the cell has been left upwards.
Definition: EditorCell.h:494
void SetType(CellType type) override
Sets the text style according to the type.
Definition: EditorCell.cpp:910
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:74
This class generates a pane containing the last commands that were issued.
Definition: History.h:56
const wxFont & GetFont(AFontSize fontSize) const
Returns the font associated with this style, but with the size fontSize.
Definition: TextStyle.cpp:349