 |
wxMaxima
|
Go to the documentation of this file.
28 #include "FontAttribs.h"
60 #if wxUSE_ACCESSIBILITY
61 wxAccStatus GetDescription(
int childId, wxString *description)
const override;
62 wxAccStatus GetFocus (
int *childId,
Cell **child)
const override;
63 wxAccStatus GetDefaultAction(
int childId, wxString *actionName)
const override;
64 wxAccStatus
GetValue (
int childId, wxString *strValue)
const override;
65 wxAccStatus GetRole (
int childId, wxAccRole *role)
const override;
83 InsertText(InterpretEscapeString(txt));
93 void AutoAnswer(
bool autoAnswer){m_autoAnswer = autoAnswer;}
116 static wxString
TabExpand(
const wxString &input,
long posInLine);
126 virtual void Draw(wxPoint point)
override;
137 wxString
ToMatlab(
bool dontLimitToSelection)
const;
140 wxString
ToRTF()
const override;
142 wxString
ToString(
bool dontLimitToSelection)
const;
144 wxString
ToTeX()
const override;
146 wxString
ToXML()
const override;
158 void SetValue(
const wxString &text)
override;
164 const wxString &
GetValue()
const override {
return m_text; }
177 void StyleTextTexts();
204 void PositionToXY(
int position,
unsigned int *x,
unsigned int *y);
220 bool includeDoubleQuotes =
false);
225 bool CopyToClipboard()
const override;
227 bool CutToClipboard()
override;
229 void PasteFromClipboard(
bool primary =
false)
override;
233 {
return m_selectionStart; }
237 {
return m_selectionEnd; }
242 m_selectionStart = 0;
243 m_selectionEnd = m_positionOfCaret = m_text.Length();
249 return (m_selectionStart == 0) && (m_selectionEnd == (long) m_text.Length());
255 m_selectionStart = m_selectionEnd = 0;
261 return (m_selectionStart >= 0) && (m_selectionEnd >= 0);
264 bool CanCopy()
const override
266 return m_selectionStart != -1;
271 void FindMatchingParens();
284 m_displayCaret = !m_displayCaret;
287 void SetFocus(
bool focus)
override
292 void SetFirstLineOnly(
bool show =
true)
294 if (m_firstLineOnly != show)
297 m_firstLineOnly = show;
303 bool IsActive()
const override;
307 {
return m_positionOfCaret == 0; }
314 {
return m_positionOfCaret == (long) m_text.Length(); }
345 void CommentSelection();
351 {
return m_containsChanges; }
355 { m_containsChanges = m_containsChangesCheck = changes; }
361 int ReplaceAll(wxString oldString,
const wxString &newString,
bool ignoreCase);
373 bool FindNext(wxString str,
const bool &down,
const bool &ignoreCase);
375 bool IsSelectionChanged()
const {
return m_selectionChanged; }
377 void SetSelection(
int start,
int end);
379 void GetSelection(
int *start,
int *end)
const
381 *start = m_selectionStart;
382 *end = m_selectionEnd;
398 bool keepSelected =
false,
bool ignoreCase =
false,
399 bool replaceMaximaString =
false);
416 bool ErrorIndexSet()
const {
return m_errorIndex >= 0;}
425 {
return m_positionOfCaret; }
432 { m_positionOfCaret = pos;
433 if(m_positionOfCaret < -1)
434 m_positionOfCaret = -1;
435 if(m_positionOfCaret > (
signed long)m_text.Length())
436 m_positionOfCaret = m_text.Length();
439 bool FindNextTemplate(
bool left =
false);
441 void InsertText(wxString text);
443 wxString TextInFrontOfSelection()
const
445 return GetValue().Mid(1, m_selectionStart);
451 SetSelection(m_lastSelectionStart, 0);
462 SetSelection(m_lastSelectionStart, m_text.Length());
466 const MaximaTokenizer::TokenList &
GetTokens()
const {
return m_tokens;}
470 bool IsZoomFactorChanged()
const;
472 double m_lastZoomFactor = -1;
489 wxString m_indentChar;
493 int m_indentPixels = 0;
497 bool m_styleThisText =
false;
500 StyledText(
TextStyle style,
const wxString &text)
501 : m_text(text), m_style(style), m_styleThisText(true) {}
504 explicit StyledText(
const wxString &text,
int indentPixels = 0,
505 const wxString &indentChar = {})
506 : m_text(text), m_indentChar(indentChar), m_indentPixels(indentPixels) {}
508 void SetWidth(
int width){
m_width = width;}
511 bool SizeKnown()
const {
return GetWidth() >= 0;}
513 const wxString &GetText()
const {
return m_text; }
515 void SetText(
const wxString &text) { m_text = text; }
517 void SetIndentation(
int indentPixels,
const wxString &indentString = {})
519 m_indentPixels = indentPixels;
520 m_indentChar = indentString;
523 int GetIndentPixels()
const {
return m_indentPixels; }
524 const wxString &GetIndentChar()
const {
return m_indentChar; }
527 TextStyle GetStyle()
const {
return m_style; }
529 bool IsStyleSet()
const {
return m_styleThisText; }
532 #if defined __WXOSX__
533 bool HandleCtrlCommand(wxKeyEvent &ev);
535 bool HandleSpecialKey(wxKeyEvent &event);
536 bool HandleOrdinaryKey(wxKeyEvent &event);
538 void FontsChanged()
override
551 void HandleSoftLineBreaks_Code(StyledText *&lastSpace,
int &lineWidth,
const wxString &token,
unsigned int charInCell,
552 wxString &text,
const size_t &lastSpacePos,
int &indentationPixels);
559 int GetIndentDepth(wxString text,
int positionOfCaret);
567 wxString InterpretEscapeString(
const wxString &txt)
const;
570 void MarkSelection(
long start,
long end,
TextStyle style);
573 wxSize GetTextSize(
const wxString &text);
578 int caretPosition = -1;
581 HistoryEntry() =
default;
582 HistoryEntry(
const wxString &text,
int caretPosition,
int selStart,
int selEnd) :
583 text(text), caretPosition(caretPosition), selStart(selStart), selEnd(selEnd) {}
586 void SetState(
const HistoryEntry &state);
588 void AppendStateToHistory();
592 WX_DECLARE_STRING_HASH_MAP(wxSize, StringHash);
597 std::vector<wxString> m_wordList;
600 MaximaTokenizer::TokenList m_tokens;
603 std::vector<StyledText> m_styledText;
605 std::vector<HistoryEntry> m_history;
614 int m_errorIndex = 1;
615 unsigned int m_numberOfLines = 1;
617 int m_historyPosition = -1;
626 long m_selectionStart = -1;
634 long m_selectionEnd = -1;
635 long m_oldSelectionStart = -1;
636 long m_oldSelectionEnd = -1;
637 long m_lastSelectionStart = -1;
639 int m_charHeight = 12;
640 int m_paren1 = -1, m_paren2 = -1;
643 int m_positionOfCaret = 0;
646 int m_caretColumn = -1;
658 m_autoAnswer =
false;
659 m_containsChanges =
false;
660 m_containsChangesCheck =
false;
661 m_displayCaret =
false;
662 m_firstLineOnly =
false;
666 m_selectionChanged =
false;
667 m_underlined =
false;
671 bool m_autoAnswer : 1 ;
673 bool m_containsChanges : 1 ;
674 bool m_containsChangesCheck : 1 ;
675 bool m_displayCaret : 1 ;
676 bool m_firstLineOnly : 1 ;
677 bool m_hasFocus : 1 ;
679 bool m_saveValue :1 ;
681 bool m_selectionChanged : 1 ;
683 bool m_underlined : 1 ;
686 #endif // EDITORCELL_H
void CaretToStart()
Move the cursor to the start of this cell.
Definition: EditorCell.cpp:4203
void ActivateCursor()
Definition: EditorCell.cpp:2597
bool CanUndo() const
True, if there is undo information for this cell.
Definition: EditorCell.cpp:3283
void StyleTextCode()
Definition: EditorCell.cpp:3395
int XYToPosition(int x, int y)
Determines which index the char at the position "x chars left, y chars down" is at.
Definition: EditorCell.cpp:2688
void ConvertNumToUNicodeChar()
Convert a number to unicode chars.
Definition: EditorCell.cpp:574
bool AllSelected() const
Does the selection currently span the whole cell?
Definition: EditorCell.h:247
bool CanRedo() const
True, if a redo can be done for this cell.
Definition: EditorCell.cpp:3311
const CellTypeInfo & GetInfo() override
Returns the information about this cell's type.
static wxString EscapeHTMLChars(wxString input)
Escape all chars that cannot be used in HTML otherwise.
Definition: EditorCell.cpp:54
void SetFont()
Set the currently used font to the one that matches this cell's formatting.
Definition: EditorCell.cpp:1026
TextStyle
Definition: TextStyle.h:307
void CaretToEnd()
Move the cursor to the end of this cell.
Definition: EditorCell.cpp:4196
void Recalculate(AFontSize fontsize) override
Definition: EditorCell.cpp:620
void CaretToPosition(int pos)
Move the cursor to a certain position in the cell.
Definition: EditorCell.cpp:4210
wxString ToMatlab() const override
Convert this cell to its Matlab representation.
Definition: EditorCell.cpp:303
int ReplaceAll(wxString oldString, const wxString &newString, bool ignoreCase)
Definition: EditorCell.cpp:3887
void Undo()
Issue an undo command.
Definition: EditorCell.cpp:3288
bool FindNext(wxString str, const bool &down, const bool &ignoreCase)
Definition: EditorCell.cpp:3940
const wxString & GetValue() const override
Definition: EditorCell.h:164
void ResetData()
Mark all cached size information as "to be calculated".
Definition: Cell.cpp:1010
int GetCaretPosition() const
Get the cursor's current position inside the cell.
Definition: EditorCell.h:424
wxString GetSelectionString() const
Convert the current selection to a string.
Definition: EditorCell.cpp:4109
bool NeedsRecalculation(AFontSize fontSize) const override
True, if something that affects the cell size has changed.
Definition: EditorCell.cpp:615
int GetLineWidth() const
Definition: Cell.cpp:282
wxString ToString() const override
Returns the cell's representation as a string.
Definition: EditorCell.cpp:279
void SetForeground()
Sets the current color to this cell's foreground color.
Definition: EditorCell.cpp:1084
void SwitchCaretDisplay() override
Toggles the visibility of the cursor which is used to make it blink.
Definition: EditorCell.h:282
size_t BeginningOfLine(long pos) const
Return the index of the 1st char of the line containing the letter pos.
Definition: EditorCell.cpp:1218
Definition: TextStyle.h:54
wxString GetFullCommandUnderCursor()
Get the whole maxima command that is currently under the cursor (including all arguments)
Definition: EditorCell.cpp:194
void SearchStartedHere() const
Remember that this is the cell the search was started in.
Definition: EditorCell.cpp:176
void DeactivateCursor()
Deactivate the blinking cursor in the EditorCell it is in.
Definition: EditorCell.cpp:2586
std::unique_ptr< Cell > Copy(GroupCell *group) const override
wxString GetCurrentCommand()
Get the command the cursor is in the arguments for.
Definition: EditorCell.cpp:1091
void ContainsChanges(bool changes)
Set the information if this cell needs to be re-evaluated by maxima.
Definition: EditorCell.h:354
size_t EndOfLine(long pos)
Return the index of the last char of the line containing the letter #pos,.
Definition: EditorCell.cpp:1239
void ProcessEvent(wxKeyEvent &event) override
Decide what to do if the user pressed a key when this cell was selected.
Definition: EditorCell.cpp:1312
void SelectRectText(wxPoint one, wxPoint two) override
Selects the text between the screen coordinates one and two.
Definition: EditorCell.cpp:2857
void ReturnToSelectionFromBot()
Return to the selection after the cell has been left downwards.
Definition: EditorCell.h:460
static wxString TabExpand(const wxString &input, long posInLine)
Definition: EditorCell.cpp:1166
void ReturnToSelectionFromTop()
Return to the selection after the cell has been left upwards.
Definition: EditorCell.h:449
const MaximaTokenizer::TokenList & GetTokens() const
Get the list of commands, parenthesis, strings and whitespaces in a code cell.
Definition: EditorCell.h:466
void SelectPointText(wxPoint point) override
Sets the cursor to the screen coordinate point.
Definition: EditorCell.cpp:2738
wxPoint PositionToPoint(int pos=-1) override
The screen coordinates of the cursor.
Definition: EditorCell.cpp:2713
void SetValue(const wxString &text) override
Definition: EditorCell.cpp:3804
void PositionToXY(int position, unsigned int *x, unsigned int *y)
Determines which line and column the pos'th char is at.
Definition: EditorCell.cpp:2664
wxString GetWordUnderCaret()
The word the cursor currently is at.
Definition: EditorCell.cpp:3009
EditorCell(GroupCell *group, Configuration **config, const wxString &text={})
The constructor.
Definition: EditorCell.cpp:41
void InsertEscCommand(const wxString &txt)
Insert the symbol that corresponds to the ESC command txt.
Definition: EditorCell.h:82
bool SelectionActive() const
Is there any text selected right now?
Definition: EditorCell.h:259
Definition: EditorCell.h:57
Cell * GetNext() const
Get the next cell in the list.
Definition: Cell.h:624
void Redo()
Issu a redo command.
Definition: EditorCell.cpp:3318
wxString SelectWordUnderCaret(bool selectParens=true, bool toRight=true, bool includeDoubleQuotes=false)
Selects the word the cursor is currently at.
Definition: EditorCell.cpp:3058
Definition: CellPointers.h:44
wxString ToTeX() const override
Convert the current cell to LaTeX code.
Definition: EditorCell.cpp:389
Definition: FontAttribs.h:97
int GetWidth() const
Definition: Cell.h:331
void MouseSelectionStartedHere() const
Remember that this is the cell the mouse selection was started in.
Definition: EditorCell.cpp:182
static wxString PrependNBSP(wxString input)
Convert all but the first of a row of multiple spaces to non-breakable.
Definition: EditorCell.cpp:233
wxString ToHTML() const
Convert the current cell to HTML code.
Definition: EditorCell.cpp:691
CellType
Definition: Cell.h:63
void SetType(CellType type) override
Sets the text style according to the type.
Definition: EditorCell.cpp:1014
int m_height
The height of this cell.
Definition: Cell.h:871
bool ReplaceSelection(const wxString &oldStr, const wxString &newString, bool keepSelected=false, bool ignoreCase=false, bool replaceMaximaString=false)
Definition: EditorCell.cpp:4047
int GetSelectionEnd() const
Get the character position the selection has been ended with.
Definition: EditorCell.h:236
wxString ToXML() const override
Convert the current cell to XML code for inclusion in a .wxmx file.
Definition: EditorCell.cpp:525
int m_width
The width of this cell; is recalculated by RecalculateHeight.
Definition: Cell.h:873
wxString DivideAtCaret()
Definition: EditorCell.cpp:2928
void StyleText()
Definition: EditorCell.cpp:3780
bool IsPointInSelection(wxPoint point)
Is the point point inside the currently selected text?
Definition: EditorCell.cpp:2874
int GetSelectionStart() const
Get the character position the selection has been started with.
Definition: EditorCell.h:232
void AddDrawParameter(wxString param)
Add a new parameter to a draw- or similar command including the comma, if needed.
Definition: EditorCell.cpp:67
Definition: Configuration.h:83
void ProcessNewline(bool keepCursorAtStartOfLine=true)
Start a new line and optionally auto-indent it.
Definition: EditorCell.cpp:1514
void SaveValue()
Save the current contents of this cell in the undo buffer.
Definition: EditorCell.cpp:3338
void SetErrorIndex(int index)
Sets the index the error is at.
Definition: EditorCell.h:414
void AutoAnswer(bool autoAnswer)
May this Editor Cell contain the answer to a question?
Definition: EditorCell.h:93
void SetCaretPosition(int pos)
Set the cursor's current position inside the cell.
Definition: EditorCell.h:431
bool FindMatchingQuotes()
Definition: EditorCell.cpp:2447
void ResetSize()
Mark the cached height and width information as "to be calculated".
Definition: Cell.cpp:1034
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:2617
Definition: GroupCell.h:68
wxString ToRTF() const override
Convert the current cell to RTF code.
Definition: EditorCell.cpp:327
void KeyboardSelectionStartedHere() const
Remember that this is the cell the keyboard selection was started in.
Definition: EditorCell.cpp:188
void SetStyle(TextStyle style) override
Sets the TextStyle of this cell.
Definition: EditorCell.cpp:1020
A class that carries information about the type of a cell.
Definition: Cell.h:90
void ClearSelection()
Unselect everything.
Definition: EditorCell.cpp:4117
bool CaretAtEnd() const
Is the cursor at the end of this cell?
Definition: EditorCell.h:313
bool CaretAtStart() const
Is the cursor at the start of this cell?
Definition: EditorCell.h:306
bool IsDirty() const override
true, if this cell's width has to be recalculated.
Definition: EditorCell.h:276
EditorCell * GetPrevious() const
Get the previous EditorCell in the list.
Definition: EditorCell.h:77
const auto & GetWordList() const
A list of words that might be applicable to the autocomplete function.
Definition: EditorCell.h:108
void SelectNone()
Unselect everything.
Definition: EditorCell.h:253
bool ContainsChanges() const
Query if this cell needs to be re-evaluated by maxima.
Definition: EditorCell.h:350
void SelectAll() override
Select the whole text contained in this Cell.
Definition: EditorCell.h:240
EditorCell * GetNext() const
Get the next EditorCell in the list.
Definition: EditorCell.h:79