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 "TreeUndoManager.h"
58#include "WorksheetCursor.h"
59#include "WorksheetDocument.h"
61#include "WorksheetSearch.h"
62#include "WorksheetLayout.h"
63#include "cells/TextCell.h"
64#include "EvaluationQueue.h"
66#include "Autocomplete.h"
67#include "AutocompletePopup.h"
69#include "ToolBar.h"
70#include <thread>
71
114class Worksheet : public wxScrolled<wxWindow>, public WorksheetView,
116{
117public:
118 // WorksheetView: the narrow window surface the layout pipeline
119 // (WorksheetLayout) drives; each forwards to the wxScrolled base.
120 void GetViewClientSize(int *width, int *height) const override
121 { GetClientSize(width, height); }
122 int GetViewScrollUnitY() const override
123 { int x, y; GetViewStart(&x, &y); return y; }
124 void SetViewVirtualSize(int width, int height) override
125 { SetVirtualSize(width, height); }
126 void SetViewScrollRate(int rate) override { SetScrollRate(rate, rate); }
127 void GetViewPosition(int *x, int *y) const override
128 { const wxPoint p = GetPosition(); *x = p.x; *y = p.y; }
129
130 // WorksheetDocumentView: how m_document tells this window that a structural
131 // edit happened; each forwards to the real layout/redraw/save machinery.
132 void NotifyRecalculation(GroupCell *start) override
133 { RequestRecalculation(start); }
134 void NotifyRedraw(GroupCell *start) override { RequestRedraw(start); }
135 void NotifyAdjustSizeNeeded() override { m_layout.RequestAdjustSize(); }
136 void NotifySavedStateChanged() override { m_updateControls = true; }
137
139 RecentDocuments &UnsavedDocuments() { return m_unsavedDocuments; }
140private:
141 RecentDocuments m_unsavedDocuments;
142public:
144 bool UpdateControlsNeeded(){bool result = m_updateControls; m_updateControls = false; return result;}
145 void UpdateControlsNeeded(bool updateControlsNeeded){m_updateControls = updateControlsNeeded;}
146private:
148 wxString m_maximaDocDir;
150 bool m_updateControls = true;
152 bool m_scrollToCaret = false;
153 // The x position to scroll to
154 int m_newxPosition = -1;
155 // The y position to scroll to
156 int m_newyPosition = -1;
158 double m_zoomAtGestureStart = 1.0;
160 bool m_scrollToTopOfCell = false;
162 bool m_windowActive = true;
164 wxRegion m_regionToRefresh;
169 wxClientDC m_dc;
171 CellPtr<GroupCell> m_redrawStart;
173 bool m_fullRedrawRequested = false;
175
177 static wxDataFormat m_wxmFormat;
179 static wxDataFormat m_mathmlFormat;
181 static wxDataFormat m_mathmlFormat2;
183 static wxDataFormat m_rtfFormat;
185 static wxDataFormat m_rtfFormat2;
189 static wxDataFormat m_rtfFormat3;
190
193 class MathMLDataObject : public wxCustomDataObject
194 {
195 public:
196 explicit MathMLDataObject(const wxString &data);
197
198 MathMLDataObject();
199
200 private:
201 wxCharBuffer m_databuf;
202 };
203
205 class wxmDataObject : public wxCustomDataObject
206 {
207 public:
208 explicit wxmDataObject(const wxString &data);
209
210 wxmDataObject();
211
212 private:
213 wxCharBuffer m_databuf;
214 };
215
216 class MathMLDataObject2 : public wxCustomDataObject
217 {
218 public:
219 explicit MathMLDataObject2(const wxString &data);
220
221 MathMLDataObject2();
222
223 private:
224 wxCharBuffer m_databuf;
225 };
226
229 class RtfDataObject : public wxCustomDataObject
230 {
231 public:
232 explicit RtfDataObject(const wxString &data);
233
234 RtfDataObject();
235
236 private:
237 wxCharBuffer m_databuf;
238 };
239
240 class RtfDataObject2 : public wxCustomDataObject
241 {
242 public:
243 explicit RtfDataObject2(const wxString &data);
244
245 RtfDataObject2();
246
247 private:
248 wxCharBuffer m_databuf;
249 };
250
253 class RtfDataObject3 : public wxCustomDataObject
254 {
255 public:
256 explicit RtfDataObject3(const wxString &data);
257
258 RtfDataObject3();
259
260 private:
261 wxCharBuffer m_databuf;
262 };
263
265 bool m_hasFocus = true;
267 long m_lastTop = 0;
269 long m_lastBottom = 0;
291 // TreeUndoAction/UndoActions live in TreeUndoAction.h and the undo/redo
292 // state (the two stacks + the active-cell snapshot) is owned by the
293 // TreeUndoManager below; only the tree surgery of applying an action
294 // remains a Worksheet responsibility.
295
296private:
298 TreeUndoManager &GetTreeUndo() { return m_document.GetTreeUndo(); }
299 const TreeUndoManager &GetTreeUndo() const { return m_document.GetTreeUndo(); }
300
301public:
304
307
309 void TreeUndo_AppendAction() { GetTreeUndo().AppendAction(); }
310
316 bool TreeUndo(UndoActions *sourcelist, UndoActions *undoForThisOperation);
317
321 bool TreeUndoTextChange(UndoActions *sourcelist, UndoActions *undoForThisOperation);
325 bool TreeUndoCellDeletion(UndoActions *sourcelist, UndoActions *undoForThisOperation);
329 bool TreeUndoCellAddition(UndoActions *sourcelist, UndoActions *undoForThisOperation);
333 bool TreeUndoFold(UndoActions *sourcelist, UndoActions *undoForThisOperation);
334
336 bool TreeUndo()
337 { return TreeUndo(&GetTreeUndo().UndoStack(), &GetTreeUndo().RedoStack()); }
338
340 bool TreeRedo()
341 { return TreeUndo(&GetTreeUndo().RedoStack(), &GetTreeUndo().UndoStack()); }
342
344 bool CanTreeUndo() const;
345
347 bool CanTreeRedo() const;
348
352
355 void TreeUndo_CellLeft();
356
365 void TreeUndo_MarkCellsAsAdded(GroupCell *start, GroupCell *end, UndoActions *undoBuffer);
366
367
373 void TreeUndo_MarkCellsAsAdded(GroupCell *parentOfStart, GroupCell *end);
375
376private:
377 bool m_scrolledAwayFromEvaluation = false;
378public:
379
382 {
383 CLICK_TYPE_NONE,
384 CLICK_TYPE_GROUP_SELECTION,
385 CLICK_TYPE_INPUT_SELECTION,
386 CLICK_TYPE_INPUT_LABEL_SELECTION,
387 CLICK_TYPE_OUTPUT_SELECTION
388 };
389
392 {
393 TIMER_ID,
394 CARET_TIMER_ID,
395 DISPLAY_TIMEOUT_ID
396 };
397
399 std::unique_ptr<Cell> CopySelection(bool asData = false) const;
400
409 std::unique_ptr<Cell> CopySelection(Cell *start, Cell *end, bool asData = false) const;
410
412 void GetMaxPoint(int *width, int *height) { m_layout.GetMaxPoint(width, height); }
413
415 void OnTimer(wxTimerEvent &event);
416
417#if wxCHECK_VERSION(3, 1, 1)
419 void OnZoom(wxZoomGestureEvent &event);
420#endif
421
422 void OnMouseExit(wxMouseEvent &event);
423
424 void OnMouseEnter(wxMouseEvent &event);
425
438 void OnPaint(wxPaintEvent &event);
440 void DrawGroupCell(wxDC &dc, wxDC &adc, GroupCell &cell);
448 void DrawGroupCell_UsingBitmap(wxDC *dc, GroupCell *cell);
449
451 void PrepareDrawGC(wxDC &dc) const;
452
453 void OnSize(wxSizeEvent &event);
454
455 void OnMouseRightDown(wxMouseEvent &event);
456
457 void OnSidebarKey(wxCommandEvent &event);
458
459 void OnMouseLeftUp(wxMouseEvent &event);
460
462 void OnMouseCaptureLost(wxMouseCaptureLostEvent &event);
463
464 void OnMouseLeftDown(wxMouseEvent &event);
465
466 void OnMouseLeftInGcCell(wxMouseEvent &event, GroupCell *clickedInGC);
467
468 void OnMouseLeftInGcLeft(wxMouseEvent &event, GroupCell *clickedInGC);
469
470 void OnMouseLeftInGc(wxMouseEvent &event, GroupCell *clickedInGC);
471
472 void OnMouseMotion(wxMouseEvent &event);
473
475 void OnDoubleClick(wxMouseEvent &event);
476
478 void OnCharInActive(wxKeyEvent &event);
479
481 void OnCharNoActive(wxKeyEvent &event);
482
484 void SelectEditable(EditorCell *editor, bool up);
485
492 void SelectWithChar(int ccode);
493
508 void ClickNDrag(wxPoint down, wxPoint up);
509
510 // Select all group cells inside the given rectangle;
511 void SelectGroupCells(wxPoint down, wxPoint up);
512
513public:
515 void AdjustSize() { m_layout.AdjustSize(); }
516
518 void OnEraseBackground(wxEraseEvent& WXUNUSED(event))
519 {}
520
521 void CheckUnixCopy();
522
523 void OnMouseMiddleUp(wxMouseEvent &event);
524
525 static bool IsLesserGCType(int type, int comparedTo);
526
529
532
534 void OnComplete(wxCommandEvent &event);
535
540 void EraseBackground(wxEraseEvent &event);
541
542private:
544 wxPoint m_leftDownPosition;
545 wxPoint m_down;
546 wxPoint m_up;
547 wxPoint m_mousePoint;
556 WorksheetCursor &GetHCaretCursor() { return m_document.GetCursor(); }
557 const WorksheetCursor &GetHCaretCursor() const { return m_document.GetCursor(); }
558 bool m_leftDown = false;
560 bool m_followEvaluation = true;
561 bool m_mouseDrag = false;
562 bool m_mouseOutside = false;
563
564public:
567private:
568 int m_clickType = CLICK_TYPE_NONE;
569 CellPtr<GroupCell> m_clickInGC;
571 bool m_blinkDisplayCaret = true;
573 bool m_hCaretBlinkVisible = true;
575 wxTimer m_timer;
577 wxTimer m_caretTimer;
578 std::vector<wxString> m_completions;
579 bool m_autocompleteTemplates = true;
580 AutocompletePopup *m_autocompletePopup;
581
582public:
584 bool IsEmpty() const
585 { return !GetTree() || (!GetTree()->GetNext() && GetTree()->GetEditable()->GetValue().Length() <= 1); }
588 {
589 if(m_autocompletePopup != NULL)
590 m_autocompletePopup->Destroy();
591 }
592
598 void OnChar(wxKeyEvent &event);
599
604 void OnKeyDown(wxKeyEvent &event);
606 void SetCellStyle(GroupCell *group, GroupType style);
607
609 void NumberSections() const;
610
612 bool SectioningMoveIn(GroupCell *parent);
614 bool SectioningMoveOut(GroupCell *parent);
616 std::optional<Notification> &GetNotification() { return m_notificationMessage; }
617private:
619 std::optional<Notification> m_notificationMessage;
620public:
622 void WindowActive(bool active){m_windowActive = active;}
624 void ClearNotification();
629 void SetNotification(const wxString &message, int flags = wxICON_INFORMATION);
630
632 void OnActivate(wxActivateEvent &event);
633private:
636 std::unique_ptr<GroupCell> &TreeOwner() { return m_document.TreeOwner(); }
637 CellPtr<GroupCell> &LastCache() const { return m_document.LastCache(); }
638// std::vector<std::jthread> m_drawThreads;
639 static std::mutex m_drawDCLock;
642 Configuration *m_configuration = NULL;
649 WorksheetLayout m_layout;
650public:
651 void FocusFindDialogue()
652 {
654 pane->SetFocus();
655 }
662 AutoComplete &GetAutocomplete() { return m_autocomplete; }
663private:
664 AutoComplete m_autocomplete;
665public:
666
667 Configuration *GetConfig() const { return m_configuration; }
668
671
675
676 EditorCell *MouseSelectionStart() const
678
679 EditorCell *SearchStart() const
680 { return GetViewCellPointers().SearchStart(); }
681
682 int IndexSearchStartedAt() const
684
691
693 TextCell *GetCurrentTextCell() const { return GetDocumentCellPointers().GetCurrentTextCell(); }
694 void SetCurrentTextCell(TextCell *cell) { GetDocumentCellPointers().SetCurrentTextCell(cell); }
695 void SetWorkingGroup(GroupCell *group) { GetDocumentCellPointers().SetWorkingGroup(group); }
696
703
721 {
722 m_redrawStart = NULL;
723 m_fullRedrawRequested = false;
724 }
725
730 bool RedrawIfRequested();
731
744 void RequestRedraw(GroupCell *start = NULL);
754 void RequestRedraw(wxRect rect);
755
758 {
761 }
762
765
768 m_configuration->ReadConfig();
771 Refresh();
772 }
773
783
785 const wxString &GetCurrentFile() const { return m_document.GetCurrentFile(); }
787 void SetCurrentFile(const wxString &file) { m_document.SetCurrentFile(file); }
788
793 const wxString UnicodeToMaxima(wxString s);
794
796 void ScrollToStart() { Scroll(0, 0); }
797
799 void ScrollToError();
800
807
809 bool HCaretActive() const { return GetHCaretCursor().IsActive(); }
810
817
818 bool CanUndo() const;
819
820 bool CanRedo() const;
821
822 void Undo();
823
824 void Redo();
825
830 void TreeUndo_ClearBuffers();
831
841 Worksheet(wxWindow *parent, int id, Configuration *config,
842 wxPoint pos = wxDefaultPosition, wxSize size = wxDefaultSize,
843 bool reactToEvents = true);
844
846 virtual ~Worksheet();
847
849 wxTimer &KeyboardInactiveTimer() { return m_keyboardInactiveTimer; }
850private:
851 wxTimer m_keyboardInactiveTimer;
852public:
853
855 void DestroyTree();
856
858 std::unique_ptr<GroupCell> CopyTree() const;
859
871 GroupCell *InsertGroupCells(std::unique_ptr<GroupCell> &&cells, GroupCell *where,
872 UndoActions *undoBuffer);
873
879 GroupCell *InsertGroupCells(std::unique_ptr<GroupCell> &&cells, GroupCell *where = NULL);
880
886 void InsertLine(std::unique_ptr<Cell> &&newCell, bool forceNewLine = false);
887
889 GroupCell *GetInsertGroup() const;
890
906 bool RecalculateIfNeeded(bool timeout = false, long timeSliceMs = 50)
907 { return m_layout.RecalculateIfNeeded(timeout, timeSliceMs); }
908
919 void RequestRecalculation(Cell *start) { m_layout.RequestRecalculation(start); }
920
931
933 int GetLastCellsVisited() const { return m_layout.GetLastCellsVisited(); }
935 int GetLastCellsRecalculated() const { return m_layout.GetLastCellsRecalculated(); }
936
941 void ClearDocument();
942
943 void ResetInputPrompts();
944
945 bool CanCopy() const
946 {
950 }
951
960 bool CanCopyAsMathML() const;
961
962 bool CanPaste() const
963 { return GetDocumentCellPointers().GetActiveCell() || GetHCaretCursor().IsActive(); }
964
965 bool CanCut() const
966 {
969 }
970
972 void SelectAll();
973
976
987 void DeleteRegion(
988 GroupCell *start,
989 GroupCell *end,
990 UndoActions *undoBuffer
991 );
992
999 void DeleteRegion(
1000 GroupCell *start,
1001 GroupCell *end
1002 );
1003
1009 void DeleteSelection();
1010
1011 void TOCdnd(GroupCell *dndStart, GroupCell *dndEnd);
1012
1014 bool CanDeleteRegion(GroupCell *start, const GroupCell *end) const;
1015
1018
1023 void DeleteCurrentCell();
1024
1027 {
1029 return NULL;
1030 return dynamic_cast<AnimationCell *>(GetSelectionStart());
1031 }
1032
1035 {
1037 return NULL;
1038 return dynamic_cast<ImgCell *>(GetSelectionStart());
1039 }
1040
1043 {
1045 return NULL;
1046 return dynamic_cast<ImgCellBase *>(GetSelectionStart());
1047 }
1048
1051 {
1053 return NULL;
1054 return dynamic_cast<TextCell *>(GetSelectionStart());
1055 }
1056
1058 bool CanAnimate() const
1059 {
1061 (dynamic_cast<AnimationCell *>(GetSelectionStart()) != NULL);
1062 }
1063
1070 void Animate(bool run = true) const;
1071
1072 void DivideCell();
1073
1074 void MergeCells();
1075
1076 void SetLastQuestion(const wxString &lastQuestion){m_document.SetLastQuestion(lastQuestion);}
1077 wxString GetLastQuestion() const {return m_document.GetLastQuestion();}
1078
1080 bool CutToClipboard();
1081
1082 void PasteFromClipboard();
1083
1090 bool Copy(bool astext = false) const;
1091
1099 std::unique_ptr<wxDataObject> CreateSelectionDataObject() const;
1100
1102 bool CopyCells() const;
1103
1110 std::unique_ptr<wxDataObject> CreateCellsDataObject() const;
1111
1113 bool CopyMatlab() const;
1114
1116 bool CopyText() const;
1117
1119 bool CopyTeX() const;
1120
1122 wxString ConvertSelectionToMathML() const;
1123
1126
1128 bool CopyMathML() const;
1129
1131 bool CopyBitmap() const;
1132
1134 bool CopyAnimation() const;
1135
1137 bool CopySVG() const;
1138
1139#if wxUSE_ENH_METAFILE
1141 bool CopyEMF() const;
1142#endif
1143
1145 bool CopyRTF() const;
1146
1150 bool CopyHTML() const;
1151
1152 wxSize CopyToFile(const wxString &file) const;
1153
1154 wxSize CopyToFile(const wxString &file, Cell *start, Cell *end, bool asData = false, double scale = 1) const;
1155
1167 int ExportSelectionOutputToDir(const wxString &dir, bool svg);
1168
1173 bool ExportToHTML(const wxString &file);
1174
1176 bool ExportToMAC(const wxString &file);
1177
1179 wxString RTFStart() const;
1180
1182 wxString RTFEnd() const;
1183
1185 bool ExportToTeX(const wxString &file);
1186
1192 wxString GetString(bool lb = false) const;
1193
1194 GroupCell *GetTree() const { return m_document.GetTree(); }
1195 std::unique_ptr<GroupCell> *GetTreeAddress() { return &m_document.TreeOwner(); }
1196
1203
1210
1212 void ClearSelection() { SetSelection(nullptr, nullptr); }
1213
1215 void SetSelection(Cell *sel) { SetSelection(sel, sel); }
1216
1218 void SetSelection(Cell *start, Cell *end);
1219
1221 Cell *FindCellByUUID(const wxString &uuid);
1222
1225
1228 bool CanEdit() const { return m_document.CanEdit(); }
1229
1230 bool ActivatePrevInput() { return ActivateInput(-1); }
1231 bool ActivateNextInput() { return ActivateInput(+1); }
1232 wxString GetStatusText() const {return m_statusText;}
1233 bool StatusTextChangedHas() {
1234 bool retval = (m_statusTextHas != m_statusTextHas_old) ||
1235 (m_statusText != m_statusText_old);
1236 m_statusText_old = m_statusText;
1237 m_statusTextHas_old = m_statusTextHas;
1238 return retval;
1239 }
1240 bool StatusTextHas() const {return m_statusTextHas;}
1241private:
1242 /* ! A timer that tells us to urgently update the display
1243
1244 Normally we prioritize tasks: If there are GUI actions to process we do so.
1245 If not we look if there is data from maxima to process. If not we
1246 If not we recalculate the worksheet element sizes and positions and if
1247 there still is no pressing task we update the display. This way we
1248 respond quickly to the most important inputs.
1249
1250 This timer, if expired, tells us that if we don't update the screen now
1251 maxima feels like not being responsive.
1252 */
1253 wxTimer m_displayTimeoutTimer;
1254
1255 template <class T_SRC, class T_DEST>
1256 inline std::unique_ptr<T_DEST> unique_cast(std::unique_ptr<T_SRC> &&src)
1257 {
1258 if (!src) return std::unique_ptr<T_DEST>();
1259
1260 T_DEST *dest_ptr = &dynamic_cast<T_DEST &>(*src.get());
1261
1262 (void) src.release();
1263 return std::unique_ptr<T_DEST>(dest_ptr);
1264 }
1265 wxString m_statusText;
1266 wxString m_statusText_old;
1267 bool m_statusTextHas = false;
1268 bool m_statusTextHas_old = false;
1269 void StatusText(const wxString &text){m_statusText = text; m_statusTextHas = true;}
1270 void UnsetStatusText(){m_statusTextHas = false;}
1271 bool ActivateInput(int direction);
1272
1273public:
1276 {
1278 m_scrollToCaret = true;
1279 }
1280
1282 bool ScrollToCaretIfNeeded();
1283
1285 void ScrollToCellIfNeeded();
1286
1288 void ScheduleScrollToCell(Cell *cell, bool scrollToTop = true)
1289 {
1290 GetViewCellPointers().ScrollToCell(cell);
1291 m_scrollToTopOfCell = scrollToTop;
1292 m_scrollToCaret = false;
1293
1295 }
1296
1298 bool PointVisibleIs(wxPoint point);
1299
1301 bool CaretVisibleIs();
1302
1305
1319 void ShowPoint(wxPoint point);
1320
1322 void OnSetFocus(wxFocusEvent &event);
1323
1325 void OnKillFocus(wxFocusEvent &event);
1326
1328 bool IsSelected(CellType type) const { return m_document.IsSelected(type); }
1329
1336 void StepAnimation(int change = 1);
1337
1339 bool IsActiveInLast() const
1341
1344 {
1345 return GetLastCellInWorksheet();
1346 }
1347
1350
1351 void SetActiveCell(EditorCell *cell);
1352
1356 void SetDefaultHCaret();
1357
1362 void SetHCaret(GroupCell *where); // call with false, when manually refreshing
1365
1367 void OpenHCaret(const wxString &txt = {})
1368 {
1369 if(m_mainToolBar == NULL)
1370 OpenHCaret(txt, GC_TYPE_CODE);
1371 else
1373 }
1374
1376 void OpenHCaret(const wxString &txt, GroupType type);
1377
1379 void ShowHCaret();
1380
1386
1387 void UndoInsideCell();
1388
1394
1395 void RedoInsideCell();
1396
1406 void FollowEvaluation(bool followEvaluation);
1407
1409 bool FollowEvaluation() const
1410 { return m_followEvaluation; }
1411
1417 void ScrolledAwayFromEvaluation(bool ScrolledAway);
1418
1419 bool ScrolledAwayFromEvaluation() const
1420 { return m_scrolledAwayFromEvaluation; }
1421
1422 void SaveValue();
1423
1424 bool IsSaved() const
1425 { return m_document.IsSaved(); }
1426
1427 void SetSaved(bool saved)
1428 { m_document.SetSaved(saved); }
1429
1430 void OutputChanged()
1432
1434 void RemoveAllOutput();
1435
1443 void RemoveAllOutput(GroupCell *cell);
1444 // methods related to evaluation queue
1445
1451 void Evaluate();
1452
1454 void AddToEvaluationQueue(GroupCell *cell);
1455
1456 void AddDocumentToEvaluationQueue();
1457
1460
1463
1466
1469
1472
1475
1478
1481
1482 void FoldOccurred();
1483
1484 // methods for folding
1486 GroupCell *Fold(GroupCell *which) { return m_document.Fold(which); }
1487
1489 GroupCell *Unfold(GroupCell *which) { return m_document.Unfold(which); }
1490
1493
1494 GroupCell *ToggleFoldAll(GroupCell *which) { return m_document.ToggleFoldAll(which); }
1495
1496 void FoldAll() { m_document.FoldAll(); }
1497
1498 void UnfoldAll() { m_document.UnfoldAll(); }
1499
1500 // methods for zooming the document in and out
1501 void SetZoomFactor(double newzoom);
1502
1503 void CommentSelection();
1504
1509 void OnScrollChanged(wxScrollEvent &ev);
1510 void OnScrollEvent(wxScrollWinEvent &ev);
1511 void CheckIfActiveCellScrolledOut();
1516 void OnMouseWheel(wxMouseEvent &event);
1517
1523 bool FindIncremental(const wxString &str, bool down, bool ignoreCase, bool searchInInput = true, bool searchInOutput = true);
1524 bool FindIncremental_RegEx(const wxString &str, bool down, bool searchInInput = true, bool searchInOutput = true);
1525
1526private:
1530 WorksheetSearch::SearchStart FindStart(bool down);
1536 bool ApplyFindResult(const WorksheetSearch::SearchTarget &target, bool warn);
1537public:
1544 bool FindNext(const wxString &str, bool down, bool ignoreCase, bool searchInInput = true, bool searchInOutput = true, bool warn = true);
1545 bool FindNext_Regex(const wxString &str, const bool &down, bool searchInInput = true, bool searchInOutput = true, bool warn = true);
1546
1551 void Replace(const wxString &oldString, const wxString &newString, bool ignoreCase);
1552 void Replace_RegEx(const wxString &oldString, const wxString &newString);
1553
1558 int ReplaceAll(const wxString &oldString, const wxString &newString, bool ignoreCase, bool searchInInput = true, bool searchInOutput = true);
1559 int ReplaceAll_RegEx(const wxString &oldString, const wxString &newString, bool searchInInput = true, bool searchInOutput = true);
1560
1571 void AnonymizeCodeCells();
1572
1573 wxString GetInputAboveCaret();
1574
1575 wxString GetOutputAboveCaret();
1576
1578 void LoadSymbols();
1579
1580 bool Autocomplete(AutoComplete::autoCompletionType type = AutoComplete::command);
1581
1583 void AddSymbol(const wxString &fun, AutoComplete::autoCompletionType type = AutoComplete::command)
1584 { m_autocomplete.AddSymbol(fun, type); }
1585
1587 void AddSymbols(const wxString &xml)
1588 { m_autocomplete.AddSymbols(xml); }
1590 void AddSymbols(wxXmlDocument xml)
1591 { m_autocomplete.AddSymbols(xml); }
1592
1593 void SetActiveCellText(const wxString &text);
1594
1595 bool InsertText(const wxString &text);
1596
1597 void OpenNextOrCreateCell();
1598
1600 void OnFollow();
1601
1604
1606 void SelectGroupCell(GroupCell *cell);
1607
1612 void SetAnswer(const wxString &answer);
1614 void QuestionAnswered();
1615
1620 bool QuestionPending() const
1621 { return m_document.QuestionPending(); }
1623
1627 void QuestionPending(bool pending)
1628 { m_document.SetQuestionPending(pending); }
1629
1630 void SetMaximaDocDir(const wxString &dir)
1631 {
1632 m_maximaDocDir = dir;
1633 }
1634 const wxString &GetMaximaDocDir() const { return m_maximaDocDir; }
1635
1637 bool GCContainsCurrentQuestion(const GroupCell *cell);
1638
1641 bool OpenQuestionCaret(const wxString &txt = {});
1642
1651 bool WillAutoAnswer() const;
1652 void UpdateScrollPos();
1653
1659 GroupCell *GetWorkingGroup(bool resortToLast = false) const;
1661 void LoadHelpFileAnchors(const wxString &docdir, const wxString &maximaVersion)
1662 {m_maximaManual.LoadHelpFileAnchors(docdir, maximaVersion);}
1663 wxString GetHelpfileAnchorName(const wxString &keyword)
1664 {return m_maximaManual.GetHelpfileAnchorName(keyword);}
1665 wxString GetHelpfileURL(const wxString &keyword)
1666 {return m_maximaManual.GetHelpfileURL(keyword);}
1667
1669 std::vector<wxString> m_replacementsForCurrentWord;
1670#if wxUSE_ACCESSIBILITY
1671 int GetAccessibilityId(Cell *cell) const;
1672#endif
1673
1674#if wxUSE_ACCESSIBILITY
1675 class AccessibilityInfo: public wxAccessible
1676 {
1677 public:
1678 AccessibilityInfo(wxWindow *parent, Worksheet *worksheet);
1679 wxAccStatus GetName (int childId, wxString *name);
1680 wxAccStatus GetChildCount (int *childCount);
1681 wxAccStatus GetChild (int childId, wxAccessible **child);
1682 wxAccStatus GetDefaultAction(int childId, wxString *actionName);
1683 wxAccStatus GetParent (wxAccessible ** parent);
1684 wxAccStatus GetFocus (int *childId, wxAccessible **child);
1685 wxAccStatus GetLocation (wxRect &rect, int elementId);
1686 wxAccStatus HitTest (const wxPoint &pt,
1687 int *childId, wxAccessible **childObject);
1688 wxAccStatus GetDescription(int childId, wxString *description);
1689 wxAccStatus GetRole(int childId, wxAccRole *role);
1690 wxAccStatus GetState(int childId, long *state);
1691 private:
1692 wxWindow *m_parent = NULL;
1693 Worksheet *m_worksheet = NULL;
1694
1695 class CaretAccessibilityInfo : public wxAccessible {
1696 public:
1697 CaretAccessibilityInfo(AccessibilityInfo* parent, Worksheet* worksheet)
1698 : wxAccessible(worksheet->GetTargetWindow()), m_parent(parent), m_worksheet(worksheet) {}
1699
1700 wxAccStatus GetName(int childId, wxString *name) override;
1701 wxAccStatus GetDescription(int WXUNUSED(childId), wxString *description) override;
1702 wxAccStatus GetParent(wxAccessible **parent) override;
1703 wxAccStatus GetChildCount(int *childCount) override;
1704 wxAccStatus GetChild(int childId, wxAccessible **child) override;
1705 wxAccStatus GetRole(int childId, wxAccRole *role) override;
1706 private:
1707 AccessibilityInfo* m_parent;
1708 Worksheet* m_worksheet;
1709 };
1710 CaretAccessibilityInfo* m_caretAccessible = nullptr;
1711 };
1712#endif
1713 MaximaManual m_maximaManual;
1714 MaximaManual *GetMaximaManual() {return &m_maximaManual;}
1715protected:
1716 void FocusTextControl();
1726 wxBitmap m_memory;
1727 virtual wxSize DoGetBestClientSize() const override;
1728#if wxUSE_ACCESSIBILITY
1729 AccessibilityInfo *m_accessibilityInfo = NULL;
1730#endif
1732 int m_pointer_x = -1;
1734 int m_pointer_y = -1;
1736 bool m_mouseMotionWas = false;
1738 bool m_inPopupMenu = false;
1739};
1740
1741wxDECLARE_EVENT(TOC_UPDATE_NEEDED_EVENT, wxCommandEvent);
1742
1743#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:43
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.
std::list< TreeUndoAction > UndoActions
The type of the list of tree actions that can be undone.
Definition: TreeUndoAction.h:141
Declares TreeUndoManager: the owner of the cell-tree undo/redo state.
This file contains the definition of the class Unicodesidebar that allows to select arbitrary unicode...
The file that contains the "variables" sidepane.
The worksheet's "between the cells" cursor (the horizontally drawn caret).
The narrow "something in the document changed" surface a WorksheetDocument needs to poke its view.
The document half of the worksheet: the state and commands that describe the edited document itself,...
The worksheet's layout engine: scheduling, the recalculation walk and the virtual-size update,...
The worksheet's search engine.
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:686
Definition: AutocompletePopup.h:47
A weak non-owning pointer that becomes null whenever the observed object is destroyed.
Definition: CellPtr.h:539
The base class all cell types the worksheet can consist of are derived from.
Definition: Cell.h:148
GroupCell * GetGroup() const
Returns the group cell this cell belongs to.
Definition: Cell.cpp:285
CellType GetType() const
Returns the type of this cell.
Definition: Cell.h:489
The configuration storage for the current worksheet.
Definition: Configuration.h:98
void ReadConfig()
Read the config from the wxConfig object.
Definition: Configuration.cpp:613
A list of editor cells containing error messages.
Definition: CellPointers.h:54
The document-model half of the cell-pointer registry.
Definition: CellPointers.h:50
TextCell * GetCurrentTextCell() const
The text cell the text maxima is currently sending us is being appended to.
Definition: CellPointers.cpp:134
const CellPtr< Cell > & GetSelectionStart() const
The first cell of the currently selected range of cells, or null. Returned by reference so callers ke...
Definition: CellPointers.h:93
const CellPtr< Cell > & GetSelectionEnd() const
The last cell of the currently selected range of cells, or null.
Definition: CellPointers.h:95
void SetCurrentTextCell(TextCell *cell)
Set the text cell maxima's incoming text is being appended to (may be null).
Definition: CellPointers.cpp:138
bool HasCellsSelected() const
Are any whole cells (as opposed to text inside an editor) selected?
Definition: CellPointers.h:88
void SetWorkingGroup(GroupCell *group)
Sets the cell maxima currently works on. NULL if there isn't such a cell.
Definition: CellPointers.cpp:146
ErrorList & GetErrorList()
The list of cells maxima has complained about errors in.
Definition: CellPointers.h:134
EditorCell * GetActiveCell() const
The editor cell the blinking text cursor is in, or null.
Definition: CellPointers.cpp:142
This class defines what the user sees as input cell.
Definition: EditorCell.h:62
const wxString & GetValue() const override
Returns the text contained in this cell.
Definition: EditorCell.h:225
bool CanCopy() const override
Select Can we copy the editable text of this cell?
Definition: EditorCell.h:377
A simple FIFO queue with manual removal of elements.
Definition: EvaluationQueue.h:43
The find+replace dialog.
Definition: FindReplaceDialog.h:42
The find+replace pane.
Definition: FindReplacePane.h:46
A cell grouping input (and, if there is one, also the output) cell to a foldable item.
Definition: GroupCell.h:88
GroupCell * GetNext() const
Get the next GroupCell in the list.
Definition: GroupCell.h:280
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:538
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:698
Owns the cell-tree undo/redo stacks and the active-cell snapshot.
Definition: TreeUndoManager.h:51
void ClearUndoActionList()
Clear the list of actions that can be undone.
Definition: TreeUndoManager.h:94
void ClearRedoActionList()
Clear the list of actions that can be redone.
Definition: TreeUndoManager.h:87
static void AppendAction(UndoActions *actionList)
Mark the newest action of the list as part of the following atomic action.
Definition: TreeUndoManager.h:77
The view/interaction half of the cell-pointer registry.
Definition: CellPointers.h:187
const CellPtr< EditorCell > & MouseSelectionStart() const
The EditorCell a mouse selection was started in, or null.
Definition: CellPointers.h:214
int IndexSearchStartedAt() const
The cursor position an incremental search was started at (-1 = none).
Definition: CellPointers.h:202
const CellPtr< EditorCell > & KeyboardSelectionStart() const
The EditorCell a keyboard selection was started in, or null.
Definition: CellPointers.h:223
const CellPtr< EditorCell > & SearchStart() const
The EditorCell an incremental search was started in, or null.
Definition: CellPointers.h:200
void SetScrollToCellScheduled(bool scheduled)
Schedule (or cancel) scrolling to CellToScrollTo().
Definition: CellPointers.h:197
The between-the-cells cursor: active flag, position, selection anchors.
Definition: WorksheetCursor.h:49
bool IsActive() const
Is this (rather than the in-cell text cursor) the active cursor?
Definition: WorksheetCursor.h:52
The view notifications a WorksheetDocument emits when it edits itself.
Definition: WorksheetDocumentView.h:50
The view-independent state and commands of an edited worksheet document.
Definition: WorksheetDocument.h:61
bool CanMergeSelection() const
Can the current selection (of more than one cell) be merged into one?
Definition: WorksheetDocument.cpp:361
CellPtr< GroupCell > & LastCache() const
The cached pointer to the document's last GroupCell (<0 = unknown).
Definition: WorksheetDocument.h:93
bool CanRedoInsideCell() const
Can the active cell's own (intra-cell) redo be invoked right now?
Definition: WorksheetDocument.cpp:390
void SetSaved(bool saved)
Record whether the document is in its saved state.
Definition: WorksheetDocument.cpp:34
void FoldAll()
Recursively folds every foldable cell in the document.
Definition: WorksheetDocument.cpp:317
void UnfoldAll()
Recursively unfolds every folded cell in the document.
Definition: WorksheetDocument.cpp:326
bool QuestionPending() const
Is Maxima currently waiting for an answer to a question?
Definition: WorksheetDocument.h:215
bool CanUndoInsideCell() const
Can the active cell's own (intra-cell) undo be invoked right now?
Definition: WorksheetDocument.cpp:386
bool IsSaved() const
True while the document has no unsaved changes.
Definition: WorksheetDocument.h:226
void SetCurrentFile(const wxString &file)
Record the file this document is associated with.
Definition: WorksheetDocument.h:205
EvaluationQueue & GetEvaluationQueue()
The list of cells scheduled to be sent to Maxima for evaluation.
Definition: WorksheetDocument.h:64
GroupCell * Unfold(GroupCell *which)
Unfold which; see GroupCell::Unfold(). Mirrors Fold().
Definition: WorksheetDocument.cpp:277
bool IsSelectionInWorkingGroup() const
Is the selection start inside the group Maxima is currently evaluating?
Definition: WorksheetDocument.cpp:381
DocumentCellPointers & GetCellPointers()
The document-model half of the cell-pointer registry (selection, the active/answer/current-text cell,...
Definition: WorksheetDocument.h:221
bool IsSelected(CellType type) const
Is the selection exactly one cell of the given type?
Definition: WorksheetDocument.cpp:374
GroupCell * ToggleFold(GroupCell *which)
Fold or unfold which, whichever it currently isn't; see GroupCell::Fold()/Unfold().
Definition: WorksheetDocument.cpp:292
TreeUndoManager & GetTreeUndo()
The document's undo/redo history of tree-structure edits.
Definition: WorksheetDocument.h:69
const wxString & GetCurrentFile() const
The file this document was last loaded from / saved to (empty if none).
Definition: WorksheetDocument.h:203
std::unique_ptr< GroupCell > & TreeOwner()
Mutable access to the owning pointer of the cell tree.
Definition: WorksheetDocument.h:87
const wxString & GetLastQuestion() const
The text of the Maxima question the user is currently being asked.
Definition: WorksheetDocument.h:208
bool CanDeleteSelection() const
Can the current selection be deleted right now (see CanRemoveCells())?
Definition: WorksheetDocument.cpp:353
bool CanEdit() const
Is exactly one cell selected, and does it directly follow Maxima's own input prompt (as opposed to be...
Definition: WorksheetDocument.cpp:335
void SetQuestionPending(bool pending)
Record whether Maxima is waiting for an answer to a question.
Definition: WorksheetDocument.h:217
WorksheetCursor & GetCursor()
The between-cells cursor (the h-caret) and its group-level selection.
Definition: WorksheetDocument.h:74
GroupCell * GetTree() const
The first GroupCell of the document (null when the document is empty).
Definition: WorksheetDocument.h:79
void SetLastQuestion(const wxString &lastQuestion)
Remember the text of the question Maxima is currently asking.
Definition: WorksheetDocument.h:210
GroupCell * ToggleFoldAll(GroupCell *which)
Like ToggleFold(), but folds/unfolds which's whole subtree.
Definition: WorksheetDocument.cpp:299
void OutputChanged()
Note that a cell's output changed.
Definition: WorksheetDocument.h:241
GroupCell * Fold(GroupCell *which)
Fold which; see GroupCell::Fold().
Definition: WorksheetDocument.cpp:262
The layout/recalculation engine of a worksheet.
Definition: WorksheetLayout.h:54
void RequestFullRecalculation()
Schedule a recalculation of the whole worksheet.
Definition: WorksheetLayout.cpp:237
void RequestAdjustSize()
Flag the virtual (scroll) size as needing re-adjustment.
Definition: WorksheetLayout.h:143
void RequestRecalculation(Cell *start)
Schedule a recalculation of the worksheet starting with the cell start.
Definition: WorksheetLayout.cpp:179
void GetMaxPoint(int *width, int *height)
Get the coordinates of the bottom right point of the worksheet.
Definition: WorksheetLayout.cpp:259
void UpdateConfigurationClientSize()
Inform the configuration about the view's current client size.
Definition: WorksheetLayout.cpp:246
int GetLastCellsVisited() const
GroupCells walked by the most recent RecalculateIfNeeded() pass (visited includes cheap reposition-on...
Definition: WorksheetLayout.h:156
void AdjustSize()
Adjust the virtual size and scrollbars to the document's extent.
Definition: WorksheetLayout.cpp:305
bool RecalculateIfNeeded(bool timeout=false, long timeSliceMs=50)
Perform the scheduled recalculation, if one is pending.
Definition: WorksheetLayout.cpp:41
The narrow view surface the worksheet's layout pipeline needs.
Definition: WorksheetSizeMath.h:172
The canvas that contains the spreadsheet the whole program is about.
Definition: Worksheet.h:116
bool IsActiveInLast() const
Is the editor active in the last cell of the worksheet?
Definition: Worksheet.h:1339
GroupCell * ToggleFold(GroupCell *which)
Fold or unfold a cell.
Definition: Worksheet.h:1492
void OnTimer(wxTimerEvent &event)
Is executed if a timer associated with Worksheet has expired.
Definition: Worksheet.cpp:3368
void ClearSelection()
Clear the selection - make it empty, i.e. no selection.
Definition: Worksheet.h:1212
const wxString UnicodeToMaxima(wxString s)
Make a few unicode characters interpretable by maxima.
Definition: Worksheet.cpp:3770
bool CanMergeSelection() const
Can we merge the selected cells into one?
Definition: Worksheet.h:816
bool IsSelectionInWorkingGroup() const
Is the selection in the current working group?
Definition: Worksheet.h:1349
int GetLastCellsRecalculated() const
How many cells the last layout pass truly recalculated. See WorksheetLayout.
Definition: Worksheet.h:935
void SetViewScrollRate(int rate) override
Set the scroll granularity (device pixels per scroll unit) on both axes.
Definition: Worksheet.h:126
ImgCellBase * GetSelectedImgCellBase() const
Returns the selected cell - or NULL, if the selection isn't image nor animation.
Definition: Worksheet.h:1042
wxString RTFStart() const
The start of a RTF document.
Definition: Worksheet.cpp:6134
int m_pointer_x
The x position of the mouse pointer.
Definition: Worksheet.h:1732
void SetDefaultHCaret()
Set the HCaret to its default location, at the end of the document.
Definition: Worksheet.cpp:4939
bool CanDeleteRegion(GroupCell *start, const GroupCell *end) const
Is it possible to delete the cells between start and end?
Definition: Worksheet.cpp:2125
void AddSectionToEvaluationQueue(GroupCell *start)
Adds a chapter, a section or a subsection to the evaluation queue.
Definition: Worksheet.cpp:4062
void AddSymbols(const wxString &xml)
Add a xml-encoded list of symbols to the autocompletion list.
Definition: Worksheet.h:1587
virtual ~Worksheet()
The destructor.
Definition: Worksheet.cpp:535
bool CutToClipboard()
Add the currently selected cells to the clipboard and delete them.
Definition: Worksheet.cpp:4637
void GetViewPosition(int *x, int *y) const override
The view's position within its parent, in device pixels (wxWindow::GetPosition).
Definition: Worksheet.h:127
WorksheetDocument m_document
The view-independent document state (file, current question, ...) that Worksheet's document accessors...
Definition: Worksheet.h:1720
FindReplacePane * m_findPane
The dockable find-and-replace sidebar (GH #2249), set once by wxMaximaFrame at startup and never dest...
Definition: Worksheet.h:806
std::unique_ptr< wxDataObject > CreateCellsDataObject() const
Build the multi-format clipboard object for a whole-cell selection.
Definition: Worksheet.cpp:2038
GroupCell * GetInsertGroup() const
The group that the line's cells will belong to - used by InsertLine.
Definition: Worksheet.cpp:959
void OnCharNoActive(wxKeyEvent &event)
Key pressed and no cell was active.
Definition: Worksheet.cpp:2892
bool QuestionPending() const
Does maxima wait for the answer of a question?
Definition: Worksheet.h:1620
void AddEntireDocumentToEvaluationQueue()
Schedule all cells in the document for evaluation.
Definition: Worksheet.cpp:4053
GroupCell * FirstVisibleGC()
The first groupCell that is currently visible.
Definition: Worksheet.cpp:1490
void UpdateConfigurationClientSize()
Inform the configuration about the current client size.
Definition: Worksheet.h:1224
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:5411
void AddSymbols(wxXmlDocument xml)
Add a xml-encoded list of symbols to the autocompletion list.
Definition: Worksheet.h:1590
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:1661
bool ExportToHTML(const wxString &file)
Export the file to an html document.
Definition: Worksheet.cpp:3739
void OpenHCaret(const wxString &txt={})
Place the cursor into a new cell where the horizontal cursor is.
Definition: Worksheet.h:1367
void NotifyAdjustSizeNeeded() override
The scrollable size will need re-adjusting once cell positions settle.
Definition: Worksheet.h:135
void ApplyOverlayScrollbarsSetting()
Apply the configuration's OverlayScrollbars() choice to this window.
Definition: Worksheet.cpp:510
TextCell * GetSelectedTextCell() const
Returns the selected cell - or NULL, if the selection isn't a text cell.
Definition: Worksheet.h:1050
void ScrollToError()
Unfold the cell that produced the error, if necessary and, if requested, scroll to it.
Definition: Worksheet.cpp:899
bool HCaretActive() const
Is the vertically-drawn cursor active?
Definition: Worksheet.h:809
void OnEraseBackground(wxEraseEvent &WXUNUSED(event))
Cannot be static as it is called using a function pointer to an object.
Definition: Worksheet.h:518
void ClearDocument()
Empties the current document.
Definition: Worksheet.cpp:1088
wxString RTFEnd() const
The end of a RTF document.
Definition: Worksheet.cpp:6138
ViewCellPointers m_viewCellPointers
The transient view-state half of the cell-pointer registry (hover, selection anchors,...
Definition: Worksheet.h:1724
void UpdateTableOfContents()
Update the table of contents.
Definition: Worksheet.cpp:6464
void RemoveAllOutput()
Remove all output cells from the whole worksheet.
Definition: Worksheet.cpp:5012
Cell * GetSelectionEnd() const
Return the last of the currently selected cells.
Definition: Worksheet.h:1208
void QuestionPending(bool pending)
Does maxima currently wait for the answer of a question?
Definition: Worksheet.h:1627
void ClickNDrag(wxPoint down, wxPoint up)
Select the rectangle surrounded by down and up.
Definition: Worksheet.cpp:1642
FindReplacePane * GetActiveFindPane() const
Whichever find/replace UI is actually in use right now: the dockable sidebar (GH #2249) if Configurat...
Definition: Worksheet.cpp:5217
DocumentCellPointers & GetDocumentCellPointers()
The document-model half of the cell-pointer registry (owned by m_document).
Definition: Worksheet.h:686
const wxString & GetCurrentFile() const
The name of the currently-opened file.
Definition: Worksheet.h:785
void SetCurrentFile(const wxString &file)
Set the name of the currently-opened file.
Definition: Worksheet.h:787
RecentDocuments & UnsavedDocuments()
The list of unsaved (autosaved) documents offered for recovery.
Definition: Worksheet.h:139
bool CopyHTML() const
Copy a self-contained HTML version (inline CSS, base64-embedded images – see WorksheetExport::Selecti...
Definition: Worksheet.cpp:3545
void DeleteCurrentCell()
Delete the currently active cell - or the cell above this one.
Definition: Worksheet.cpp:2110
AutoComplete & GetAutocomplete()
The storage for the autocompletion feature.
Definition: Worksheet.h:662
AnimationCell * GetSelectedAnimation() const
Returns the selected cell - or NULL, if the selection isn't an animation.
Definition: Worksheet.h:1026
void Replace(const wxString &oldString, const wxString &newString, bool ignoreCase)
Replace the current occurrence of a string.
Definition: Worksheet.cpp:5377
bool CopyMatlab() const
Copy a Matlab representation of the current selection to the clipboard.
Definition: Worksheet.cpp:1930
bool CopyText() const
Copy a textual representation of the current selection to the clipboard.
Definition: Worksheet.cpp:1993
bool m_inPopupMenu
Is there an active popup menu?
Definition: Worksheet.h:1738
EvaluationQueue & GetEvaluationQueue()
The list of cells that have to be evaluated.
Definition: Worksheet.h:1480
void Animate(bool run=true) const
Animate the current slide show.
Definition: Worksheet.cpp:4916
static GroupCell * StartOfSectioningUnit(GroupCell *start)
Finds the start of the current chapter/section/...
Definition: Worksheet.cpp:2507
bool CopyRTF() const
Copy a rtf version of the current selection to the clipboard.
Definition: Worksheet.cpp:3514
void UpdateConfig()
Re-read the configuration.
Definition: Worksheet.h:767
int m_pointer_y
The y position of the mouse pointer.
Definition: Worksheet.h:1734
bool Copy(bool astext=false) const
Copy the current selection to the clipboard.
Definition: Worksheet.cpp:1749
bool CopyAnimation() const
Copy the current animation to the clipboard.
Definition: Worksheet.cpp:3492
void StepAnimation(int change=1)
Set the slide of the currently selected animation or advance it by one step.
Definition: Worksheet.cpp:3342
GroupCell * Unfold(GroupCell *which)
Unfold a cell (see WorksheetDocument::Unfold())
Definition: Worksheet.h:1489
void SelectEditable(EditorCell *editor, bool up)
Is called when a hCursor is active and we have a WXK_UP/WXK_DOWN event.
Definition: Worksheet.cpp:2861
void SetAnswer(const wxString &answer)
Handling questions from and answers for maxima.
Definition: Worksheet.cpp:2234
ViewCellPointers & GetViewCellPointers()
The transient view-state half of the cell-pointer registry (owned here).
Definition: Worksheet.h:689
void OnChar(wxKeyEvent &event)
Key for a printable character pressed.
Definition: Worksheet.cpp:3226
void SelectWithChar(int ccode)
Handle selecting text using the keyboard Is called when the all of the following is true:
Definition: Worksheet.cpp:2776
void AddSelectionToEvaluationQueue()
Schedule all cells in the selection to be evaluated.
Definition: Worksheet.cpp:4091
bool HasCellsSelected() const
Is at least one entire cell selected?
Definition: Worksheet.h:975
std::optional< Notification > & GetNotification()
The error notification message, if any.
Definition: Worksheet.h:616
void OnSetFocus(wxFocusEvent &event)
What to do if the worksheet is in the input focus.
Definition: Worksheet.cpp:4876
void SetNotification(const wxString &message, int flags=wxICON_INFORMATION)
Inform the user that something happened in a non-active window.
Definition: Worksheet.cpp:3204
bool IsSelected(CellType type) const
Does the selection start with a cell of the type "type".
Definition: Worksheet.h:1328
void ScheduleScrollToCell(Cell *cell, bool scrollToTop=true)
Schedules scrolling to a given cell.
Definition: Worksheet.h:1288
int GetViewScrollUnitY() const override
The current vertical scroll position, in scroll units (not pixels).
Definition: Worksheet.h:122
GroupCell * InsertGroupCells(std::unique_ptr< GroupCell > &&cells, GroupCell *where, UndoActions *undoBuffer)
Insert group cells into the worksheet.
Definition: Worksheet.cpp:879
void AddDocumentTillHereToEvaluationQueue()
Schedule all cells stopping with the one the caret is in for evaluation.
Definition: Worksheet.cpp:4107
void OnComplete(wxCommandEvent &event)
Is called if an action from the autocomplete menu is selected.
Definition: Worksheet.cpp:5874
bool CanAnimate() const
Does it make sense to enable the "Play" button and the slider now?
Definition: Worksheet.h:1058
bool RecalculateIfNeeded(bool timeout=false, long timeSliceMs=50)
Actually recalculate the worksheet.
Definition: Worksheet.h:906
bool m_mouseMotionWas
Was there a mouse motion we didn't react to until now?
Definition: Worksheet.h:1736
void SelectAll()
Select the whole document.
Definition: Worksheet.cpp:4799
void OnKillFocus(wxFocusEvent &event)
What to do if the worksheet looses the input focus.
Definition: Worksheet.cpp:4888
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:968
void ClearNotification()
Clears the notification message from SetNotification.
Definition: Worksheet.cpp:3202
void OnPaint(wxPaintEvent &event)
Is called by wxWidgets when it wants to redraw the worksheet or a part of it.
Definition: Worksheet.cpp:578
void OnFollow()
Called when the "Scroll to currently evaluated" button is pressed.
Definition: Worksheet.cpp:6058
void PrepareDrawGC(wxDC &dc) const
All that has need to be done before drawing a GroupCell in a DC.
Definition: Worksheet.cpp:755
void OnCharInActive(wxKeyEvent &event)
Key pressed inside a cell.
Definition: Worksheet.cpp:2551
Cell * GetSelectionStart() const
Return the first of the currently selected cells.
Definition: Worksheet.h:1201
void FoldOccurred()
Call when a fold action was detected, to update the state in response to a fold occurring.
Definition: Worksheet.cpp:1177
void OnMouseCaptureLost(wxMouseCaptureLostEvent &event)
Is called if we loose the mouse connection whilst selecting text/cells.
Definition: Worksheet.cpp:6142
wxTimer & KeyboardInactiveTimer()
The timer that tells us when the keyboard is inactive so an autosave isn't disrupting.
Definition: Worksheet.h:849
ClickType
An enum for all classes of items one can click on.
Definition: Worksheet.h:382
ImgCell * GetSelectedImgCell() const
Returns the selected cell - or NULL, if the selection isn't an image.
Definition: Worksheet.h:1034
Cell * FindCellByUUID(const wxString &uuid)
Find a cell by its UUID.
Definition: Worksheet.cpp:4155
void EraseBackground(wxEraseEvent &event)
Is called if wxWidgets wants to erase the worksheet's background.
Definition: Worksheet.cpp:313
bool CanDeleteSelection() const
Is it possible to delete the currently selected cells?
Definition: Worksheet.h:1017
ToolBar * m_mainToolBar
The toolbar of the main window: We need to access it and therefore have it defined here.
Definition: Worksheet.h:1603
bool CaretVisibleIs()
Is the caret (hcaret or vcaret) currently visible on the worksheet?
Definition: Worksheet.cpp:5313
EditorCell * GetActiveCell() const
Get the currently active EditorCell.
Definition: Worksheet.h:670
bool UpdateControlsNeeded()
Is an update of the worksheet controls needed?
Definition: Worksheet.h:144
bool CopyCells() const
Copy the selection to the clipboard as it would appear in a .wxm file.
Definition: Worksheet.cpp:2022
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:2249
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:5154
GroupCell * GetLastCell()
Returns the last cell of the worksheet.
Definition: Worksheet.h:1343
GroupCell * GetHCaret()
The cell the horizontal cursor is above. NULL means at the start of the document.
Definition: Worksheet.cpp:4922
wxString ConvertSelectionToMathML() const
Convert the current selection to MathML.
Definition: Worksheet.cpp:1835
bool CanUndoInsideCell() const
Is it possible to issue an undo in the currently selected cell?
Definition: Worksheet.h:1385
void SetHCaret(GroupCell *where)
Set the HCaret at the location of the given Cell.
Definition: Worksheet.cpp:4949
bool CanRedoInsideCell() const
Is it possible to issue an undo in the currently selected cell?
Definition: Worksheet.h:1393
bool GCContainsCurrentQuestion(const GroupCell *cell)
Does the GroupCell cell points to contain the question currently asked by maxima?
Definition: Worksheet.cpp:2479
bool WillAutoAnswer() const
Execute all collected scroll events in one go.
Definition: Worksheet.cpp:2242
bool IsEmpty() const
Is this worksheet empty?
Definition: Worksheet.h:584
void NumberSections() const
Renumber all sections.
Definition: Worksheet.cpp:1121
void SetViewVirtualSize(int width, int height) override
Set the scrollable (virtual) area, in device pixels.
Definition: Worksheet.h:124
void OnKeyDown(wxKeyEvent &event)
A special key has been pressed.
Definition: Worksheet.cpp:2374
EditorCell * KeyboardSelectionStart() const
Tells us which cell the keyboard selection has started in.
Definition: Worksheet.h:673
void SetSelection(Cell *sel)
Select the cell sel.
Definition: Worksheet.h:1215
void AddCellToEvaluationQueue(GroupCell *gc)
Schedule this cell for evaluation.
Definition: Worksheet.cpp:4125
void SetCellStyle(GroupCell *group, GroupType style)
Change the style of a cell.
Definition: Worksheet.cpp:2167
bool Autocomplete(AutoComplete::autoCompletionType type=AutoComplete::command)
Definition: Worksheet.cpp:5619
wxBitmap m_memory
A memory we can manually buffer the contents of the area that is to be redrawn in.
Definition: Worksheet.h:1726
void LoadSymbols()
Compile a list of known autocompletion symbols.
Definition: Worksheet.cpp:3768
void SelectGroupCell(GroupCell *cell)
Set this cell as the currently selected one.
Definition: Worksheet.cpp:6044
void ShowPoint(wxPoint point)
Scrolls to a point on the worksheet.
Definition: Worksheet.cpp:4588
void WindowActive(bool active)
Is this window active?
Definition: Worksheet.h:622
bool ExportToTeX(const wxString &file)
export to a LaTeX file
Definition: Worksheet.cpp:3761
void AdjustSize()
Adjust the virtual size and scrollbars; see WorksheetLayout::AdjustSize().
Definition: Worksheet.h:515
void ShowHCaret()
Activates the horizontal cursor.
Definition: Worksheet.cpp:4981
TimerIDs
An enum of individual IDs for all timers this class handles.
Definition: Worksheet.h:392
void CodeCellVisibilityChanged()
To be called after enabling or disabling the visibility of code cells.
Definition: Worksheet.cpp:3749
void ScrollToCaret()
Request to scroll to the cursor as soon as wxMaxima is idle.
Definition: Worksheet.h:1275
void MarkRefreshAsDone()
Handle redrawing the worksheet or of parts of it.
Definition: Worksheet.h:720
bool CopyMathML() const
Copy the MathML representation of the current selection to the clipboard.
Definition: Worksheet.cpp:1903
bool CopyBitmap() const
Copy a bitmap of the current selection to the clipboard.
Definition: Worksheet.cpp:3485
bool CanCopyAsMathML() const
Would "Copy as MathML" of the current selection produce actual math?
Definition: Worksheet.cpp:1884
void GetViewClientSize(int *width, int *height) const override
The visible client area, in device pixels.
Definition: Worksheet.h:120
GroupCell * Fold(GroupCell *which)
Fold a cell (see WorksheetDocument::Fold())
Definition: Worksheet.h:1486
bool PointVisibleIs(wxPoint point)
Is the point currently visible on the worksheet?
Definition: Worksheet.cpp:4567
std::unique_ptr< Cell > CopySelection(bool asData=false) const
Copy the currently selected cells.
Definition: Worksheet.cpp:3661
GroupCell * GetLastCellInWorksheet() const
Returns a pointer to the last cell of this worksheet.
Definition: Worksheet.cpp:1637
void ScrollToStart()
Scroll to the start of the worksheet.
Definition: Worksheet.h:796
void NotifyRecalculation(GroupCell *start) override
Schedule a re-layout of the document starting at start (null = all).
Definition: Worksheet.h:132
void AddSymbol(const wxString &fun, AutoComplete::autoCompletionType type=AutoComplete::command)
Add a symbol to the autocompletion list.
Definition: Worksheet.h:1583
bool CanEdit() const
We can edit the input if the we have the whole input in selection!
Definition: Worksheet.h:1228
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:5247
bool SectioningMoveIn(GroupCell *parent)
Make this chapter/section/... a section/subsection/... changing its subheadings, too.
Definition: Worksheet.cpp:5911
wxBitmap ConvertSelectionToBitmap() const
Convert the current selection to a bitmap.
void RequestRedraw(GroupCell *start=NULL)
Request the worksheet to be redrawn.
Definition: Worksheet.cpp:482
bool RedrawIfRequested()
Redraw the worksheet if RequestRedraw() has been called.
Definition: Worksheet.cpp:325
bool ExportToMAC(const wxString &file)
Export the file to a text file maxima's load command can read.
Definition: Worksheet.cpp:3894
void SetActiveCell(EditorCell *cell)
Mark an editor cell as the active one.
Definition: Worksheet.cpp:4483
FindReplaceDialog * m_findDialog
The find-and-replace-dialog.
Definition: Worksheet.h:802
void DrawGroupCell(wxDC &dc, wxDC &adc, GroupCell &cell)
Draws a groupcell on the DC.
Definition: Worksheet.cpp:821
void QuestionAnswered()
Mark the current question from maxima as "answered"..
Definition: Worksheet.cpp:2483
void DeleteRegion(GroupCell *start, GroupCell *end, UndoActions *undoBuffer)
Definition: Worksheet.cpp:2198
bool ScrollToCaretIfNeeded()
Scrolls to the cursor, if requested.
Definition: Worksheet.cpp:5347
void NotifyRedraw(GroupCell *start) override
Schedule a redraw of the document starting at start (null = all).
Definition: Worksheet.h:134
std::unique_ptr< GroupCell > CopyTree() const
Copies the worksheet's entire contents.
Definition: Worksheet.cpp:3481
GroupCell * EndOfSectioningUnit(GroupCell *start)
Finds the end of the current chapter/section/...
Definition: Worksheet.cpp:2524
std::vector< wxString > m_replacementsForCurrentWord
Suggestions for how the word that was right-clicked on could continue.
Definition: Worksheet.h:1669
int ExportSelectionOutputToDir(const wxString &dir, bool svg)
Write each selected group cell's output to an image file in a folder.
Definition: Worksheet.cpp:3606
void ForceRedraw()
Redraw the window now and mark any pending redraw request as "handled".
Definition: Worksheet.h:757
bool CopyTeX() const
Copy the TeX representation of the current selection to the clipboard.
Definition: Worksheet.cpp:1958
void AddRestToEvaluationQueue()
Add all cells below the cursor to the evaluation queue.
Definition: Worksheet.cpp:4071
void ScrollToCellIfNeeded()
Scrolls to the cell given by ScheduleScrollToCell; Is called once we have time to do so.
Definition: Worksheet.cpp:4177
void DrawGroupCell_UsingBitmap(wxDC *dc, GroupCell *cell)
Draws a groupcell in a bitmap and then blits it onto the DC.
Definition: Worksheet.cpp:770
void GetMaxPoint(int *width, int *height)
Get the coordinates of the bottom right point of the worksheet.
Definition: Worksheet.h:412
void OnMouseWheel(wxMouseEvent &event)
Called if the mouse wheel sents events.
Definition: Worksheet.cpp:1524
void RequestRecalculation()
Schedule a recalculation of the whole worksheet.
Definition: Worksheet.h:930
void CloseAutoCompletePopup()
Close the autocompletion pop-up if it is currently open.
Definition: Worksheet.h:587
bool SectioningMoveOut(GroupCell *parent)
Make this section/subsection/... a chapter/section/... changing its subheadings, too.
Definition: Worksheet.cpp:5953
bool FollowEvaluation() const
Query if we want to automatically scroll to the cell that is currently evaluated.
Definition: Worksheet.h:1409
void DestroyTree()
Clear the whole worksheet.
Definition: Worksheet.cpp:3472
wxString GetString(bool lb=false) const
Convert the current selection to a string.
Definition: Worksheet.cpp:1731
void NotifySavedStateChanged() override
The document's saved-state flipped; refresh the controls that show it.
Definition: Worksheet.h:136
int GetLastCellsVisited() const
How many cells the last layout pass visited. See WorksheetLayout.
Definition: Worksheet.h:933
std::unique_ptr< wxDataObject > CreateSelectionDataObject() const
Build the multi-format clipboard object for a non-cell selection.
Definition: Worksheet.cpp:1778
GroupCell * GetWorkingGroup(bool resortToLast=false) const
Returns the cell maxima currently works on.
Definition: Worksheet.cpp:937
bool CopySVG() const
Copy a svg of the current selection to the clipboard.
Definition: Worksheet.cpp:3500
void Evaluate()
Trigger the evaluation of the current cell(s)
Definition: Worksheet.cpp:2365
void OnScrollChanged(wxScrollEvent &ev)
Called if the user is using the scrollbar for scrolling through the document.
Definition: Worksheet.cpp:5080
void OnDoubleClick(wxMouseEvent &event)
Is called on double click on a cell.
Definition: Worksheet.cpp:3970
void OnActivate(wxActivateEvent &event)
Is called if this element looses or gets the focus.
Definition: Worksheet.cpp:4941
void AddToEvaluationQueue(GroupCell *cell)
Adds a group cell to the evaluation queue marking its contents as "outdated".
Definition: Worksheet.cpp:4046
void RequestRecalculation(Cell *start)
Schedule a recalculation of the worksheet starting with the cell start.
Definition: Worksheet.h:919
void AnonymizeCodeCells()
Anonymize the code cells in the current selection for a bug report (GH #1339).
Definition: Worksheet.cpp:5495
Definition: CellPointers.h:32
bool CanTreeRedo() const
Can we redo a tree operation?
Definition: Worksheet.cpp:4296
void TreeUndo_CellEntered()
The cursor has entered one cell => save the value to see if it has changed.
Definition: Worksheet.cpp:2158
void TreeUndo_AppendAction()
Add another action to this undo action.
Definition: Worksheet.h:309
bool TreeUndoTextChange(UndoActions *sourcelist, UndoActions *undoForThisOperation)
Undo a text change.
Definition: Worksheet.cpp:4388
bool TreeUndo()
Undo a tree operation.
Definition: Worksheet.h:336
void TreeUndo_ClearRedoActionList()
Clear the list of actions for which an undo can be undone.
Definition: Worksheet.h:303
bool CanTreeUndo() const
Can we undo a tree operation?
Definition: Worksheet.cpp:4292
void TreeUndo_CellLeft()
The cursor is about to leave the current cell => Store the change if the value has changed.
Definition: Worksheet.cpp:2143
void TreeUndo_ClearUndoActionList()
Clear the list of actions for which undo can undo.
Definition: Worksheet.h:306
bool TreeUndoCellAddition(UndoActions *sourcelist, UndoActions *undoForThisOperation)
Undo adding cells.
Definition: Worksheet.cpp:4324
bool TreeUndoCellDeletion(UndoActions *sourcelist, UndoActions *undoForThisOperation)
Undo a call deletion.
Definition: Worksheet.cpp:4311
bool TreeRedo()
Redo an undone tree operation.
Definition: Worksheet.h:340
void TreeUndo_MarkCellsAsAdded(GroupCell *start, GroupCell *end, UndoActions *undoBuffer)
Remember that these cells were just added so this addition can be undone.
Definition: Worksheet.cpp:2134
bool TreeUndoFold(UndoActions *sourcelist, UndoActions *undoForThisOperation)
Undo a fold or unfold (GH #266)
Definition: Worksheet.cpp:4359
Where a search starts: a group plus what the cursor is doing there.
Definition: WorksheetSearch.h:113
A search match: the group it is in and the matching part.
Definition: WorksheetSearch.h:97