wxMaxima
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 "stx/optional.hpp"
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"
49 #include "sidebars/VariablesPane.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 
94 class Worksheet : public wxScrolled<wxWindow>
95 {
96 public:
97  RecentDocuments m_unsavedDocuments;
99  bool UpdateControlsNeeded(){bool result = m_updateControls; m_updateControls = false; return result;}
100  void UpdateControlsNeeded(bool updateControlsNeeded){m_updateControls = updateControlsNeeded;}
101 private:
103  wxString m_maximaDocDir;
105  bool m_updateControls = true;
107  bool m_scrollToCaret = false;
109  CellPointers m_cellPointers;
110  // The x position to scroll to
111  int m_newxPosition = -1;
112  // The y position to scroll to
113  int m_newyPosition = -1;
115  double m_zoomAtGestureStart = 1.0;
117  bool m_scrollToTopOfCell = false;
119  bool m_windowActive = true;
121  wxRegion m_regionToRefresh;
128  int m_scrollUnit = 10;
133  wxClientDC m_dc;
135  CellPtr<GroupCell> m_redrawStart;
137  bool m_fullRedrawRequested = false;
139 
141  static wxDataFormat m_wxmFormat;
143  static wxDataFormat m_mathmlFormat;
145  static wxDataFormat m_mathmlFormat2;
147  static wxDataFormat m_rtfFormat;
149  static wxDataFormat m_rtfFormat2;
150 
153  class MathMLDataObject : public wxCustomDataObject
154  {
155  public:
156  explicit MathMLDataObject(const wxString &data);
157 
158  MathMLDataObject();
159 
160  private:
161  wxCharBuffer m_databuf;
162  };
163 
165  class wxmDataObject : public wxCustomDataObject
166  {
167  public:
168  explicit wxmDataObject(const wxString &data);
169 
170  wxmDataObject();
171 
172  private:
173  wxCharBuffer m_databuf;
174  };
175 
176  class MathMLDataObject2 : public wxCustomDataObject
177  {
178  public:
179  explicit MathMLDataObject2(const wxString &data);
180 
181  MathMLDataObject2();
182 
183  private:
184  wxCharBuffer m_databuf;
185  };
186 
189  class RtfDataObject : public wxCustomDataObject
190  {
191  public:
192  explicit RtfDataObject(const wxString &data);
193 
194  RtfDataObject();
195 
196  private:
197  wxCharBuffer m_databuf;
198  };
199 
200  class RtfDataObject2 : public wxCustomDataObject
201  {
202  public:
203  explicit RtfDataObject2(const wxString &data);
204 
205  RtfDataObject2();
206 
207  private:
208  wxCharBuffer m_databuf;
209  };
210 
212  bool m_hasFocus = true;
214  long m_lastTop = 0;
216  long m_lastBottom = 0;
241  class TreeUndoAction
242  {
243  public:
244  TreeUndoAction(GroupCell *start, const wxString &oldText) :
245  m_start(start), m_oldText(oldText)
246  {
247  wxASSERT_MSG(start, _("Bug: Trying to record a cell contents change for undo without a cell."));
248  }
249  TreeUndoAction(GroupCell *start, GroupCell *end) :
250  m_start(start), m_newCellsEnd(end)
251  {
252  wxASSERT_MSG(start, _("Bug: Trying to record a cell contents change for undo without a cell."));
253  }
254  TreeUndoAction(GroupCell *start, GroupCell *end, GroupCell *oldCells) :
255  m_start(start), m_newCellsEnd(end), m_oldCells(oldCells)
256  {
257  }
258 
264  bool m_partOfAtomicAction = false;
265 
270  GroupCell *const m_start = nullptr;
271 
277  const wxString m_oldText;
278 
285  GroupCell *const m_newCellsEnd = nullptr;
286 
294  std::unique_ptr<GroupCell> m_oldCells;
295  };
296 
298  using UndoActions = std::list<TreeUndoAction>;
299 
301  UndoActions treeUndoActions;
302 
304  UndoActions treeRedoActions;
305 
307  wxString m_treeUndo_ActiveCellOldText;
308 
310  void TreeUndo_ClearRedoActionList();
311 
313  void TreeUndo_ClearUndoActionList();
314 
316  static void TreeUndo_DiscardAction(UndoActions *actionList);
317 
319  static void TreeUndo_AppendAction(UndoActions *actionList)
320  {
321  if(!actionList->empty())
322  actionList->front().m_partOfAtomicAction = true;
323  }
324 
326  void TreeUndo_AppendAction(){TreeUndo_AppendAction(&treeUndoActions);}
327 
332  CellPtr<GroupCell> TreeUndo_ActiveCell;
333 
335  void TreeUndo_LimitUndoBuffer();
336 
342  bool TreeUndo(UndoActions *sourcelist, UndoActions *undoForThisOperation);
343 
347  bool TreeUndoTextChange(UndoActions *sourcelist, UndoActions *undoForThisOperation);
351  bool TreeUndoCellDeletion(UndoActions *sourcelist, UndoActions *undoForThisOperation);
355  bool TreeUndoCellAddition(UndoActions *sourcelist, UndoActions *undoForThisOperation);
356 
358  bool TreeUndo()
359  { return TreeUndo(&treeUndoActions, &treeRedoActions); }
360 
362  bool TreeRedo()
363  { return TreeUndo(&treeRedoActions, &treeUndoActions); }
364 
366  bool CanTreeUndo() const;
367 
369  bool CanTreeRedo() const;
370 
373  void TreeUndo_CellEntered();
374 
377  void TreeUndo_CellLeft();
378 
387  void TreeUndo_MarkCellsAsAdded(GroupCell *start, GroupCell *end, UndoActions *undoBuffer);
388 
389 
395  void TreeUndo_MarkCellsAsAdded(GroupCell *parentOfStart, GroupCell *end);
397 
398  bool m_scrolledAwayFromEvaluation = false;
399 
404  wxString EscapeHTMLChars(wxString input);
405 
407  wxString PrependNBSP(wxString input);
408 
410  enum ClickType
411  {
412  CLICK_TYPE_NONE,
413  CLICK_TYPE_GROUP_SELECTION,
414  CLICK_TYPE_INPUT_SELECTION,
415  CLICK_TYPE_INPUT_LABEL_SELECTION,
416  CLICK_TYPE_OUTPUT_SELECTION
417  };
418 
420  enum TimerIDs
421  {
422  TIMER_ID,
423  CARET_TIMER_ID,
424  DISPLAY_TIMEOUT_ID
425  };
426 
428  static void AddLineToFile(wxTextFile &output, const wxString &s);
429 
431  std::unique_ptr<Cell> CopySelection(bool asData = false) const;
432 
441  std::unique_ptr<Cell> CopySelection(Cell *start, Cell *end, bool asData = false) const;
442 
444  void GetMaxPoint(int *width, int *height);
445 
447  void OnTimer(wxTimerEvent &event);
448 
449 #if wxCHECK_VERSION(3, 1, 1)
451  void OnZoom(wxZoomGestureEvent &event);
452 #endif
453 
454  void OnMouseExit(wxMouseEvent &event);
455 
456  void OnMouseEnter(wxMouseEvent &event);
457 
470  void OnPaint(wxPaintEvent &event);
472  void DrawGroupCell(wxDC &dc, wxDC &adc, GroupCell &cell);
480  void DrawGroupCell_UsingBitmap(wxDC *dc, GroupCell *cell);
481 
483  void PrepareDrawGC(wxDC &dc) const;
484 
485  void OnSize(wxSizeEvent &event);
486 
487  void OnMouseRightDown(wxMouseEvent &event);
488 
489  void OnSidebarKey(wxCommandEvent &event);
490 
491  void OnMouseLeftUp(wxMouseEvent &event);
492 
494  void OnMouseCaptureLost(wxMouseCaptureLostEvent &event);
495 
496  void OnMouseLeftDown(wxMouseEvent &event);
497 
498  void OnMouseLeftInGcCell(wxMouseEvent &event, GroupCell *clickedInGC);
499 
500  void OnMouseLeftInGcLeft(wxMouseEvent &event, GroupCell *clickedInGC);
501 
502  void OnMouseLeftInGc(wxMouseEvent &event, GroupCell *clickedInGC);
503 
504  void OnMouseMotion(wxMouseEvent &event);
505 
507  void OnDoubleClick(wxMouseEvent &event);
508 
510  void OnCharInActive(wxKeyEvent &event);
511 
513  void OnCharNoActive(wxKeyEvent &event);
514 
516  void SelectEditable(EditorCell *editor, bool up);
517 
524  void SelectWithChar(int ccode);
525 
540  void ClickNDrag(wxPoint down, wxPoint up);
541 
542  // Select all group cells inside the given rectangle;
543  void SelectGroupCells(wxPoint down, wxPoint up);
544 
545  void AdjustSize();
546 
548  void OnEraseBackground(wxEraseEvent& WXUNUSED(event))
549  {}
550 
551  void CheckUnixCopy();
552 
553  void OnMouseMiddleUp(wxMouseEvent &event);
554 
555  static bool IsLesserGCType(int type, int comparedTo);
556 
558  static GroupCell *StartOfSectioningUnit(GroupCell *start);
559 
561  GroupCell *EndOfSectioningUnit(GroupCell *start);
562 
564  void OnComplete(wxCommandEvent &event);
565 
570  void EraseBackground(wxEraseEvent &event);
571 
573  wxPoint m_leftDownPosition;
574  wxPoint m_down;
575  wxPoint m_up;
576  wxPoint m_mousePoint;
582  bool m_hCaretActive = true;
587  CellPtr<GroupCell> m_hCaretPosition;
593  CellPtr<GroupCell> m_hCaretPositionStart;
599  CellPtr<GroupCell> m_hCaretPositionEnd;
600  bool m_leftDown = false;
602  bool m_followEvaluation = true;
603  bool m_mouseDrag = false;
604  bool m_mouseOutside = false;
606  mutable bool m_adjustWorksheetSizeNeeded = false;
608  GroupCell *GetLastCellInWorksheet() const;
609  int m_clickType = CLICK_TYPE_NONE;
610  CellPtr<GroupCell> m_clickInGC;
612  bool m_blinkDisplayCaret = true;
614  bool m_hCaretBlinkVisible = true;
616  wxTimer m_timer;
618  wxTimer m_caretTimer;
620  bool m_saved = true;
621  std::vector<wxString> m_completions;
622  bool m_autocompleteTemplates = true;
623  AutocompletePopup *m_autocompletePopup;
624 
625 public:
627  bool IsEmpty() const
628  { return !m_tree || (!m_tree->GetNext() && m_tree->GetEditable()->GetValue().Length() <= 1); }
631  {
632  if(m_autocompletePopup != NULL)
633  m_autocompletePopup->Destroy();
634  }
635 
641  void OnChar(wxKeyEvent &event);
642 
647  void OnKeyDown(wxKeyEvent &event);
649  void SetCellStyle(GroupCell *group, GroupType style);
650 
652  void NumberSections() const;
653 
655  bool SectioningMoveIn(GroupCell *parent);
657  bool SectioningMoveOut(GroupCell *parent);
659  stx::optional<Notification> m_notificationMessage;
661  void WindowActive(bool active){m_windowActive = active;}
663  void ClearNotification();
668  void SetNotification(const wxString &message, int flags = wxICON_INFORMATION);
669 
671  void OnActivate(wxActivateEvent &event);
672 private:
674  std::unique_ptr<GroupCell> m_tree;
676  mutable CellPtr<GroupCell> m_last;
677 // std::vector<std::thread> m_drawThreads;
678  static std::mutex m_drawDCLock;
681  Configuration *m_configuration = NULL;
682 public:
685 
687  EditorCell *GetActiveCell() const { return m_cellPointers.m_activeCell; }
688 
691  { return m_cellPointers.m_cellKeyboardSelectionStartedIn; }
692 
693  EditorCell *MouseSelectionStart() const
694  { return m_cellPointers.m_cellMouseSelectionStartedIn; }
695 
696  EditorCell *SearchStart() const
697  { return m_cellPointers.m_cellSearchStartedIn; }
698 
699  int IndexSearchStartedAt() const
700  { return m_cellPointers.m_indexSearchStartedAt; }
701 
702  CellPointers &GetCellPointers() { return m_cellPointers; }
703 
704  CellPointers::ErrorList &GetErrorList() { return m_cellPointers.m_errorList; }
705  TextCell *GetCurrentTextCell() const { return m_cellPointers.m_currentTextCell; }
706  void SetCurrentTextCell(TextCell *cell) { m_cellPointers.m_currentTextCell = cell; }
707  void SetWorkingGroup(GroupCell *group) { m_cellPointers.SetWorkingGroup(group); }
708 
714  void UpdateTableOfContents();
715 
733  {
734  m_redrawStart = NULL;
735  m_fullRedrawRequested = false;
736  }
737 
742  bool RedrawIfRequested();
743 
756  void RequestRedraw(GroupCell *start = NULL);
766  void RequestRedraw(wxRect rect);
767 
769  void ForceRedraw()
770  {
771  RequestRedraw();
773  }
774 
777 
779  void UpdateConfig() {
780  m_configuration->ReadConfig();
781  Recalculate();
782  Refresh();
783  }
784 
786  wxString m_currentFile;
787 
792  const wxString UnicodeToMaxima(wxString s);
793 
795  void ScrollToStart() { Scroll(0, 0); }
796 
798  void ScrollToError();
799 
802 
804  bool HCaretActive() const { return m_hCaretActive; }
805 
811  bool CanMergeSelection() const;
812 
813  bool CanUndo() const;
814 
815  bool CanRedo() const;
816 
817  void Undo();
818 
819  void Redo();
820 
825  void TreeUndo_ClearBuffers();
826 
836  Worksheet(wxWindow *parent, int id, Configuration *config,
837  wxPoint pos = wxDefaultPosition, wxSize size = wxDefaultSize,
838  bool reactToEvents = true);
839 
841  virtual ~Worksheet();
842 
845 
847  void DestroyTree();
848 
850  std::unique_ptr<GroupCell> CopyTree() const;
851 
863  GroupCell *InsertGroupCells(std::unique_ptr<GroupCell> &&cells, GroupCell *where,
864  UndoActions *undoBuffer);
865 
871  GroupCell *InsertGroupCells(std::unique_ptr<GroupCell> &&cells, GroupCell *where = NULL);
872 
878  void InsertLine(std::unique_ptr<Cell> &&newCell, bool forceNewLine = false);
879 
881  GroupCell *GetInsertGroup() const;
882 
883  // Actually recalculate the worksheet.
884  bool RecalculateIfNeeded(bool timeout = false);
885 
887  void Recalculate(Cell *start);
888 
889  void Recalculate() { Recalculate(GetTree()); }
890 
895  void ClearDocument();
896 
897  void ResetInputPrompts();
898 
899  bool CanCopy() const
900  {
901  return m_cellPointers.m_selectionStart ||
902  (m_cellPointers.m_activeCell &&
903  m_cellPointers.m_activeCell->CanCopy());
904  }
905 
906  bool CanPaste() const
907  { return m_cellPointers.m_activeCell || m_hCaretActive; }
908 
909  bool CanCut() const
910  {
911  return (m_cellPointers.m_activeCell && m_cellPointers.m_activeCell->CanCopy()) ||
912  (m_cellPointers.m_selectionStart && m_cellPointers.m_selectionStart->GetType() == MC_TYPE_GROUP);
913  }
914 
916  void SelectAll();
917 
919  bool HasCellsSelected() const { return m_cellPointers.HasCellsSelected(); }
920 
931  void DeleteRegion(
932  GroupCell *start,
933  GroupCell *end,
934  UndoActions *undoBuffer
935  );
936 
943  void DeleteRegion(
944  GroupCell *start,
945  GroupCell *end
946  );
947 
953  void DeleteSelection();
954 
955  void TOCdnd(GroupCell *dndStart, GroupCell *dndEnd);
956 
958  bool CanDeleteRegion(GroupCell *start, const GroupCell *end) const;
959 
961  bool CanDeleteSelection() const;
962 
967  void DeleteCurrentCell();
968 
971  {
972  if(m_cellPointers.m_selectionStart != m_cellPointers.m_selectionEnd)
973  return NULL;
974  return dynamic_cast<AnimationCell *>(GetSelectionStart());
975  }
976 
979  {
980  if(m_cellPointers.m_selectionStart != m_cellPointers.m_selectionEnd)
981  return NULL;
982  return dynamic_cast<ImgCell *>(GetSelectionStart());
983  }
984 
987  {
988  if(m_cellPointers.m_selectionStart != m_cellPointers.m_selectionEnd)
989  return NULL;
990  return dynamic_cast<ImgCellBase *>(GetSelectionStart());
991  }
992 
995  {
996  if(m_cellPointers.m_selectionStart != m_cellPointers.m_selectionEnd)
997  return NULL;
998  return dynamic_cast<TextCell *>(GetSelectionStart());
999  }
1000 
1002  bool CanAnimate() const
1003  {
1004  return m_cellPointers.m_selectionStart && m_cellPointers.m_selectionStart == m_cellPointers.m_selectionEnd &&
1005  (dynamic_cast<AnimationCell *>(GetSelectionStart()) != NULL);
1006  }
1007 
1014  void Animate(bool run = true) const;
1015 
1016  void DivideCell();
1017 
1018  void MergeCells();
1019 
1020  void SetLastQuestion(const wxString &lastQuestion){m_lastQuestion = lastQuestion;}
1021  wxString GetLastQuestion() const {return m_lastQuestion;}
1022 
1024  bool CutToClipboard();
1025 
1026  void PasteFromClipboard();
1027 
1034  bool Copy(bool astext = false) const;
1035 
1037  bool CopyCells() const;
1038 
1040  bool CopyMatlab() const;
1041 
1043  bool CopyText() const;
1044 
1046  bool CopyTeX() const;
1047 
1049  wxString ConvertSelectionToMathML() const;
1050 
1052  wxBitmap ConvertSelectionToBitmap() const;
1053 
1055  bool CopyMathML() const;
1056 
1058  bool CopyBitmap() const;
1059 
1061  bool CopyAnimation() const;
1062 
1064  bool CopySVG() const;
1065 
1066 #if wxUSE_ENH_METAFILE
1068  bool CopyEMF() const;
1069 #endif
1070 
1072  bool CopyRTF() const;
1073 
1074  wxSize CopyToFile(const wxString &file) const;
1075 
1076  wxSize CopyToFile(const wxString &file, Cell *start, Cell *end, bool asData = false, double scale = 1) const;
1077 
1078  void CalculateReorderedCellIndices(GroupCell *tree, int &cellIndex, std::vector<int> &cellMap);
1079 
1084  bool ExportToHTML(const wxString &file);
1085 
1090  void
1091  ExportToMAC(wxTextFile &output, GroupCell *tree, bool wxm, const std::vector<int> &cellMap, bool fixReorderedIndices);
1092 
1094  bool ExportToMAC(const wxString &file);
1095 
1097  wxString RTFStart() const;
1098 
1100  wxString RTFEnd() const;
1101 
1103  bool ExportToTeX(const wxString &file);
1104 
1110  wxString GetString(bool lb = false) const;
1111 
1112  GroupCell *GetTree() const { return m_tree.get(); }
1113  std::unique_ptr<GroupCell> *GetTreeAddress() { return &m_tree; }
1114 
1120  { return m_cellPointers.m_selectionStart; }
1121 
1127  { return m_cellPointers.m_selectionEnd; }
1128 
1130  void ClearSelection() { SetSelection(nullptr, nullptr); }
1131 
1133  void SetSelection(Cell *sel) { SetSelection(sel, sel); }
1134 
1136  void SetSelection(Cell *start, Cell *end);
1137 
1140  bool CanEdit();
1141 
1142  bool ActivatePrevInput() { return ActivateInput(-1); }
1143  bool ActivateNextInput() { return ActivateInput(+1); }
1144  wxString GetStatusText() const {return m_statusText;}
1145  bool StatusTextChangedHas() {
1146  bool retval = (m_statusTextHas != m_statusTextHas_old) ||
1147  (m_statusText != m_statusText_old);
1148  m_statusText_old = m_statusText;
1149  m_statusTextHas_old = m_statusTextHas;
1150  return retval;
1151  }
1152  bool StatusTextHas() const {return m_statusTextHas;}
1153 private:
1154  /* ! A timer that tells us to urgently update the display
1155 
1156  Normally we priorize tasks: If there are GUI actions to process we do so.
1157  If not we look if there is data from maxima to process. If not we
1158  If not we recalculate the worksheet element sizes and positions and if
1159  there still is no pressing task we update the display. This way we
1160  respond quickly to the most important inputs.
1161 
1162  This timer, if expired, tells us that if we don't update the screen now
1163  maxima feels like not being responsive.
1164  */
1165  wxTimer m_displayTimeoutTimer;
1166 
1167  template <class T_SRC, class T_DEST>
1168  inline std::unique_ptr<T_DEST> unique_cast(std::unique_ptr<T_SRC> &&src)
1169  {
1170  if (!src) return std::unique_ptr<T_DEST>();
1171 
1172  T_DEST *dest_ptr = &dynamic_cast<T_DEST &>(*src.get());
1173 
1174  (void) src.release();
1175  return std::unique_ptr<T_DEST>(dest_ptr);
1176  }
1177  wxString m_statusText;
1178  wxString m_statusText_old;
1179  bool m_statusTextHas = false;
1180  bool m_statusTextHas_old = false;
1181  void StatusText(const wxString &text){m_statusText = text; m_statusTextHas = true;}
1182  void UnsetStatusText(){m_statusTextHas = false;}
1183  bool ActivateInput(int direction);
1184 
1185 public:
1188  {
1189  m_cellPointers.m_scrollToCell = false;
1190  m_scrollToCaret = true;
1191  }
1192 
1194  bool ScrollToCaretIfNeeded();
1195 
1197  void ScrollToCellIfNeeded();
1198 
1200  void ScheduleScrollToCell(Cell *cell, bool scrollToTop = true)
1201  {
1202  m_cellPointers.ScrollToCell(cell);
1203  m_scrollToTopOfCell = scrollToTop;
1204  m_scrollToCaret = false;
1205 
1206  m_cellPointers.m_scrollToCell = true;
1207  }
1208 
1210  bool PointVisibleIs(wxPoint point);
1211 
1213  bool CaretVisibleIs();
1214 
1217 
1231  void ShowPoint(wxPoint point);
1232 
1234  void OnSetFocus(wxFocusEvent &event);
1235 
1237  void OnKillFocus(wxFocusEvent &event);
1238 
1240  bool IsSelected(CellType type);
1241 
1248  void StepAnimation(int change = 1);
1249 
1251  bool IsActiveInLast() const
1252  { return m_cellPointers.m_activeCell && m_cellPointers.m_activeCell->GetGroup() == m_last; }
1253 
1256  {
1257  return m_last;
1258  }
1259 
1262 
1263  void SetActiveCell(EditorCell *cell);
1264 
1268  void SetDefaultHCaret();
1269 
1274  void SetHCaret(GroupCell *where); // call with false, when manually refreshing
1276  GroupCell *GetHCaret();
1277 
1279  void OpenHCaret(const wxString &txt = {})
1280  {
1281  if(m_mainToolBar == NULL)
1282  OpenHCaret(txt, GC_TYPE_CODE);
1283  else
1285  }
1286 
1288  void OpenHCaret(const wxString &txt, GroupType type);
1289 
1291  void ShowHCaret();
1292 
1297  bool CanUndoInsideCell() const;
1298 
1299  void UndoInsideCell();
1300 
1305  bool CanRedoInsideCell() const;
1306 
1307  void RedoInsideCell();
1308 
1318  void FollowEvaluation(bool followEvaluation);
1319 
1321  bool FollowEvaluation() const
1322  { return m_followEvaluation; }
1323 
1329  void ScrolledAwayFromEvaluation(bool ScrolledAway);
1330 
1331  bool ScrolledAwayFromEvaluation() const
1332  { return m_scrolledAwayFromEvaluation; }
1333 
1334  void SaveValue();
1335 
1336  bool IsSaved() const
1337  { return m_saved; }
1338 
1339  void SetSaved(bool saved)
1340  { if(m_saved != saved) m_updateControls = true; m_saved = saved;}
1341 
1342  void OutputChanged()
1343  {
1344  if(m_currentFile.EndsWith(".wxmx"))
1345  m_saved = false;
1346  }
1347 
1348  void RemoveAllOutput();
1349 
1350  void RemoveAllOutput(GroupCell *cell);
1351  // methods related to evaluation queue
1352 
1358  void Evaluate();
1359 
1361  void AddToEvaluationQueue(GroupCell *cell);
1362 
1363  void AddDocumentToEvaluationQueue();
1364 
1367 
1370 
1372  void AddRestToEvaluationQueue();
1373 
1376 
1379 
1382 
1385 
1388 
1389  void FoldOccurred();
1390 
1391  // methods for folding
1393  GroupCell *ToggleFold(GroupCell *which);
1394 
1396 
1397  void FoldAll();
1398 
1399  void UnfoldAll();
1400 
1401  // methods for zooming the document in and out
1402  void SetZoomFactor(double newzoom, bool recalc = true);
1403 
1404  void CommentSelection();
1405 
1410  void OnScrollChanged(wxScrollEvent &ev);
1411  void OnScrollEvent(wxScrollWinEvent &ev);
1416  void OnMouseWheel(wxMouseEvent &event);
1417 
1423  bool FindIncremental(const wxString &str, bool down, bool ignoreCase);
1424  bool FindIncremental_RegEx(const wxString &str, bool down);
1425 
1430  bool FindNext(const wxString &str, bool down, bool ignoreCase, bool warn = true);
1431  bool FindNext_Regex(const wxString &str, const bool &down, bool warn = true);
1432 
1437  void Replace(const wxString &oldString, const wxString &newString, bool ignoreCase);
1438  void Replace_RegEx(const wxString &oldString, const wxString &newString);
1439 
1444  int ReplaceAll(const wxString &oldString, const wxString &newString, bool ignoreCase);
1445  int ReplaceAll_RegEx(const wxString &oldString, const wxString &newString);
1446 
1447  wxString GetInputAboveCaret();
1448 
1449  wxString GetOutputAboveCaret();
1450 
1452  void LoadSymbols();
1453 
1454  bool Autocomplete(AutoComplete::autoCompletionType type = AutoComplete::command);
1455 
1457  void AddSymbol(const wxString &fun, AutoComplete::autoCompletionType type = AutoComplete::command)
1458  { m_autocomplete.AddSymbol(fun, type); }
1459 
1461  void AddSymbols(const wxString &xml)
1462  { m_autocomplete.AddSymbols(xml); }
1464  void AddSymbols(wxXmlDocument xml)
1465  { m_autocomplete.AddSymbols(xml); }
1466 
1467  void SetActiveCellText(const wxString &text);
1468 
1469  bool InsertText(const wxString &text);
1470 
1471  void OpenNextOrCreateCell();
1472 
1474  void OnFollow();
1475 
1478 
1480  void SelectGroupCell(GroupCell *cell);
1481 
1486  void SetAnswer(const wxString &answer);
1488  void QuestionAnswered();
1489 
1491  bool m_questionPrompt = false;
1492 
1497  bool QuestionPending() const
1498  { return m_questionPrompt; }
1500 
1504  void QuestionPending(bool pending)
1505  { m_questionPrompt = pending; }
1506 
1507  void SetMaximaDocDir(const wxString &dir)
1508  {
1509  m_maximaDocDir = dir;
1510  }
1511 
1513  bool GCContainsCurrentQuestion(const GroupCell *cell);
1514 
1517  void OpenQuestionCaret(const wxString &txt = {});
1519  void UpdateScrollPos();
1520 
1526  GroupCell *GetWorkingGroup(bool resortToLast = false) const;
1528  void LoadHelpFileAnchors(const wxString &docdir, const wxString &maximaVersion)
1529  {m_maximaManual.LoadHelpFileAnchors(docdir, maximaVersion);}
1530  wxString GetHelpfileAnchorName(const wxString &keyword)
1531  {return m_maximaManual.GetHelpfileAnchorName(keyword);}
1532  wxString GetHelpfileURL(const wxString &keyword)
1533  {return m_maximaManual.GetHelpfileURL(keyword);}
1535  int GetCellIndex(Cell *cell) const;
1536 
1538  std::vector<wxString> m_replacementsForCurrentWord;
1539  //Simple iterator over a Maxima input string, skipping comments and strings
1541  {
1542  public:
1543  explicit SimpleMathConfigurationIterator(const wxString &ainput);
1544 
1545  void operator++();
1546 
1547  bool isValid() const
1548  { return pos < input.length(); }
1549 
1550 
1551  inline wxChar operator*() const
1552  { return input[pos]; }
1553 
1554  std::size_t pos;
1555 
1560  const wxString &input;
1561  };
1562 
1563 #if wxUSE_ACCESSIBILITY
1564  class AccessibilityInfo: public wxAccessible
1565  {
1566  public:
1567  AccessibilityInfo(wxWindow *parent, Worksheet *worksheet);
1568  wxAccStatus GetChildCount (int *childCount);
1569  wxAccStatus GetChild (int childId, wxAccessible **child);
1570  wxAccStatus GetDefaultAction(int childId, wxString *actionName);
1571  wxAccStatus GetParent (wxAccessible ** parent);
1572 // wxAccStatus GetFocus (int *childId, wxAccessible **child);
1573  wxAccStatus GetLocation (wxRect &rect, int elementId);
1574  wxAccStatus HitTest (const wxPoint &pt,
1575  int *childId, wxAccessible **childObject);
1576  wxAccStatus GetDescription(int childId, wxString *description);
1577  private:
1578  wxWindow *m_parent = NULL;
1579  Worksheet *m_worksheet = NULL;
1580  };
1581 #endif
1582  MaximaManual m_maximaManual;
1583  MaximaManual *GetMaximaManual() {return &m_maximaManual;}
1584 protected:
1585  void FocusTextControl();
1586  wxString m_lastQuestion;
1587  int m_virtualWidth_Last = -1;
1588  int m_virtualHeight_Last = -1;
1590  wxBitmap m_memory;
1591  virtual wxSize DoGetBestClientSize() const override;
1592 #if wxUSE_ACCESSIBILITY
1593  AccessibilityInfo *m_accessibilityInfo = NULL;
1594 #endif
1595  void UpdateConfigurationClientSize();
1599  int m_pointer_x = -1;
1601  int m_pointer_y = -1;
1603  bool m_mouseMotionWas = false;
1605  bool m_inPopupMenu = false;
1606 };
1607 
1608 inline Worksheet *Cell::GetWorksheet() const
1609 {
1610  wxWindow *worksheet = m_configuration->GetWorkSheet();
1611  wxASSERT(worksheet != NULL);
1612  return static_cast<Worksheet*>(worksheet);
1613 }
1614 
1615 wxDECLARE_EVENT(TOC_UPDATE_NEEDED_EVENT, wxCommandEvent);
1616 
1617 #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:60
autoCompletionType
All types of things we can autocomplete.
Definition: Autocomplete.h:67
void AddSymbols(wxString xml)
Interprets the XML autocompletable symbol list maxima can send us.
Definition: Autocomplete.cpp:109
void AddSymbol(wxString fun, autoCompletionType type=command)
Manually add an autocompletable symbol to our symbols lists.
Definition: Autocomplete.cpp:559
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:194
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
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:234
CellType GetType() const
Returns the type of this cell.
Definition: Cell.h:412
Configuration * m_configuration
A pointer to the configuration responsible for this worksheet.
Definition: Cell.h:975
The configuration storage for the current worksheet.
Definition: Configuration.h:95
void ReadConfig()
Read the config from the wxConfig object.
Definition: Configuration.cpp:607
wxWindow * GetWorkSheet() const
Get the worksheet this configuration storage is valid for.
Definition: Configuration.h:894
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:284
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:74
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:524
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:498
Definition: Worksheet.h:1541
const wxString & input
reference to input string (must be a reference, so it can be modified)
Definition: Worksheet.h:1560
The canvas that contains the spreadsheet the whole program is about.
Definition: Worksheet.h:95
TextCell * GetSelectedTextCell() const
Returns the selected cell - or NULL, if the selection isn't a text cell.
Definition: Worksheet.h:994
bool IsActiveInLast() const
Is the editor active in the last cell of the worksheet?
Definition: Worksheet.h:1251
GroupCell * ToggleFold(GroupCell *which)
Fold or unfold a cell.
Definition: Worksheet.cpp:1172
void ClearSelection()
Clear the selection - make it empty, i.e. no selection.
Definition: Worksheet.h:1130
const wxString UnicodeToMaxima(wxString s)
Make a few unicode characters interpretable by maxima.
Definition: Worksheet.cpp:5696
bool CanMergeSelection() const
Can we merge the selected cells into one?
Definition: Worksheet.cpp:6287
wxString RTFStart() const
The start of a RTF document.
Definition: Worksheet.cpp:7872
int m_pointer_x
The x position of the mouse pointer.
Definition: Worksheet.h:1599
void SetDefaultHCaret()
Set the HCaret to its default location, at the end of the document.
Definition: Worksheet.cpp:6888
bool CanDeleteRegion(GroupCell *start, const GroupCell *end) const
Is it possible to delete the cells between start and end?
Definition: Worksheet.cpp:2897
void AddSectionToEvaluationQueue(GroupCell *start)
Adds a chapter, a section or a subsection to the evaluation queue.
Definition: Worksheet.cpp:6045
void AddSymbols(const wxString &xml)
Add a xml-encoded list of symbols to the autocompletion list.
Definition: Worksheet.h:1461
void FoldAll()
Recursively folds the whole document.
Definition: Worksheet.cpp:1209
virtual ~Worksheet()
The destructor.
Definition: Worksheet.cpp:412
bool CutToClipboard()
Add the currently selected cells to the clipboard and delete them.
Definition: Worksheet.cpp:6582
GroupCell * GetInsertGroup() const
The group that the line's cells will belong to - used by InsertLine.
Definition: Worksheet.cpp:831
bool QuestionPending() const
Does maxima wait for the answer of a question?
Definition: Worksheet.h:1497
void AddEntireDocumentToEvaluationQueue()
Schedule all cells in the document for evaluation.
Definition: Worksheet.cpp:6036
AnimationCell * GetSelectedAnimation() const
Returns the selected cell - or NULL, if the selection isn't an animation.
Definition: Worksheet.h:970
GroupCell * FirstVisibleGC()
The first groupCell that is currently visible.
Definition: Worksheet.cpp:2291
void AddSymbols(wxXmlDocument xml)
Add a xml-encoded list of symbols to the autocompletion list.
Definition: Worksheet.h:1464
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:1528
bool ExportToHTML(const wxString &file)
Export the file to an html document.
Definition: Worksheet.cpp:4638
void OpenHCaret(const wxString &txt={})
Place the cursor into a new cell where the horizontal cursor is.
Definition: Worksheet.h:1279
void ScrollToError()
Unfold the cell that produced the error, if necessary and, if requested, scroll to it.
Definition: Worksheet.cpp:781
bool HCaretActive() const
Is the vertically-drawn cursor active?
Definition: Worksheet.h:804
void ClearDocument()
Empties the current document.
Definition: Worksheet.cpp:1066
wxString RTFEnd() const
The end of a RTF document.
Definition: Worksheet.cpp:7924
void UnfoldAll()
Recursively unfolds the whole document.
Definition: Worksheet.cpp:1219
void UpdateTableOfContents()
Update the table of contents.
Definition: Worksheet.cpp:8123
void QuestionPending(bool pending)
Does maxima currently wait for the answer of a question?
Definition: Worksheet.h:1504
void DeleteCurrentCell()
Delete the currently active cell - or the cell above this one.
Definition: Worksheet.cpp:2882
void Replace(const wxString &oldString, const wxString &newString, bool ignoreCase)
Replace the current occurrence of a string.
Definition: Worksheet.cpp:7333
bool CopyMatlab() const
Copy a Matlab representation of the current selection to the clipboard.
Definition: Worksheet.cpp:2704
bool CopyText() const
Copy a textual representation of the current selection to the clipboard.
Definition: Worksheet.cpp:2767
bool m_inPopupMenu
Is there an active popup menu?
Definition: Worksheet.h:1605
wxTimer m_keyboardInactiveTimer
The timer that tells us when the keyboard is inactive so an autosave isn't disrupting.
Definition: Worksheet.h:844
int ReplaceAll(const wxString &oldString, const wxString &newString, bool ignoreCase)
Replace all occurrences of a string.
Definition: Worksheet.cpp:7367
void Animate(bool run=true) const
Animate the current slide show.
Definition: Worksheet.cpp:6860
bool CopyRTF() const
Copy a rtf version of the current selection to the clipboard.
Definition: Worksheet.cpp:4407
void UpdateConfig()
Re-read the configuration.
Definition: Worksheet.h:779
int m_pointer_y
The y position of the mouse pointer.
Definition: Worksheet.h:1601
bool Copy(bool astext=false) const
Copy the current selection to the clipboard.
Definition: Worksheet.cpp:2547
bool CopyAnimation() const
Copy the current animation to the clipboard.
Definition: Worksheet.cpp:4385
void StepAnimation(int change=1)
Set the slide of the currently selected animation or advance it by one step.
Definition: Worksheet.cpp:4236
void SetAnswer(const wxString &answer)
Handling questions from and answers for maxima.
Definition: Worksheet.cpp:3072
GroupCell * ToggleFoldAll(GroupCell *which)
Toggles the status of the fold for the given GroupCell and its children.
Definition: Worksheet.cpp:1193
void OnChar(wxKeyEvent &event)
Key for a printable character pressed.
Definition: Worksheet.cpp:4063
void AddSelectionToEvaluationQueue()
Schedule all cells in the selection to be evaluated.
Definition: Worksheet.cpp:6074
bool CanEdit()
We can edit the input if the we have the whole input in selection!
Definition: Worksheet.cpp:5926
bool HasCellsSelected() const
Is at least one entire cell selected?
Definition: Worksheet.h:919
void OnSetFocus(wxFocusEvent &event)
What to do if the worksheet is in the input focus.
Definition: Worksheet.cpp:6813
void SetNotification(const wxString &message, int flags=wxICON_INFORMATION)
Inform the user that something happened in a non-active window.
Definition: Worksheet.cpp:4041
void ScheduleScrollToCell(Cell *cell, bool scrollToTop=true)
Schedules scrolling to a given cell.
Definition: Worksheet.h:1200
GroupCell * InsertGroupCells(std::unique_ptr< GroupCell > &&cells, GroupCell *where, UndoActions *undoBuffer)
Insert group cells into the worksheet.
Definition: Worksheet.cpp:722
void AddDocumentTillHereToEvaluationQueue()
Schedule all cells stopping with the one the caret is in for evaluation.
Definition: Worksheet.cpp:6094
bool CanAnimate() const
Does it make sense to enable the "Play" button and the slider now?
Definition: Worksheet.h:1002
bool m_mouseMotionWas
Was there a mouse motion we didn't react to until now?
Definition: Worksheet.h:1603
void SelectAll()
Select the whole document.
Definition: Worksheet.cpp:6736
void OnKillFocus(wxFocusEvent &event)
What to do if the worksheet looses the input focus.
Definition: Worksheet.cpp:6825
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:840
void ClearNotification()
Clears the notification message from SetNotification.
Definition: Worksheet.cpp:4039
void OnFollow()
Called when the "Scroll to currently evaluated" button is pressed.
Definition: Worksheet.cpp:7806
Cell * GetSelectionEnd() const
Return the last of the currently selected cells.
Definition: Worksheet.h:1126
void FoldOccurred()
Call when a fold action was detected, to update the state in response to a fold occurring.
Definition: Worksheet.cpp:1160
Worksheet(wxWindow *parent, int id, Configuration *config, wxPoint pos=wxDefaultPosition, wxSize size=wxDefaultSize, bool reactToEvents=true)
The constructor.
Definition: Worksheet.cpp:87
bool CanDeleteSelection() const
Is it possible to delete the currently selected cells?
Definition: Worksheet.cpp:2866
AutoComplete m_autocomplete
The storage for the autocompletion feature.
Definition: Worksheet.h:684
ToolBar * m_mainToolBar
The toolbar of the main window: We need to access it and therefore have it defined here.
Definition: Worksheet.h:1477
bool m_questionPrompt
true = the last reply from maxima was a question
Definition: Worksheet.h:1491
Cell * GetSelectionStart() const
Return the first of the currently selected cells.
Definition: Worksheet.h:1119
bool CaretVisibleIs()
Is the caret (hcaret or vcaret) currently visible on the worksheet?
Definition: Worksheet.cpp:7278
bool UpdateControlsNeeded()
Is an update of the worksheet controls needed?
Definition: Worksheet.h:99
bool CopyCells() const
Copy the selection to the clipboard as it would appear in a .wxm file.
Definition: Worksheet.cpp:2796
GroupCell * GetLastCell()
Returns the last cell of the worksheet.
Definition: Worksheet.h:1255
GroupCell * GetHCaret()
The cell the horizontal cursor is above. NULL means at the start of the document.
Definition: Worksheet.cpp:6871
bool IsSelected(CellType type)
Does the selection start with a cell of the type "type".
Definition: Worksheet.cpp:6851
wxString ConvertSelectionToMathML() const
Convert the current selection to MathML.
Definition: Worksheet.cpp:2628
bool CanUndoInsideCell() const
Is it possible to issue an undo in the currently selected cell?
Definition: Worksheet.cpp:6937
void SetHCaret(GroupCell *where)
Set the HCaret at the location of the given Cell.
Definition: Worksheet.cpp:6898
bool CanRedoInsideCell() const
Is it possible to issue an undo in the currently selected cell?
Definition: Worksheet.cpp:6951
bool GCContainsCurrentQuestion(const GroupCell *cell)
Does the GroupCell cell points to contain the question currently asked by maxima?
Definition: Worksheet.cpp:3305
bool IsEmpty() const
Is this worksheet empty?
Definition: Worksheet.h:627
void NumberSections() const
Renumber all sections.
Definition: Worksheet.cpp:1099
CellPtr< GroupCell > m_recalculateStart
Where to start recalculation. NULL = No recalculation needed.
Definition: Worksheet.h:1597
void OnKeyDown(wxKeyEvent &event)
A special key has been pressed.
Definition: Worksheet.cpp:3200
EditorCell * GetActiveCell() const
Get the currently active EditorCell.
Definition: Worksheet.h:687
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:5801
void SetSelection(Cell *sel)
Select the cell sel.
Definition: Worksheet.h:1133
void AddCellToEvaluationQueue(GroupCell *gc)
Schedule this cell for evaluation.
Definition: Worksheet.cpp:6116
void SetCellStyle(GroupCell *group, GroupType style)
Change the style of a cell.
Definition: Worksheet.cpp:2986
bool Autocomplete(AutoComplete::autoCompletionType type=AutoComplete::command)
Definition: Worksheet.cpp:7426
wxBitmap m_memory
A memory we can manually buffer the contents of the area that is to be redrawn in.
Definition: Worksheet.h:1590
void LoadSymbols()
Compile a list of known autocompletion symbols.
Definition: Worksheet.cpp:5694
void SelectGroupCell(GroupCell *cell)
Set this cell as the currently selected one.
Definition: Worksheet.cpp:7792
void ShowPoint(wxPoint point)
Scrolls to a point on the worksheet.
Definition: Worksheet.cpp:6538
void WindowActive(bool active)
Is this window active?
Definition: Worksheet.h:661
bool ExportToTeX(const wxString &file)
export to a LaTeX file
Definition: Worksheet.cpp:5577
bool IsSelectionInWorkingGroup()
Is the selection in the current working group?
Definition: Worksheet.cpp:6866
void ShowHCaret()
Activates the horizontal cursor.
Definition: Worksheet.cpp:6930
EditorCell * KeyboardSelectionStart() const
Tells us which cell the keyboard selection has started in.
Definition: Worksheet.h:690
void CodeCellVisibilityChanged()
To be called after enabling or disabling the visibility of code cells.
Definition: Worksheet.cpp:5565
void ScrollToCaret()
Request to scroll to the cursor as soon as wxMaxima is idle.
Definition: Worksheet.h:1187
void 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:3080
void MarkRefreshAsDone()
Handle redrawing the worksheet or of parts of it.
Definition: Worksheet.h:732
bool CopyMathML() const
Copy the MathML representation of the current selection to the clipboard.
Definition: Worksheet.cpp:2677
bool CopyBitmap() const
Copy a bitmap of the current selection to the clipboard.
Definition: Worksheet.cpp:4378
bool PointVisibleIs(wxPoint point)
Is the point currently visible on the worksheet?
Definition: Worksheet.cpp:6517
ImgCellBase * GetSelectedImgCellBase() const
Returns the selected cell - or NULL, if the selection isn't image nor animation.
Definition: Worksheet.h:986
void ScrollToStart()
Scroll to the start of the worksheet.
Definition: Worksheet.h:795
ImgCell * GetSelectedImgCell() const
Returns the selected cell - or NULL, if the selection isn't an image.
Definition: Worksheet.h:978
void Recalculate(Cell *start)
Schedule a recalculation of the worksheet starting with the cell start.
Definition: Worksheet.cpp:971
bool FindIncremental(const wxString &str, bool down, bool ignoreCase)
Do an incremental search from the cursor or the point the last search started at.
Definition: Worksheet.cpp:7082
void AddSymbol(const wxString &fun, AutoComplete::autoCompletionType type=AutoComplete::command)
Add a symbol to the autocompletion list.
Definition: Worksheet.h:1457
bool SectioningMoveIn(GroupCell *parent)
Make this chapter/section/... a section/subsection/... changing its subheadings, too.
Definition: Worksheet.cpp:7663
wxBitmap ConvertSelectionToBitmap() const
Convert the current selection to a bitmap.
void RequestRedraw(GroupCell *start=NULL)
Request the worksheet to be redrawn.
Definition: Worksheet.cpp:384
int GetCellIndex(Cell *cell) const
Returns the index in (i...) or (o...)
Definition: Worksheet.cpp:4541
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:3322
void SetActiveCell(EditorCell *cell)
Mark an editor cell as the active one.
Definition: Worksheet.cpp:6441
FindReplaceDialog * m_findDialog
The find-and-replace-dialog.
Definition: Worksheet.h:801
void QuestionAnswered()
Mark the current question from maxima as "answered"..
Definition: Worksheet.cpp:3309
void DeleteRegion(GroupCell *start, GroupCell *end, UndoActions *undoBuffer)
Definition: Worksheet.cpp:3010
bool ScrollToCaretIfNeeded()
Scrolls to the cursor, if requested.
Definition: Worksheet.cpp:7305
std::unique_ptr< GroupCell > CopyTree() const
Copies the worksheet's entire contents.
Definition: Worksheet.cpp:4374
std::vector< wxString > m_replacementsForCurrentWord
Suggestions for how the word that was right-clicked on could continue.
Definition: Worksheet.h:1538
EvaluationQueue m_evaluationQueue
The list of cells that have to be evaluated.
Definition: Worksheet.h:1387
void ForceRedraw()
Redraw the window now and mark any pending redraw request as "handled".
Definition: Worksheet.h:769
bool CopyTeX() const
Copy the TeX representation of the current selection to the clipboard.
Definition: Worksheet.cpp:2732
bool FindNext(const wxString &str, bool down, bool ignoreCase, bool warn=true)
Find the next occurrence of a string.
Definition: Worksheet.cpp:7102
void AddRestToEvaluationQueue()
Add all cells below the cursor to the evaluation queue.
Definition: Worksheet.cpp:6054
void ScrollToCellIfNeeded()
Scrolls to the cell given by ScheduleScrollToCell; Is called once we have time to do so.
Definition: Worksheet.cpp:6142
void OnMouseWheel(wxMouseEvent &event)
Called if the mouse wheel sents events.
Definition: Worksheet.cpp:2325
void CloseAutoCompletePopup()
Close the autocompletion pop-up if it is currently open.
Definition: Worksheet.h:630
bool SectioningMoveOut(GroupCell *parent)
Make this section/subsection/... a chapter/section/... changing its subheadings, too.
Definition: Worksheet.cpp:7705
bool FollowEvaluation() const
Query if we want to automatically scroll to the cell that is currently evaluated.
Definition: Worksheet.h:1321
void DestroyTree()
Clear the whole worksheet.
Definition: Worksheet.cpp:4365
wxString GetString(bool lb=false) const
Convert the current selection to a string.
Definition: Worksheet.cpp:2529
stx::optional< Notification > m_notificationMessage
A error notification message.
Definition: Worksheet.h:659
GroupCell * GetWorkingGroup(bool resortToLast=false) const
Returns the cell maxima currently works on.
Definition: Worksheet.cpp:809
bool CopySVG() const
Copy a svg of the current selection to the clipboard.
Definition: Worksheet.cpp:4393
wxString m_currentFile
The name of the currently-opened file.
Definition: Worksheet.h:786
void Evaluate()
Trigger the evaluation of the current cell(s)
Definition: Worksheet.cpp:3191
void OnScrollChanged(wxScrollEvent &ev)
Called if the user is using the scrollbar for scrolling through the document.
Definition: Worksheet.cpp:7039
void OnActivate(wxActivateEvent &event)
Is called if this element looses or gets the focus.
Definition: Worksheet.cpp:6890
void AddToEvaluationQueue(GroupCell *cell)
Adds a group cell to the evaluation queue marking its contents as "outdated".
Definition: Worksheet.cpp:6022
Definition: CellPointers.h:32