wxMaxima
Loading...
Searching...
No Matches
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
58class EditorCell : public Cell
59{
60private:
61#if wxUSE_ACCESSIBILITY
62 wxAccStatus GetName (int childId, wxString *name) const override;
63 wxAccStatus GetDescription(int childId, wxString *description) const override;
64 wxAccStatus GetFocus (int *childId, Cell **child) const override;
65 wxAccStatus GetDefaultAction(int childId, wxString *actionName) const override;
66 wxAccStatus GetValue (int childId, wxString *strValue) const override;
67 wxAccStatus GetRole (int childId, wxAccRole *role) const override;
68 wxAccStatus GetState (int childId, long *state) const override;
69#endif
70
71public:
73 EditorCell(GroupCell *group, Configuration *config, wxString text = {});
74 EditorCell(GroupCell *group, const EditorCell &cell);
75
84 static std::unique_ptr<EditorCell> Create(GroupCell *group,
85 Configuration *config, CellType type,
86 wxString text = {});
87
89 static bool IsCodeType(CellType type);
90
98 virtual bool IsCodeEditor() const { return false; }
99 void UpdateSelectionString();
100 // The selection/cursor setters clamp their argument to a valid index into the
101 // current text via ClampToText(), so m_selectionStart / m_selectionEnd are
102 // always in [0, m_text.Length()] (e.g. CursorMove(-n) past the start clamps to
103 // 0 instead of wrapping a size_t to a huge value). The getters below keep a
104 // defensive std::min as well, because the text can still shrink *after* a
105 // selection was set without the selection being updated.
106 void SetSelection(size_t start, size_t end){m_selectionStart = ClampToText(start); m_selectionEnd = ClampToText(end); UpdateSelectionString();}
107 bool SelectionActive() const {return m_selectionStart != m_selectionEnd;}
108 void ClearSelection() {SelectionEnd(SelectionEnd());}
109 void SelectionStart(size_t start) {m_selectionStart = ClampToText(start); UpdateSelectionString();}
110 void SelectionEnd(size_t end) {m_selectionEnd = ClampToText(end); UpdateSelectionString();}
111 size_t SelectionStart() const {return std::min(m_selectionStart, m_text.Length());}
112 size_t SelectionEnd() const {return std::min(m_selectionEnd, m_text.Length());}
113 size_t SelectionLeft() const {return std::min(SelectionStart(), SelectionEnd());}
114 size_t SelectionRight() const {return std::max(SelectionStart(), SelectionEnd());}
115 size_t SelectionLength() const {return(SelectionEnd()-SelectionStart());}
116 void SelectionLength(size_t length) {SelectionEnd(SelectionStart() + length); UpdateSelectionString();}
117 void CursorMove(long long increment) {m_selectionEnd = ClampToText(static_cast<long long>(m_selectionEnd) + increment);
118 m_selectionStart = m_selectionEnd; UpdateSelectionString();}
119 size_t CursorPosition() const {return std::min(m_selectionEnd, m_text.Length());}
120 void CursorPosition(size_t pos) {m_selectionStart = ClampToText(pos);
121 m_selectionEnd = m_selectionStart; UpdateSelectionString();}
122 const CellTypeInfo &GetInfo() override;
123 std::unique_ptr<Cell> Copy(GroupCell *group) const override;
124
126 // cppcheck-suppress duplInheritedMember
127 EditorCell *GetPrevious() const { return dynamic_cast<EditorCell*>(Cell::GetPrevious()); }
129 // cppcheck-suppress duplInheritedMember
130 EditorCell *GetNext() const { return dynamic_cast<EditorCell*>(Cell::GetNext()); }
131
133 void InsertEscCommand(const wxString &txt) {
134 InsertText(InterpretEscapeString(txt));
135 }
136
138 wxString GetFullCommandUnderCursor();
139
141 void AddDrawParameter(wxString param);
142
144 void AutoAnswer(bool autoAnswer){m_autoAnswer = autoAnswer;}
145
150 void SearchStartedHere(size_t index) const;
152 void SearchStartedHere() const;
154 void MouseSelectionStartedHere() const;
156 void KeyboardSelectionStartedHere() const;
157
159 const auto &GetWordList() const { return m_wordList; }
160
167 static wxString TabExpand(const wxString &input_, size_t posInLine);
168
170 static wxString EscapeHTMLChars(wxString input);
171
173 static wxString PrependNBSP(wxString input);
174
175 void Recalculate(const AFontSize fontsize) const override;
176
178 void SetCurrentPoint(wxPoint point) const override;
179 virtual void Draw(wxDC *dc, wxDC *antialiassingDC) override;
180
182 wxString ToHTML() const;
183 wxString ToMatlab() const override;
191 wxString ToMatlab(bool dontLimitToSelection) const;
193 wxString ToRTF() const override;
194 wxString ToString() const override;
195 wxString ToString(bool dontLimitToSelection) const;
197 wxString ToTeX() const override;
199 wxString ToXML() const override;
200
202 const wxFont &GetFont() const {
204 }
206 void SetFont(wxDC *dc) const;
207
209 void SetForeground(wxDC *dc);
210
215 void SetValue(const wxString &text) override;
216
221 const wxString &GetValue() const override { return m_text; }
222
231 void StyleText() const;
233 void StyleTextCode() const;
234 void StyleTextTexts() const;
235
236protected:
243 virtual void StyleTypedText() const;
244
251 virtual wxString PreprocessNewValue(const wxString &text,
252 std::size_t &cursorPos) const;
253
260 virtual wxString XMLTypeAttribute() const;
261
262public:
263 void Reset();
264
266 void ProcessEvent(wxKeyEvent &event) override;
267
275 bool ActivateCursor();
276
278 void DeactivateCursor();
279
281 size_t BeginningOfLine(size_t pos) const;
282
284 size_t EndOfLine(size_t pos);
285
287 bool AddEnding() override;
288
290 void PositionToXY(size_t position, size_t *x, size_t *y);
291
293 size_t XYToPosition(size_t x, size_t y);
294
296 wxPoint PositionToPoint(size_t pos) override;
297 wxPoint PositionToPoint() override {return PositionToPoint(CursorPosition());}
298
300 void SelectPointText(wxPoint point) override;
301
303 void SelectRectText(wxPoint one, wxPoint two) override;
304
306 wxString SelectWordUnderCaret(bool selectParens = true, bool toRight = true,
307 bool includeDoubleQuotes = false);
308
310 bool IsPointInSelection(wxPoint point);
311
312 bool CopyToClipboard() const override;
313
314 bool CutToClipboard() override;
315
316 void PasteFromClipboard(bool primary = false) override;
317
319 size_t GetSelectionStart() const
320 { return SelectionStart(); }
321
323 long GetSelectionEnd() const
324 { return SelectionEnd(); }
325
327 void SelectAll() override
328 {
329 SetSelection(0, m_text.Length());
330 }
331
333 bool AllSelected() const
334 {
335 return (SelectionStart() == 0) && (SelectionEnd() == m_text.Length());
336 }
337
340 {
341 ClearSelection();
342 }
343
344
345 bool CanCopy() const override
346 {
347 return SelectionActive();
348 }
349
350 bool FindMatchingQuotes();
351
352 void FindMatchingParens();
353
354 wxCoord GetLineWidth(size_t line, size_t pos);
355
358 bool IsDirty() const override
359 {
360 return m_isDirty;
361 }
362
364 void SwitchCaretDisplay() override
365 {
366 m_displayCaret = !m_displayCaret;
367 }
368
369 void SetFocus(bool focus) override
370 {
371 m_hasFocus = focus;
372 }
373
374 bool IsActive() const override;
375
377 bool CaretAtStart() const
378 { return CursorPosition() == 0; }
379
381 void CaretToStart();
382
384 bool CaretAtEnd() const
385 { return CursorPosition() == m_text.Length(); }
386
388 void CaretToEnd();
389
391 void CaretToPosition(size_t pos);
392
394 bool CanUndo() const {return m_history.CanUndo();}
395
397 void Undo();
398
400 bool CanRedo() const {return m_history.CanRedo();}
401
403 void Redo();
404
407 {
408 public:
409 enum Action : uintptr_t {
410 any = 0,
411 removeChar = 1,
412 addChar = 2
413 };
414
416 class HistoryEntry // 64 bytes
417 {
418 public:
419 HistoryEntry(){};
420 HistoryEntry(const wxString &text, long long selStart, long long selEnd) :
421 m_text(text), m_selStart(selStart), m_selEnd(selEnd) {}
422 long long SelectionStart() const {return m_selStart;}
423 long long SelectionEnd() const {return m_selEnd;}
424 wxString GetText() const {return m_text;}
425 private:
426 wxString m_text;
427 long long m_selStart = -1;
428 long long m_selEnd = -1;
429 };
430 bool AddState(HistoryEntry entry, Action action = any);
431 bool AddState(const wxString &text, long long selStart, long long selEnd, Action action = any);
432 bool Undo();
433 bool Redo();
434 bool CanUndo() const;
435 bool CanRedo() const;
436 void ClearUndoBuffer();
437 HistoryEntry GetState() const;
438 private:
439 std::vector<HistoryEntry> m_history;
441 size_t m_historyPosition = 0;
442 Action m_lastAction = any;
443 };
444
446 void SaveValue(History::Action action = History::Action::any);
447
454 wxString DivideAtCaret();
455
456 void CommentSelection();
457
459 bool ContainsChanges() const
460 { return m_containsChanges; }
461
463 void ContainsChanges(bool changes)
464 { m_containsChanges = m_containsChangesCheck = changes; }
465
466 bool CheckChanges();
467
470 size_t ReplaceAll(wxString oldString, const wxString &newString, bool ignoreCase);
471 size_t ReplaceAll_RegEx(const wxString &oldString, const wxString &newString);
472
483 bool FindNext(wxString str, const bool &down, const bool &ignoreCase);
484 bool FindNext_RegEx(wxString str, const bool &down);
485
486 bool IsSelectionChanged() const { return m_selectionChanged; }
487
488 void GetSelection(size_t *start, size_t *end) const
489 {
490 *start = SelectionStart();
491 *end = SelectionEnd();
492 }
493
506 bool ReplaceSelection(const wxString &oldStr, const wxString &newString,
507 bool keepSelected = false, bool ignoreCase = false,
508 bool replaceMaximaString = false);
509 bool ReplaceSelection_RegEx(const wxString &oldStr, const wxString &newString);
510
512 wxString GetSelectionString() const;
513
516
518 wxString GetWordUnderCaret();
519
521 wxString GetCurrentCommand() const;
522
524 void SetErrorIndex(size_t index){m_errorIndex = index; m_errorIndexSet = true;}
526 void ClearErrorIndex(){m_errorIndexSet = false;}
527
528 bool ErrorIndexSet() const {return m_errorIndexSet;}
529
530 void GotoError(){SetCaretPosition(m_errorIndex); ActivateCursor(); ClearErrorIndex();}
531
533 void ProcessNewline(bool keepCursorAtStartOfLine = true);
534
536 size_t GetCaretPosition() const
537 { return CursorPosition(); }
538
541
543 void SetCaretPosition(size_t pos){CursorPosition(pos);}
544
545 bool FindNextTemplate(bool left = false);
546
547 void InsertText(wxString text);
548
549 wxString TextInFrontOfSelection() const
550 {
551 return GetValue().Left(SelectionLeft());
552 }
553
556 {
557 SetSelection(m_lastSelectionStart, 0);
558 }
559
560 void SetType(CellType type) override;
561 void SetStyle(TextStyle style) override;
562
563 bool NeedsRecalculation(AFontSize fontSize) const override;
564
567 {
568 SetSelection(m_lastSelectionStart, m_text.Length());
569 }
570
572// const MaximaTokenizer::TokenList &GetDisplayedTokens() const;
574 const MaximaTokenizer::TokenList &GetAllTokens() const;
575
576private:
580 size_t ClampToText(long long pos) const {
581 if (pos < 0)
582 return 0;
583 return std::min(static_cast<size_t>(pos), m_text.Length());
584 }
585 size_t m_selectionStart = 0;
586 size_t m_selectionEnd = 0;
587 size_t m_lastSelectionStart = 0;
598 class StyledText
599 {
600 private:
603 wxString m_text;
605 TextStyle m_style = TS_CODE_DEFAULT;
607 wxString m_indentChar;
609 mutable CachedInteger<wxCoord> m_width;
611 wxCoord m_indentPixels = 0;
613 bool m_styleThisText = false;
614 public:
616 StyledText(TextStyle style, const wxString &text)
617 : m_text(text), m_style(style), m_styleThisText(true) {}
618
620 explicit StyledText(const wxString &text, TextStyle style, wxCoord indentPixels = 0,
621 const wxString &indentChar = {})
622 : m_text(text), m_style(style), m_indentChar(indentChar), m_indentPixels(indentPixels) {}
623
624 void SetWidth(wxCoord width){m_width = width;}
625 void ResetSize(){m_width.Invalidate();}
626 wxCoord GetWidth() const {return m_width;}
627 bool SizeKnown() const {return m_width.IsValid();}
629 const wxString &GetText() const { return m_text; }
631 void SetText(const wxString &text) { m_text = text; }
633 void SetIndentation(wxCoord indentPixels, const wxString &indentString = {})
634 {
635 m_indentPixels = indentPixels;
636 m_indentChar = indentString;
637 }
639 wxCoord GetIndentPixels() const { return m_indentPixels; }
640 const wxString &GetIndentChar() const { return m_indentChar; }
643 TextStyle GetTextStyle() const { return m_style; }
644 // Has an individual text style been set for this text portion?
645 bool IsStyleSet() const { return m_styleThisText; }
646 };
647
648#if defined __WXOSX__
649 bool HandleCtrlCommand(wxKeyEvent &ev);
650#endif
651 bool HandleSpecialKey(wxKeyEvent &event);
652 bool HandleOrdinaryKey(wxKeyEvent &event);
653
654 void FontsChanged() const override
655 {
656 m_widths.clear();
657 }
658
665 void HandleSoftLineBreaks_Code(StyledText *&lastSpace, wxCoord &lineWidth, const wxString &token, size_t charInCell,
666 wxString &text, const size_t &lastSpacePos, wxCoord &indentationPixels) const;
667
673 size_t GetIndentDepth(wxString text, size_t positionOfCaret) const;
674
681 static wxString InterpretEscapeString(const wxString &txt);
682
684 void MarkSelection(wxDC *dc, size_t start, size_t end, TextStyle style);
685
687 wxSize GetTextSize(const wxString &text) const;
688
690 History m_history;
692 void SetState(const History::HistoryEntry &state);
694 std::vector<StyledText> &GetStyledText();
695
696//** Large fields
697//**
698 typedef std::unordered_map <wxString, wxSize, wxStringHash> StringHash;
700 mutable StringHash m_widths;
701
703 mutable std::vector<wxString> m_wordList;
704
706 mutable MaximaTokenizer::TokenList m_tokens;
708 mutable MaximaTokenizer::TokenList m_tokens_including_hidden;
709
712 mutable wxString m_text;
713 mutable std::vector<StyledText> m_styledText;
714
715//** 8/4 bytes
716//**
717 CellPointers *const m_cellPointers = GetCellPointers();
718
719//** 4 bytes
720//**
721 size_t m_errorIndex = 1;
722 mutable size_t m_numberOfLines = 1;
723 mutable wxCoord m_charHeight = 12;
724 long m_paren1 = -1, m_paren2 = -1;
725
726//** 2 bytes
727//**
728 AFontStyle m_fontStyle;
729 AFontWeight m_fontWeight;
730
731
733 mutable bool m_tokens_including_hidden_valid = false;
735 mutable bool m_tokens_valid = false;
736
737
738//** Bitfield objects (2 bytes)
739//**
740 void InitBitFields_EditorCell()
741 { // Keep the initialization order below same as the order
742 // of bit fields in this class!
743 m_autoAnswer = false;
744 m_containsChanges = false;
745 m_containsChangesCheck = false;
746 m_displayCaret = false;
747 m_hasFocus = false;
748 m_selectionChanged = false;
749 m_underlined = false;
750 m_errorIndexSet = false;
751 }
752
754 bool m_autoAnswer : 1 /* InitBitFields_EditorCell */;
756 mutable bool m_containsChanges : 1 /* InitBitFields_EditorCell */;
757 bool m_containsChangesCheck : 1 /* InitBitFields_EditorCell */;
758 bool m_displayCaret : 1 /* InitBitFields_EditorCell */;
759 bool m_hasFocus : 1 /* InitBitFields_EditorCell */;
760 bool m_errorIndexSet : 1 /* InitBitFields_EditorCell */;
762 bool m_selectionChanged : 1 /* InitBitFields_EditorCell */;
764 bool m_underlined : 1 /* InitBitFields_EditorCell */;
765 mutable bool m_isDirty = true /* InitBitFields_EditorCell */;
766};
767
768#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:63
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:97
A cached integer value.
Definition: CachedValue.h:45
The storage for pointers to cells.
Definition: CellPointers.h:45
A class that carries information about the type of a cell.
Definition: Cell.h:92
The base class all cell types the worksheet can consist of are derived from.
Definition: Cell.h:141
Cell * GetNext() const
Get the next cell in the list.
Definition: Cell.h:737
Cell * GetPrevious() const
Returns a pointer to the previous cell in the current cell list.
Definition: Cell.h:734
wxCoord GetLineWidth() const
How many pixels is the current line of this list of cells wide?
Definition: Cell.cpp:403
Configuration * m_configuration
A pointer to the configuration responsible for this worksheet.
Definition: Cell.h:1075
virtual void SetCurrentPoint(wxPoint point) const
Pass 2: Arrangement.
Definition: Cell.cpp:499
AFontSize m_fontSize_Scaled
The font size is smaller in super- and subscripts.
Definition: Cell.h:1118
bool NeedsRecalculation() const
True, if something that affects the cell size has changed.
Definition: Cell.h:512
const TextStyle & GetTextStyle() const
Get the text style.
Definition: Cell.h:565
The configuration storage for the current worksheet.
Definition: Configuration.h:97
const Style * GetStyle(TextStyle textStyle) const
Get the text Style for a given text style identifier.
Definition: Configuration.h:963
How an entry to the undo history looks like.
Definition: EditorCell.h:417
The undo history of this cell.
Definition: EditorCell.h:407
This class defines what the user sees as input cell.
Definition: EditorCell.h:59
const MaximaTokenizer::TokenList & GetAllTokens() const
Get the list of commands, parenthesis, strings and whitespaces in a code cell.
Definition: EditorCell.cpp:3407
void SetValue(const wxString &text) override
Sets the text that is to be displayed.
Definition: EditorCell.cpp:3460
virtual wxString XMLTypeAttribute() const
The type="..." attribute ToXML() writes for this cell.
Definition: EditorCell.cpp:606
void SetCurrentPoint(wxPoint point) const override
Pass 2: Arrangement.
Definition: EditorCell.cpp:862
size_t ReplaceAll(wxString oldString, const wxString &newString, bool ignoreCase)
Replaces all occurrences of a given string.
Definition: EditorCell.cpp:3484
const wxFont & GetFont() const
Get the font that matches this cell's formatting.
Definition: EditorCell.h:202
virtual wxString PreprocessNewValue(const wxString &text, std::size_t &cursorPos) const
Transform text on its way into SetValue(); returns what to store and sets cursorPos.
Definition: EditorCell.cpp:3454
void CaretToStart()
Move the cursor to the start of this cell.
Definition: EditorCell.cpp:3917
bool IsActive() const override
Is this editor cell focused?
Definition: EditorCell.cpp:3000
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:2403
std::unique_ptr< Cell > Copy(GroupCell *group) const override
Create a copy of this cell.
size_t GetSelectionStart() const
Get the character position the selection has been started with.
Definition: EditorCell.h:319
void ContainsChanges(bool changes)
Set the information if this cell needs to be re-evaluated by maxima.
Definition: EditorCell.h:463
wxString ToXML() const override
Convert the current cell to XML code for inclusion in a .wxmx file.
Definition: EditorCell.cpp:592
void DeactivateCursor()
Deactivate the blinking cursor in the EditorCell it is in.
Definition: EditorCell.cpp:2287
void StyleTextCode() const
Is Called by StyleText() if this is a code cell.
Definition: EditorCell.cpp:3070
void CaretToEnd()
Move the cursor to the end of this cell.
Definition: EditorCell.cpp:3911
size_t GetCaretPosition() const
Get the cursor's current position inside the cell.
Definition: EditorCell.h:536
bool CopyToClipboard() const override
Copy this cell's editable contents to the clipboard.
Definition: EditorCell.cpp:2742
wxString ToRTF() const override
Convert the current cell to RTF code.
Definition: EditorCell.cpp:404
void ClearErrorIndex()
Clears the index the error is at.
Definition: EditorCell.h:526
wxString DivideAtCaret()
DivideAtCaret Returns the string from caret to end and modifies the m_text so it contains only the st...
Definition: EditorCell.cpp:2608
wxString ToString() const override
Returns the cell's representation as a string.
Definition: EditorCell.cpp:352
size_t BeginningOfLine(size_t pos) const
Return the index of the 1st char of the line containing the letter pos.
Definition: EditorCell.cpp:1176
wxString GetCurrentCommand() const
Get the command the cursor is in the arguments for.
Definition: EditorCell.cpp:1077
bool IsDirty() const override
true, if this cell's width has to be recalculated.
Definition: EditorCell.h:358
void ProcessEvent(wxKeyEvent &event) override
Decide what to do if the user pressed a key when this cell was selected.
Definition: EditorCell.cpp:1259
virtual bool IsCodeEditor() const
Does this concrete cell edit code (Maxima input) rather than prose?
Definition: EditorCell.h:98
bool CanRedo() const
True, if a redo can be done for this cell.
Definition: EditorCell.h:400
wxString GetSelectionString() const
Convert the current selection to a string.
Definition: EditorCell.cpp:3821
static wxString TabExpand(const wxString &input_, size_t posInLine)
Expand all tabulators.
Definition: EditorCell.cpp:1142
long GetSelectionEnd() const
Get the character position the selection has been ended with.
Definition: EditorCell.h:323
void Redo()
Issu a redo command.
Definition: EditorCell.cpp:3019
void SetCaretPosition(size_t pos)
Set the cursor's current position inside the cell.
Definition: EditorCell.h:543
size_t EndOfLine(size_t pos)
Return the index of the last char of the line containing the letter #pos,.
Definition: EditorCell.cpp:1192
void SearchStartedHere() const
Remember that this is the cell the search was started in.
Definition: EditorCell.cpp:273
bool CaretAtStart() const
Is the cursor at the start of this cell?
Definition: EditorCell.h:377
virtual void StyleTypedText() const
The code-vs-prose-specific half of StyleText(), chosen by the subclass.
Definition: EditorCell.cpp:3452
void KeyboardSelectionStartedHere() const
Remember that this is the cell the keyboard selection was started in.
Definition: EditorCell.cpp:283
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:3727
void SwitchCaretDisplay() override
Toggles the visibility of the cursor which is used to make it blink.
Definition: EditorCell.h:364
wxString SelectWordUnderCaret(bool selectParens=true, bool toRight=true, bool includeDoubleQuotes=false)
Selects the word the cursor is currently at.
Definition: EditorCell.cpp:2708
wxString ToTeX() const override
Convert the current cell to LaTeX code.
Definition: EditorCell.cpp:461
const wxString & GetValue() const override
Returns the text contained in this cell.
Definition: EditorCell.h:221
void SelectAll() override
Select the whole text contained in this Cell.
Definition: EditorCell.h:327
void ReturnToSelectionFromBot()
Return to the selection after the cell has been left downwards.
Definition: EditorCell.h:566
bool CanCopy() const override
Select Can we copy the editable text of this cell?
Definition: EditorCell.h:345
void SelectNone()
Unselect everything.
Definition: EditorCell.h:339
bool FindMatchingQuotes()
For a given quotation mark ("), find a matching quote.
Definition: EditorCell.cpp:2183
void AddDrawParameter(wxString param)
Add a new parameter to a draw- or similar command including the comma, if needed.
Definition: EditorCell.cpp:190
void AutoAnswer(bool autoAnswer)
May this Editor Cell contain the answer to a question?
Definition: EditorCell.h:144
void StyleText() const
Converts m_text to a list of styled text snippets that will later be displayed by draw().
Definition: EditorCell.cpp:3426
wxString GetWordUnderCaret()
The word the cursor currently is at.
Definition: EditorCell.cpp:2669
const CellTypeInfo & GetInfo() override
Returns the information about this cell's type.
wxString GetFullCommandUnderCursor()
Get the whole maxima command that is currently under the cursor (including all arguments)
Definition: EditorCell.cpp:288
wxPoint PositionToPoint() override
Locates the cursor in the editable text of this cell.
Definition: EditorCell.h:297
void SelectRectText(wxPoint one, wxPoint two) override
Selects the text between the screen coordinates one and two.
Definition: EditorCell.cpp:2547
void SetErrorIndex(size_t index)
Sets the index the error is at.
Definition: EditorCell.h:524
bool AllSelected() const
Does the selection currently span the whole cell?
Definition: EditorCell.h:333
TextStyle GetSelectionStyle() const
Try to determine the selection's text style.
Definition: EditorCell.cpp:3825
void SaveValue(History::Action action=History::Action::any)
Save the current contents of this cell in the undo buffer.
Definition: EditorCell.cpp:3030
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:2383
bool IsPointInSelection(wxPoint point)
Is the point point inside the currently selected text?
Definition: EditorCell.cpp:2558
void PasteFromClipboard(bool primary=false) override
Paste from the clipboard into this cell.
Definition: EditorCell.cpp:2824
void Undo()
Issue an undo command.
Definition: EditorCell.cpp:3004
void SetFont(wxDC *dc) const
Set the currently used font to the one that matches this cell's formatting.
Definition: EditorCell.cpp:1052
wxString ToMatlab() const override
Convert this cell to its Matlab representation.
Definition: EditorCell.cpp:378
bool CutToClipboard() override
Cut this cell's editable contents to the clipboard.
Definition: EditorCell.cpp:2776
EditorCell * GetPrevious() const
Get the previous EditorCell in the list.
Definition: EditorCell.h:127
static bool IsCodeType(CellType type)
Is type a code (Maxima-input) cell type, as opposed to text/sectioning?
Definition: EditorCell.cpp:178
bool CanUndo() const
True, if there is undo information for this cell.
Definition: EditorCell.h:394
bool ActivateCursor()
Activate the blinking cursor in this cell.
Definition: EditorCell.cpp:2297
void SetStyle(TextStyle style) override
Sets the TextStyle of this cell.
Definition: EditorCell.cpp:1047
void InsertEscCommand(const wxString &txt)
Insert the symbol that corresponds to the ESC command txt.
Definition: EditorCell.h:133
bool FindNext(wxString str, const bool &down, const bool &ignoreCase)
Finds the next occurrences of a string.
Definition: EditorCell.cpp:3563
void CaretToPosition(size_t pos)
Move the cursor to a certain position in the cell.
Definition: EditorCell.cpp:3923
bool ContainsChanges() const
Query if this cell needs to be re-evaluated by maxima.
Definition: EditorCell.h:459
EditorCell * GetNext() const
Get the next EditorCell in the list.
Definition: EditorCell.h:130
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:2329
void SetForeground(wxDC *dc)
Sets the current color to this cell's foreground color.
Definition: EditorCell.cpp:1073
bool CaretAtEnd() const
Is the cursor at the end of this cell?
Definition: EditorCell.h:384
void SelectPointText(wxPoint point) override
Sets the cursor to the screen coordinate point.
Definition: EditorCell.cpp:2447
virtual void Draw(wxDC *dc, wxDC *antialiassingDC) override
Pass 3 (Paint): Renders the cell using pre-calculated coordinates.
Definition: EditorCell.cpp:866
const auto & GetWordList() const
A list of words that might be applicable to the autocomplete function.
Definition: EditorCell.h:159
void Recalculate(const AFontSize fontsize) const override
Recalculate the size of the cell and the difference between top and center.
Definition: EditorCell.cpp:675
void MouseSelectionStartedHere() const
Remember that this is the cell the mouse selection was started in.
Definition: EditorCell.cpp:278
wxString ToHTML() const
Convert the current cell to HTML code.
Definition: EditorCell.cpp:750
static std::unique_ptr< EditorCell > Create(GroupCell *group, Configuration *config, CellType type, wxString text={})
Construct the EditorCell subtype (code vs.
Definition: EditorCell.cpp:182
void ProcessNewline(bool keepCursorAtStartOfLine=true)
Start a new line and optionally auto-indent it.
Definition: EditorCell.cpp:1430
void ConvertNumToUNicodeChar()
Convert a number to unicode chars.
Definition: EditorCell.cpp:631
static wxString PrependNBSP(wxString input)
Convert all but the first of a row of multiple spaces to non-breakable.
Definition: EditorCell.cpp:322
static wxString EscapeHTMLChars(wxString input)
Escape all chars that cannot be used in HTML otherwise.
Definition: EditorCell.cpp:84
void ReturnToSelectionFromTop()
Return to the selection after the cell has been left upwards.
Definition: EditorCell.h:555
void SetType(CellType type) override
Sets the text style according to the type.
Definition: EditorCell.cpp:1042
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:87
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:355