Cadabra
Computer algebra system for field theory problems
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
cadabra::NotebookWindow Class Reference

Description

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>

Inheritance diagram for cadabra::NotebookWindow:
cadabra::DocumentThread cadabra::GUIBase

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...
 
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 set_name (const std::string &)
 
void set_title_prefix (const std::string &)
 
void load_file (const std::string &notebook_contents)
 
void refresh_highlighting ()
 
void on_help_register ()
 
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 Json::Value &msg) 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...
 
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 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
 
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
GUIBasegui
 
ComputeThreadcompute
 
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_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_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)
 
void on_edit_undo ()
 
void on_edit_copy ()
 
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_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 (int on)
 
void on_prefs_choose_colours ()
 
void on_prefs_use_defaults ()
 
void on_help_about ()
 
void on_help () const
 
void on_kernel_restart ()
 
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 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)
 
void interactive_execute ()
 
void dim_output_cells (DTree::iterator it)
 
bool on_tex_error (const std::string &, DTree::iterator)
 
void load_css (const std::string &)
 
void on_text_scaling_factor_changed (const std::string &key)
 
bool idle_handler ()
 

Private Attributes

Cadabracdbapp
 
std::vector< Glib::RefPtr< Gtk::Action > > default_actions
 
Glib::Dispatcher dispatcher
 
Glib::RefPtr< Gtk::ActionGroup > actiongroup
 
Glib::RefPtr< Gtk::UIManager > uimanager
 
Gtk::VBox topbox
 
Gtk::HBox supermainbox
 
Gtk::VBox mainbox
 
Gtk::HBox statusbarbox
 
Console console
 
Gtk::Dialog console_win
 
std::unique_ptr< DiffViewerdiffviewer
 
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
 
std::mutex status_mutex
 
std::string status_string
 
std::string kernel_string
 
std::string name
 
std::string title_prefix
 
bool modified
 
bool read_only
 
Glib::RefPtr< Gtk::Action > action_copy
 
Glib::RefPtr< Gtk::Action > action_paste
 
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
 
bool is_configured
 
Glib::RefPtr< Gtk::Action > menu_help_register
 

Additional Inherited Members

- Protected Types inherited from cadabra::DocumentThread
enum  help_t { help_t::algorithm, help_t::property, help_t::latex, help_t::none }
 Help system. More...
 
typedef std::stack< std::shared_ptr< ActionBase > > ActionStack
 

Constructor & Destructor Documentation

◆ NotebookWindow()

NotebookWindow::NotebookWindow ( Cadabra c,
bool  read_only = false 
)

◆ ~NotebookWindow()

NotebookWindow::~NotebookWindow ( )

Member Function Documentation

◆ add_cell()

void NotebookWindow::add_cell ( const DTree ,
DTree::iterator  ,
bool  visible 
)
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.

◆ cell_content_changed()

bool NotebookWindow::cell_content_changed ( DTree::iterator  it,
int  i 
)
private

◆ cell_content_erase()

bool NotebookWindow::cell_content_erase ( int  start,
int  end,
DTree::iterator  it,
int   
)
private

◆ cell_content_execute()

bool NotebookWindow::cell_content_execute ( DTree::iterator  it,
int  canvas_number,
bool  shift_enter_pressed 
)
private

◆ cell_content_insert()

bool NotebookWindow::cell_content_insert ( const std::string &  content,
int  pos,
DTree::iterator  it,
int   
)
private

◆ cell_got_focus()

bool NotebookWindow::cell_got_focus ( DTree::iterator  it,
int  canvas_number 
)
private

◆ cell_toggle_visibility()

bool NotebookWindow::cell_toggle_visibility ( DTree::iterator  it,
int   
)
private

◆ compare_git()

void NotebookWindow::compare_git ( const std::string &  commit_hash)

◆ compare_git_choose()

void NotebookWindow::compare_git_choose ( )

◆ compare_git_latest()

void NotebookWindow::compare_git_latest ( )

◆ compare_git_specific()

void NotebookWindow::compare_git_specific ( )

◆ compare_to_file()

void NotebookWindow::compare_to_file ( )

◆ dim_output_cells()

void NotebookWindow::dim_output_cells ( DTree::iterator  it)
private

◆ get_cursor_position()

size_t NotebookWindow::get_cursor_position ( const DTree ,
DTree::iterator   
)
overridevirtual

Retrieve the position of the cursor in the current cell.

Implements cadabra::GUIBase.

◆ handle_outbox_select()

bool NotebookWindow::handle_outbox_select ( GdkEventButton *  ,
DTree::iterator  it 
)
protected

◆ idle_handler()

bool NotebookWindow::idle_handler ( )
private

◆ interactive_execute()

void NotebookWindow::interactive_execute ( )
private

◆ load_css()

void NotebookWindow::load_css ( const std::string &  text_colour)
private

◆ load_file()

void NotebookWindow::load_file ( const std::string &  notebook_contents)

◆ on_clipboard_clear()

void NotebookWindow::on_clipboard_clear ( )
private

◆ on_clipboard_get()

void NotebookWindow::on_clipboard_get ( Gtk::SelectionData &  selection_data,
guint  info 
)
private

Clipboard handling.

◆ on_configure_event()

bool NotebookWindow::on_configure_event ( GdkEventConfigure *  cfg)
overrideprotectedvirtual

◆ on_connect()

void NotebookWindow::on_connect ( )
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.

◆ on_crash_window_closed()

void NotebookWindow::on_crash_window_closed ( int  )
private

◆ on_delete_event()

bool NotebookWindow::on_delete_event ( GdkEventAny *  event)
overrideprotectedvirtual

◆ on_disconnect()

void NotebookWindow::on_disconnect ( const std::string &  reason)
overridevirtual

Implements cadabra::GUIBase.

◆ on_edit_cell_is_latex()

void NotebookWindow::on_edit_cell_is_latex ( )
private

◆ on_edit_cell_is_python()

void NotebookWindow::on_edit_cell_is_python ( )
private

◆ on_edit_copy()

void NotebookWindow::on_edit_copy ( )
private

◆ on_edit_delete()

void NotebookWindow::on_edit_delete ( )
private

◆ on_edit_insert_above()

void NotebookWindow::on_edit_insert_above ( )
private

◆ on_edit_insert_below()

void NotebookWindow::on_edit_insert_below ( )
private

◆ on_edit_paste()

void NotebookWindow::on_edit_paste ( )
private

◆ on_edit_split()

void NotebookWindow::on_edit_split ( )
private

◆ on_edit_undo()

void NotebookWindow::on_edit_undo ( )
private

◆ on_file_close()

void NotebookWindow::on_file_close ( )
private

◆ on_file_export_html()

void NotebookWindow::on_file_export_html ( )
private

◆ on_file_export_html_segment()

void NotebookWindow::on_file_export_html_segment ( )
private

◆ on_file_export_latex()

void NotebookWindow::on_file_export_latex ( )
private

◆ on_file_export_python()

void NotebookWindow::on_file_export_python ( )
private

◆ on_file_new()

void NotebookWindow::on_file_new ( )
private

◆ on_file_open()

void NotebookWindow::on_file_open ( )
private

◆ on_file_quit()

void NotebookWindow::on_file_quit ( )
private

◆ on_file_save()

void NotebookWindow::on_file_save ( )
private

◆ on_file_save_as()

void NotebookWindow::on_file_save_as ( )
private

◆ on_help()

void NotebookWindow::on_help ( ) const
private

◆ on_help_about()

void NotebookWindow::on_help_about ( )
private

◆ on_help_register()

void NotebookWindow::on_help_register ( )

◆ on_interactive_output()

void NotebookWindow::on_interactive_output ( const Json::Value &  msg)
overridevirtual

Reimplemented from cadabra::DocumentThread.

◆ on_kernel_restart()

void NotebookWindow::on_kernel_restart ( )
private

◆ on_kernel_runstatus()

void NotebookWindow::on_kernel_runstatus ( bool  running)
overridevirtual

Implements cadabra::GUIBase.

◆ on_key_press_event()

bool NotebookWindow::on_key_press_event ( GdkEventKey *  event)
overrideprotectedvirtual

◆ on_network_error()

void NotebookWindow::on_network_error ( )
overridevirtual

Implements cadabra::GUIBase.

◆ on_outbox_copy()

void NotebookWindow::on_outbox_copy ( Glib::RefPtr< Gtk::Clipboard >  refClipboard,
DTree::iterator  it 
)
protected

◆ on_prefs_choose_colours()

void NotebookWindow::on_prefs_choose_colours ( )
private

◆ on_prefs_font_size()

void NotebookWindow::on_prefs_font_size ( int  num)
private

◆ on_prefs_highlight_syntax()

void NotebookWindow::on_prefs_highlight_syntax ( int  on)
private

◆ on_prefs_set_cv()

void NotebookWindow::on_prefs_set_cv ( int  vis)
private

◆ on_prefs_use_defaults()

void NotebookWindow::on_prefs_use_defaults ( )
private

◆ on_run_cell()

void NotebookWindow::on_run_cell ( )
private

◆ on_run_runall()

void NotebookWindow::on_run_runall ( )
private

◆ on_run_runtocursor()

void NotebookWindow::on_run_runtocursor ( )
private

◆ on_run_stop()

void NotebookWindow::on_run_stop ( )
private

◆ on_scroll()

bool NotebookWindow::on_scroll ( GdkEventScroll *  )

◆ on_scroll_size_allocate()

void NotebookWindow::on_scroll_size_allocate ( Gtk::Allocation &  )

◆ on_tex_error()

bool NotebookWindow::on_tex_error ( const std::string &  str,
DTree::iterator   
)
private

◆ on_text_scaling_factor_changed()

void NotebookWindow::on_text_scaling_factor_changed ( const std::string &  key)
private

◆ on_view_close()

void NotebookWindow::on_view_close ( )
private

◆ on_view_split()

void NotebookWindow::on_view_split ( )
private

◆ on_vscroll_changed()

bool NotebookWindow::on_vscroll_changed ( Gtk::ScrollType  ,
double   
)

◆ position_cursor()

void NotebookWindow::position_cursor ( const DTree ,
DTree::iterator  ,
int   
)
overridevirtual

Position the cursor in the current canvas in the widget corresponding to the indicated cell.

Implements cadabra::GUIBase.

◆ process_data()

void NotebookWindow::process_data ( )
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.

◆ process_todo_queue()

void NotebookWindow::process_todo_queue ( )
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.

◆ quit_safeguard()

bool NotebookWindow::quit_safeguard ( bool  quit)
private

◆ refresh_highlighting()

void NotebookWindow::refresh_highlighting ( )

◆ remove_all_cells()

void NotebookWindow::remove_all_cells ( )
overridevirtual

Remove all GUI cells from the display (used as a quick way to clear all before loading a new document).

Implements cadabra::GUIBase.

◆ remove_cell()

void NotebookWindow::remove_cell ( const DTree ,
DTree::iterator   
)
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.

◆ run_git_command()

std::string NotebookWindow::run_git_command ( const std::string &  args)

◆ save()

std::string NotebookWindow::save ( const std::string &  fn) const
private

◆ scroll_current_cell_into_view()

void NotebookWindow::scroll_current_cell_into_view ( )

◆ select_git_path()

void NotebookWindow::select_git_path ( )

Functionality for the diff viewer.

◆ set_compute_thread()

void NotebookWindow::set_compute_thread ( ComputeThread cl)
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.

◆ set_name()

void NotebookWindow::set_name ( const std::string &  n)

◆ set_stop_sensitive()

void NotebookWindow::set_stop_sensitive ( bool  s)
private

◆ set_title_prefix()

void NotebookWindow::set_title_prefix ( const std::string &  pf)

◆ unselect_output_cell()

void NotebookWindow::unselect_output_cell ( )
protected

◆ update_cell()

void NotebookWindow::update_cell ( const DTree ,
DTree::iterator   
)
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.

◆ update_title()

void NotebookWindow::update_title ( )
private

Member Data Documentation

◆ action_copy

Glib::RefPtr<Gtk::Action> cadabra::NotebookWindow::action_copy
private

◆ action_paste

Glib::RefPtr<Gtk::Action> cadabra::NotebookWindow::action_paste
private

◆ actiongroup

Glib::RefPtr<Gtk::ActionGroup> cadabra::NotebookWindow::actiongroup
private

◆ canvasses

std::vector<NotebookCanvas *> cadabra::NotebookWindow::canvasses
private

◆ cdbapp

Cadabra* cadabra::NotebookWindow::cdbapp
private

◆ clipboard_cdb

std::string cadabra::NotebookWindow::clipboard_cdb
private

◆ clipboard_txt

std::string cadabra::NotebookWindow::clipboard_txt
private

◆ console

Console cadabra::NotebookWindow::console
private

◆ console_win

Gtk::Dialog cadabra::NotebookWindow::console_win
private

◆ crash_window_hidden

bool cadabra::NotebookWindow::crash_window_hidden
private

◆ css_provider

Glib::RefPtr<Gtk::CssProvider> cadabra::NotebookWindow::css_provider
private

◆ current_canvas

int cadabra::NotebookWindow::current_canvas
private

◆ current_cell

DTree::iterator cadabra::NotebookWindow::current_cell
protected

◆ default_actions

std::vector<Glib::RefPtr<Gtk::Action> > cadabra::NotebookWindow::default_actions
private

◆ diffviewer

std::unique_ptr<DiffViewer> cadabra::NotebookWindow::diffviewer
private

◆ dispatcher

Glib::Dispatcher cadabra::NotebookWindow::dispatcher
private

◆ display_scale

double cadabra::NotebookWindow::display_scale

◆ engine

TeXEngine cadabra::NotebookWindow::engine

◆ follow_cell

DTree::iterator cadabra::NotebookWindow::follow_cell
private

◆ is_configured

bool cadabra::NotebookWindow::is_configured
private

◆ kernel_label

Gtk::Label cadabra::NotebookWindow::kernel_label
private

◆ kernel_spinner

Gtk::Spinner cadabra::NotebookWindow::kernel_spinner
private

◆ kernel_spinner_status

bool cadabra::NotebookWindow::kernel_spinner_status
private

◆ kernel_string

std::string cadabra::NotebookWindow::kernel_string
private

◆ last_configure_width

int cadabra::NotebookWindow::last_configure_width
private

◆ mainbox

Gtk::VBox cadabra::NotebookWindow::mainbox
private

◆ menu_help_register

Glib::RefPtr<Gtk::Action> cadabra::NotebookWindow::menu_help_register
private

◆ modified

bool cadabra::NotebookWindow::modified
private

◆ name

std::string cadabra::NotebookWindow::name
private

◆ progressbar

Gtk::ProgressBar cadabra::NotebookWindow::progressbar
private

◆ read_only

bool cadabra::NotebookWindow::read_only
private

◆ scale

double cadabra::NotebookWindow::scale

◆ selected_cell

DTree::iterator cadabra::NotebookWindow::selected_cell
protected

◆ settings

Glib::RefPtr<Gio::Settings> cadabra::NotebookWindow::settings
private

◆ status_label

Gtk::Label cadabra::NotebookWindow::status_label
private

◆ status_mutex

std::mutex cadabra::NotebookWindow::status_mutex
private

◆ status_string

std::string cadabra::NotebookWindow::status_string
private

◆ statusbarbox

Gtk::HBox cadabra::NotebookWindow::statusbarbox
private

◆ supermainbox

Gtk::HBox cadabra::NotebookWindow::supermainbox
private

◆ title_prefix

std::string cadabra::NotebookWindow::title_prefix
private

◆ topbox

Gtk::VBox cadabra::NotebookWindow::topbox
private

◆ uimanager

Glib::RefPtr<Gtk::UIManager> cadabra::NotebookWindow::uimanager
private

The documentation for this class was generated from the following files: