Cadabra
Computer algebra system for field theory problems
|
Each notebook has one main window which controls it.
It has a menu bar, a status pane and one or more panels that represent a view on the document.
#include <NotebookWindow.hh>
Public Member Functions | |
NotebookWindow (Cadabra *, bool read_only=false) | |
~NotebookWindow () | |
virtual void | add_cell (const DTree &, DTree::iterator, bool) override |
Add a GUI cell corresponding to the document cell at the iterator. More... | |
virtual void | remove_cell (const DTree &, DTree::iterator) override |
Remove a single cell together with all its child cells. More... | |
virtual void | remove_all_cells () override |
Remove all GUI cells from the display (used as a quick way to clear all before loading a new document). More... | |
virtual void | update_cell (const DTree &, DTree::iterator) override |
The basic manipulations that a GUI needs to implement are adding, removing and updating (refreshing the display of) a cell. More... | |
virtual void | position_cursor (const DTree &, DTree::iterator, int pos) override |
Position the cursor in the current canvas in the widget corresponding to the indicated cell. More... | |
virtual size_t | get_cursor_position (const DTree &, DTree::iterator) override |
Retrieve the position of the cursor in the current cell. More... | |
void | select_range (const DTree &, DTree::iterator, int start, int len) |
virtual void | on_connect () override |
Network status is propagated from the ComputeThread to the GUI using the following methods. More... | |
virtual void | on_disconnect (const std::string &) override |
virtual void | on_network_error () override |
virtual void | on_kernel_runstatus (bool) override |
virtual void | process_data () override |
When the ComputeThread needs to modify the document, it stores an ActionBase object on the stack (see the DocumenThread class) and then wakes up the GUI thread signalling it to process this action. More... | |
bool | on_vscroll_changed (Gtk::ScrollType, double) |
bool | on_scroll (GdkEventScroll *) |
void | on_scroll_size_allocate (Gtk::Allocation &) |
void | scroll_current_cell_into_view () |
void | scroll_cell_into_view (DTree::iterator cell) |
void | set_name (const std::string &) |
void | set_title_prefix (const std::string &) |
void | load_file (const std::string ¬ebook_contents) |
void | refresh_highlighting () |
void | on_help_register () |
void | set_statusbar_message (const std::string &message="", int line=-1, int col=-1) |
void | select_git_path () |
Functionality for the diff viewer. More... | |
void | compare_to_file () |
void | compare_git_latest () |
void | compare_git_choose () |
void | compare_git_specific () |
void | compare_git (const std::string &commit_hash) |
std::string | run_git_command (const std::string &args) |
virtual void | set_compute_thread (ComputeThread *compute) override |
Let the notebook know about the ComputeThread so that it can send cells for evaluation. More... | |
virtual void | on_interactive_output (const nlohmann::json &msg) override |
virtual void | set_progress (const std::string &msg, int cur_step, int total_steps) override |
Public Member Functions inherited from cadabra::DocumentThread | |
DocumentThread (GUIBase *) | |
DocumentThread (const DocumentThread &)=delete | |
It is not possible to copy-construct a DocumentThread as it holds on to resources which are not easily copied (such as GUI elements). More... | |
void | build_visual_representation () |
Ensure that the gui has an up-to-date representation of the dtree. More... | |
void | queue_action (std::shared_ptr< ActionBase >) |
All changes to the document should be made by submitting ActionBase derived objects to the 'queue_action' function, so that an undo stack can be kept. More... | |
void | new_document () |
Setup an empty new document with a single Python input cell. More... | |
void | load_from_string (const std::string &) |
Load a new notebook from a JSON string. More... | |
void | undo () |
One undo step. More... | |
std::pair< DTree::iterator, size_t > | find_string (DTree::iterator start_it, size_t start_pos, const std::string &f, bool case_ins) const |
Find string, return match, or a (doc.end(), std::string::npos). More... | |
void | set_user_details (const std::string &name, const std::string &email, const std::string &affiliation) |
Set user details which will be sent to the Cadabra log server. More... | |
Public Attributes | |
TeXEngine | engine |
double | scale |
double | display_scale |
Public Attributes inherited from cadabra::DocumentThread | |
friend | ActionBase |
friend | ActionAddCell |
friend | ActionPositionCursor |
friend | ActionRemoveCell |
friend | ActionSplitCell |
friend | ActionSetRunStatus |
friend | ActionInsertText |
friend | ActionCompleteText |
friend | ActionEraseText |
Prefs | prefs |
Protected Member Functions | |
virtual bool | on_key_press_event (GdkEventKey *) override |
virtual bool | on_delete_event (GdkEventAny *) override |
virtual bool | on_configure_event (GdkEventConfigure *cfg) override |
virtual bool | on_unhandled_error (const std::exception &err) override |
bool | handle_outbox_select (GdkEventButton *, DTree::iterator it) |
void | unselect_output_cell () |
void | on_outbox_copy (Glib::RefPtr< Gtk::Clipboard > refClipboard, DTree::iterator it) |
Protected Member Functions inherited from cadabra::DocumentThread | |
void | process_action_queue () |
Process the action queue. More... | |
bool | help_type_and_topic (const std::string &before, const std::string &after, help_t &help_type, std::string &help_topic) const |
Protected Attributes | |
DTree::iterator | current_cell |
DTree::iterator | selected_cell |
Protected Attributes inherited from cadabra::DocumentThread | |
GUIBase * | gui |
ComputeThread * | compute |
DTree | doc |
The actual document tree. More... | |
std::mutex | stack_mutex |
The action undo/redo/todo stacks and logic to execute them. More... | |
ActionStack | undo_stack |
ActionStack | redo_stack |
std::queue< std::shared_ptr< ActionBase > > | pending_actions |
bool | disable_stacks |
Private Member Functions | |
void | update_status () |
void | tex_run_async () |
void | update_title () |
void | set_stop_sensitive (bool) |
void | on_file_new () |
void | on_file_open () |
void | on_file_close () |
void | on_file_save () |
void | on_file_save_as () |
void | on_file_save_as_jupyter () |
void | on_file_export_html () |
void | on_file_export_html_segment () |
void | on_file_export_latex () |
void | on_file_export_python () |
void | on_file_quit () |
bool | quit_safeguard (bool quit) |
bool | on_first_redraw () |
void | on_edit_undo () |
void | on_edit_copy (const Glib::VariantBase &) |
void | on_edit_paste () |
void | on_edit_insert_above () |
void | on_edit_insert_below () |
void | on_edit_delete () |
void | on_edit_split () |
void | on_edit_cell_is_latex () |
void | on_edit_cell_is_python () |
void | on_ignore_cell_on_import () |
void | on_edit_find () |
void | on_view_split () |
void | on_view_close () |
void | on_run_cell () |
void | on_run_runall () |
void | on_run_runtocursor () |
void | on_run_stop () |
void | on_prefs_set_cv (int vis) |
void | on_prefs_font_size (int num) |
void | on_prefs_highlight_syntax (bool on) |
void | on_prefs_microtex (bool on) |
void | on_prefs_choose_colours () |
void | on_prefs_use_defaults () |
void | on_tools_options () |
void | on_tools_clear_cache () |
void | on_help_about () |
void | on_help () const |
void | on_kernel_restart () |
void | on_search_text_changed () |
Search handling. More... | |
void | on_clipboard_get (Gtk::SelectionData &, guint info) |
Clipboard handling. More... | |
void | on_clipboard_clear () |
std::string | save (const std::string &fn) const |
void | process_todo_queue () |
Todo deque processing logic. More... | |
void | refresh_after_tex_engine_run () |
Refresh the display after a TeX engine run has completed. More... | |
void | handle_thread_tex_error () |
Handle a TeX error which occurred on a threaded TeX run (activated by tex_run_async ) and is stored in tex_error_string . More... | |
void | on_crash_window_closed (int) |
bool | cell_got_focus (DTree::iterator, int) |
bool | cell_toggle_visibility (DTree::iterator it, int) |
bool | cell_content_insert (const std::string &, int, DTree::iterator, int) |
bool | cell_content_erase (int, int, DTree::iterator, int) |
bool | cell_content_execute (DTree::iterator, int, bool shift_enter_pressed) |
bool | cell_content_changed (DTree::iterator it, int i) |
bool | cell_complete_request (DTree::iterator it, int pos, int i) |
void | interactive_execute () |
void | dim_output_cells (DTree::iterator it) |
bool | on_tex_error (const std::string &, DTree::iterator) |
void | load_css () |
void | on_text_scaling_factor_changed (const std::string &key) |
bool | idle_handler () |
Private Attributes | |
Glib::RefPtr< Cadabra > | cdbapp |
std::vector< Glib::RefPtr< Gio::SimpleAction > > | default_actions |
Glib::Dispatcher | dispatcher |
Glib::RefPtr< Gio::SimpleActionGroup > | actiongroup |
Glib::RefPtr< Gtk::Builder > | uimanager |
Gtk::VBox | topbox |
Gtk::HBox | toolbar |
Gtk::Button | tool_open |
Gtk::Button | tool_save |
Gtk::Button | tool_save_as |
Gtk::Button | tool_run |
Gtk::Button | tool_run_to |
Gtk::Button | tool_stop |
Gtk::Button | tool_restart |
Gtk::HBox | supermainbox |
Gtk::Paned | dragbox |
Gtk::VBox | mainbox |
Gtk::SearchBar | searchbar |
Gtk::HBox | search_hbox |
Gtk::SearchEntry | searchentry |
Gtk::CheckButton | search_case_insensitive |
Gtk::Label | search_result |
Gtk::HBox | statusbarbox |
Console | console |
Gtk::Dialog | console_win |
std::unique_ptr< DiffViewer > | diffviewer |
std::vector< NotebookCanvas * > | canvasses |
int | current_canvas |
Gtk::ProgressBar | progressbar |
Gtk::Spinner | kernel_spinner |
bool | kernel_spinner_status |
Gtk::Label | status_label |
Gtk::Label | kernel_label |
Gtk::Label | top_label |
std::mutex | status_mutex |
std::string | status_string |
std::string | kernel_string |
std::string | progress_string |
double | progress_frac |
int | status_line |
int | status_col |
Glib::Dispatcher | dispatch_update_status |
Glib::Dispatcher | dispatch_refresh |
Glib::Dispatcher | dispatch_tex_error |
std::string | name |
std::string | title_prefix |
bool | modified |
bool | read_only |
std::string | clipboard_txt |
std::string | clipboard_cdb |
bool | crash_window_hidden |
Glib::RefPtr< Gtk::CssProvider > | css_provider |
Glib::RefPtr< Gio::Settings > | settings |
int | last_configure_width |
DTree::iterator | follow_cell |
std::recursive_mutex | tex_need_width_mutex |
std::unique_ptr< std::thread > | tex_thread |
bool | tex_running |
int | tex_need_width |
std::string | tex_error_string |
std::pair< DTree::iterator, size_t > | last_find_location |
std::string | last_find_string |
bool | is_configured |
Glib::RefPtr< Gio::SimpleAction > | action_copy |
Glib::RefPtr< Gio::SimpleAction > | action_paste |
Glib::RefPtr< Gio::SimpleAction > | action_fontsize |
Glib::RefPtr< Gio::SimpleAction > | action_highlight |
Glib::RefPtr< Gio::SimpleAction > | action_stop |
Glib::RefPtr< Gio::SimpleAction > | action_register |
Glib::RefPtr< Gio::SimpleAction > | action_console |
Glib::RefPtr< Gio::SimpleAction > | action_microtex |
Additional Inherited Members | |
Protected Types inherited from cadabra::DocumentThread | |
enum class | help_t { algorithm , property , latex , none } |
Help system. More... | |
typedef std::stack< std::shared_ptr< ActionBase > > | ActionStack |
NotebookWindow::NotebookWindow | ( | Cadabra * | c, |
bool | read_only = false |
||
) |
NotebookWindow::~NotebookWindow | ( | ) |
|
overridevirtual |
Add a GUI cell corresponding to the document cell at the iterator.
The GUI needs to figure out from the location of this cell in the DTree where to insert the cell in the visual display. If the 'visible' flag is false, hide the cell from view independent of whether its hidden flag is set (this is only used when constructing a document on load time and we do not want to show cells until they have all been added to the document).
Implements cadabra::GUIBase.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
void NotebookWindow::compare_git | ( | const std::string & | commit_hash | ) |
void NotebookWindow::compare_git_choose | ( | ) |
void NotebookWindow::compare_git_latest | ( | ) |
void NotebookWindow::compare_git_specific | ( | ) |
void NotebookWindow::compare_to_file | ( | ) |
|
private |
|
overridevirtual |
Retrieve the position of the cursor in the current cell.
Implements cadabra::GUIBase.
|
protected |
|
private |
Handle a TeX error which occurred on a threaded TeX run (activated by tex_run_async
) and is stored in tex_error_string
.
|
private |
|
private |
|
private |
void NotebookWindow::load_file | ( | const std::string & | notebook_contents | ) |
|
private |
|
private |
Clipboard handling.
|
overrideprotectedvirtual |
|
overridevirtual |
Network status is propagated from the ComputeThread to the GUI using the following methods.
These get called on the compute thread (as opposed to the functions above, which get called on the gui thread).
Implements cadabra::GUIBase.
|
private |
|
overrideprotectedvirtual |
|
overridevirtual |
Implements cadabra::GUIBase.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
void NotebookWindow::on_help_register | ( | ) |
|
private |
|
overridevirtual |
Reimplemented from cadabra::DocumentThread.
|
private |
|
overridevirtual |
Implements cadabra::GUIBase.
|
overrideprotectedvirtual |
|
overridevirtual |
Implements cadabra::GUIBase.
|
protected |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
bool NotebookWindow::on_scroll | ( | GdkEventScroll * | ) |
void NotebookWindow::on_scroll_size_allocate | ( | Gtk::Allocation & | ) |
|
private |
Search handling.
|
private |
|
private |
|
private |
|
private |
|
overrideprotectedvirtual |
Reimplemented from cadabra::DocumentThread.
|
private |
|
private |
bool NotebookWindow::on_vscroll_changed | ( | Gtk::ScrollType | , |
double | |||
) |
|
overridevirtual |
Position the cursor in the current canvas in the widget corresponding to the indicated cell.
Implements cadabra::GUIBase.
|
overridevirtual |
When the ComputeThread needs to modify the document, it stores an ActionBase object on the stack (see the DocumenThread class) and then wakes up the GUI thread signalling it to process this action.
The following member should wake up the GUI thread and make it enter the processing part.
Implements cadabra::GUIBase.
|
private |
Todo deque processing logic.
This gets called by the dispatcher, but it is also allowed to call this from within NotebookWindow itself. The important thing is that it is run on the GUI thread.
|
private |
|
private |
Refresh the display after a TeX engine run has completed.
The TeX engine is run on a different thread so as to not block the UI, and on completion triggers dispatcher_refresh
, which calls this function on the main thread.
void NotebookWindow::refresh_highlighting | ( | ) |
|
overridevirtual |
Remove all GUI cells from the display (used as a quick way to clear all before loading a new document).
Implements cadabra::GUIBase.
|
overridevirtual |
Remove a single cell together with all its child cells.
Some toolkits (e.g. Gtk) will take care of that entire child tree removal automatically, in which case the only thing that needs done for the child cells is to remove any reference to their VisualCells.
Implements cadabra::GUIBase.
std::string NotebookWindow::run_git_command | ( | const std::string & | args | ) |
|
private |
void NotebookWindow::scroll_cell_into_view | ( | DTree::iterator | cell | ) |
void NotebookWindow::scroll_current_cell_into_view | ( | ) |
void NotebookWindow::select_git_path | ( | ) |
Functionality for the diff viewer.
void NotebookWindow::select_range | ( | const DTree & | , |
DTree::iterator | it, | ||
int | start, | ||
int | len | ||
) |
|
overridevirtual |
Let the notebook know about the ComputeThread so that it can send cells for evaluation.
Notebook does NOT own this pointer.
Reimplemented from cadabra::DocumentThread.
void NotebookWindow::set_name | ( | const std::string & | n | ) |
|
overridevirtual |
Reimplemented from cadabra::DocumentThread.
void NotebookWindow::set_statusbar_message | ( | const std::string & | message = "" , |
int | line = -1 , |
||
int | col = -1 |
||
) |
|
private |
void NotebookWindow::set_title_prefix | ( | const std::string & | pf | ) |
|
private |
|
protected |
|
overridevirtual |
The basic manipulations that a GUI needs to implement are adding, removing and updating (refreshing the display of) a cell.
The code in DocumentThread will call these to make the GUI update its display. Called on the document thread.
Implements cadabra::GUIBase.
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
protected |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
double cadabra::NotebookWindow::display_scale |
|
private |
TeXEngine cadabra::NotebookWindow::engine |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
double cadabra::NotebookWindow::scale |
|
private |
|
private |
|
private |
|
private |
|
private |
|
protected |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |