4 #include <gtkmm/window.h>
5 #include <gtkmm/applicationwindow.h>
7 #include <gtkmm/progressbar.h>
8 #include <gtkmm/spinner.h>
9 #include <gtkmm/label.h>
10 #include <gtkmm/stock.h>
11 #include <gtkmm/button.h>
12 #include <gtkmm/builder.h>
13 #include <gtkmm/cssprovider.h>
14 #include <gtkmm/toolbar.h>
15 #include <glibmm/dispatcher.h>
16 #include <giomm/settings.h>
17 #include <giomm/actiongroup.h>
22 #include "nlohmann/json.hpp"
29 #include "../common/TeXEngine.hh"
48 virtual void add_cell(
const DTree&, DTree::iterator,
bool)
override;
97 void load_file(
const std::string& notebook_contents);
115 virtual void set_progress(
const std::string& msg,
int cur_step,
int total_steps)
override;
127 void on_outbox_copy(Glib::RefPtr<Gtk::Clipboard> refClipboard, DTree::iterator it);
259 std::string
save(
const std::string& fn)
const;
327 #if GTKMM_MINOR_VERSION>=10
328 std::vector<Gtk::Revealer *> to_reveal;
int quit(void *)
Definition: Server.cc:315
The Cadabra notebook application.
Definition: Cadabra.hh:11
Base class which talks to the server and sends Action objects back to the DocumentThread.
Definition: ComputeThread.hh:36
Definition: Console.hh:15
A base class with all the logic to manipulate a Cadabra notebook document.
Definition: DocumentThread.hh:40
ComputeThread * compute
Definition: DocumentThread.hh:129
Abstract base class with methods that need to be implemented by any GUI.
Definition: GUIBase.hh:16
Each notebook has one main window which controls it.
Definition: NotebookWindow.hh:41
void on_file_quit()
Definition: NotebookWindow.cc:2175
void on_view_split()
Definition: NotebookWindow.cc:2374
bool kernel_spinner_status
Definition: NotebookWindow.hh:176
virtual void process_data() override
When the ComputeThread needs to modify the document, it stores an ActionBase object on the stack (see...
Definition: NotebookWindow.cc:956
virtual void set_compute_thread(ComputeThread *compute) override
Let the notebook know about the ComputeThread so that it can send cells for evaluation.
Definition: NotebookWindow.cc:2484
bool cell_content_erase(int, int, DTree::iterator, int)
Definition: NotebookWindow.cc:1714
DTree::iterator current_cell
Definition: NotebookWindow.hh:122
void tex_run_async()
Definition: NotebookWindow.cc:1000
Gtk::HBox toolbar
Definition: NotebookWindow.hh:146
Gtk::VBox topbox
Definition: NotebookWindow.hh:145
std::unique_ptr< DiffViewer > diffviewer
Definition: NotebookWindow.hh:163
Gtk::Label kernel_label
Definition: NotebookWindow.hh:177
Gtk::HBox statusbarbox
Definition: NotebookWindow.hh:158
Glib::RefPtr< Gio::SimpleAction > action_fontsize
Definition: NotebookWindow.hh:323
virtual void set_progress(const std::string &msg, int cur_step, int total_steps) override
Definition: NotebookWindow.cc:1352
std::string progress_string
Definition: NotebookWindow.hh:184
void on_tools_options()
Definition: NotebookWindow.cc:2926
void on_file_export_html()
Definition: NotebookWindow.cc:2026
virtual void on_connect() override
Network status is propagated from the ComputeThread to the GUI using the following methods.
Definition: NotebookWindow.cc:962
std::recursive_mutex tex_need_width_mutex
Definition: NotebookWindow.hh:310
bool tex_running
Definition: NotebookWindow.hh:312
double display_scale
Definition: NotebookWindow.hh:67
Glib::RefPtr< Gtk::CssProvider > css_provider
Definition: NotebookWindow.hh:302
void on_edit_copy(const Glib::VariantBase &)
Definition: NotebookWindow.cc:2188
void compare_to_file()
Definition: NotebookWindow.cc:2620
void on_scroll_size_allocate(Gtk::Allocation &)
Definition: NotebookWindow.cc:1645
Glib::Dispatcher dispatch_update_status
Definition: NotebookWindow.hh:187
virtual bool on_configure_event(GdkEventConfigure *cfg) override
Definition: NotebookWindow.cc:872
void on_crash_window_closed(int)
Definition: NotebookWindow.cc:1102
void on_prefs_choose_colours()
Definition: NotebookWindow.cc:2903
int status_col
Definition: NotebookWindow.hh:186
bool cell_content_execute(DTree::iterator, int, bool shift_enter_pressed)
Definition: NotebookWindow.cc:1780
void on_run_cell()
Definition: NotebookWindow.cc:2395
void on_search_text_changed()
Search handling.
Definition: NotebookWindow.cc:2299
int tex_need_width
Definition: NotebookWindow.hh:313
int last_configure_width
Definition: NotebookWindow.hh:306
void select_range(const DTree &, DTree::iterator, int start, int len)
Definition: NotebookWindow.cc:1529
void process_todo_queue()
Todo deque processing logic.
Definition: NotebookWindow.cc:1053
virtual void remove_cell(const DTree &, DTree::iterator) override
Remove a single cell together with all its child cells.
Definition: NotebookWindow.cc:1385
double progress_frac
Definition: NotebookWindow.hh:185
virtual size_t get_cursor_position(const DTree &, DTree::iterator) override
Retrieve the position of the cursor in the current cell.
Definition: NotebookWindow.cc:1551
Gtk::Button tool_restart
Definition: NotebookWindow.hh:148
Glib::RefPtr< Gio::SimpleActionGroup > actiongroup
Definition: NotebookWindow.hh:142
void on_run_runall()
Definition: NotebookWindow.cc:2408
void compare_git_latest()
Definition: NotebookWindow.cc:2692
Glib::Dispatcher dispatcher
Definition: NotebookWindow.hh:138
virtual bool on_unhandled_error(const std::exception &err) override
Definition: NotebookWindow.cc:909
void interactive_execute()
Definition: NotebookWindow.cc:1754
void on_edit_find()
Definition: NotebookWindow.cc:2291
std::string kernel_string
Definition: NotebookWindow.hh:184
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...
Definition: NotebookWindow.cc:902
bool read_only
Definition: NotebookWindow.hh:198
DTree::iterator selected_cell
Definition: NotebookWindow.hh:125
void load_file(const std::string ¬ebook_contents)
Definition: NotebookWindow.cc:1914
Gtk::Button tool_run
Definition: NotebookWindow.hh:148
Glib::RefPtr< Gio::SimpleAction > action_paste
Definition: NotebookWindow.hh:323
Gtk::Label status_label
Definition: NotebookWindow.hh:177
void on_edit_paste()
Definition: NotebookWindow.cc:2200
Glib::RefPtr< Cadabra > cdbapp
Definition: NotebookWindow.hh:130
void on_file_export_python()
Definition: NotebookWindow.cc:2069
std::mutex status_mutex
Definition: NotebookWindow.hh:183
Gtk::Label top_label
Definition: NotebookWindow.hh:177
Gtk::SearchBar searchbar
Definition: NotebookWindow.hh:153
void refresh_highlighting()
Definition: NotebookWindow.cc:3032
std::string last_find_string
Definition: NotebookWindow.hh:317
Gtk::ProgressBar progressbar
Definition: NotebookWindow.hh:174
void on_view_close()
Definition: NotebookWindow.cc:2384
Gtk::CheckButton search_case_insensitive
Definition: NotebookWindow.hh:156
void on_help_about()
Definition: NotebookWindow.cc:2489
Gtk::Label search_result
Definition: NotebookWindow.hh:157
void on_edit_insert_below()
Definition: NotebookWindow.cc:2257
void on_edit_insert_above()
Definition: NotebookWindow.cc:2241
void on_prefs_use_defaults()
Definition: NotebookWindow.cc:2910
std::string run_git_command(const std::string &args)
Definition: NotebookWindow.cc:2647
void on_help() const
Definition: NotebookWindow.cc:2452
Glib::Dispatcher dispatch_tex_error
Definition: NotebookWindow.hh:187
void on_edit_split()
Definition: NotebookWindow.cc:2336
virtual bool on_key_press_event(GdkEventKey *) override
Definition: NotebookWindow.cc:1107
std::string clipboard_cdb
Definition: NotebookWindow.hh:256
void on_help_register()
Definition: NotebookWindow.cc:2520
void update_title()
Definition: NotebookWindow.cc:921
Gtk::Button tool_stop
Definition: NotebookWindow.hh:148
std::vector< Glib::RefPtr< Gio::SimpleAction > > default_actions
Definition: NotebookWindow.hh:132
std::unique_ptr< std::thread > tex_thread
Definition: NotebookWindow.hh:311
NotebookWindow(Cadabra *, bool read_only=false)
Definition: NotebookWindow.cc:40
void on_edit_delete()
Definition: NotebookWindow.cc:2273
bool is_configured
Definition: NotebookWindow.hh:319
void on_clipboard_get(Gtk::SelectionData &, guint info)
Clipboard handling.
Definition: NotebookWindow.cc:3121
Gtk::Paned dragbox
Definition: NotebookWindow.hh:150
std::string clipboard_txt
Definition: NotebookWindow.hh:256
void on_prefs_microtex(bool on)
Definition: NotebookWindow.cc:2871
void on_prefs_highlight_syntax(bool on)
Definition: NotebookWindow.cc:2839
void on_file_save_as_jupyter()
Definition: NotebookWindow.cc:1993
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.
Definition: NotebookWindow.cc:1504
Glib::RefPtr< Gio::SimpleAction > action_copy
Definition: NotebookWindow.hh:323
bool on_first_redraw()
Definition: NotebookWindow.cc:1927
void set_stop_sensitive(bool)
Definition: NotebookWindow.cc:948
void on_clipboard_clear()
Definition: NotebookWindow.cc:3134
void unselect_output_cell()
Definition: NotebookWindow.cc:3051
std::string tex_error_string
Definition: NotebookWindow.hh:314
void scroll_cell_into_view(DTree::iterator cell)
Definition: NotebookWindow.cc:1570
void on_file_export_latex()
Definition: NotebookWindow.cc:2046
void on_run_stop()
Definition: NotebookWindow.cc:2432
double scale
Definition: NotebookWindow.hh:66
void on_prefs_font_size(int num)
Definition: NotebookWindow.cc:2806
std::pair< DTree::iterator, size_t > last_find_location
Definition: NotebookWindow.hh:316
void select_git_path()
Functionality for the diff viewer.
Definition: NotebookWindow.cc:2610
void on_text_scaling_factor_changed(const std::string &key)
Definition: NotebookWindow.cc:2588
bool crash_window_hidden
Definition: NotebookWindow.hh:277
std::vector< NotebookCanvas * > canvasses
Definition: NotebookWindow.hh:167
virtual void on_disconnect(const std::string &) override
Definition: NotebookWindow.cc:979
bool cell_complete_request(DTree::iterator it, int pos, int i)
Definition: NotebookWindow.cc:1761
void on_ignore_cell_on_import()
Definition: NotebookWindow.cc:2354
bool on_vscroll_changed(Gtk::ScrollType, double)
Definition: NotebookWindow.cc:1621
void on_edit_undo()
Definition: NotebookWindow.cc:2183
virtual void on_interactive_output(const nlohmann::json &msg) override
Definition: NotebookWindow.cc:1347
void on_file_new()
Definition: NotebookWindow.cc:1848
void refresh_after_tex_engine_run()
Refresh the display after a TeX engine run has completed.
Definition: NotebookWindow.cc:896
bool quit_safeguard(bool quit)
Definition: NotebookWindow.cc:2137
virtual void on_network_error() override
Definition: NotebookWindow.cc:986
void on_outbox_copy(Glib::RefPtr< Gtk::Clipboard > refClipboard, DTree::iterator it)
Definition: NotebookWindow.cc:3091
virtual bool on_delete_event(GdkEventAny *) override
Definition: NotebookWindow.cc:819
TeXEngine engine
Definition: NotebookWindow.hh:65
void on_edit_cell_is_python()
Definition: NotebookWindow.cc:2343
Glib::RefPtr< Gio::SimpleAction > action_console
Definition: NotebookWindow.hh:324
void dim_output_cells(DTree::iterator it)
Definition: NotebookWindow.cc:1727
std::string save(const std::string &fn) const
Definition: NotebookWindow.cc:2112
void on_kernel_restart()
Definition: NotebookWindow.cc:2437
void on_prefs_set_cv(int vis)
Definition: NotebookWindow.cc:829
Glib::RefPtr< Gtk::Builder > uimanager
Definition: NotebookWindow.hh:143
void on_file_save()
Definition: NotebookWindow.cc:1933
void scroll_current_cell_into_view()
Definition: NotebookWindow.cc:1564
Gtk::Button tool_save_as
Definition: NotebookWindow.hh:147
void on_run_runtocursor()
Definition: NotebookWindow.cc:2420
Gtk::HBox supermainbox
Definition: NotebookWindow.hh:149
Gtk::Button tool_run_to
Definition: NotebookWindow.hh:148
void on_file_save_as()
Definition: NotebookWindow.cc:1956
bool idle_handler()
Definition: NotebookWindow.cc:3040
Gtk::Button tool_save
Definition: NotebookWindow.hh:147
void compare_git_choose()
Definition: NotebookWindow.cc:2724
Gtk::VBox mainbox
Definition: NotebookWindow.hh:151
void set_title_prefix(const std::string &)
Definition: NotebookWindow.cc:916
bool cell_got_focus(DTree::iterator, int)
Definition: NotebookWindow.cc:1744
bool on_tex_error(const std::string &, DTree::iterator)
Definition: NotebookWindow.cc:1820
Gtk::SearchEntry searchentry
Definition: NotebookWindow.hh:155
bool modified
Definition: NotebookWindow.hh:198
void update_status()
Definition: NotebookWindow.cc:1368
Gtk::Dialog console_win
Definition: NotebookWindow.hh:161
void on_edit_cell_is_latex()
Definition: NotebookWindow.cc:2363
bool cell_toggle_visibility(DTree::iterator it, int)
Definition: NotebookWindow.cc:1662
Glib::RefPtr< Gio::SimpleAction > action_highlight
Definition: NotebookWindow.hh:323
Console console
Definition: NotebookWindow.hh:160
int status_line
Definition: NotebookWindow.hh:186
Glib::RefPtr< Gio::SimpleAction > action_stop
Definition: NotebookWindow.hh:324
void on_tools_clear_cache()
Definition: NotebookWindow.cc:3014
void compare_git_specific()
Definition: NotebookWindow.cc:2779
bool handle_outbox_select(GdkEventButton *, DTree::iterator it)
Definition: NotebookWindow.cc:3066
virtual void update_cell(const DTree &, DTree::iterator) override
The basic manipulations that a GUI needs to implement are adding, removing and updating (refreshing t...
Definition: NotebookWindow.cc:1474
std::string name
Definition: NotebookWindow.hh:197
Gtk::HBox search_hbox
Definition: NotebookWindow.hh:154
void set_statusbar_message(const std::string &message="", int line=-1, int col=-1)
Definition: NotebookWindow.cc:937
virtual void add_cell(const DTree &, DTree::iterator, bool) override
Add a GUI cell corresponding to the document cell at the iterator.
Definition: NotebookWindow.cc:1165
bool cell_content_changed(DTree::iterator it, int i)
Definition: NotebookWindow.cc:1690
~NotebookWindow()
Definition: NotebookWindow.cc:745
bool on_scroll(GdkEventScroll *)
Definition: NotebookWindow.cc:1636
Glib::RefPtr< Gio::SimpleAction > action_microtex
Definition: NotebookWindow.hh:324
Gtk::Button tool_open
Definition: NotebookWindow.hh:147
void compare_git(const std::string &commit_hash)
Definition: NotebookWindow.cc:2674
void on_file_open()
Definition: NotebookWindow.cc:1875
std::string status_string
Definition: NotebookWindow.hh:184
virtual void on_kernel_runstatus(bool) override
Definition: NotebookWindow.cc:993
void on_file_export_html_segment()
Definition: NotebookWindow.cc:2089
Glib::Dispatcher dispatch_refresh
Definition: NotebookWindow.hh:187
DTree::iterator follow_cell
Definition: NotebookWindow.hh:307
Gtk::Spinner kernel_spinner
Definition: NotebookWindow.hh:175
Glib::RefPtr< Gio::Settings > settings
Definition: NotebookWindow.hh:303
void on_file_close()
Definition: NotebookWindow.cc:1861
bool cell_content_insert(const std::string &, int, DTree::iterator, int)
Definition: NotebookWindow.cc:1701
void load_css()
Definition: NotebookWindow.cc:749
int current_canvas
Definition: NotebookWindow.hh:168
std::string title_prefix
Definition: NotebookWindow.hh:197
void set_name(const std::string &)
Definition: NotebookWindow.cc:1908
Glib::RefPtr< Gio::SimpleAction > action_register
Definition: NotebookWindow.hh:324
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...
Definition: NotebookWindow.cc:1464
TeXEngine is used to convert LaTeX strings into PNG images.
Definition: TeXEngine.hh:23
Functions to handle the exchange properties of two or more symbols in a product.
Definition: Adjform.cc:83
tree< DataCell > DTree
Definition: DataCell.hh:109
start
Definition: nevaluate.py:20
const char info[]
Definition: Snoop.hh:336