wxMaxima
Loading...
Searching...
No Matches
Worksheet.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) 2004-2015 Andrej Vodopivec <andrej.vodopivec@gmail.com>
4// (C) 2012-2013 Doug Ilijev <doug.ilijev@gmail.com>
5// (C) 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
30#ifndef WORKSHEET_H
31#define WORKSHEET_H
32
33#include <optional>
34#include "precomp.h"
35#include "MaximaManual.h"
36#include "EventIDs.h"
37#include "RecentDocuments.h"
38#include <wx/wx.h>
39#include <wx/xml/xml.h>
40#include <wx/aui/aui.h>
41#include <wx/textfile.h>
42#include <wx/fdrepdlg.h>
43#include <wx/dc.h>
44#include <vector>
45#include <utility>
46#include <memory>
47#include <list>
48#include "CellPointers.h"
50#include "Notification.h"
51#include "cells/Cell.h"
52#include "cells/EditorCell.h"
53#include "cells/ImgCell.h"
54#include "cells/ImgCellBase.h"
55#include "cells/AnimationCell.h"
56#include "cells/GroupCell.h"
57#include "cells/TextCell.h"
58#include "EvaluationQueue.h"
60#include "Autocomplete.h"
61#include "AutocompletePopup.h"
63#include "ToolBar.h"
64#include <thread>
65
108class Worksheet : public wxScrolled<wxWindow>
109{
110public:
111 RecentDocuments m_unsavedDocuments;
113 bool UpdateControlsNeeded(){bool result = m_updateControls; m_updateControls = false; return result;}
114 void UpdateControlsNeeded(bool updateControlsNeeded){m_updateControls = updateControlsNeeded;}
115private:
117 wxString m_maximaDocDir;
119 bool m_updateControls = true;
121 bool m_scrollToCaret = false;
123 CellPointers m_cellPointers;
124 // The x position to scroll to
125 int m_newxPosition = -1;
126 // The y position to scroll to
127 int m_newyPosition = -1;
129 double m_zoomAtGestureStart = 1.0;
131 bool m_scrollToTopOfCell = false;
133 bool m_windowActive = true;
135 wxRegion m_regionToRefresh;
142 int m_scrollUnit = 10;
147 wxClientDC m_dc;
149 CellPtr<GroupCell> m_redrawStart;
151 bool m_fullRedrawRequested = false;
153
155 static wxDataFormat m_wxmFormat;
157 static wxDataFormat m_mathmlFormat;
159 static wxDataFormat m_mathmlFormat2;
161 static wxDataFormat m_rtfFormat;
163 static wxDataFormat m_rtfFormat2;
164
167 class MathMLDataObject : public wxCustomDataObject
168 {
169 public:
170 explicit MathMLDataObject(const wxString &data);
171
172 MathMLDataObject();
173
174 private:
175 wxCharBuffer m_databuf;
176 };
177
179 class wxmDataObject : public wxCustomDataObject
180 {
181 public:
182 explicit wxmDataObject(const wxString &data);
183
184 wxmDataObject();
185
186 private:
187 wxCharBuffer m_databuf;
188 };
189
190 class MathMLDataObject2 : public wxCustomDataObject
191 {
192 public:
193 explicit MathMLDataObject2(const wxString &data);
194
195 MathMLDataObject2();
196
197 private:
198 wxCharBuffer m_databuf;
199 };
200
203 class RtfDataObject : public wxCustomDataObject
204 {
205 public:
206 explicit RtfDataObject(const wxString &data);
207
208 RtfDataObject();
209
210 private:
211 wxCharBuffer m_databuf;
212 };
213
214 class RtfDataObject2 : public wxCustomDataObject
215 {
216 public:
217 explicit RtfDataObject2(const wxString &data);
218
219 RtfDataObject2();
220
221 private:
222 wxCharBuffer m_databuf;
223 };
224
226 bool m_hasFocus = true;
228 long m_lastTop = 0;
230 long m_lastBottom = 0;
255 class TreeUndoAction
256 {
257 public:
258 TreeUndoAction(GroupCell *start, const wxString &oldText,
259 long long oldSelStart = -1, long long oldSelEnd = -1) :
260 m_start(start), m_oldText(oldText),
261 m_oldSelStart(oldSelStart), m_oldSelEnd(oldSelEnd)
262 {
263 wxASSERT_MSG(start, _("Bug: Trying to record a cell contents change for undo without a cell."));
264 }
265 TreeUndoAction(GroupCell *start, GroupCell *end) :
266 m_start(start), m_newCellsEnd(end)
267 {
268 wxASSERT_MSG(start, _("Bug: Trying to record a cell contents change for undo without a cell."));
269 }
270 TreeUndoAction(GroupCell *start, GroupCell *end, GroupCell *oldCells) :
271 m_start(start), m_newCellsEnd(end), m_oldCells(oldCells)
272 {
273 }
274
280 bool m_partOfAtomicAction = false;
281
292 CellPtr<GroupCell> m_start;
293
299 const wxString m_oldText;
300
307 const long long m_oldSelStart = -1;
308 const long long m_oldSelEnd = -1;
309
319 CellPtr<GroupCell> m_newCellsEnd;
320
328 std::unique_ptr<GroupCell> m_oldCells;
329 };
330
332 using UndoActions = std::list<TreeUndoAction>;
333
335 UndoActions treeUndoActions;
336
338 UndoActions treeRedoActions;
339
341 wxString m_treeUndo_ActiveCellOldText;
343 long long m_treeUndo_ActiveCellOldSelStart = -1;
344 long long m_treeUndo_ActiveCellOldSelEnd = -1;
345
347 void TreeUndo_ClearRedoActionList();
348
350 void TreeUndo_ClearUndoActionList();
351
353 static void TreeUndo_DiscardAction(UndoActions *actionList);
354
356 static void TreeUndo_AppendAction(UndoActions *actionList)
357 {
358 if(!actionList->empty())
359 actionList->front().m_partOfAtomicAction = true;
360 }
361
363 void TreeUndo_AppendAction(){TreeUndo_AppendAction(&treeUndoActions);}
364
369 CellPtr<GroupCell> TreeUndo_ActiveCell;
370
372 void TreeUndo_LimitUndoBuffer();
373
379 bool TreeUndo(UndoActions *sourcelist, UndoActions *undoForThisOperation);
380
384 bool TreeUndoTextChange(UndoActions *sourcelist, UndoActions *undoForThisOperation);
388 bool TreeUndoCellDeletion(UndoActions *sourcelist, UndoActions *undoForThisOperation);
392 bool TreeUndoCellAddition(UndoActions *sourcelist, UndoActions *undoForThisOperation);
393
395 bool TreeUndo()
396 { return TreeUndo(&treeUndoActions, &treeRedoActions); }
397
399 bool TreeRedo()
400 { return TreeUndo(&treeRedoActions, &treeUndoActions); }
401
403 bool CanTreeUndo() const;
404
406 bool CanTreeRedo() const;
407
410 void TreeUndo_CellEntered();
411
414 void TreeUndo_CellLeft();
415
424 void TreeUndo_MarkCellsAsAdded(GroupCell *start, GroupCell *end, UndoActions *undoBuffer);
425
426
432 void TreeUndo_MarkCellsAsAdded(GroupCell *parentOfStart, GroupCell *end);
434
435 bool m_scrolledAwayFromEvaluation = false;
436
441 wxString EscapeHTMLChars(wxString input);
442
444 wxString PrependNBSP(wxString input);
445
447 enum ClickType
448 {
449 CLICK_TYPE_NONE,
450 CLICK_TYPE_GROUP_SELECTION,
451 CLICK_TYPE_INPUT_SELECTION,
452 CLICK_TYPE_INPUT_LABEL_SELECTION,
453 CLICK_TYPE_OUTPUT_SELECTION
454 };
455
457 enum TimerIDs
458 {
459 TIMER_ID,
460 CARET_TIMER_ID,
461 DISPLAY_TIMEOUT_ID
462 };
463
465 static void AddLineToFile(wxTextFile &output, const wxString &s);
466
468 std::unique_ptr<Cell> CopySelection(bool asData = false) const;
469
478 std::unique_ptr<Cell> CopySelection(Cell *start, Cell *end, bool asData = false) const;
479
481 void GetMaxPoint(int *width, int *height);
482
484 void OnTimer(wxTimerEvent &event);
485
486#if wxCHECK_VERSION(3, 1, 1)
488 void OnZoom(wxZoomGestureEvent &event);
489#endif
490
491 void OnMouseExit(wxMouseEvent &event);
492
493 void OnMouseEnter(wxMouseEvent &event);
494
507 void OnPaint(wxPaintEvent &event);
509 void DrawGroupCell(wxDC &dc, wxDC &adc, GroupCell &cell);
517 void DrawGroupCell_UsingBitmap(wxDC *dc, GroupCell *cell);
518
520 void PrepareDrawGC(wxDC &dc) const;
521
522 void OnSize(wxSizeEvent &event);
523
524 void OnMouseRightDown(wxMouseEvent &event);
525
526 void OnSidebarKey(wxCommandEvent &event);
527
528 void OnMouseLeftUp(wxMouseEvent &event);
529
531 void OnMouseCaptureLost(wxMouseCaptureLostEvent &event);
532
533 void OnMouseLeftDown(wxMouseEvent &event);
534
535 void OnMouseLeftInGcCell(wxMouseEvent &event, GroupCell *clickedInGC);
536
537 void OnMouseLeftInGcLeft(wxMouseEvent &event, GroupCell *clickedInGC);
538
539 void OnMouseLeftInGc(wxMouseEvent &event, GroupCell *clickedInGC);
540
541 void OnMouseMotion(wxMouseEvent &event);
542
544 void OnDoubleClick(wxMouseEvent &event);
545
547 void OnCharInActive(wxKeyEvent &event);
548
550 void OnCharNoActive(wxKeyEvent &event);
551
553 void SelectEditable(EditorCell *editor, bool up);
554
561 void SelectWithChar(int ccode);
562
577 void ClickNDrag(wxPoint down, wxPoint up);
578
579 // Select all group cells inside the given rectangle;
580 void SelectGroupCells(wxPoint down, wxPoint up);
581
582public:
583 void AdjustSize();
584
586 void OnEraseBackground(wxEraseEvent& WXUNUSED(event))
587 {}
588
589 void CheckUnixCopy();
590
591 void OnMouseMiddleUp(wxMouseEvent &event);
592
593 static bool IsLesserGCType(int type, int comparedTo);
594
597
600
602 void OnComplete(wxCommandEvent &event);
603
608 void EraseBackground(wxEraseEvent &event);
609
612 wxPoint m_down;
613 wxPoint m_up;
614 wxPoint m_mousePoint;
620 bool m_hCaretActive = true;
638 bool m_leftDown = false;
641 bool m_mouseDrag = false;
642 bool m_mouseOutside = false;
643
646 int m_clickType = CLICK_TYPE_NONE;
647 CellPtr<GroupCell> m_clickInGC;
653 wxTimer m_timer;
657 bool m_saved = true;
658 std::vector<wxString> m_completions;
659 bool m_autocompleteTemplates = true;
660 AutocompletePopup *m_autocompletePopup;
661
662public:
664 bool IsEmpty() const
665 { return !m_tree || (!m_tree->GetNext() && m_tree->GetEditable()->GetValue().Length() <= 1); }
668 {
669 if(m_autocompletePopup != NULL)
670 m_autocompletePopup->Destroy();
671 }
672
678 void OnChar(wxKeyEvent &event);
679
684 void OnKeyDown(wxKeyEvent &event);
686 void SetCellStyle(GroupCell *group, GroupType style);
687
689 void NumberSections() const;
690
692 bool SectioningMoveIn(GroupCell *parent);
694 bool SectioningMoveOut(GroupCell *parent);
696 std::optional<Notification> m_notificationMessage;
698 void WindowActive(bool active){m_windowActive = active;}
700 void ClearNotification();
705 void SetNotification(const wxString &message, int flags = wxICON_INFORMATION);
706
708 void OnActivate(wxActivateEvent &event);
709private:
711 std::unique_ptr<GroupCell> m_tree;
713 mutable CellPtr<GroupCell> m_last;
714// std::vector<std::jthread> m_drawThreads;
715 static std::mutex m_drawDCLock;
718 Configuration *m_configuration = NULL;
719public:
720 void FocusFindDialogue()
721 {
722 if(m_findDialog)
723 m_findDialog->SetFocus();
724 }
727
728 Configuration *GetConfig() const { return m_configuration; }
729
731 EditorCell *GetActiveCell() const { return m_cellPointers.m_activeCell; }
732
735 { return m_cellPointers.m_cellKeyboardSelectionStartedIn; }
736
737 EditorCell *MouseSelectionStart() const
738 { return m_cellPointers.m_cellMouseSelectionStartedIn; }
739
740 EditorCell *SearchStart() const
741 { return m_cellPointers.m_cellSearchStartedIn; }
742
743 int IndexSearchStartedAt() const
744 { return m_cellPointers.m_indexSearchStartedAt; }
745
746 CellPointers &GetCellPointers() { return m_cellPointers; }
747
748 CellPointers::ErrorList &GetErrorList() { return m_cellPointers.m_errorList; }
749 TextCell *GetCurrentTextCell() const { return m_cellPointers.m_currentTextCell; }
750 void SetCurrentTextCell(TextCell *cell) { m_cellPointers.m_currentTextCell = cell; }
751 void SetWorkingGroup(GroupCell *group) { m_cellPointers.SetWorkingGroup(group); }
752
759
777 {
778 m_redrawStart = NULL;
779 m_fullRedrawRequested = false;
780 }
781
786 bool RedrawIfRequested();
787
800 void RequestRedraw(GroupCell *start = NULL);
810 void RequestRedraw(wxRect rect);
811
814 {
817 }
818
821
824 m_configuration->ReadConfig();
825 Recalculate();
826 Refresh();
827 }
828
831
836 const wxString UnicodeToMaxima(wxString s);
837
839 void ScrollToStart() { Scroll(0, 0); }
840
842 void ScrollToError();
843
846
848 bool HCaretActive() const { return m_hCaretActive; }
849
855 bool CanMergeSelection() const;
856
857 bool CanUndo() const;
858
859 bool CanRedo() const;
860
861 void Undo();
862
863 void Redo();
864
869 void TreeUndo_ClearBuffers();
870
880 Worksheet(wxWindow *parent, int id, Configuration *config,
881 wxPoint pos = wxDefaultPosition, wxSize size = wxDefaultSize,
882 bool reactToEvents = true);
883
885 virtual ~Worksheet();
886
889
891 void DestroyTree();
892
894 std::unique_ptr<GroupCell> CopyTree() const;
895
907 GroupCell *InsertGroupCells(std::unique_ptr<GroupCell> &&cells, GroupCell *where,
908 UndoActions *undoBuffer);
909
915 GroupCell *InsertGroupCells(std::unique_ptr<GroupCell> &&cells, GroupCell *where = NULL);
916
922 void InsertLine(std::unique_ptr<Cell> &&newCell, bool forceNewLine = false);
923
925 GroupCell *GetInsertGroup() const;
926
933 bool RecalculateIfNeeded(bool timeout = false);
934
936 void Recalculate(Cell *start);
937
938 void Recalculate() { Recalculate(GetTree()); }
939
944 void ClearDocument();
945
946 void ResetInputPrompts();
947
948 bool CanCopy() const
949 {
950 return m_cellPointers.m_selectionStart ||
951 (m_cellPointers.m_activeCell &&
952 m_cellPointers.m_activeCell->CanCopy());
953 }
954
955 bool CanPaste() const
956 { return m_cellPointers.m_activeCell || m_hCaretActive; }
957
958 bool CanCut() const
959 {
960 return (m_cellPointers.m_activeCell && m_cellPointers.m_activeCell->CanCopy()) ||
961 (m_cellPointers.m_selectionStart && m_cellPointers.m_selectionStart->GetType() == MC_TYPE_GROUP);
962 }
963
965 void SelectAll();
966
968 bool HasCellsSelected() const { return m_cellPointers.HasCellsSelected(); }
969
980 void DeleteRegion(
981 GroupCell *start,
982 GroupCell *end,
983 UndoActions *undoBuffer
984 );
985
992 void DeleteRegion(
993 GroupCell *start,
994 GroupCell *end
995 );
996
1002 void DeleteSelection();
1003
1004 void TOCdnd(GroupCell *dndStart, GroupCell *dndEnd);
1005
1007 bool CanDeleteRegion(GroupCell *start, const GroupCell *end) const;
1008
1010 bool CanDeleteSelection() const;
1011
1016 void DeleteCurrentCell();
1017
1020 {
1021 if(m_cellPointers.m_selectionStart != m_cellPointers.m_selectionEnd)
1022 return NULL;
1023 return dynamic_cast<AnimationCell *>(GetSelectionStart());
1024 }
1025
1028 {
1029 if(m_cellPointers.m_selectionStart != m_cellPointers.m_selectionEnd)
1030 return NULL;
1031 return dynamic_cast<ImgCell *>(GetSelectionStart());
1032 }
1033
1036 {
1037 if(m_cellPointers.m_selectionStart != m_cellPointers.m_selectionEnd)
1038 return NULL;
1039 return dynamic_cast<ImgCellBase *>(GetSelectionStart());
1040 }
1041
1044 {
1045 if(m_cellPointers.m_selectionStart != m_cellPointers.m_selectionEnd)
1046 return NULL;
1047 return dynamic_cast<TextCell *>(GetSelectionStart());
1048 }
1049
1051 bool CanAnimate() const
1052 {
1053 return m_cellPointers.m_selectionStart && m_cellPointers.m_selectionStart == m_cellPointers.m_selectionEnd &&
1054 (dynamic_cast<AnimationCell *>(GetSelectionStart()) != NULL);
1055 }
1056
1063 void Animate(bool run = true) const;
1064
1065 void DivideCell();
1066
1067 void MergeCells();
1068
1069 void SetLastQuestion(const wxString &lastQuestion){m_lastQuestion = lastQuestion;}
1070 wxString GetLastQuestion() const {return m_lastQuestion;}
1071
1073 bool CutToClipboard();
1074
1075 void PasteFromClipboard();
1076
1083 bool Copy(bool astext = false) const;
1084
1086 bool CopyCells() const;
1087
1089 bool CopyMatlab() const;
1090
1092 bool CopyText() const;
1093
1095 bool CopyTeX() const;
1096
1098 wxString ConvertSelectionToMathML() const;
1099
1102
1104 bool CopyMathML() const;
1105
1107 bool CopyBitmap() const;
1108
1110 bool CopyAnimation() const;
1111
1113 bool CopySVG() const;
1114
1115#if wxUSE_ENH_METAFILE
1117 bool CopyEMF() const;
1118#endif
1119
1121 bool CopyRTF() const;
1122
1123 wxSize CopyToFile(const wxString &file) const;
1124
1125 wxSize CopyToFile(const wxString &file, Cell *start, Cell *end, bool asData = false, double scale = 1) const;
1126
1127 void CalculateReorderedCellIndices(GroupCell *tree, int &cellIndex, std::vector<int> &cellMap);
1128
1133 bool ExportToHTML(const wxString &file);
1134
1139 void
1140 ExportToMAC(wxTextFile &output, GroupCell *tree, bool wxm, const std::vector<int> &cellMap, bool fixReorderedIndices);
1141
1143 bool ExportToMAC(const wxString &file);
1144
1146 wxString RTFStart() const;
1147
1149 wxString RTFEnd() const;
1150
1152 bool ExportToTeX(const wxString &file);
1153
1159 wxString GetString(bool lb = false) const;
1160
1161 GroupCell *GetTree() const { return m_tree.get(); }
1162 std::unique_ptr<GroupCell> *GetTreeAddress() { return &m_tree; }
1163
1169 { return m_cellPointers.m_selectionStart; }
1170
1176 { return m_cellPointers.m_selectionEnd; }
1177
1179 void ClearSelection() { SetSelection(nullptr, nullptr); }
1180
1182 void SetSelection(Cell *sel) { SetSelection(sel, sel); }
1183
1185 void SetSelection(Cell *start, Cell *end);
1186
1188 Cell *FindCellByUUID(const wxString &uuid);
1189
1192
1195 bool CanEdit();
1196
1197 bool ActivatePrevInput() { return ActivateInput(-1); }
1198 bool ActivateNextInput() { return ActivateInput(+1); }
1199 wxString GetStatusText() const {return m_statusText;}
1200 bool StatusTextChangedHas() {
1201 bool retval = (m_statusTextHas != m_statusTextHas_old) ||
1202 (m_statusText != m_statusText_old);
1203 m_statusText_old = m_statusText;
1204 m_statusTextHas_old = m_statusTextHas;
1205 return retval;
1206 }
1207 bool StatusTextHas() const {return m_statusTextHas;}
1208private:
1209 /* ! A timer that tells us to urgently update the display
1210
1211 Normally we prioritize tasks: If there are GUI actions to process we do so.
1212 If not we look if there is data from maxima to process. If not we
1213 If not we recalculate the worksheet element sizes and positions and if
1214 there still is no pressing task we update the display. This way we
1215 respond quickly to the most important inputs.
1216
1217 This timer, if expired, tells us that if we don't update the screen now
1218 maxima feels like not being responsive.
1219 */
1220 wxTimer m_displayTimeoutTimer;
1221
1222 template <class T_SRC, class T_DEST>
1223 inline std::unique_ptr<T_DEST> unique_cast(std::unique_ptr<T_SRC> &&src)
1224 {
1225 if (!src) return std::unique_ptr<T_DEST>();
1226
1227 T_DEST *dest_ptr = &dynamic_cast<T_DEST &>(*src.get());
1228
1229 (void) src.release();
1230 return std::unique_ptr<T_DEST>(dest_ptr);
1231 }
1232 wxString m_statusText;
1233 wxString m_statusText_old;
1234 bool m_statusTextHas = false;
1235 bool m_statusTextHas_old = false;
1236 void StatusText(const wxString &text){m_statusText = text; m_statusTextHas = true;}
1237 void UnsetStatusText(){m_statusTextHas = false;}
1238 bool ActivateInput(int direction);
1239
1240public:
1243 {
1244 m_cellPointers.m_scrollToCell = false;
1245 m_scrollToCaret = true;
1246 }
1247
1249 bool ScrollToCaretIfNeeded();
1250
1252 void ScrollToCellIfNeeded();
1253
1255 void ScheduleScrollToCell(Cell *cell, bool scrollToTop = true)
1256 {
1257 m_cellPointers.ScrollToCell(cell);
1258 m_scrollToTopOfCell = scrollToTop;
1259 m_scrollToCaret = false;
1260
1261 m_cellPointers.m_scrollToCell = true;
1262 }
1263
1265 bool PointVisibleIs(wxPoint point);
1266
1268 bool CaretVisibleIs();
1269
1272
1286 void ShowPoint(wxPoint point);
1287
1289 void OnSetFocus(wxFocusEvent &event);
1290
1292 void OnKillFocus(wxFocusEvent &event);
1293
1295 bool IsSelected(CellType type);
1296
1303 void StepAnimation(int change = 1);
1304
1306 bool IsActiveInLast() const
1307 { return m_cellPointers.m_activeCell && m_cellPointers.m_activeCell->GetGroup() == GetLastCellInWorksheet(); }
1308
1311 {
1312 return GetLastCellInWorksheet();
1313 }
1314
1317
1318 void SetActiveCell(EditorCell *cell);
1319
1323 void SetDefaultHCaret();
1324
1329 void SetHCaret(GroupCell *where); // call with false, when manually refreshing
1332
1334 void OpenHCaret(const wxString &txt = {})
1335 {
1336 if(m_mainToolBar == NULL)
1337 OpenHCaret(txt, GC_TYPE_CODE);
1338 else
1340 }
1341
1343 void OpenHCaret(const wxString &txt, GroupType type);
1344
1346 void ShowHCaret();
1347
1352 bool CanUndoInsideCell() const;
1353
1354 void UndoInsideCell();
1355
1360 bool CanRedoInsideCell() const;
1361
1362 void RedoInsideCell();
1363
1373 void FollowEvaluation(bool followEvaluation);
1374
1376 bool FollowEvaluation() const
1377 { return m_followEvaluation; }
1378
1384 void ScrolledAwayFromEvaluation(bool ScrolledAway);
1385
1386 bool ScrolledAwayFromEvaluation() const
1387 { return m_scrolledAwayFromEvaluation; }
1388
1389 void SaveValue();
1390
1391 bool IsSaved() const
1392 { return m_saved; }
1393
1394 void SetSaved(bool saved)
1395 { if(m_saved != saved) m_updateControls = true; m_saved = saved;}
1396
1397 void OutputChanged()
1398 {
1399 if(m_currentFile.EndsWith(".wxmx"))
1400 m_saved = false;
1401 }
1402
1403 void RemoveAllOutput();
1404
1405 void RemoveAllOutput(GroupCell *cell);
1406 // methods related to evaluation queue
1407
1413 void Evaluate();
1414
1416 void AddToEvaluationQueue(GroupCell *cell);
1417
1418 void AddDocumentToEvaluationQueue();
1419
1422
1425
1428
1431
1434
1437
1440
1443
1444 void FoldOccurred();
1445
1446 // methods for folding
1449
1451
1452 void FoldAll();
1453
1454 void UnfoldAll();
1455
1456 // methods for zooming the document in and out
1457 void SetZoomFactor(double newzoom);
1458
1459 void CommentSelection();
1460
1465 void OnScrollChanged(wxScrollEvent &ev);
1466 void OnScrollEvent(wxScrollWinEvent &ev);
1467 void CheckIfActiveCellScrolledOut();
1472 void OnMouseWheel(wxMouseEvent &event);
1473
1479 bool FindIncremental(const wxString &str, bool down, bool ignoreCase, bool searchInInput = true, bool searchInOutput = true);
1480 bool FindIncremental_RegEx(const wxString &str, bool down, bool searchInInput = true, bool searchInOutput = true);
1481
1486 bool FindNext(const wxString &str, bool down, bool ignoreCase, bool searchInInput = true, bool searchInOutput = true, bool warn = true);
1487 bool FindNext_Regex(const wxString &str, const bool &down, bool searchInInput = true, bool searchInOutput = true, bool warn = true);
1488
1493 void Replace(const wxString &oldString, const wxString &newString, bool ignoreCase);
1494 void Replace_RegEx(const wxString &oldString, const wxString &newString);
1495
1500 int ReplaceAll(const wxString &oldString, const wxString &newString, bool ignoreCase, bool searchInInput = true, bool searchInOutput = true);
1501 int ReplaceAll_RegEx(const wxString &oldString, const wxString &newString, bool searchInInput = true, bool searchInOutput = true);
1502
1503 wxString GetInputAboveCaret();
1504
1505 wxString GetOutputAboveCaret();
1506
1508 void LoadSymbols();
1509
1510 bool Autocomplete(AutoComplete::autoCompletionType type = AutoComplete::command);
1511
1513 void AddSymbol(const wxString &fun, AutoComplete::autoCompletionType type = AutoComplete::command)
1514 { m_autocomplete.AddSymbol(fun, type); }
1515
1517 void AddSymbols(const wxString &xml)
1518 { m_autocomplete.AddSymbols(xml); }
1520 void AddSymbols(wxXmlDocument xml)
1521 { m_autocomplete.AddSymbols(xml); }
1522
1523 void SetActiveCellText(const wxString &text);
1524
1525 bool InsertText(const wxString &text);
1526
1527 void OpenNextOrCreateCell();
1528
1530 void OnFollow();
1531
1534
1536 void SelectGroupCell(GroupCell *cell);
1537
1542 void SetAnswer(const wxString &answer);
1544 void QuestionAnswered();
1545
1547 bool m_questionPrompt = false;
1548
1553 bool QuestionPending() const
1554 { return m_questionPrompt; }
1556
1560 void QuestionPending(bool pending)
1561 { m_questionPrompt = pending; }
1562
1563 void SetMaximaDocDir(const wxString &dir)
1564 {
1565 m_maximaDocDir = dir;
1566 }
1567
1569 bool GCContainsCurrentQuestion(const GroupCell *cell);
1570
1573 bool OpenQuestionCaret(const wxString &txt = {});
1574 void UpdateScrollPos();
1575
1581 GroupCell *GetWorkingGroup(bool resortToLast = false) const;
1583 void LoadHelpFileAnchors(const wxString &docdir, const wxString &maximaVersion)
1584 {m_maximaManual.LoadHelpFileAnchors(docdir, maximaVersion);}
1585 wxString GetHelpfileAnchorName(const wxString &keyword)
1586 {return m_maximaManual.GetHelpfileAnchorName(keyword);}
1587 wxString GetHelpfileURL(const wxString &keyword)
1588 {return m_maximaManual.GetHelpfileURL(keyword);}
1590 int GetCellIndex(Cell *cell) const;
1591
1593 std::vector<wxString> m_replacementsForCurrentWord;
1594#if wxUSE_ACCESSIBILITY
1595 int GetAccessibilityId(Cell *cell) const;
1596#endif
1597 //Simple iterator over a Maxima input string, skipping comments and strings
1599 {
1600 public:
1601 explicit SimpleMathConfigurationIterator(const wxString &ainput);
1602
1603 void operator++();
1604
1605 bool isValid() const
1606 { return pos < input.length(); }
1607
1608
1609 inline wxChar operator*() const
1610 { return input.at(pos); }
1611
1612 std::size_t pos;
1613
1618 const wxString &input;
1619 };
1620
1621#if wxUSE_ACCESSIBILITY
1622 class AccessibilityInfo: public wxAccessible
1623 {
1624 public:
1625 AccessibilityInfo(wxWindow *parent, Worksheet *worksheet);
1626 wxAccStatus GetName (int childId, wxString *name);
1627 wxAccStatus GetChildCount (int *childCount);
1628 wxAccStatus GetChild (int childId, wxAccessible **child);
1629 wxAccStatus GetDefaultAction(int childId, wxString *actionName);
1630 wxAccStatus GetParent (wxAccessible ** parent);
1631 wxAccStatus GetFocus (int *childId, wxAccessible **child);
1632 wxAccStatus GetLocation (wxRect &rect, int elementId);
1633 wxAccStatus HitTest (const wxPoint &pt,
1634 int *childId, wxAccessible **childObject);
1635 wxAccStatus GetDescription(int childId, wxString *description);
1636 wxAccStatus GetRole(int childId, wxAccRole *role);
1637 wxAccStatus GetState(int childId, long *state);
1638 private:
1639 wxWindow *m_parent = NULL;
1640 Worksheet *m_worksheet = NULL;
1641
1642 class CaretAccessibilityInfo : public wxAccessible {
1643 public:
1644 CaretAccessibilityInfo(AccessibilityInfo* parent, Worksheet* worksheet)
1645 : wxAccessible(worksheet->GetTargetWindow()), m_parent(parent), m_worksheet(worksheet) {}
1646
1647 wxAccStatus GetName(int childId, wxString *name) override;
1648 wxAccStatus GetDescription(int WXUNUSED(childId), wxString *description) override;
1649 wxAccStatus GetParent(wxAccessible **parent) override;
1650 wxAccStatus GetChildCount(int *childCount) override;
1651 wxAccStatus GetChild(int childId, wxAccessible **child) override;
1652 wxAccStatus GetRole(int childId, wxAccRole *role) override;
1653 private:
1654 AccessibilityInfo* m_parent;
1655 Worksheet* m_worksheet;
1656 };
1657 CaretAccessibilityInfo* m_caretAccessible = nullptr;
1658 };
1659#endif
1660 MaximaManual m_maximaManual;
1661 MaximaManual *GetMaximaManual() {return &m_maximaManual;}
1662protected:
1663 void FocusTextControl();
1664 wxString m_lastQuestion;
1665 int m_virtualWidth_Last = -1;
1666 int m_virtualHeight_Last = -1;
1667 int m_maxWidth_Cached = -1;
1669 wxBitmap m_memory;
1670 virtual wxSize DoGetBestClientSize() const override;
1671#if wxUSE_ACCESSIBILITY
1672 AccessibilityInfo *m_accessibilityInfo = NULL;
1673#endif
1677 int m_pointer_x = -1;
1679 int m_pointer_y = -1;
1681 bool m_mouseMotionWas = false;
1683 bool m_inPopupMenu = false;
1684};
1685
1686inline Worksheet *Cell::GetWorksheet() const
1687{
1688 wxWindow *worksheet = m_configuration->GetWorkSheet();
1689 wxASSERT(worksheet != NULL);
1690 return static_cast<Worksheet*>(worksheet);
1691}
1692
1693wxDECLARE_EVENT(TOC_UPDATE_NEEDED_EVENT, wxCommandEvent);
1694
1695#endif // WORKSHEET_H
This file declares the class AnimationCell.
The first number that is open for dynamic ID assignment.
This file declares the class AutoComplete.
The definition of the base class of all cells the worksheet consists of.
CellType
The supported types of math cells.
Definition: Cell.h:64
@ MC_TYPE_GROUP
A group cells that bundles several individual cells together.
Definition: Cell.h:82
This file contains the definition of the class EditorCell.
The evaluation queue.
This file declares the class EventIDs that contains unique IDs for many events wxMaxima needs.
This file defines the class FindReplaceDialog.
This file defines the class GroupCell that bundles input and output in the worksheet.
GroupType
All types a GroupCell can be of.
Definition: GroupCell.h:42
This file declares the class MaximaManual.
This file defines the class Notification.
The definition of the class RecentDocuments that provides a recent files mechanism that is extensible...
This file declares the class ToolBar that represents wxMaxima's main tool bar.
This file contains the definition of the class Unicodesidebar that allows to select arbitrary unicode...
The file that contains the "variables" sidepane.
Definition: AnimationCell.h:46
Definition: Autocomplete.h:61
autoCompletionType
All types of things we can autocomplete.
Definition: Autocomplete.h:68
void AddSymbols(wxString xml)
Interprets the XML autocompletable symbol list maxima can send us.
Definition: Autocomplete.cpp:135
void AddSymbol(wxString fun, autoCompletionType type=command)
Manually add an autocompletable symbol to our symbols lists.
Definition: Autocomplete.cpp:647
Definition: AutocompletePopup.h:47
A list of editor cells containing error messages.
Definition: CellPointers.h:70
The storage for pointers to cells.
Definition: CellPointers.h:45
ErrorList m_errorList
The list of cells maxima has complained about errors in.
Definition: CellPointers.h:93
bool m_scrollToCell
Is scrolling to a cell scheduled?
Definition: CellPointers.h:199
CellPtr< EditorCell > m_activeCell
Which EditCell the blinking cursor is in?
Definition: CellPointers.h:103
CellPtr< EditorCell > m_cellKeyboardSelectionStartedIn
The EditorCell the keyboard selection has started in.
Definition: CellPointers.h:97
void SetWorkingGroup(GroupCell *group)
Sets the cell maxima currently works on. NULL if there isn't such a cell.
Definition: CellPointers.cpp:90
CellPtr< Cell > m_selectionStart
The first cell of the currently selected range of Cells.
Definition: CellPointers.h:147
int m_indexSearchStartedAt
Which cursor position incremental search has started at?
Definition: CellPointers.h:101
CellPtr< EditorCell > m_cellMouseSelectionStartedIn
The EditorCell the mouse selection has started in.
Definition: CellPointers.h:95
CellPtr< EditorCell > m_cellSearchStartedIn
The EditorCell the search was started in.
Definition: CellPointers.h:99
CellPtr< TextCell > m_currentTextCell
The textcell the text maxima is sending us was ending in.
Definition: CellPointers.h:111
CellPtr< Cell > m_selectionEnd
The last cell of the currently selected range of Cells.
Definition: CellPointers.h:168
A weak non-owning pointer that becomes null whenever the observed object is destroyed.
Definition: CellPtr.h:489
The base class all cell types the worksheet can consist of are derived from.
Definition: Cell.h:142
GroupCell * GetGroup() const
Returns the group cell this cell belongs to.
Definition: Cell.cpp:278
CellType GetType() const
Returns the type of this cell.
Definition: Cell.h:453
Configuration * m_configuration
A pointer to the configuration responsible for this worksheet.
Definition: Cell.h:1066
The configuration storage for the current worksheet.
Definition: Configuration.h:87
wxWindow * GetWorkSheet() const
Get the worksheet this configuration storage is valid for.
Definition: Configuration.h:945
void ReadConfig()
Read the config from the wxConfig object.
Definition: Configuration.cpp:771
This class defines what the user sees as input cell.
Definition: EditorCell.h:59
bool CanCopy() const override
Select Can we copy the editable text of this cell?
Definition: EditorCell.h:288
A simple FIFO queue with manual removal of elements.
Definition: EvaluationQueue.h:43
The find+replace dialog.
Definition: FindReplaceDialog.h:42
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:87
Definition: ImgCellBase.h:42
Definition: ImgCell.h:35
Definition: MaximaManual.h:59
void LoadHelpFileAnchors(const wxString &docdir, const wxString &maximaVersion)
Search maxima's help file for command and variable names.
Definition: MaximaManual.cpp:532
A class that maintains a list of recent documents.
Definition: RecentDocuments.h:42
A Text cell.
Definition: TextCell.h:38
Definition: ToolBar.h:41
GroupType GetCellType()
Get the cell style for new cells.
Definition: ToolBar.cpp:539
Definition: Worksheet.h:1599
const wxString & input
reference to input string (must be a reference, so it can be modified)
Definition: Worksheet.h:1618
The canvas that contains the spreadsheet the whole program is about.
Definition: Worksheet.h:109
bool IsActiveInLast() const
Is the editor active in the last cell of the worksheet?
Definition: Worksheet.h:1306
GroupCell * ToggleFold(GroupCell *which)
Fold or unfold a cell.
Definition: Worksheet.cpp:1252
void ClearSelection()
Clear the selection - make it empty, i.e. no selection.
Definition: Worksheet.h:1179
const wxString UnicodeToMaxima(wxString s)
Make a few unicode characters interpretable by maxima.
Definition: Worksheet.cpp:5831
bool CanMergeSelection() const
Can we merge the selected cells into one?
Definition: Worksheet.cpp:6458
ImgCellBase * GetSelectedImgCellBase() const
Returns the selected cell - or NULL, if the selection isn't image nor animation.
Definition: Worksheet.h:1035
wxString RTFStart() const
The start of a RTF document.
Definition: Worksheet.cpp:8448
int m_pointer_x
The x position of the mouse pointer.
Definition: Worksheet.h:1677
void SetDefaultHCaret()
Set the HCaret to its default location, at the end of the document.
Definition: Worksheet.cpp:7081
bool CanDeleteRegion(GroupCell *start, const GroupCell *end) const
Is it possible to delete the cells between start and end?
Definition: Worksheet.cpp:3007
void AddSectionToEvaluationQueue(GroupCell *start)
Adds a chapter, a section or a subsection to the evaluation queue.
Definition: Worksheet.cpp:6194
void AddSymbols(const wxString &xml)
Add a xml-encoded list of symbols to the autocompletion list.
Definition: Worksheet.h:1517
void FoldAll()
Recursively folds the whole document.
Definition: Worksheet.cpp:1289
virtual ~Worksheet()
The destructor.
Definition: Worksheet.cpp:441
bool CutToClipboard()
Add the currently selected cells to the clipboard and delete them.
Definition: Worksheet.cpp:6776
GroupCell * GetInsertGroup() const
The group that the line's cells will belong to - used by InsertLine.
Definition: Worksheet.cpp:861
bool QuestionPending() const
Does maxima wait for the answer of a question?
Definition: Worksheet.h:1553
void AddEntireDocumentToEvaluationQueue()
Schedule all cells in the document for evaluation.
Definition: Worksheet.cpp:6185
GroupCell * FirstVisibleGC()
The first groupCell that is currently visible.
Definition: Worksheet.cpp:2404
void UpdateConfigurationClientSize()
Inform the configuration about the current client size.
Definition: Worksheet.cpp:3492
int ReplaceAll(const wxString &oldString, const wxString &newString, bool ignoreCase, bool searchInInput=true, bool searchInOutput=true)
Replace all occurrences of a string.
Definition: Worksheet.cpp:7897
void AddSymbols(wxXmlDocument xml)
Add a xml-encoded list of symbols to the autocompletion list.
Definition: Worksheet.h:1520
void LoadHelpFileAnchors(const wxString &docdir, const wxString &maximaVersion)
Tries to parse maxima's manual in order to find out which anchors it contains.
Definition: Worksheet.h:1583
bool ExportToHTML(const wxString &file)
Export the file to an html document.
Definition: Worksheet.cpp:4792
void OpenHCaret(const wxString &txt={})
Place the cursor into a new cell where the horizontal cursor is.
Definition: Worksheet.h:1334
TextCell * GetSelectedTextCell() const
Returns the selected cell - or NULL, if the selection isn't a text cell.
Definition: Worksheet.h:1043
void ScrollToError()
Unfold the cell that produced the error, if necessary and, if requested, scroll to it.
Definition: Worksheet.cpp:811
bool HCaretActive() const
Is the vertically-drawn cursor active?
Definition: Worksheet.h:848
void OnEraseBackground(wxEraseEvent &WXUNUSED(event))
Cannot be static as it is called using a function pointer to an object.
Definition: Worksheet.h:586
void ClearDocument()
Empties the current document.
Definition: Worksheet.cpp:1146
wxString RTFEnd() const
The end of a RTF document.
Definition: Worksheet.cpp:8500
void UnfoldAll()
Recursively unfolds the whole document.
Definition: Worksheet.cpp:1299
void UpdateTableOfContents()
Update the table of contents.
Definition: Worksheet.cpp:8824
Cell * GetSelectionEnd() const
Return the last of the currently selected cells.
Definition: Worksheet.h:1175
bool m_blinkDisplayCaret
true = blink the cursor
Definition: Worksheet.h:649
void QuestionPending(bool pending)
Does maxima currently wait for the answer of a question?
Definition: Worksheet.h:1560
void DeleteCurrentCell()
Delete the currently active cell - or the cell above this one.
Definition: Worksheet.cpp:2992
AnimationCell * GetSelectedAnimation() const
Returns the selected cell - or NULL, if the selection isn't an animation.
Definition: Worksheet.h:1019
void Replace(const wxString &oldString, const wxString &newString, bool ignoreCase)
Replace the current occurrence of a string.
Definition: Worksheet.cpp:7863
bool CopyMatlab() const
Copy a Matlab representation of the current selection to the clipboard.
Definition: Worksheet.cpp:2814
bool CopyText() const
Copy a textual representation of the current selection to the clipboard.
Definition: Worksheet.cpp:2877
bool m_inPopupMenu
Is there an active popup menu?
Definition: Worksheet.h:1683
wxTimer m_keyboardInactiveTimer
The timer that tells us when the keyboard is inactive so an autosave isn't disrupting.
Definition: Worksheet.h:888
void Animate(bool run=true) const
Animate the current slide show.
Definition: Worksheet.cpp:7053
static GroupCell * StartOfSectioningUnit(GroupCell *start)
Finds the start of the current chapter/section/...
Definition: Worksheet.cpp:3455
bool CopyRTF() const
Copy a rtf version of the current selection to the clipboard.
Definition: Worksheet.cpp:4543
void UpdateConfig()
Re-read the configuration.
Definition: Worksheet.h:823
int m_pointer_y
The y position of the mouse pointer.
Definition: Worksheet.h:1679
bool Copy(bool astext=false) const
Copy the current selection to the clipboard.
Definition: Worksheet.cpp:2657
bool CopyAnimation() const
Copy the current animation to the clipboard.
Definition: Worksheet.cpp:4521
void StepAnimation(int change=1)
Set the slide of the currently selected animation or advance it by one step.
Definition: Worksheet.cpp:4372
void SetAnswer(const wxString &answer)
Handling questions from and answers for maxima.
Definition: Worksheet.cpp:3190
GroupCell * ToggleFoldAll(GroupCell *which)
Toggles the status of the fold for the given GroupCell and its children.
Definition: Worksheet.cpp:1273
void OnChar(wxKeyEvent &event)
Key for a printable character pressed.
Definition: Worksheet.cpp:4164
void AddSelectionToEvaluationQueue()
Schedule all cells in the selection to be evaluated.
Definition: Worksheet.cpp:6223
bool CanEdit()
We can edit the input if the we have the whole input in selection!
Definition: Worksheet.cpp:6075
bool HasCellsSelected() const
Is at least one entire cell selected?
Definition: Worksheet.h:968
void OnSetFocus(wxFocusEvent &event)
What to do if the worksheet is in the input focus.
Definition: Worksheet.cpp:7006
void SetNotification(const wxString &message, int flags=wxICON_INFORMATION)
Inform the user that something happened in a non-active window.
Definition: Worksheet.cpp:4142
void ScheduleScrollToCell(Cell *cell, bool scrollToTop=true)
Schedules scrolling to a given cell.
Definition: Worksheet.h:1255
GroupCell * InsertGroupCells(std::unique_ptr< GroupCell > &&cells, GroupCell *where, UndoActions *undoBuffer)
Insert group cells into the worksheet.
Definition: Worksheet.cpp:741
void AddDocumentTillHereToEvaluationQueue()
Schedule all cells stopping with the one the caret is in for evaluation.
Definition: Worksheet.cpp:6243
void OnComplete(wxCommandEvent &event)
Is called if an action from the autocomplete menu is selected.
Definition: Worksheet.cpp:8198
bool CanAnimate() const
Does it make sense to enable the "Play" button and the slider now?
Definition: Worksheet.h:1051
bool m_mouseMotionWas
Was there a mouse motion we didn't react to until now?
Definition: Worksheet.h:1681
void SelectAll()
Select the whole document.
Definition: Worksheet.cpp:6929
void OnKillFocus(wxFocusEvent &event)
What to do if the worksheet looses the input focus.
Definition: Worksheet.cpp:7018
void InsertLine(std::unique_ptr< Cell > &&newCell, bool forceNewLine=false)
Add a new line to the output cell of the working group.
Definition: Worksheet.cpp:870
void ClearNotification()
Clears the notification message from SetNotification.
Definition: Worksheet.cpp:4140
void OnFollow()
Called when the "Scroll to currently evaluated" button is pressed.
Definition: Worksheet.cpp:8382
bool m_hCaretActive
Is the active cursor the one represented by a horizontal line?
Definition: Worksheet.h:620
Cell * GetSelectionStart() const
Return the first of the currently selected cells.
Definition: Worksheet.h:1168
void FoldOccurred()
Call when a fold action was detected, to update the state in response to a fold occurring.
Definition: Worksheet.cpp:1240
ImgCell * GetSelectedImgCell() const
Returns the selected cell - or NULL, if the selection isn't an image.
Definition: Worksheet.h:1027
Cell * FindCellByUUID(const wxString &uuid)
Find a cell by its UUID.
Definition: Worksheet.cpp:6291
void EraseBackground(wxEraseEvent &event)
Is called if wxWidgets wants to erase the worksheet's background.
Definition: Worksheet.cpp:244
bool CanDeleteSelection() const
Is it possible to delete the currently selected cells?
Definition: Worksheet.cpp:2976
AutoComplete m_autocomplete
The storage for the autocompletion feature.
Definition: Worksheet.h:726
ToolBar * m_mainToolBar
The toolbar of the main window: We need to access it and therefore have it defined here.
Definition: Worksheet.h:1533
CellPtr< GroupCell > m_hCaretPositionEnd
The end of the selection when selecting group with the horizontally drawn cursor.
Definition: Worksheet.h:637
bool m_questionPrompt
true = the last reply from maxima was a question
Definition: Worksheet.h:1547
bool CaretVisibleIs()
Is the caret (hcaret or vcaret) currently visible on the worksheet?
Definition: Worksheet.cpp:7806
EditorCell * GetActiveCell() const
Get the currently active EditorCell.
Definition: Worksheet.h:731
bool UpdateControlsNeeded()
Is an update of the worksheet controls needed?
Definition: Worksheet.h:113
bool CopyCells() const
Copy the selection to the clipboard as it would appear in a .wxm file.
Definition: Worksheet.cpp:2906
bool OpenQuestionCaret(const wxString &txt={})
Move the cursor to the question maxima currently asks and if needed add a cell for user input.
Definition: Worksheet.cpp:3198
bool FindIncremental(const wxString &str, bool down, bool ignoreCase, bool searchInInput=true, bool searchInOutput=true)
Do an incremental search from the cursor or the point the last search started at.
Definition: Worksheet.cpp:7290
GroupCell * GetLastCell()
Returns the last cell of the worksheet.
Definition: Worksheet.h:1310
GroupCell * GetHCaret()
The cell the horizontal cursor is above. NULL means at the start of the document.
Definition: Worksheet.cpp:7064
bool IsSelected(CellType type)
Does the selection start with a cell of the type "type".
Definition: Worksheet.cpp:7044
wxString ConvertSelectionToMathML() const
Convert the current selection to MathML.
Definition: Worksheet.cpp:2738
bool CanUndoInsideCell() const
Is it possible to issue an undo in the currently selected cell?
Definition: Worksheet.cpp:7130
bool RecalculateIfNeeded(bool timeout=false)
Actually recalculate the worksheet.
Definition: Worksheet.cpp:945
void SetHCaret(GroupCell *where)
Set the HCaret at the location of the given Cell.
Definition: Worksheet.cpp:7091
bool CanRedoInsideCell() const
Is it possible to issue an undo in the currently selected cell?
Definition: Worksheet.cpp:7144
bool GCContainsCurrentQuestion(const GroupCell *cell)
Does the GroupCell cell points to contain the question currently asked by maxima?
Definition: Worksheet.cpp:3427
bool IsEmpty() const
Is this worksheet empty?
Definition: Worksheet.h:664
void NumberSections() const
Renumber all sections.
Definition: Worksheet.cpp:1179
CellPtr< GroupCell > m_recalculateStart
Where to start recalculation. NULL = No recalculation needed.
Definition: Worksheet.h:1675
bool m_saved
True if no changes have to be saved.
Definition: Worksheet.h:657
void OnKeyDown(wxKeyEvent &event)
A special key has been pressed.
Definition: Worksheet.cpp:3322
EditorCell * KeyboardSelectionStart() const
Tells us which cell the keyboard selection has started in.
Definition: Worksheet.h:734
void ExportToMAC(wxTextFile &output, GroupCell *tree, bool wxm, const std::vector< int > &cellMap, bool fixReorderedIndices)
Export a region of the file to a .wxm or .mac file maxima's load command can read.
Definition: Worksheet.cpp:5955
void SetSelection(Cell *sel)
Select the cell sel.
Definition: Worksheet.h:1182
void AddCellToEvaluationQueue(GroupCell *gc)
Schedule this cell for evaluation.
Definition: Worksheet.cpp:6265
void SetCellStyle(GroupCell *group, GroupType style)
Change the style of a cell.
Definition: Worksheet.cpp:3103
bool Autocomplete(AutoComplete::autoCompletionType type=AutoComplete::command)
Definition: Worksheet.cpp:7957
wxBitmap m_memory
A memory we can manually buffer the contents of the area that is to be redrawn in.
Definition: Worksheet.h:1669
wxTimer m_caretTimer
The cursor blink rate. Also the timeout for redrawing the worksheet.
Definition: Worksheet.h:655
void LoadSymbols()
Compile a list of known autocompletion symbols.
Definition: Worksheet.cpp:5829
void SelectGroupCell(GroupCell *cell)
Set this cell as the currently selected one.
Definition: Worksheet.cpp:8368
void ShowPoint(wxPoint point)
Scrolls to a point on the worksheet.
Definition: Worksheet.cpp:6732
void WindowActive(bool active)
Is this window active?
Definition: Worksheet.h:698
bool ExportToTeX(const wxString &file)
export to a LaTeX file
Definition: Worksheet.cpp:5712
bool IsSelectionInWorkingGroup()
Is the selection in the current working group?
Definition: Worksheet.cpp:7059
void ShowHCaret()
Activates the horizontal cursor.
Definition: Worksheet.cpp:7123
void CodeCellVisibilityChanged()
To be called after enabling or disabling the visibility of code cells.
Definition: Worksheet.cpp:5700
void ScrollToCaret()
Request to scroll to the cursor as soon as wxMaxima is idle.
Definition: Worksheet.h:1242
bool m_hCaretBlinkVisible
Is the blinking vertically-drawn cursor currently visible?
Definition: Worksheet.h:651
void MarkRefreshAsDone()
Handle redrawing the worksheet or of parts of it.
Definition: Worksheet.h:776
bool CopyMathML() const
Copy the MathML representation of the current selection to the clipboard.
Definition: Worksheet.cpp:2787
bool CopyBitmap() const
Copy a bitmap of the current selection to the clipboard.
Definition: Worksheet.cpp:4514
bool PointVisibleIs(wxPoint point)
Is the point currently visible on the worksheet?
Definition: Worksheet.cpp:6711
GroupCell * GetLastCellInWorksheet() const
Returns a pointer to the last cell of this worksheet.
Definition: Worksheet.cpp:2542
void ScrollToStart()
Scroll to the start of the worksheet.
Definition: Worksheet.h:839
void Recalculate(Cell *start)
Schedule a recalculation of the worksheet starting with the cell start.
Definition: Worksheet.cpp:1075
void AddSymbol(const wxString &fun, AutoComplete::autoCompletionType type=AutoComplete::command)
Add a symbol to the autocompletion list.
Definition: Worksheet.h:1513
bool FindNext(const wxString &str, bool down, bool ignoreCase, bool searchInInput=true, bool searchInOutput=true, bool warn=true)
Find the next occurrence of a string.
Definition: Worksheet.cpp:7312
bool SectioningMoveIn(GroupCell *parent)
Make this chapter/section/... a section/subsection/... changing its subheadings, too.
Definition: Worksheet.cpp:8235
wxBitmap ConvertSelectionToBitmap() const
Convert the current selection to a bitmap.
std::optional< Notification > m_notificationMessage
A error notification message.
Definition: Worksheet.h:696
void RequestRedraw(GroupCell *start=NULL)
Request the worksheet to be redrawn.
Definition: Worksheet.cpp:413
int GetCellIndex(Cell *cell) const
Returns the index in (i...) or (o...)
Definition: Worksheet.cpp:4695
bool RedrawIfRequested()
Redraw the worksheet if RequestRedraw() has been called.
Definition: Worksheet.cpp:256
void UpdateScrollPos()
Execute all collected scroll events in one go.
Definition: Worksheet.cpp:3444
CellPtr< GroupCell > m_hCaretPosition
The group above the hcaret, NULL for the top of the document See EditorCell::GetActiveCell() for the ...
Definition: Worksheet.h:625
void SetActiveCell(EditorCell *cell)
Mark an editor cell as the active one.
Definition: Worksheet.cpp:6627
FindReplaceDialog * m_findDialog
The find-and-replace-dialog.
Definition: Worksheet.h:845
void QuestionAnswered()
Mark the current question from maxima as "answered"..
Definition: Worksheet.cpp:3431
void DeleteRegion(GroupCell *start, GroupCell *end, UndoActions *undoBuffer)
Definition: Worksheet.cpp:3127
bool ScrollToCaretIfNeeded()
Scrolls to the cursor, if requested.
Definition: Worksheet.cpp:7833
std::unique_ptr< GroupCell > CopyTree() const
Copies the worksheet's entire contents.
Definition: Worksheet.cpp:4510
GroupCell * EndOfSectioningUnit(GroupCell *start)
Finds the end of the current chapter/section/...
Definition: Worksheet.cpp:3472
std::vector< wxString > m_replacementsForCurrentWord
Suggestions for how the word that was right-clicked on could continue.
Definition: Worksheet.h:1593
EvaluationQueue m_evaluationQueue
The list of cells that have to be evaluated.
Definition: Worksheet.h:1442
void ForceRedraw()
Redraw the window now and mark any pending redraw request as "handled".
Definition: Worksheet.h:813
bool CopyTeX() const
Copy the TeX representation of the current selection to the clipboard.
Definition: Worksheet.cpp:2842
void AddRestToEvaluationQueue()
Add all cells below the cursor to the evaluation queue.
Definition: Worksheet.cpp:6203
void ScrollToCellIfNeeded()
Scrolls to the cell given by ScheduleScrollToCell; Is called once we have time to do so.
Definition: Worksheet.cpp:6313
wxTimer m_timer
Time step for autoscrolll when the mouse is outside the window.
Definition: Worksheet.h:653
void OnMouseWheel(wxMouseEvent &event)
Called if the mouse wheel sents events.
Definition: Worksheet.cpp:2438
void CloseAutoCompletePopup()
Close the autocompletion pop-up if it is currently open.
Definition: Worksheet.h:667
bool SectioningMoveOut(GroupCell *parent)
Make this section/subsection/... a chapter/section/... changing its subheadings, too.
Definition: Worksheet.cpp:8277
bool FollowEvaluation() const
Query if we want to automatically scroll to the cell that is currently evaluated.
Definition: Worksheet.h:1376
CellPtr< GroupCell > m_hCaretPositionStart
The start for the selection when selecting group with the horizontally drawn cursor.
Definition: Worksheet.h:631
void DestroyTree()
Clear the whole worksheet.
Definition: Worksheet.cpp:4501
wxString GetString(bool lb=false) const
Convert the current selection to a string.
Definition: Worksheet.cpp:2639
GroupCell * GetWorkingGroup(bool resortToLast=false) const
Returns the cell maxima currently works on.
Definition: Worksheet.cpp:839
bool m_followEvaluation
Do we want to automatically scroll to a cell as soon as it is being evaluated?
Definition: Worksheet.h:640
bool CopySVG() const
Copy a svg of the current selection to the clipboard.
Definition: Worksheet.cpp:4529
wxPoint m_leftDownPosition
The position the left mouse key was pressed at.
Definition: Worksheet.h:611
wxString m_currentFile
The name of the currently-opened file.
Definition: Worksheet.h:830
void Evaluate()
Trigger the evaluation of the current cell(s)
Definition: Worksheet.cpp:3313
void OnScrollChanged(wxScrollEvent &ev)
Called if the user is using the scrollbar for scrolling through the document.
Definition: Worksheet.cpp:7227
void OnActivate(wxActivateEvent &event)
Is called if this element looses or gets the focus.
Definition: Worksheet.cpp:7083
void AddToEvaluationQueue(GroupCell *cell)
Adds a group cell to the evaluation queue marking its contents as "outdated".
Definition: Worksheet.cpp:6171
Definition: CellPointers.h:32