diff --git a/src/cmake.cpp b/src/cmake.cpp index 19fd522..177ec81 100644 --- a/src/cmake.cpp +++ b/src/cmake.cpp @@ -82,7 +82,7 @@ bool CMake::update_default_build(const boost::filesystem::path &default_build_pa } message.hide(); if(exit_status == 0) { -#ifdef _WIN32 //Temporary fix to MSYS2's libclang +#ifdef _WIN32 // Temporary fix to MSYS2's libclang auto compile_commands_file = filesystem::read(compile_commands_path); auto replace_drive = [&compile_commands_file](const std::string ¶m) { size_t pos = 0; diff --git a/src/ctags.cpp b/src/ctags.cpp index 85eee71..37e2cde 100644 --- a/src/ctags.cpp +++ b/src/ctags.cpp @@ -238,7 +238,7 @@ std::vector Ctags::get_locations(const boost::filesystem::path if(!ctags) return {}; - //insert name into type + // insert name into type size_t c = 0; size_t bracket_count = 0; for(; c < type.size(); ++c) { @@ -272,7 +272,7 @@ std::vector Ctags::get_locations(const boost::filesystem::path auto source_parts = get_type_parts(location.source); - //Find match score + // Find match score long score = 0; size_t source_index = 0; for(auto &part : parts) { diff --git a/src/debug_lldb.cpp b/src/debug_lldb.cpp index fe5023d..8110abf 100644 --- a/src/debug_lldb.cpp +++ b/src/debug_lldb.cpp @@ -102,7 +102,7 @@ void Debug::LLDB::start(const std::string &command, const boost::filesystem::pat listener = std::make_unique("juCi++ lldb listener"); } - //Create executable string and argument array + // Create executable string and argument array auto parsed_run_arguments = parse_run_arguments(command); auto &environment_from_arguments = std::get<0>(parsed_run_arguments); auto &executable = std::get<1>(parsed_run_arguments); @@ -127,7 +127,7 @@ void Debug::LLDB::start(const std::string &command, const boost::filesystem::pat return; } - //Set breakpoints + // Set breakpoints for(auto &breakpoint : breakpoints) { if(!(target.BreakpointCreateByLocation(breakpoint.first.string().c_str(), breakpoint.second)).IsValid()) { Terminal::get().async_print("\e[31mError (debug)\e[m: Could not create breakpoint at: " + breakpoint.first.string() + ":" + std::to_string(breakpoint.second) + '\n', true); @@ -244,7 +244,7 @@ void Debug::LLDB::start(const std::string &command, const boost::filesystem::pat while((n = process->GetSTDOUT(buffer, buffer_size)) != 0) Terminal::get().async_print(std::string(buffer, n)); } - //TODO: for some reason stderr is redirected to stdout + // TODO: for some reason stderr is redirected to stdout if((event.GetType() & lldb::SBProcess::eBroadcastBitSTDERR) > 0) { char buffer[buffer_size]; size_t n; @@ -427,7 +427,7 @@ std::string Debug::LLDB::get_value(const std::string &variable, const boost::fil auto frame = process->GetSelectedThread().GetSelectedFrame(); auto values = frame.GetVariables(true, true, true, false); - //First try to find variable based on name, file and line number + // First try to find variable based on name, file and line number if(!file_path.empty()) { for(uint32_t value_index = 0; value_index < values.GetSize(); value_index++) { lldb::SBStream stream; diff --git a/src/debug_lldb.hpp b/src/debug_lldb.hpp index 3c11938..905aec1 100644 --- a/src/debug_lldb.hpp +++ b/src/debug_lldb.hpp @@ -59,7 +59,7 @@ namespace Debug { void start(const std::string &command, const boost::filesystem::path &path = "", const std::vector> &breakpoints = {}, const std::vector &startup_commands = {}, const std::string &remote_host = "") EXCLUDES(mutex); - void continue_debug() EXCLUDES(mutex); //can't use continue as function name + void continue_debug() EXCLUDES(mutex); // can't use continue as function name void stop() EXCLUDES(mutex); void kill() EXCLUDES(mutex); void step_over() EXCLUDES(mutex); diff --git a/src/filesystem.cpp b/src/filesystem.cpp index 8553c61..26ab49e 100644 --- a/src/filesystem.cpp +++ b/src/filesystem.cpp @@ -10,7 +10,7 @@ boost::optional filesystem::rust_sysroot_path; boost::optional filesystem::rust_nightly_sysroot_path; boost::optional> filesystem::executable_search_paths; -//Only use on small files +// Only use on small files std::string filesystem::read(const std::string &path) { std::string str; std::ifstream input(path, std::ios::binary); @@ -25,7 +25,7 @@ std::string filesystem::read(const std::string &path) { return str; } -//Only use on small files +// Only use on small files bool filesystem::write(const std::string &path, const std::string &new_content) { std::ofstream output(path, std::ios::binary); if(output) diff --git a/src/git.cpp b/src/git.cpp index a912252..4147fc0 100644 --- a/src/git.cpp +++ b/src/git.cpp @@ -38,7 +38,7 @@ Git::Repository::Diff::Lines Git::Repository::Diff::get_lines(const std::string LockGuard lock(mutex); error.code = git_diff_blob_to_buffer( blob.get(), nullptr, buffer.c_str(), buffer.size(), nullptr, &options, nullptr, nullptr, [](const git_diff_delta *delta, const git_diff_hunk *hunk, void *payload) { - //Based on https://github.com/atom/git-diff/blob/master/lib/git-diff-view.coffee + // Based on https://github.com/atom/git-diff/blob/master/lib/git-diff-view.coffee auto lines = static_cast(payload); auto start = hunk->new_start - 1; auto end = hunk->new_start + hunk->new_lines - 1; diff --git a/src/git.hpp b/src/git.hpp index c03d97e..597b695 100644 --- a/src/git.hpp +++ b/src/git.hpp @@ -91,12 +91,12 @@ public: private: static bool initialized GUARDED_BY(mutex); - ///Mutex for thread safe operations + /// Mutex for thread safe operations static Mutex mutex; static Error error GUARDED_BY(mutex); - ///Call initialize in public static methods + /// Call initialize in public static methods static void initialize() noexcept REQUIRES(mutex); static boost::filesystem::path path(const char *cpath, boost::optional cpath_length = {}) noexcept REQUIRES(mutex); diff --git a/src/info.cpp b/src/info.cpp index 75602f9..05f27b4 100644 --- a/src/info.cpp +++ b/src/info.cpp @@ -11,9 +11,9 @@ Info::Info() { get_style_context()->add_class("juci_info"); - //Workaround from https://bugzilla.gnome.org/show_bug.cgi?id=710888 - //Issue described at the same issue report - //TODO: remove later + // Workaround from https://bugzilla.gnome.org/show_bug.cgi?id=710888 + // Issue described at the same issue report + // TODO: remove later auto revealer = gtk_widget_get_template_child(GTK_WIDGET(gobj()), GTK_TYPE_INFO_BAR, "revealer"); if(revealer) { gtk_revealer_set_transition_type(GTK_REVEALER(revealer), GTK_REVEALER_TRANSITION_TYPE_NONE); @@ -21,9 +21,10 @@ Info::Info() { } } + void Info::print(const std::string &text) { timeout_connection.disconnect(); - //Timeout based on https://en.wikipedia.org/wiki/Words_per_minute + // Timeout based on https://en.wikipedia.org/wiki/Words_per_minute //(average_words_per_minute*average_letters_per_word)/60 => (228*4.5)/60 = 17.1 double timeout = 1000.0 * std::max(3.0, 1.0 + text.size() / 17.1); timeout_connection = Glib::signal_timeout().connect( diff --git a/src/juci.cpp b/src/juci.cpp index f0ec0a7..b50656b 100644 --- a/src/juci.cpp +++ b/src/juci.cpp @@ -38,7 +38,7 @@ int Application::on_command_line(const Glib::RefPtr else if(boost::filesystem::is_directory(path, ec)) directories.emplace_back(path); } - //Open new file if parent path exists + // Open new file if parent path exists else { if(path.is_absolute() && boost::filesystem::is_directory(path.parent_path(), ec)) files.emplace_back(path, 0); @@ -134,7 +134,7 @@ void Application::on_startup() { Application::Application() : Gtk::Application("no.sout.juci", Gio::APPLICATION_NON_UNIQUE | Gio::APPLICATION_HANDLES_COMMAND_LINE) { Glib::set_application_name("juCi++"); - //Gtk::MessageDialog without buttons caused text to be selected, this prevents that + // Gtk::MessageDialog without buttons caused text to be selected, this prevents that Gtk::Settings::get_default()->property_gtk_label_select_on_focus() = false; } diff --git a/src/notebook.cpp b/src/notebook.cpp index dbf8a30..1681c3e 100644 --- a/src/notebook.cpp +++ b/src/notebook.cpp @@ -13,6 +13,7 @@ #include #include + Notebook::TabLabel::TabLabel(const std::function &on_close) { set_can_focus(false); @@ -115,7 +116,7 @@ Source::View *Notebook::get_current_view() { if(view == current_view) return view; } - //In case there exist a tab that has not yet received focus again in a different notebook + // In case there exist a tab that has not yet received focus again in a different notebook for(int notebook_index = 0; notebook_index < 2; ++notebook_index) { auto page = notebooks[notebook_index].get_current_page(); if(page >= 0) @@ -463,7 +464,7 @@ bool Notebook::open(const boost::filesystem::path &file_path_, Position position configure(source_views.size() - 1); - //Set up tab label + // Set up tab label tab_labels.emplace_back(new TabLabel([this, view]() { close(view); })); @@ -836,8 +837,8 @@ void Notebook::toggle_split() { pack2(notebooks[1], true, true); set_position(get_width() / 2); show_all(); - //Make sure the position is correct - //TODO: report bug to gtk if it is not fixed in gtk3.22 + // Make sure the position is correct + // TODO: report bug to gtk if it is not fixed in gtk3.22 Glib::signal_timeout().connect( [this] { set_position(get_width() / 2); diff --git a/src/notebook.hpp b/src/notebook.hpp index cda86ae..8ea52d6 100644 --- a/src/notebook.hpp +++ b/src/notebook.hpp @@ -87,7 +87,7 @@ private: /// Throws if view is not found std::pair get_notebook_page(Source::View *view); - std::vector source_views; //Is NOT freed in destructor, this is intended for quick program exit. + 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; diff --git a/src/project_build.hpp b/src/project_build.hpp index 4f24643..11b6fe6 100644 --- a/src/project_build.hpp +++ b/src/project_build.hpp @@ -2,6 +2,7 @@ #include "cmake.hpp" #include "meson.hpp" #include +#include namespace Project { class Build { diff --git a/src/selection_dialog.cpp b/src/selection_dialog.cpp index 5aea79e..2565278 100644 --- a/src/selection_dialog.cpp +++ b/src/selection_dialog.cpp @@ -125,7 +125,7 @@ SelectionDialogBase::SelectionDialogBase(Source::BaseView *view_, const boost::o auto screen_width = Gdk::Screen::get_default()->get_width(); root_x = root_x + window_width > screen_width ? screen_width - window_width : root_x; - window.move(root_x, root_y + 1); //TODO: replace 1 with some margin + window.move(root_x, root_y + 1); // TODO: replace 1 with some margin } } else @@ -237,7 +237,7 @@ SelectionDialog::SelectionDialog(Source::BaseView *view, const boost::optionalrefilter(); - list_view_text.set_search_entry(search_entry); //TODO:Report the need of this to GTK's git (bug) + list_view_text.set_search_entry(search_entry); // TODO:Report the need of this to GTK's git (bug) if(search_text->empty()) { if(list_view_text.get_model()->children().size() > 0) list_view_text.set_cursor(list_view_text.get_model()->get_path(list_view_text.get_model()->children().begin())); @@ -304,7 +304,7 @@ bool SelectionDialog::on_key_press(GdkEventKey *event) { return false; } else if(show_search_entry) { -#ifdef __APPLE__ //OS X bug most likely: Gtk::Entry will not work if window is of type POPUP +#ifdef __APPLE__ // OS X bug most likely: Gtk::Entry will not work if window is of type POPUP if(event->is_modifier) return true; else if(event->keyval == GDK_KEY_BackSpace) { @@ -379,7 +379,7 @@ CompletionDialog::CompletionDialog(Source::BaseView *view, const Gtk::TextIter & search_entry.signal_changed().connect([this, search_text, filter_model]() { *search_text = search_entry.get_text(); filter_model->refilter(); - list_view_text.set_search_entry(search_entry); //TODO:Report the need of this to GTK's git (bug) + list_view_text.set_search_entry(search_entry); // TODO:Report the need of this to GTK's git (bug) }); list_view_text.signal_row_activated().connect([this](const Gtk::TreeModel::Path &path, Gtk::TreeViewColumn *) { diff --git a/src/source_base.cpp b/src/source_base.cpp index a432918..c55dfd5 100644 --- a/src/source_base.cpp +++ b/src/source_base.cpp @@ -578,7 +578,7 @@ std::pair Source::BaseView::find_tab_char_and_size() { long last_tab_count = 0; bool single_quoted = false; bool double_quoted = false; - //For bracket languages, TODO: add more language ids + // For bracket languages, TODO: add more language ids if(is_bracket_language && language_id != "html") { bool line_comment = false; bool comment = false; @@ -1126,7 +1126,7 @@ bool Source::BaseView::on_key_press_event(GdkEventKey *event) { scroll_to(get_buffer()->get_insert()); return true; } - //Move cursor one paragraph up + // Move cursor one paragraph up else if((event->keyval == GDK_KEY_Up || event->keyval == GDK_KEY_KP_Up) && (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_META_MASK)) == GDK_CONTROL_MASK) { auto selection_start_iter = get_buffer()->get_selection_bound()->get_iter(); auto iter = get_buffer()->get_iter_at_line(get_buffer()->get_insert()->get_iter().get_line()); diff --git a/src/source_diff.cpp b/src/source_diff.cpp index c54f89b..71b7b2e 100644 --- a/src/source_diff.cpp +++ b/src/source_diff.cpp @@ -120,7 +120,7 @@ void Source::DiffView::configure() { buffer_insert_connection = get_buffer()->signal_insert().connect( [this](const Gtk::TextIter &iter, const Glib::ustring &text, int) { - //Do not perform git diff if no newline is added and line is already marked as added + // Do not perform git diff if no newline is added and line is already marked as added if(!iter.starts_line() && iter.has_tag(renderer->tag_added)) { bool newline = false; for(auto &c : text.raw()) { @@ -132,7 +132,7 @@ void Source::DiffView::configure() { if(!newline) return; } - //Remove tag_removed_above/below if newline is inserted + // Remove tag_removed_above/below if newline is inserted else if(!text.empty() && text[0] == '\n' && iter.has_tag(renderer->tag_removed)) { auto start_iter = get_buffer()->get_iter_at_line(iter.get_line()); auto end_iter = get_iter_at_line_end(iter.get_line()); @@ -153,7 +153,7 @@ void Source::DiffView::configure() { buffer_erase_connection = get_buffer()->signal_erase().connect( [this](const Gtk::TextIter &start_iter, const Gtk::TextIter &end_iter) { - //Do not perform git diff if start_iter and end_iter is at the same line in addition to the line is tagged added + // Do not perform git diff if start_iter and end_iter is at the same line in addition to the line is tagged added if(start_iter.get_line() == end_iter.get_line() && start_iter.has_tag(renderer->tag_added)) return; @@ -332,7 +332,7 @@ std::string Source::DiffView::get_diff_details() { return details; } -///Return repository diff instance. Throws exception on error +/// Return repository diff instance. Throws exception on error std::unique_ptr Source::DiffView::get_diff() { auto work_path = filesystem::get_normal_path(repository->get_work_path()); boost::filesystem::path relative_path; diff --git a/src/source_spellcheck.cpp b/src/source_spellcheck.cpp index d13c2da..21f35e2 100644 --- a/src/source_spellcheck.cpp +++ b/src/source_spellcheck.cpp @@ -29,7 +29,7 @@ Source::SpellCheckView::SpellCheckView(const boost::filesystem::path &file_path, }, false); - //The following signal is added in case SpellCheckView is not subclassed + // The following signal is added in case SpellCheckView is not subclassed signal_key_press_event().connect([this](GdkEventKey *event) { last_keyval = event->keyval; return false; @@ -70,7 +70,7 @@ Source::SpellCheckView::SpellCheckView(const boost::filesystem::path &file_path, } else { auto previous_iter = iter; - //When for instance using space to split two words + // When for instance using space to split two words if(!iter.starts_line() && !iter.ends_line() && is_word_iter(iter) && previous_iter.backward_char() && !previous_iter.starts_line() && !is_word_iter(previous_iter)) { auto first = previous_iter; @@ -374,7 +374,7 @@ bool Source::SpellCheckView::is_spellcheck_iter(const Gtk::TextIter &iter) { if(comment_tag) { if(iter.has_tag(comment_tag) && !iter.begins_tag(comment_tag)) return true; - //Exception at the end of /**/ + // Exception at the end of /**/ else if(iter.ends_tag(comment_tag)) { auto previous_iter = iter; if(previous_iter.backward_char() && *previous_iter == '/') { diff --git a/src/terminal.cpp b/src/terminal.cpp index fa19c1b..42a1511 100644 --- a/src/terminal.cpp +++ b/src/terminal.cpp @@ -554,7 +554,7 @@ void Terminal::clear() { } bool Terminal::on_button_press_event(GdkEventButton *button_event) { - //open clicked link in terminal + // open clicked link in terminal if(button_event->type == GDK_BUTTON_PRESS && button_event->button == GDK_BUTTON_PRIMARY) { Gtk::TextIter iter; int location_x, location_y; diff --git a/src/tooltips.cpp b/src/tooltips.cpp index caceb8d..bfbe4e9 100644 --- a/src/tooltips.cpp +++ b/src/tooltips.cpp @@ -45,7 +45,7 @@ void Tooltip::show(bool disregard_drawn, const std::function &on_motion) Tooltips::shown_tooltips.emplace(this); if(!window) { - //init window + // init window window = std::make_unique(Gtk::WindowType::WINDOW_POPUP); if(auto active_window = Glib::RefPtr::cast_dynamic(Gtk::Application::get_default())->get_active_window()) diff --git a/src/usages_clang.cpp b/src/usages_clang.cpp index c48e2e4..3a7c870 100644 --- a/src/usages_clang.cpp +++ b/src/usages_clang.cpp @@ -127,7 +127,7 @@ boost::optional> Usages::Clang::get_usages(co PathSet visited; auto usr_extended = cursor.get_usr_extended(); - if(!usr_extended.empty() && usr_extended[0] >= '0' && usr_extended[0] <= '9') { //if declared within a function, return + if(!usr_extended.empty() && usr_extended[0] >= '0' && usr_extended[0] <= '9') { // if declared within a function, return if(!translation_units.empty()) add_usages(project_path, build_path, boost::filesystem::path(), usages, visited, spelling, cursor, translation_units.front(), false); return usages; diff --git a/tests/language_protocol_client_test.cpp b/tests/language_protocol_client_test.cpp index 32ad3cc..238eedb 100644 --- a/tests/language_protocol_client_test.cpp +++ b/tests/language_protocol_client_test.cpp @@ -1,10 +1,10 @@ #include "source_language_protocol.hpp" #include -//Requires display server to work -//However, it is possible to use the Broadway backend if the test is run in a pure terminal environment: -//broadwayd& -//make test +// Requires display server to work +// However, it is possible to use the Broadway backend if the test is run in a pure terminal environment: +// broadwayd& +// make test void flush_events() { while(Gtk::Main::events_pending()) diff --git a/tests/source_clang_test.cpp b/tests/source_clang_test.cpp index db159a9..9d51843 100644 --- a/tests/source_clang_test.cpp +++ b/tests/source_clang_test.cpp @@ -9,10 +9,10 @@ std::string main_error = R"(int main() { } )"; -//Requires display server to work -//However, it is possible to use the Broadway backend if the test is run in a pure terminal environment: -//broadwayd& -//make test +// Requires display server to work +// However, it is possible to use the Broadway backend if the test is run in a pure terminal environment: +// broadwayd& +// make test void flush_events() { while(Gtk::Main::events_pending()) @@ -40,7 +40,7 @@ int main() { flush_events(); g_assert_cmpuint(clang_view->clang_diagnostics.size(), ==, 0); - //test get_declaration and get_implementation + // test get_declaration and get_implementation clang_view->place_cursor_at_line_index(15, 7); auto locations = clang_view->get_declaration_locations(); g_assert(locations.size() == 1); @@ -56,7 +56,7 @@ int main() { g_assert(locations.size() == 1); g_assert_cmpuint(locations[0].line, ==, 6); - //test get_usages and get_methods + // test get_usages and get_methods { auto locations = clang_view->get_usages(); g_assert_cmpuint(locations.size(), >, 0); @@ -65,7 +65,7 @@ int main() { g_assert_cmpuint(locations.size(), >, 0); } - //Test rename class (error if not constructor and destructor is renamed as well) + // Test rename class (error if not constructor and destructor is renamed as well) auto saved_main = clang_view->get_buffer()->get_text(); clang_view->place_cursor_at_line_index(0, 6); auto token = clang_view->get_token(clang_view->get_buffer()->get_insert()->get_iter()); @@ -84,7 +84,7 @@ int main() { clang_view->get_buffer()->set_text(saved_main); clang_view->save(); - //test error + // test error clang_view->get_buffer()->set_text(main_error); while(!clang_view->parsed) flush_events(); diff --git a/tests/source_key_test.cpp b/tests/source_key_test.cpp index 6a7323a..25247bc 100644 --- a/tests/source_key_test.cpp +++ b/tests/source_key_test.cpp @@ -2,10 +2,10 @@ #include "source.hpp" #include -//Requires display server to work -//However, it is possible to use the Broadway backend if the test is run in a pure terminal environment: -//broadwayd& -//make test +// Requires display server to work +// However, it is possible to use the Broadway backend if the test is run in a pure terminal environment: +// broadwayd& +// make test int main() { auto app = Gtk::Application::create(); diff --git a/tests/source_test.cpp b/tests/source_test.cpp index c7b372e..bd54b9d 100644 --- a/tests/source_test.cpp +++ b/tests/source_test.cpp @@ -16,10 +16,10 @@ int main() { } )"; -//Requires display server to work -//However, it is possible to use the Broadway backend if the test is run in a pure terminal environment: -//broadwayd& -//make test +// Requires display server to work +// However, it is possible to use the Broadway backend if the test is run in a pure terminal environment: +// broadwayd& +// make test int main() { auto app = Gtk::Application::create(); diff --git a/tests/terminal_test.cpp b/tests/terminal_test.cpp index ef24ec9..946d8ae 100644 --- a/tests/terminal_test.cpp +++ b/tests/terminal_test.cpp @@ -4,10 +4,10 @@ #include #include -//Requires display server to work -//However, it is possible to use the Broadway backend if the test is run in a pure terminal environment: -//broadwayd& -//make test +// Requires display server to work +// However, it is possible to use the Broadway backend if the test is run in a pure terminal environment: +// broadwayd& +// make test int main() { auto app = Gtk::Application::create(); diff --git a/tests/usages_clang_test.cpp b/tests/usages_clang_test.cpp index 59ab51f..40a52c2 100644 --- a/tests/usages_clang_test.cpp +++ b/tests/usages_clang_test.cpp @@ -7,10 +7,10 @@ #include #include -//Requires display server to work -//However, it is possible to use the Broadway backend if the test is run in a pure terminal environment: -//broadwayd& -//make test +// Requires display server to work +// However, it is possible to use the Broadway backend if the test is run in a pure terminal environment: +// broadwayd& +// make test int main() { auto app = Gtk::Application::create();