From 50adce1c4a63a530bf987b0a5f96bb5d50e5a6da Mon Sep 17 00:00:00 2001 From: Shivang Gangadia Date: Sat, 21 Sep 2024 15:26:09 +0100 Subject: [PATCH 1/2] Added support for configuration of space between lines in editor. Updated IsClangType to use a set. --- src/config.cpp | 2 ++ src/config.hpp | 1 + src/notebook.cpp | 14 +++++++++++++- src/source_base.cpp | 2 ++ src/source_base.hpp | 4 ++++ src/source_clang.hpp | 3 +++ src/window.cpp | 8 ++++++-- 7 files changed, 31 insertions(+), 3 deletions(-) diff --git a/src/config.cpp b/src/config.cpp index e002d33..4484be9 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -134,6 +134,7 @@ void Config::read(const JSON &cfg) { source.smart_brackets = true; source.show_map = source_json.boolean("show_map", JSON::ParseOptions::accept_string); source.map_font_size = source_json.integer("map_font_size", JSON::ParseOptions::accept_string); + source.space_between_lines = source_json.integer("space_between_lines", JSON::ParseOptions::accept_string); source.show_git_diff = source_json.boolean("show_git_diff", JSON::ParseOptions::accept_string); source.show_background_pattern = source_json.boolean("show_background_pattern", JSON::ParseOptions::accept_string); source.show_right_margin = source_json.boolean("show_right_margin", JSON::ParseOptions::accept_string); @@ -279,6 +280,7 @@ std::string Config::default_config() { "smart_inserts": true, "show_map": true, "map_font_size": 1, + "space_between_lines": 1, "show_git_diff": true, "show_background_pattern": true, "show_right_margin": false, diff --git a/src/config.hpp b/src/config.hpp index 73389f6..22e0115 100644 --- a/src/config.hpp +++ b/src/config.hpp @@ -80,6 +80,7 @@ public: bool smart_inserts; bool show_map; + float space_between_lines; unsigned map_font_size; bool show_git_diff; bool show_background_pattern; diff --git a/src/notebook.cpp b/src/notebook.cpp index fdd04d4..4389782 100644 --- a/src/notebook.cpp +++ b/src/notebook.cpp @@ -307,6 +307,14 @@ bool Notebook::open(const boost::filesystem::path &file_path_, Position position Terminal::get().print("For installation instructions please visit: https://gitlab.com/cppit/jucipp/-/blob/master/docs/language_servers.md#julia.\n"); shown.emplace(language_id); } +<<<<<<< HEAD +======= + else if(Source::IsClangType(language_id)) { + Terminal::get().print("\e[33mWarning\e[m: could not find ClangD language server for C/C++.\n"); + Terminal::get().print("For installation instructions please visit: https://gitlab.com/cppit/jucipp/-/blob/master/docs/language_servers.md#julia.\n"); + shown.emplace(language_id); + } +>>>>>>> e7c897b (Added support for configuration of space between lines in editor. Updated IsClangType to use a set.) } } source_views.emplace_back(new Source::GenericView(file_path, language)); @@ -541,7 +549,11 @@ bool Notebook::open(const boost::filesystem::path &file_path_, Position position }); #ifdef JUCI_ENABLE_DEBUG +<<<<<<< HEAD if(dynamic_cast(view) || view->language_id == "rust") { +======= + if(Source::IsClangType(view->language_id) || view->language_id == "rust") { +>>>>>>> e7c897b (Added support for configuration of space between lines in editor. Updated IsClangType to use a set.) view->toggle_breakpoint = [view](int line_nr) { if(view->get_source_buffer()->get_source_marks_at_line(line_nr, "debug_breakpoint").size() > 0) { auto start_iter = view->get_buffer()->get_iter_at_line(line_nr); @@ -858,7 +870,7 @@ void Notebook::update_status(Source::BaseView *view) { if(view->update_status_diagnostics) view->update_status_diagnostics(view); if(view->update_status_state) - view->update_status_state(view); + view->update_status_state(view); } void Notebook::clear_status() { diff --git a/src/source_base.cpp b/src/source_base.cpp index 0c152d4..00fb8be 100644 --- a/src/source_base.cpp +++ b/src/source_base.cpp @@ -383,6 +383,8 @@ Source::BaseView::BaseView(const boost::filesystem::path &file_path, const Glib: extra_cursor_selection = get_buffer()->create_tag(); + this->set_pixels_below_lines(Config::get().source.space_between_lines); + get_buffer()->signal_mark_set().connect([this](const Gtk::TextIter &iter, const Glib::RefPtr &mark) { if(mark->get_name() == "insert") { keep_clipboard = false; diff --git a/src/source_base.hpp b/src/source_base.hpp index f6a160a..1bd813c 100644 --- a/src/source_base.hpp +++ b/src/source_base.hpp @@ -8,9 +8,13 @@ #include #include #include +#include #include + namespace Source { + const std::set ClangTypeLanguages{"chdr", "cpphdr", "c", "cpp", "objc", "h", "hpp", "cc", "ino"}; + inline bool IsClangType(std::string language_id) {return ClangTypeLanguages.contains(language_id);} /// RAII-style text mark. Use instead of Gtk::TextBuffer::create_mark and Gtk::TextBuffer::delete_mark, /// since Gtk::TextBuffer::delete_mark is not called upon Glib::RefPtr deletion class Mark : public Glib::RefPtr { diff --git a/src/source_clang.hpp b/src/source_clang.hpp index 78fd573..fcb7c0e 100644 --- a/src/source_clang.hpp +++ b/src/source_clang.hpp @@ -52,6 +52,9 @@ namespace Source { Glib::ustring parse_thread_buffer GUARDED_BY(parse_mutex); static const std::map &clang_types(); + /** + * @brief Adds formatting tags to tokens in the current file + */ void update_syntax() REQUIRES(parse_mutex); std::map> syntax_tags; diff --git a/src/window.cpp b/src/window.cpp index c443709..d1847ca 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -221,7 +221,9 @@ void Window::configure() { fonts_style += "* {" + font_description_string_to_style(Config::get().theme.font) + "}"; if(!Config::get().source.font.empty()) { auto font_description = Pango::FontDescription(Config::get().source.font); - fonts_style += ".juci_source_view {" + font_description_to_style(font_description) + "}"; + fonts_style += ".juci_source_view {" + + font_description_to_style(font_description) + + "}"; font_description.set_size(Config::get().source.map_font_size * 1024); fonts_style += ".juci_source_map {" + font_description_to_style(font_description) + "}"; } @@ -282,8 +284,10 @@ void Window::configure() { Menu::get().set_keys(); Terminal::get().configure(); Directories::get().update(); - if(auto view = Notebook::get().get_current_view()) + if(auto view = Notebook::get().get_current_view()) { + view->set_pixels_below_lines(Config::get().source.space_between_lines); Notebook::get().update_status(view); + } } void Window::set_menu_actions() { From 69cec55f5a50f897b6686afe5fc7ed45bfb67d84 Mon Sep 17 00:00:00 2001 From: Shivang Gangadia Date: Tue, 24 Sep 2024 21:23:30 +0100 Subject: [PATCH 2/2] Added option to configure spacing between lines in editor --- src/notebook.cpp | 14 +------------- src/source_base.hpp | 4 ---- src/source_clang.hpp | 3 --- src/window.cpp | 5 ++--- 4 files changed, 3 insertions(+), 23 deletions(-) diff --git a/src/notebook.cpp b/src/notebook.cpp index 4389782..fdd04d4 100644 --- a/src/notebook.cpp +++ b/src/notebook.cpp @@ -307,14 +307,6 @@ bool Notebook::open(const boost::filesystem::path &file_path_, Position position Terminal::get().print("For installation instructions please visit: https://gitlab.com/cppit/jucipp/-/blob/master/docs/language_servers.md#julia.\n"); shown.emplace(language_id); } -<<<<<<< HEAD -======= - else if(Source::IsClangType(language_id)) { - Terminal::get().print("\e[33mWarning\e[m: could not find ClangD language server for C/C++.\n"); - Terminal::get().print("For installation instructions please visit: https://gitlab.com/cppit/jucipp/-/blob/master/docs/language_servers.md#julia.\n"); - shown.emplace(language_id); - } ->>>>>>> e7c897b (Added support for configuration of space between lines in editor. Updated IsClangType to use a set.) } } source_views.emplace_back(new Source::GenericView(file_path, language)); @@ -549,11 +541,7 @@ bool Notebook::open(const boost::filesystem::path &file_path_, Position position }); #ifdef JUCI_ENABLE_DEBUG -<<<<<<< HEAD if(dynamic_cast(view) || view->language_id == "rust") { -======= - if(Source::IsClangType(view->language_id) || view->language_id == "rust") { ->>>>>>> e7c897b (Added support for configuration of space between lines in editor. Updated IsClangType to use a set.) view->toggle_breakpoint = [view](int line_nr) { if(view->get_source_buffer()->get_source_marks_at_line(line_nr, "debug_breakpoint").size() > 0) { auto start_iter = view->get_buffer()->get_iter_at_line(line_nr); @@ -870,7 +858,7 @@ void Notebook::update_status(Source::BaseView *view) { if(view->update_status_diagnostics) view->update_status_diagnostics(view); if(view->update_status_state) - view->update_status_state(view); + view->update_status_state(view); } void Notebook::clear_status() { diff --git a/src/source_base.hpp b/src/source_base.hpp index 1bd813c..f6a160a 100644 --- a/src/source_base.hpp +++ b/src/source_base.hpp @@ -8,13 +8,9 @@ #include #include #include -#include #include - namespace Source { - const std::set ClangTypeLanguages{"chdr", "cpphdr", "c", "cpp", "objc", "h", "hpp", "cc", "ino"}; - inline bool IsClangType(std::string language_id) {return ClangTypeLanguages.contains(language_id);} /// RAII-style text mark. Use instead of Gtk::TextBuffer::create_mark and Gtk::TextBuffer::delete_mark, /// since Gtk::TextBuffer::delete_mark is not called upon Glib::RefPtr deletion class Mark : public Glib::RefPtr { diff --git a/src/source_clang.hpp b/src/source_clang.hpp index fcb7c0e..78fd573 100644 --- a/src/source_clang.hpp +++ b/src/source_clang.hpp @@ -52,9 +52,6 @@ namespace Source { Glib::ustring parse_thread_buffer GUARDED_BY(parse_mutex); static const std::map &clang_types(); - /** - * @brief Adds formatting tags to tokens in the current file - */ void update_syntax() REQUIRES(parse_mutex); std::map> syntax_tags; diff --git a/src/window.cpp b/src/window.cpp index d1847ca..3ab2d8d 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -221,9 +221,7 @@ void Window::configure() { fonts_style += "* {" + font_description_string_to_style(Config::get().theme.font) + "}"; if(!Config::get().source.font.empty()) { auto font_description = Pango::FontDescription(Config::get().source.font); - fonts_style += ".juci_source_view {" - + font_description_to_style(font_description) - + "}"; + fonts_style += ".juci_source_view {" + font_description_to_style(font_description) + "}"; font_description.set_size(Config::get().source.map_font_size * 1024); fonts_style += ".juci_source_map {" + font_description_to_style(font_description) + "}"; } @@ -285,6 +283,7 @@ void Window::configure() { Terminal::get().configure(); Directories::get().update(); if(auto view = Notebook::get().get_current_view()) { + // Special call since this property is not part of CSS view->set_pixels_below_lines(Config::get().source.space_between_lines); Notebook::get().update_status(view); }