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 <algorithm>
32#include <list>
33#include <unordered_map>
34
35struct BidiRun;
36
61class EditorCell : public Cell
62{
63private:
64#if wxUSE_ACCESSIBILITY
65 wxAccStatus GetName (int childId, wxString *name) const override;
66 wxAccStatus GetDescription(int childId, wxString *description) const override;
67 wxAccStatus GetFocus (int *childId, Cell **child) const override;
68 wxAccStatus GetDefaultAction(int childId, wxString *actionName) const override;
69 wxAccStatus GetValue (int childId, wxString *strValue) const override;
70 wxAccStatus GetRole (int childId, wxAccRole *role) const override;
71 wxAccStatus GetState (int childId, long *state) const override;
72#endif
73
74public:
76 EditorCell(GroupCell *group, Configuration *config, wxString text = {});
77 EditorCell(GroupCell *group, const EditorCell &cell);
78
87 static std::unique_ptr<EditorCell> Create(GroupCell *group,
88 Configuration *config, CellType type,
89 wxString text = {});
90
92 static bool IsCodeType(CellType type);
93
101 virtual bool IsCodeEditor() const { return false; }
102 void UpdateSelectionString();
103 // The selection/cursor setters clamp their argument to a valid index into the
104 // current text via ClampToText(), so m_selectionStart / m_selectionEnd are
105 // always in [0, m_text.Length()] (e.g. CursorMove(-n) past the start clamps to
106 // 0 instead of wrapping a size_t to a huge value). The getters below keep a
107 // defensive std::min as well, because the text can still shrink *after* a
108 // selection was set without the selection being updated.
109 void SetSelection(size_t start, size_t end){m_selectionStart = ClampToText(start); m_selectionEnd = ClampToText(end); UpdateSelectionString();}
110 bool SelectionActive() const {return m_selectionStart != m_selectionEnd;}
111 void ClearSelection() {SelectionEnd(SelectionEnd());}
112 void SelectionStart(size_t start) {m_selectionStart = ClampToText(start); UpdateSelectionString();}
113 void SelectionEnd(size_t end) {m_selectionEnd = ClampToText(end); UpdateSelectionString();}
114 size_t SelectionStart() const {return std::min(m_selectionStart, m_text.Length());}
115 size_t SelectionEnd() const {return std::min(m_selectionEnd, m_text.Length());}
116 size_t SelectionLeft() const {return std::min(SelectionStart(), SelectionEnd());}
117 size_t SelectionRight() const {return std::max(SelectionStart(), SelectionEnd());}
118 size_t SelectionLength() const {return(SelectionEnd()-SelectionStart());}
119 void SelectionLength(size_t length) {SelectionEnd(SelectionStart() + length); UpdateSelectionString();}
120 void CursorMove(long long increment) {m_selectionEnd = ClampToText(static_cast<long long>(m_selectionEnd) + increment);
121 m_selectionStart = m_selectionEnd; UpdateSelectionString();}
122 size_t CursorPosition() const {return std::min(m_selectionEnd, m_text.Length());}
123 void CursorPosition(size_t pos) {m_selectionStart = ClampToText(pos);
124 m_selectionEnd = m_selectionStart; UpdateSelectionString();}
125 const CellTypeInfo &GetInfo() override;
126 std::unique_ptr<Cell> Copy(GroupCell *group) const override;
127
129 // cppcheck-suppress duplInheritedMember
130 EditorCell *GetPrevious() const { return dynamic_cast<EditorCell*>(Cell::GetPrevious()); }
132 // cppcheck-suppress duplInheritedMember
133 EditorCell *GetNext() const { return dynamic_cast<EditorCell*>(Cell::GetNext()); }
134
136 void InsertEscCommand(const wxString &txt) {
137 InsertText(InterpretEscapeString(txt));
138 }
139
141 wxString GetFullCommandUnderCursor();
142
144 void AddDrawParameter(wxString param);
145
147 void AutoAnswer(bool autoAnswer){m_autoAnswer = autoAnswer;}
148
153 void SearchStartedHere(size_t index) const;
155 void SearchStartedHere() const;
157 void MouseSelectionStartedHere() const;
159 void KeyboardSelectionStartedHere() const;
160
162 const auto &GetWordList() const { return m_wordList; }
163
171 static wxString NormalizeLineEndings(const wxString &input_);
172
174 static wxString EscapeHTMLChars(wxString input);
175
177 static wxString PrependNBSP(wxString input);
178
179 void Recalculate(const AFontSize fontsize) const override;
180
182 void SetCurrentPoint(wxPoint point) const override;
183 virtual void Draw(wxDC *dc, wxDC *antialiassingDC) override;
184
186 wxString ToHTML() const;
187 wxString ToMatlab() const override;
195 wxString ToMatlab(bool dontLimitToSelection) const;
197 wxString ToRTF() const override;
198 wxString ToString() const override;
199 wxString ToString(bool dontLimitToSelection) const;
201 wxString ToTeX() const override;
203 wxString ToXML() const override;
204
206 const wxFont &GetFont() const {
208 }
210 void SetFont(wxDC *dc) const;
211
213 void SetForeground(wxDC *dc);
214
219 void SetValue(const wxString &text) override;
220
225 const wxString &GetValue() const override { return m_text; }
226
234 const std::vector<std::size_t> &GetSoftBreaks() const { return m_softBreaks; }
235
246 void SetDiffHighlights(std::vector<std::pair<std::size_t, std::size_t>> ranges) {
247 m_diffHighlights = std::move(ranges);
248 m_diffHighlightsTextLength = m_text.Length();
249 }
251 const std::vector<std::pair<std::size_t, std::size_t>> &GetDiffHighlights() const {
252 return m_diffHighlights;
253 }
254
263 void StyleText() const;
265 void StyleTextCode() const;
266 void StyleTextTexts() const;
267
268protected:
275 virtual void StyleTypedText() const;
276
283 virtual wxString PreprocessNewValue(const wxString &text,
284 std::size_t &cursorPos) const;
285
292 virtual wxString XMLTypeAttribute() const;
293
294public:
295 void Reset();
296
298 void ProcessEvent(wxKeyEvent &event) override;
299
307 bool ActivateCursor();
308
310 void DeactivateCursor();
311
313 size_t BeginningOfLine(size_t pos) const;
314
316 size_t EndOfLine(size_t pos);
317
319 bool AddEnding() override;
320
322 void PositionToXY(size_t position, size_t *x, size_t *y);
323
325 size_t XYToPosition(size_t x, size_t y);
326
328 wxPoint PositionToPoint(size_t pos) override;
329 wxPoint PositionToPoint() override {return PositionToPoint(CursorPosition());}
330
332 void SelectPointText(wxPoint point) override;
333
335 void SelectRectText(wxPoint one, wxPoint two) override;
336
338 wxString SelectWordUnderCaret(bool selectParens = true, bool toRight = true,
339 bool includeDoubleQuotes = false);
340
342 bool IsPointInSelection(wxPoint point);
343
344 bool CopyToClipboard() const override;
345
346 bool CutToClipboard() override;
347
348 void PasteFromClipboard(bool primary = false) override;
349
351 size_t GetSelectionStart() const
352 { return SelectionStart(); }
353
355 long GetSelectionEnd() const
356 { return SelectionEnd(); }
357
359 void SelectAll() override
360 {
361 SetSelection(0, m_text.Length());
362 }
363
365 bool AllSelected() const
366 {
367 return (SelectionStart() == 0) && (SelectionEnd() == m_text.Length());
368 }
369
372 {
373 ClearSelection();
374 }
375
376
377 bool CanCopy() const override
378 {
379 return SelectionActive();
380 }
381
382 bool FindMatchingQuotes();
383
384 void FindMatchingParens();
385
386 wxCoord GetLineWidth(size_t line, size_t pos);
387
392 wxCoord NextTabStop(wxCoord startX) const;
393
402 wxCoord MeasureTextWidth(wxCoord startX, const wxString &text) const;
403
410 static bool IsStrongRightToLeft(wxUniChar c);
411
413 static bool IsStrongLeftToRight(wxUniChar c);
414
429 bool LineIsRightToLeft(size_t line);
430
432 bool LineIsMixedDirection(size_t line);
433
435 size_t LineLength(size_t line);
436
446 wxCoord SelectionRunLeft(size_t runStart, size_t runEnd, wxCoord runStartX,
447 wxCoord runWidth);
448
457 bool GetLineBidiRuns(size_t line, std::vector<BidiRun> *runs);
458
465 bool MixedDirectionOffset(size_t line, size_t position, wxCoord *offset);
466
473 std::vector<wxCoord> RightToLeftLineOffsets();
474
476 wxCoord RightToLeftLineOffset(size_t line);
477
480 bool IsDirty() const override
481 {
482 return m_isDirty;
483 }
484
486 void SwitchCaretDisplay() override
487 {
488 m_displayCaret = !m_displayCaret;
489 }
490
491 void SetFocus(bool focus) override
492 {
493 m_hasFocus = focus;
494 }
495
496 bool IsActive() const override;
497
499 bool CaretAtStart() const
500 { return CursorPosition() == 0; }
501
503 void CaretToStart();
504
506 bool CaretAtEnd() const
507 { return CursorPosition() == m_text.Length(); }
508
510 void CaretToEnd();
511
513 void CaretToPosition(size_t pos);
514
516 bool CanUndo() const {return m_history.CanUndo();}
517
519 void Undo();
520
522 bool CanRedo() const {return m_history.CanRedo();}
523
525 void Redo();
526
529 {
530 public:
531 enum Action : uintptr_t {
532 any = 0,
533 removeChar = 1,
534 addChar = 2
535 };
536
538 class HistoryEntry // 64 bytes
539 {
540 public:
541 HistoryEntry(){};
542 HistoryEntry(const wxString &text, long long selStart, long long selEnd) :
543 m_text(text), m_selStart(selStart), m_selEnd(selEnd) {}
544 long long SelectionStart() const {return m_selStart;}
545 long long SelectionEnd() const {return m_selEnd;}
546 wxString GetText() const {return m_text;}
547 private:
548 wxString m_text;
549 long long m_selStart = -1;
550 long long m_selEnd = -1;
551 };
552 bool AddState(HistoryEntry entry, Action action = any);
553 bool AddState(const wxString &text, long long selStart, long long selEnd, Action action = any);
554 bool Undo();
555 bool Redo();
556 bool CanUndo() const;
557 bool CanRedo() const;
558 void ClearUndoBuffer();
559 HistoryEntry GetState() const;
560 private:
561 std::vector<HistoryEntry> m_history;
563 size_t m_historyPosition = 0;
564 Action m_lastAction = any;
565 };
566
568 void SaveValue(History::Action action = History::Action::any);
569
576 wxString DivideAtCaret();
577
578 void CommentSelection();
579
581 bool ContainsChanges() const
582 { return m_containsChanges; }
583
585 void ContainsChanges(bool changes)
586 { m_containsChanges = m_containsChangesCheck = changes; }
587
588 bool CheckChanges();
589
592 size_t ReplaceAll(wxString oldString, const wxString &newString, bool ignoreCase);
593 size_t ReplaceAll_RegEx(const wxString &oldString, const wxString &newString);
594
605 bool FindNext(wxString str, const bool &down, const bool &ignoreCase);
606 bool FindNext_RegEx(wxString str, const bool &down);
607
608 bool IsSelectionChanged() const { return m_selectionChanged; }
609
610 void GetSelection(size_t *start, size_t *end) const
611 {
612 *start = SelectionStart();
613 *end = SelectionEnd();
614 }
615
628 bool ReplaceSelection(const wxString &oldStr, const wxString &newString,
629 bool keepSelected = false, bool ignoreCase = false,
630 bool replaceMaximaString = false);
631 bool ReplaceSelection_RegEx(const wxString &oldStr, const wxString &newString);
632
634 wxString GetSelectionString() const;
635
638
640 wxString GetWordUnderCaret();
641
643 wxString GetCurrentCommand() const;
644
646 void SetErrorIndex(size_t index){m_errorIndex = index; m_errorIndexSet = true;}
648 void ClearErrorIndex(){m_errorIndexSet = false;}
649
650 bool ErrorIndexSet() const {return m_errorIndexSet;}
651
652 void GotoError(){SetCaretPosition(m_errorIndex); ActivateCursor(); ClearErrorIndex();}
653
655 void ProcessNewline(bool keepCursorAtStartOfLine = true);
656
658 size_t GetCaretPosition() const
659 { return CursorPosition(); }
660
663
665 void SetCaretPosition(size_t pos){CursorPosition(pos);}
666
667 bool FindNextTemplate(bool left = false);
668
669 void InsertText(wxString text);
670
671 wxString TextInFrontOfSelection() const
672 {
673 return GetValue().Left(SelectionLeft());
674 }
675
678 {
679 SetSelection(m_lastSelectionStart, 0);
680 }
681
682 void SetType(CellType type) override;
683 void SetStyle(TextStyle style) override;
684
685 bool NeedsRecalculation(AFontSize fontSize) const override;
686
689 {
690 SetSelection(m_lastSelectionStart, m_text.Length());
691 }
692
694// const MaximaTokenizer::TokenList &GetDisplayedTokens() const;
696 const MaximaTokenizer::TokenList &GetAllTokens() const;
697
698private:
706 void PushTextLine(const wxString &line, const wxString &indentChar) const;
707
711 size_t ClampToText(long long pos) const {
712 if (pos < 0)
713 return 0;
714 return std::min(static_cast<size_t>(pos), m_text.Length());
715 }
716 size_t m_selectionStart = 0;
717 size_t m_selectionEnd = 0;
718 size_t m_lastSelectionStart = 0;
719protected:
734 {
735 private:
738 wxString m_text;
740 TextStyle m_style = TS_CODE_DEFAULT;
742 wxString m_indentChar;
744 mutable CachedInteger<wxCoord> m_width;
746 wxCoord m_indentPixels = 0;
748 bool m_styleThisText = false;
749 public:
751 StyledText(TextStyle style, const wxString &text)
752 : m_text(text), m_style(style), m_styleThisText(true) {}
753
755 explicit StyledText(const wxString &text, TextStyle style, wxCoord indentPixels = 0,
756 const wxString &indentChar = {})
757 : m_text(text), m_style(style), m_indentChar(indentChar), m_indentPixels(indentPixels) {}
758
759 void SetWidth(wxCoord width){m_width = width;}
760 void ResetSize(){m_width.Invalidate();}
761 wxCoord GetWidth() const {return m_width;}
762 bool SizeKnown() const {return m_width.IsValid();}
764 const wxString &GetText() const { return m_text; }
766 void SetText(const wxString &text) { m_text = text; }
768 void SetIndentation(wxCoord indentPixels, const wxString &indentString = {})
769 {
770 m_indentPixels = indentPixels;
771 m_indentChar = indentString;
772 }
774 wxCoord GetIndentPixels() const { return m_indentPixels; }
775 const wxString &GetIndentChar() const { return m_indentChar; }
778 TextStyle GetTextStyle() const { return m_style; }
779 // Has an individual text style been set for this text portion?
780 bool IsStyleSet() const { return m_styleThisText; }
781 };
782
783private:
784#if defined __WXOSX__
785 bool HandleCtrlCommand(wxKeyEvent &ev);
786#endif
787 bool HandleSpecialKey(wxKeyEvent &event);
788 bool HandleOrdinaryKey(wxKeyEvent &event);
789
790 void FontsChanged() const override
791 {
792 m_widths.clear();
793 }
794
810 struct SoftBreakCandidate {
811 std::size_t snippetIdx = 0;
812 std::size_t textPos = 0;
813 bool insert = false;
814 bool valid = false;
815 };
816
817 void HandleSoftLineBreaks_Code(SoftBreakCandidate &candidate, wxCoord &lineWidth,
818 const wxString &token, wxCoord &indentationPixels) const;
819
827 static bool BreakAfterOperator(const wxString &token, const wxString &prevToken,
828 const wxString &nextToken);
829
836 bool IsSoftBreakBefore(std::size_t pos) const {
837 return std::binary_search(m_softBreaks.begin(), m_softBreaks.end(), pos);
838 }
839
845 size_t GetIndentDepth(wxString text, size_t positionOfCaret) const;
846
853 static wxString InterpretEscapeString(const wxString &txt);
854
856 void MarkSelection(wxDC *dc, size_t start, size_t end, TextStyle style);
857
859 wxSize GetTextSize(const wxString &text) const;
860
862 History m_history;
864 void SetState(const History::HistoryEntry &state);
866 std::vector<StyledText> &GetStyledText();
867
868//** Large fields
869//**
870 typedef std::unordered_map <wxString, wxSize, wxStringHash> StringHash;
872 mutable StringHash m_widths;
873
875 mutable std::vector<wxString> m_wordList;
876
878 mutable MaximaTokenizer::TokenList m_tokens;
880 mutable MaximaTokenizer::TokenList m_tokens_including_hidden;
881
884 mutable wxString m_text;
885protected:
887 mutable std::vector<StyledText> m_styledText;
888private:
889
905 mutable std::vector<std::size_t> m_softBreaks;
906
908 std::vector<std::pair<std::size_t, std::size_t>> m_diffHighlights;
912 std::size_t m_diffHighlightsTextLength = 0;
913
914//** 8/4 bytes
915//**
916 DocumentCellPointers *const m_documentCellPointers = GetDocumentCellPointers();
917 ViewCellPointers *const m_viewCellPointers = GetViewCellPointers();
918
919//** 4 bytes
920//**
921 size_t m_errorIndex = 1;
922 mutable size_t m_numberOfLines = 1;
923 mutable wxCoord m_charHeight = 12;
924 long m_paren1 = -1, m_paren2 = -1;
925
926//** 2 bytes
927//**
928 AFontStyle m_fontStyle;
929 AFontWeight m_fontWeight;
930
931//** Bitfield objects (2 bytes)
932//**
934 bool m_autoAnswer : 1 = false;
936 mutable bool m_containsChanges : 1 = false;
937 bool m_containsChangesCheck : 1 = false;
938 bool m_displayCaret : 1 = false;
939 bool m_hasFocus : 1 = false;
940 bool m_errorIndexSet : 1 = false;
942 bool m_selectionChanged : 1 = false;
944 bool m_underlined : 1 = false;
946 mutable bool m_tokens_including_hidden_valid : 1 = false;
948 mutable bool m_tokens_valid : 1 = false;
949 mutable bool m_isDirty : 1 = true;
950};
951
952#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:235
A Type-Safe Fixed-Point Font Size.
Definition: FontAttribs.h:99
A cached integer value.
Definition: CachedValue.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:148
Cell * GetNext() const
Get the next cell in the list.
Definition: Cell.h:803
Cell * GetPrevious() const
Returns a pointer to the previous cell in the current cell list.
Definition: Cell.h:800
Configuration * m_configuration
A pointer to the configuration responsible for this worksheet.
Definition: Cell.h:1138
DocumentCellPointers * GetDocumentCellPointers() const
The document-model half of the cell-pointer registry this cell uses.
Definition: Cell.cpp:71
virtual void SetCurrentPoint(wxPoint point) const
Pass 2: Arrangement.
Definition: Cell.cpp:514
AFontSize m_fontSize_Scaled
The font size is smaller in super- and subscripts.
Definition: Cell.h:1181
ViewCellPointers * GetViewCellPointers() const
The transient view-state half of the cell-pointer registry this cell uses.
Definition: Cell.cpp:75
bool NeedsRecalculation() const
True, if something that affects the cell size has changed.
Definition: Cell.h:549
const TextStyle & GetTextStyle() const
Get the text style.
Definition: Cell.h:631
The configuration storage for the current worksheet.
Definition: Configuration.h:98
const Style * GetStyle(TextStyle textStyle) const
Get the text Style for a given text style identifier.
Definition: Configuration.h:1048
The document-model half of the cell-pointer registry.
Definition: CellPointers.h:50
How an entry to the undo history looks like.
Definition: EditorCell.h:539
The undo history of this cell.
Definition: EditorCell.h:529
A piece of styled text for syntax highlighting.
Definition: EditorCell.h:734
const wxString & GetText() const
Returns the piece of text.
Definition: EditorCell.h:764
void SetIndentation(wxCoord indentPixels, const wxString &indentString={})
Changes the indentation level of this token.
Definition: EditorCell.h:768
StyledText(const wxString &text, TextStyle style, wxCoord indentPixels=0, const wxString &indentChar={})
Defines a piece of text with the default style that possibly is indented.
Definition: EditorCell.h:755
TextStyle GetTextStyle() const
If IsStyleSet() is true this function returns the style of this text portion.
Definition: EditorCell.h:778
StyledText(TextStyle style, const wxString &text)
Defines a piece of styled text.
Definition: EditorCell.h:751
wxCoord GetIndentPixels() const
By how many pixels do we need to indent this line due to a bullet list or similar?
Definition: EditorCell.h:774
void SetText(const wxString &text)
Changes the piece of text kept in this token.
Definition: EditorCell.h:766
This class defines what the user sees as input cell.
Definition: EditorCell.h:62
const MaximaTokenizer::TokenList & GetAllTokens() const
Get the list of commands, parenthesis, strings and whitespaces in a code cell.
Definition: EditorCell.cpp:3958
void SetValue(const wxString &text) override
Sets the text that is to be displayed.
Definition: EditorCell.cpp:4015
virtual wxString XMLTypeAttribute() const
The type="..." attribute ToXML() writes for this cell.
Definition: EditorCell.cpp:609
void SetCurrentPoint(wxPoint point) const override
Pass 2: Arrangement.
Definition: EditorCell.cpp:913
size_t ReplaceAll(wxString oldString, const wxString &newString, bool ignoreCase)
Replaces all occurrences of a given string.
Definition: EditorCell.cpp:4043
const wxFont & GetFont() const
Get the font that matches this cell's formatting.
Definition: EditorCell.h:206
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:4009
wxCoord NextTabStop(wxCoord startX) const
Pixel x of the next 4-column tab stop at or after startX, where one column is the width of a space gl...
Definition: EditorCell.cpp:1226
void CaretToStart()
Move the cursor to the start of this cell.
Definition: EditorCell.cpp:4477
bool IsActive() const override
Is this editor cell focused?
Definition: EditorCell.cpp:3416
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:2554
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:351
void ContainsChanges(bool changes)
Set the information if this cell needs to be re-evaluated by maxima.
Definition: EditorCell.h:585
wxString ToXML() const override
Convert the current cell to XML code for inclusion in a .wxmx file.
Definition: EditorCell.cpp:595
void DeactivateCursor()
Deactivate the blinking cursor in the EditorCell it is in.
Definition: EditorCell.cpp:2424
void StyleTextCode() const
Is Called by StyleText() if this is a code cell.
Definition: EditorCell.cpp:3531
void SetDiffHighlights(std::vector< std::pair< std::size_t, std::size_t > > ranges)
Sets the character ranges of this cell's text the diff viewer wants painted with the TS_DIFF_CHANGED ...
Definition: EditorCell.h:246
void CaretToEnd()
Move the cursor to the end of this cell.
Definition: EditorCell.cpp:4471
size_t GetCaretPosition() const
Get the cursor's current position inside the cell.
Definition: EditorCell.h:658
bool CopyToClipboard() const override
Copy this cell's editable contents to the clipboard.
Definition: EditorCell.cpp:2966
wxString ToRTF() const override
Convert the current cell to RTF code.
Definition: EditorCell.cpp:431
void ClearErrorIndex()
Clears the index the error is at.
Definition: EditorCell.h:648
wxString DivideAtCaret()
DivideAtCaret Returns the string from caret to end and modifies the m_text so it contains only the st...
Definition: EditorCell.cpp:2832
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:1254
std::vector< StyledText > m_styledText
The styled-run rendering representation of m_text; see StyledText.
Definition: EditorCell.h:887
std::vector< wxCoord > RightToLeftLineOffsets()
How far each line has to move right to sit flush with the widest one.
Definition: EditorCell.cpp:3072
wxString GetCurrentCommand() const
Get the command the cursor is in the arguments for.
Definition: EditorCell.cpp:1155
bool IsDirty() const override
true, if this cell's width has to be recalculated.
Definition: EditorCell.h:480
void ProcessEvent(wxKeyEvent &event) override
Decide what to do if the user pressed a key when this cell was selected.
Definition: EditorCell.cpp:1346
wxCoord MeasureTextWidth(wxCoord startX, const wxString &text) const
Width, in pixels, of text when it starts at horizontal position startX on its line – like GetTextSize...
Definition: EditorCell.cpp:1233
virtual bool IsCodeEditor() const
Does this concrete cell edit code (Maxima input) rather than prose?
Definition: EditorCell.h:101
bool CanRedo() const
True, if a redo can be done for this cell.
Definition: EditorCell.h:522
wxString GetSelectionString() const
Convert the current selection to a string.
Definition: EditorCell.cpp:4380
long GetSelectionEnd() const
Get the character position the selection has been ended with.
Definition: EditorCell.h:355
void Redo()
Issu a redo command.
Definition: EditorCell.cpp:3435
void SetCaretPosition(size_t pos)
Set the cursor's current position inside the cell.
Definition: EditorCell.h:665
size_t EndOfLine(size_t pos)
Return the index of the last char of the line containing the letter #pos,.
Definition: EditorCell.cpp:1276
void SearchStartedHere() const
Remember that this is the cell the search was started in.
Definition: EditorCell.cpp:275
bool CaretAtStart() const
Is the cursor at the start of this cell?
Definition: EditorCell.h:499
virtual void StyleTypedText() const
The code-vs-prose-specific half of StyleText(), chosen by the subclass.
Definition: EditorCell.cpp:4007
void KeyboardSelectionStartedHere() const
Remember that this is the cell the keyboard selection was started in.
Definition: EditorCell.cpp:284
static wxString NormalizeLineEndings(const wxString &input_)
Normalize line endings.
Definition: EditorCell.cpp:1220
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:4288
void SwitchCaretDisplay() override
Toggles the visibility of the cursor which is used to make it blink.
Definition: EditorCell.h:486
wxString SelectWordUnderCaret(bool selectParens=true, bool toRight=true, bool includeDoubleQuotes=false)
Selects the word the cursor is currently at.
Definition: EditorCell.cpp:2932
wxString ToTeX() const override
Convert the current cell to LaTeX code.
Definition: EditorCell.cpp:465
const wxString & GetValue() const override
Returns the text contained in this cell.
Definition: EditorCell.h:225
static bool IsStrongLeftToRight(wxUniChar c)
Is this character a strong left-to-right one?
Definition: EditorCell.cpp:3147
const std::vector< std::pair< std::size_t, std::size_t > > & GetDiffHighlights() const
The ranges set by SetDiffHighlights() (empty outside the diff viewer).
Definition: EditorCell.h:251
void SelectAll() override
Select the whole text contained in this Cell.
Definition: EditorCell.h:359
void ReturnToSelectionFromBot()
Return to the selection after the cell has been left downwards.
Definition: EditorCell.h:688
bool CanCopy() const override
Select Can we copy the editable text of this cell?
Definition: EditorCell.h:377
void SelectNone()
Unselect everything.
Definition: EditorCell.h:371
bool FindMatchingQuotes()
For a given quotation mark ("), find a matching quote.
Definition: EditorCell.cpp:2320
void AddDrawParameter(wxString param)
Add a new parameter to a draw- or similar command including the comma, if needed.
Definition: EditorCell.cpp:193
void AutoAnswer(bool autoAnswer)
May this Editor Cell contain the answer to a question?
Definition: EditorCell.h:147
void StyleText() const
Converts m_text to a list of styled text snippets that will later be displayed by draw().
Definition: EditorCell.cpp:3977
bool MixedDirectionOffset(size_t line, size_t position, wxCoord *offset)
Where position sits, in pixels from the line's own left edge, found via the real bidi algorithm (GetL...
Definition: EditorCell.cpp:3213
wxCoord SelectionRunLeft(size_t runStart, size_t runEnd, wxCoord runStartX, wxCoord runWidth)
The left edge of the rectangle covering the run [runStart, runEnd).
Definition: EditorCell.cpp:805
wxString GetWordUnderCaret()
The word the cursor currently is at.
Definition: EditorCell.cpp:2893
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:329
bool GetLineBidiRuns(size_t line, std::vector< BidiRun > *runs)
Bidi::GetRuns() for a display line, as absolute positions into m_text (Bidi::GetRuns() itself only kn...
Definition: EditorCell.cpp:3192
void SelectRectText(wxPoint one, wxPoint two) override
Selects the text between the screen coordinates one and two.
Definition: EditorCell.cpp:2768
void SetErrorIndex(size_t index)
Sets the index the error is at.
Definition: EditorCell.h:646
size_t LineLength(size_t line)
How many characters the given display line holds, excluding its newline.
Definition: EditorCell.cpp:3169
bool AllSelected() const
Does the selection currently span the whole cell?
Definition: EditorCell.h:365
wxCoord RightToLeftLineOffset(size_t line)
RightToLeftLineOffsets() for a single line, 0 when there is none.
Definition: EditorCell.cpp:3124
TextStyle GetSelectionStyle() const
Try to determine the selection's text style.
Definition: EditorCell.cpp:4385
void SaveValue(History::Action action=History::Action::any)
Save the current contents of this cell in the undo buffer.
Definition: EditorCell.cpp:3446
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:2525
bool IsPointInSelection(wxPoint point)
Is the point point inside the currently selected text?
Definition: EditorCell.cpp:2779
void PasteFromClipboard(bool primary=false) override
Paste from the clipboard into this cell.
Definition: EditorCell.cpp:3047
void Undo()
Issue an undo command.
Definition: EditorCell.cpp:3420
void SetFont(wxDC *dc) const
Set the currently used font to the one that matches this cell's formatting.
Definition: EditorCell.cpp:1130
wxString ToMatlab() const override
Convert this cell to its Matlab representation.
Definition: EditorCell.cpp:378
bool LineIsRightToLeft(size_t line)
Is the given display line written right to left?
Definition: EditorCell.cpp:3154
bool CutToClipboard() override
Cut this cell's editable contents to the clipboard.
Definition: EditorCell.cpp:3000
EditorCell * GetPrevious() const
Get the previous EditorCell in the list.
Definition: EditorCell.h:130
static bool IsCodeType(CellType type)
Is type a code (Maxima-input) cell type, as opposed to text/sectioning?
Definition: EditorCell.cpp:181
bool CanUndo() const
True, if there is undo information for this cell.
Definition: EditorCell.h:516
bool ActivateCursor()
Activate the blinking cursor in this cell.
Definition: EditorCell.cpp:2434
void SetStyle(TextStyle style) override
Sets the TextStyle of this cell.
Definition: EditorCell.cpp:1125
void InsertEscCommand(const wxString &txt)
Insert the symbol that corresponds to the ESC command txt.
Definition: EditorCell.h:136
bool FindNext(wxString str, const bool &down, const bool &ignoreCase)
Finds the next occurrences of a string.
Definition: EditorCell.cpp:4119
void CaretToPosition(size_t pos)
Move the cursor to a certain position in the cell.
Definition: EditorCell.cpp:4483
bool ContainsChanges() const
Query if this cell needs to be re-evaluated by maxima.
Definition: EditorCell.h:581
EditorCell * GetNext() const
Get the next EditorCell in the list.
Definition: EditorCell.h:133
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:2466
void SetForeground(wxDC *dc)
Sets the current color to this cell's foreground color.
Definition: EditorCell.cpp:1151
bool CaretAtEnd() const
Is the cursor at the end of this cell?
Definition: EditorCell.h:506
void SelectPointText(wxPoint point) override
Sets the cursor to the screen coordinate point.
Definition: EditorCell.cpp:2633
virtual void Draw(wxDC *dc, wxDC *antialiassingDC) override
Pass 3 (Paint): Renders the cell using pre-calculated coordinates.
Definition: EditorCell.cpp:917
const std::vector< std::size_t > & GetSoftBreaks() const
The soft (word-wrap) line-break offsets of the last styling pass.
Definition: EditorCell.h:234
const auto & GetWordList() const
A list of words that might be applicable to the autocomplete function.
Definition: EditorCell.h:162
void Recalculate(const AFontSize fontsize) const override
Recalculate the size of the cell and the difference between top and center.
Definition: EditorCell.cpp:678
void MouseSelectionStartedHere() const
Remember that this is the cell the mouse selection was started in.
Definition: EditorCell.cpp:280
wxString ToHTML() const
Convert the current cell to HTML code.
Definition: EditorCell.cpp:758
bool LineIsMixedDirection(size_t line)
Does this line mix strong characters of both directions?
Definition: EditorCell.cpp:3178
static std::unique_ptr< EditorCell > Create(GroupCell *group, Configuration *config, CellType type, wxString text={})
Construct the EditorCell subtype (code vs.
Definition: EditorCell.cpp:185
static bool IsStrongRightToLeft(wxUniChar c)
Is this character a strong right-to-left one (Hebrew, Arabic, Farsi, ...)?
Definition: EditorCell.cpp:3131
void ProcessNewline(bool keepCursorAtStartOfLine=true)
Start a new line and optionally auto-indent it.
Definition: EditorCell.cpp:1517
void ConvertNumToUNicodeChar()
Convert a number to unicode chars.
Definition: EditorCell.cpp:634
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:677
void SetType(CellType type) override
Sets the text style according to the type.
Definition: EditorCell.cpp:1120
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:88
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:365
The view/interaction half of the cell-pointer registry.
Definition: CellPointers.h:187
One maximal run of same-direction text within a display line, in visual (left-to-right on screen) ord...
Definition: Bidi.h:47