Browse Source

Added support for configuration of space between lines in editor. Updated IsClangType to use a set.

pipelines/1486128344
Shivang Gangadia 1 year ago
parent
commit
50adce1c4a
  1. 2
      src/config.cpp
  2. 1
      src/config.hpp
  3. 12
      src/notebook.cpp
  4. 2
      src/source_base.cpp
  5. 4
      src/source_base.hpp
  6. 3
      src/source_clang.hpp
  7. 8
      src/window.cpp

2
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,

1
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;

12
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<Source::ClangView *>(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);

2
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<Gtk::TextBuffer::Mark> &mark) {
if(mark->get_name() == "insert") {
keep_clipboard = false;

4
src/source_base.hpp

@ -8,9 +8,13 @@
#include <list>
#include <regex>
#include <set>
#include <string>
#include <vector>
namespace Source {
const std::set<std::string> 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<Gtk::TextMark> deletion
class Mark : public Glib::RefPtr<Gtk::TextMark> {

3
src/source_clang.hpp

@ -52,6 +52,9 @@ namespace Source {
Glib::ustring parse_thread_buffer GUARDED_BY(parse_mutex);
static const std::map<int, std::string> &clang_types();
/**
* @brief Adds formatting tags to tokens in the current file
*/
void update_syntax() REQUIRES(parse_mutex);
std::map<int, Glib::RefPtr<Gtk::TextTag>> syntax_tags;

8
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() {

Loading…
Cancel
Save