#pragma once #include #include "gtkmm.h" #include "source.h" #include #include #include class Notebook : public Gtk::Paned { class TabLabel : public Gtk::EventBox { public: TabLabel(std::function on_close); Gtk::Label label; }; class CursorLocation { public: CursorLocation(Source::View *view, Glib::RefPtr mark) : view(view), mark(mark) {} Source::View *view; Glib::RefPtr mark; }; private: Notebook(); public: static Notebook &get() { static Notebook singleton; return singleton; } size_t size(); Source::View* get_view(size_t index); Source::View* get_current_view(); std::vector &get_views(); void open(const boost::filesystem::path &file_path, size_t notebook_index=-1); void configure(size_t index); bool save(size_t index); bool save_current(); bool close(size_t index); bool close_current(); void next(); void previous(); void toggle_split(); /// Hide/Show tabs. void toggle_tabs(); boost::filesystem::path get_current_folder(); std::vector> get_notebook_views(); Gtk::Label status_location; Gtk::Label status_file_path; Gtk::Label status_branch; Gtk::Label status_diagnostics; Gtk::Label status_state; void update_status(Source::BaseView *view); void clear_status(); std::function on_change_page; std::function on_close_page; /// Cursor history std::vector cursor_locations; size_t current_cursor_location=-1; bool disable_next_update_cursor_locations=false; void delete_cursor_locations(Source::View *view); private: size_t get_index(Source::View *view); Source::View *get_view(size_t notebook_index, int page); void focus_view(Source::View *view); std::pair get_notebook_page(size_t index); std::vector notebooks; std::vector source_views; //Is NOT freed in destructor, this is intended for quick program exit. std::vector > source_maps; std::vector > scrolled_windows; std::vector > hboxes; std::vector > tab_labels; bool split=false; size_t last_index=-1; void set_current_view(Source::View *view); Source::View* current_view=nullptr; Source::View* intermediate_view=nullptr; bool save_modified_dialog(size_t index); };