diff --git a/src/notebook.cc b/src/notebook.cc index 41aa214..24ad15e 100644 --- a/src/notebook.cc +++ b/src/notebook.cc @@ -87,6 +87,11 @@ void Notebook::open(std::string path) { if(page!=-1) set_tab_label_text(*(get_nth_page(page)), title); }); + + get_current_view()->on_update_status=[this](Source::View* view, const std::string &status) { + if(get_current_view()==view) + Singleton::status()->set_text(status); + }; } bool Notebook::save(int page) { diff --git a/src/singletons.cc b/src/singletons.cc index 17f4b37..076bf46 100644 --- a/src/singletons.cc +++ b/src/singletons.cc @@ -10,3 +10,9 @@ Terminal *Singleton::terminal() { terminal_=std::unique_ptr(new Terminal()); return terminal_.get(); } +std::unique_ptr Singleton::status_=std::unique_ptr(); +Gtk::Label *Singleton::status() { + if(!status_) + status_=std::unique_ptr(new Gtk::Label()); + return status_.get(); +} diff --git a/src/singletons.h b/src/singletons.h index 2652d99..d305e85 100644 --- a/src/singletons.h +++ b/src/singletons.h @@ -6,6 +6,7 @@ #include "terminal.h" #include "notebook.h" #include "menu.h" +#include #include class Singleton { @@ -23,8 +24,10 @@ public: static std::string config_dir() { return std::string(getenv("HOME")) + "/.juci/config/"; } static std::string log_dir() { return std::string(getenv("HOME")) + "/.juci/log/"; } static Terminal *terminal(); + static Gtk::Label *status(); private: static std::unique_ptr terminal_; + static std::unique_ptr status_; }; #endif // JUCI_SINGLETONS_H_ diff --git a/src/source.cc b/src/source.cc index 6771c28..fe7f71c 100644 --- a/src/source.cc +++ b/src/source.cc @@ -134,6 +134,12 @@ void Source::View::replace_all(const std::string &replacement) { gtk_source_search_context_replace_all(search_context, replacement.c_str(), replacement.size(), NULL); } +void Source::View::set_status(const std::string &status) { + this->status=status; + if(on_update_status) + on_update_status(this, status); +} + string Source::View::get_line(size_t line_number) { Gtk::TextIter line_it = get_source_buffer()->get_iter_at_line(line_number); Gtk::TextIter line_end_it = line_it; @@ -343,6 +349,7 @@ parse_thread_go(true), parse_thread_mapped(false), parse_thread_stop(false) { update_diagnostics(); update_types(); clang_readable=true; + set_status(""); parsing_mutex.unlock(); INFO("Syntax updated"); } @@ -353,6 +360,7 @@ parse_thread_go(true), parse_thread_mapped(false), parse_thread_stop(false) { } }); + set_status("parsing..."); parse_thread=std::thread([this]() { while(true) { while(!parse_thread_go && !parse_thread_stop) @@ -418,6 +426,7 @@ void Source::ClangViewParse::start_reparse() { delayed_reparse_connection=Glib::signal_timeout().connect([this]() { clang_readable=false; parse_thread_go=true; + set_status("parsing..."); return false; }, 1000); } @@ -838,14 +847,17 @@ void Source::ClangViewAutocomplete::autocomplete() { completion_dialog->add_row(ss.str() + " --> " + return_value, data.brief_comments); } } + set_status(""); if (!rows->empty()) { completion_dialog_shown=true; get_source_buffer()->begin_user_action(); completion_dialog->show(); } } - else + else { + set_status(""); start_autocomplete(); + } }); std::shared_ptr > buffer_map=std::make_shared >(); @@ -859,6 +871,7 @@ void Source::ClangViewAutocomplete::autocomplete() { column_nr--; } buffer+="\n"; + set_status("autocomplete..."); std::thread autocomplete_thread([this, ac_data, line_nr, column_nr, buffer_map](){ parsing_mutex.lock(); *ac_data=move(get_autocomplete_suggestions(line_nr, column_nr, *buffer_map)); diff --git a/src/source.h b/src/source.h index d695093..c874520 100644 --- a/src/source.h +++ b/src/source.h @@ -56,10 +56,7 @@ namespace Source { void replace_forward(const std::string &replacement); void replace_backward(const std::string &replacement); void replace_all(const std::string &replacement); - - std::string get_line(size_t line_number); - std::string get_line_before_insert(); - + std::string file_path; std::string project_path; @@ -69,7 +66,15 @@ namespace Source { std::function get_token_name; std::function tag_similar_tokens; std::function rename_similar_tokens; + + std::function on_update_status; + std::string status; protected: + void set_status(const std::string &status); + + std::string get_line(size_t line_number); + std::string get_line_before_insert(); + bool on_key_press_event(GdkEventKey* key); private: GtkSourceSearchContext *search_context; diff --git a/src/window.cc b/src/window.cc index 2e81910..70c487c 100644 --- a/src/window.cc +++ b/src/window.cc @@ -26,10 +26,14 @@ Window::Window() : box(Gtk::ORIENTATION_VERTICAL) { directory_and_notebook_panes.pack1(directories, true, true); directory_and_notebook_panes.pack2(notebook); directory_and_notebook_panes.set_position(120); - vpaned.set_position(300); vpaned.pack1(directory_and_notebook_panes, true, false); - vpaned.pack2(*Singleton::terminal(), true, true); + + terminal_vbox.pack_start(*Singleton::terminal()); + status_hbox.pack_end(*Singleton::status(), Gtk::PACK_SHRINK); + terminal_vbox.pack_end(status_hbox, Gtk::PACK_SHRINK); + vpaned.pack2(terminal_vbox, true, true); + box.pack_end(vpaned); show_all_children(); @@ -70,6 +74,8 @@ Window::Window() : box(Gtk::ORIENTATION_VERTICAL) { menu_item->set_sensitive((bool)notebook.get_current_view()->rename_similar_tokens); directories.select_path(notebook.get_current_view()->file_path); + + Singleton::status()->set_text(notebook.get_current_view()->status); } }); INFO("Window created"); diff --git a/src/window.h b/src/window.h index b257fc3..992d2be 100644 --- a/src/window.h +++ b/src/window.h @@ -1,7 +1,7 @@ #ifndef JUCI_WINDOW_H_ #define JUCI_WINDOW_H_ -#include +#include "gtkmm.h" #include "directories.h" #include "entrybox.h" #include "notebook.h" @@ -19,6 +19,8 @@ private: Gtk::Box box; Gtk::VPaned vpaned; Gtk::Paned directory_and_notebook_panes; + Gtk::VBox terminal_vbox; + Gtk::HBox status_hbox; EntryBox entry_box; std::mutex running; Menu menu;