Commit 3c726f52 authored by Ole Christian Eidheim's avatar Ole Christian Eidheim
Browse files

Formatting cleanup

parent d518aab0
Pipeline #188473393 passed with stages
in 19 minutes and 3 seconds
......@@ -25,14 +25,15 @@ Autocomplete::Autocomplete(Gsv::View *view, bool &interactive_completion, guint
stop();
});
view->signal_key_release_event().connect([](GdkEventKey *event) {
if(CompletionDialog::get() && CompletionDialog::get()->is_visible()) {
if(CompletionDialog::get()->on_key_release(event))
return true;
}
return false;
},
false);
view->signal_key_release_event().connect(
[](GdkEventKey *event) {
if(CompletionDialog::get() && CompletionDialog::get()->is_visible()) {
if(CompletionDialog::get()->on_key_release(event))
return true;
}
return false;
},
false);
view->signal_focus_out_event().connect([this](GdkEventFocus *event) {
stop();
......
......@@ -674,12 +674,13 @@ void Directories::add_or_update_path(const boost::filesystem::path &dir_path, co
if(repository)
repository->clear_saved_status();
connection->disconnect();
*connection = Glib::signal_timeout().connect([path_and_row, this]() {
if(directories.find(path_and_row->first.string()) != directories.end())
add_or_update_path(path_and_row->first, path_and_row->second, true);
return false;
},
500);
*connection = Glib::signal_timeout().connect(
[path_and_row, this]() {
if(directories.find(path_and_row->first.string()) != directories.end())
add_or_update_path(path_and_row->first, path_and_row->second, true);
return false;
},
500);
}
});
......@@ -695,12 +696,13 @@ void Directories::add_or_update_path(const boost::filesystem::path &dir_path, co
Gio::FileMonitorEvent monitor_event) {
if(monitor_event != Gio::FileMonitorEvent::FILE_MONITOR_EVENT_CHANGES_DONE_HINT) {
connection->disconnect();
*connection = Glib::signal_timeout().connect([this, path_and_row] {
if(directories.find(path_and_row->first.string()) != directories.end())
colorize_path(path_and_row->first, false);
return false;
},
500);
*connection = Glib::signal_timeout().connect(
[this, path_and_row] {
if(directories.find(path_and_row->first.string()) != directories.end())
colorize_path(path_and_row->first, false);
return false;
},
500);
}
});
}
......
......@@ -4,9 +4,11 @@
/// If you add or remove nodes from the default_config_file, increase the juci
/// version number (JUCI_VERSION) in ../CMakeLists.txt to automatically apply
/// the changes to user's ~/.juci/config/config.json files
const std::string default_config_file = R"RAW({
"version": ")RAW" + std::string(JUCI_VERSION) +
R"RAW(",
const std::string default_config_file =
R"RAW({
"version": ")RAW" +
std::string(JUCI_VERSION) +
R"RAW(",
"gtk_theme": {
"name_comment": "Use \"\" for default theme, At least these two exist on all systems: Adwaita, Raleigh",
"name": "",
......@@ -20,18 +22,18 @@ const std::string default_config_file = R"RAW({
"style": "juci-light",
"font_comment": "Use \"\" for default font, and for instance \"Monospace 12\" to also set size",)RAW"
#ifdef __APPLE__
R"RAW(
R"RAW(
"font": "Menlo",)RAW"
#else
#ifdef _WIN32
R"RAW(
R"RAW(
"font": "Consolas",)RAW"
#else
R"RAW(
R"RAW(
"font": "Monospace",)RAW"
#endif
#endif
R"RAW(
R"RAW(
"cleanup_whitespace_characters_comment": "Remove trailing whitespace characters on save, and add trailing newline if missing",
"cleanup_whitespace_characters": false,
"show_whitespace_characters_comment": "Determines what kind of whitespaces should be drawn. Use comma-separated list of: space, tab, newline, nbsp, leading, text, trailing or all",
......@@ -91,13 +93,13 @@ const std::string default_config_file = R"RAW({
"debug_build_path": "<default_build_path>/debug",
"cmake": {)RAW"
#ifdef _WIN32
R"RAW(
R"RAW(
"command": "cmake -G\"MSYS Makefiles\"",)RAW"
#else
R"RAW(
R"RAW(
"command": "cmake",)RAW"
#endif
R"RAW(
R"RAW(
"compile_command": "cmake --build ."
},
"meson": {
......@@ -108,13 +110,13 @@ const std::string default_config_file = R"RAW({
"default_build_management_system": "cmake",
"save_on_compile_or_run": true,)RAW"
#ifdef JUCI_USE_UCTAGS
R"RAW(
R"RAW(
"ctags_command": "uctags",)RAW"
#else
R"RAW(
R"RAW(
"ctags_command": "ctags",)RAW"
#endif
R"RAW(
R"RAW(
"grep_command": "grep",
"cargo_command": "cargo",
"python_command": "python -u",
......@@ -194,26 +196,26 @@ const std::string default_config_file = R"RAW({
"debug_show_breakpoints": "<primary><shift><alt>b",
"debug_goto_stop": "<primary><shift>l",)RAW"
#ifdef __linux
R"RAW(
R"RAW(
"window_next_tab": "<primary>Tab",
"window_previous_tab": "<primary><shift>Tab",)RAW"
#else
R"RAW(
R"RAW(
"window_next_tab": "<primary><alt>Right",
"window_previous_tab": "<primary><alt>Left",)RAW"
#endif
R"RAW(
R"RAW(
"window_goto_tab": "",
"window_toggle_split": "",
"window_split_source_buffer": "",)RAW"
#ifdef __APPLE__
R"RAW(
R"RAW(
"window_toggle_full_screen": "<primary><control>f",)RAW"
#else
R"RAW(
R"RAW(
"window_toggle_full_screen": "F11",)RAW"
#endif
R"RAW(
R"RAW(
"window_toggle_tabs": "",
"window_toggle_zen_mode": "",
"window_clear_terminal": ""
......
......@@ -116,14 +116,15 @@ Git::Repository::Repository(const boost::filesystem::path &path) {
auto git_directory = Gio::File::create_for_path(get_path().string());
monitor = git_directory->monitor_directory(Gio::FileMonitorFlags::FILE_MONITOR_WATCH_MOVES);
monitor_changed_connection = monitor->signal_changed().connect([this](const Glib::RefPtr<Gio::File> &file,
const Glib::RefPtr<Gio::File> &,
Gio::FileMonitorEvent monitor_event) {
if(monitor_event != Gio::FileMonitorEvent::FILE_MONITOR_EVENT_CHANGES_DONE_HINT) {
this->clear_saved_status();
}
},
false);
monitor_changed_connection = monitor->signal_changed().connect(
[this](const Glib::RefPtr<Gio::File> &file,
const Glib::RefPtr<Gio::File> &,
Gio::FileMonitorEvent monitor_event) {
if(monitor_event != Gio::FileMonitorEvent::FILE_MONITOR_EVENT_CHANGES_DONE_HINT) {
this->clear_saved_status();
}
},
false);
}
Git::Repository::~Repository() {
......
......@@ -26,11 +26,12 @@ void Info::print(const std::string &text) {
//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([this]() {
hide();
return false;
},
timeout);
timeout_connection = Glib::signal_timeout().connect(
[this]() {
hide();
return false;
},
timeout);
label.set_text(text);
show();
......
......@@ -618,11 +618,12 @@ void Notebook::toggle_split() {
show_all();
//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);
return false;
},
200);
Glib::signal_timeout().connect(
[this] {
set_position(get_width() / 2);
return false;
},
200);
}
else {
for(size_t c = size() - 1; c != static_cast<size_t>(-1); --c) {
......
......@@ -44,11 +44,12 @@ SelectionDialogBase::SelectionDialogBase(Gtk::TextView *text_view, const boost::
window.set_type_hint(Gdk::WindowTypeHint::WINDOW_TYPE_HINT_COMBO);
search_entry.signal_changed().connect([this] {
if(on_search_entry_changed)
on_search_entry_changed(search_entry.get_text());
},
false);
search_entry.signal_changed().connect(
[this] {
if(on_search_entry_changed)
on_search_entry_changed(search_entry.get_text());
},
false);
list_view_text.set_search_entry(search_entry);
......
......@@ -588,18 +588,19 @@ void Source::View::setup_signals() {
if(on_motion_last_x != event->x || on_motion_last_y != event->y) {
delayed_tooltips_connection.disconnect();
if((event->state & GDK_BUTTON1_MASK) == 0) {
delayed_tooltips_connection = Glib::signal_timeout().connect([this, x = event->x, y = event->y]() {
type_tooltips.hide();
diagnostic_tooltips.hide();
Tooltips::init();
Gdk::Rectangle rectangle(x, y, 1, 1);
if(parsed) {
show_type_tooltips(rectangle);
show_diagnostic_tooltips(rectangle);
}
return false;
},
100);
delayed_tooltips_connection = Glib::signal_timeout().connect(
[this, x = event->x, y = event->y]() {
type_tooltips.hide();
diagnostic_tooltips.hide();
Tooltips::init();
Gdk::Rectangle rectangle(x, y, 1, 1);
if(parsed) {
show_type_tooltips(rectangle);
show_diagnostic_tooltips(rectangle);
}
return false;
},
100);
}
if(clickable_tag_applied) {
......@@ -608,16 +609,17 @@ void Source::View::setup_signals() {
}
if((event->state & primary_modifier_mask) && !(event->state & GDK_SHIFT_MASK) && !(event->state & GDK_BUTTON1_MASK)) {
delayed_tag_clickable_connection.disconnect();
delayed_tag_clickable_connection = Glib::signal_timeout().connect([this, x = event->x, y = event->y]() {
int buffer_x, buffer_y;
window_to_buffer_coords(Gtk::TextWindowType::TEXT_WINDOW_TEXT, x, y, buffer_x, buffer_y);
Gtk::TextIter iter;
get_iter_at_location(iter, buffer_x, buffer_y);
apply_clickable_tag(iter);
clickable_tag_applied = true;
return false;
},
100);
delayed_tag_clickable_connection = Glib::signal_timeout().connect(
[this, x = event->x, y = event->y]() {
int buffer_x, buffer_y;
window_to_buffer_coords(Gtk::TextWindowType::TEXT_WINDOW_TEXT, x, y, buffer_x, buffer_y);
Gtk::TextIter iter;
get_iter_at_location(iter, buffer_x, buffer_y);
apply_clickable_tag(iter);
clickable_tag_applied = true;
return false;
},
100);
}
auto last_mouse_pos = std::make_pair<int, int>(on_motion_last_x, on_motion_last_y);
......@@ -646,30 +648,32 @@ void Source::View::setup_signals() {
hide_tooltips();
delayed_tooltips_connection.disconnect();
delayed_tooltips_connection = Glib::signal_timeout().connect([this]() {
Tooltips::init();
Gdk::Rectangle rectangle;
get_iter_location(get_buffer()->get_insert()->get_iter(), rectangle);
int location_window_x, location_window_y;
buffer_to_window_coords(Gtk::TextWindowType::TEXT_WINDOW_TEXT, rectangle.get_x(), rectangle.get_y(), location_window_x, location_window_y);
rectangle.set_x(location_window_x - 2);
rectangle.set_y(location_window_y);
rectangle.set_width(5);
if(parsed) {
show_type_tooltips(rectangle);
show_diagnostic_tooltips(rectangle);
}
return false;
},
500);
delayed_tooltips_connection = Glib::signal_timeout().connect(
[this]() {
Tooltips::init();
Gdk::Rectangle rectangle;
get_iter_location(get_buffer()->get_insert()->get_iter(), rectangle);
int location_window_x, location_window_y;
buffer_to_window_coords(Gtk::TextWindowType::TEXT_WINDOW_TEXT, rectangle.get_x(), rectangle.get_y(), location_window_x, location_window_y);
rectangle.set_x(location_window_x - 2);
rectangle.set_y(location_window_y);
rectangle.set_width(5);
if(parsed) {
show_type_tooltips(rectangle);
show_diagnostic_tooltips(rectangle);
}
return false;
},
500);
delayed_tag_similar_symbols_connection.disconnect();
delayed_tag_similar_symbols_connection = Glib::signal_timeout().connect([this] {
apply_similar_symbol_tag();
similar_symbol_tag_applied = true;
return false;
},
100);
delayed_tag_similar_symbols_connection = Glib::signal_timeout().connect(
[this] {
apply_similar_symbol_tag();
similar_symbol_tag_applied = true;
return false;
},
100);
if(SelectionDialog::get())
SelectionDialog::get()->hide();
......
......@@ -343,23 +343,24 @@ void Source::BaseView::monitor_file() {
public:
static void f(BaseView *view, boost::optional<std::time_t> previous_last_write_time = {}, bool check_called = false) {
view->delayed_monitor_changed_connection.disconnect();
view->delayed_monitor_changed_connection = Glib::signal_timeout().connect([view, previous_last_write_time, check_called]() {
boost::system::error_code ec;
auto last_write_time = boost::filesystem::last_write_time(view->file_path, ec);
if(!ec && last_write_time != view->last_write_time) {
if(last_write_time == previous_last_write_time) { // If no change has happened in the last second (std::time_t is in seconds).
if(!check_called) // To avoid several info messages when file is changed but not reloaded.
view->check_last_write_time(last_write_time);
Recursive::f(view, last_write_time, true);
view->delayed_monitor_changed_connection = Glib::signal_timeout().connect(
[view, previous_last_write_time, check_called]() {
boost::system::error_code ec;
auto last_write_time = boost::filesystem::last_write_time(view->file_path, ec);
if(!ec && last_write_time != view->last_write_time) {
if(last_write_time == previous_last_write_time) { // If no change has happened in the last second (std::time_t is in seconds).
if(!check_called) // To avoid several info messages when file is changed but not reloaded.
view->check_last_write_time(last_write_time);
Recursive::f(view, last_write_time, true);
return false;
}
Recursive::f(view, last_write_time);
return false;
}
Recursive::f(view);
return false;
}
Recursive::f(view, last_write_time);
return false;
}
Recursive::f(view);
return false;
},
1000);
},
1000);
}
};
delayed_monitor_changed_connection.disconnect();
......@@ -374,11 +375,12 @@ void Source::BaseView::monitor_file() {
Gio::FileMonitorEvent monitor_event) {
if(monitor_event != Gio::FileMonitorEvent::FILE_MONITOR_EVENT_CHANGES_DONE_HINT) {
delayed_monitor_changed_connection.disconnect();
delayed_monitor_changed_connection = Glib::signal_timeout().connect([this]() {
check_last_write_time();
return false;
},
1000); // Has to wait 1 second (std::time_t is in seconds)
delayed_monitor_changed_connection = Glib::signal_timeout().connect(
[this]() {
check_last_write_time();
return false;
},
1000); // Has to wait 1 second (std::time_t is in seconds)
}
});
}
......@@ -1322,27 +1324,28 @@ void Source::BaseView::setup_extra_cursor_signals() {
auto erase_backward_length = std::make_shared<int>(0);
auto erase_forward_length = std::make_shared<int>(0);
auto erase_selection = std::make_shared<bool>(false);
get_buffer()->signal_erase().connect([this, erase_backward_length, erase_forward_length, erase_selection](const Gtk::TextIter &iter_start, const Gtk::TextIter &iter_end) {
if(enable_multiple_cursors && (!extra_cursors.empty())) {
auto insert_offset = get_buffer()->get_insert()->get_iter().get_offset();
*erase_backward_length = insert_offset - iter_start.get_offset();
*erase_forward_length = iter_end.get_offset() - insert_offset;
if(*erase_backward_length == 0) {
auto iter = get_buffer()->get_insert()->get_iter();
iter.forward_chars(*erase_forward_length);
if(iter == get_buffer()->get_selection_bound()->get_iter())
*erase_selection = true;
}
else if(*erase_forward_length == 0) {
auto iter = get_buffer()->get_insert()->get_iter();
iter.backward_chars(*erase_backward_length);
if(iter == get_buffer()->get_selection_bound()->get_iter())
*erase_selection = true;
}
}
},
false);
get_buffer()->signal_erase().connect(
[this, erase_backward_length, erase_forward_length, erase_selection](const Gtk::TextIter &iter_start, const Gtk::TextIter &iter_end) {
if(enable_multiple_cursors && (!extra_cursors.empty())) {
auto insert_offset = get_buffer()->get_insert()->get_iter().get_offset();
*erase_backward_length = insert_offset - iter_start.get_offset();
*erase_forward_length = iter_end.get_offset() - insert_offset;
if(*erase_backward_length == 0) {
auto iter = get_buffer()->get_insert()->get_iter();
iter.forward_chars(*erase_forward_length);
if(iter == get_buffer()->get_selection_bound()->get_iter())
*erase_selection = true;
}
else if(*erase_forward_length == 0) {
auto iter = get_buffer()->get_insert()->get_iter();
iter.backward_chars(*erase_backward_length);
if(iter == get_buffer()->get_selection_bound()->get_iter())
*erase_selection = true;
}
}
},
false);
get_buffer()->signal_erase().connect([this, erase_backward_length, erase_forward_length, erase_selection](const Gtk::TextIter & /*iter_start*/, const Gtk::TextIter & /*iter_end*/) {
if(enable_multiple_cursors && (*erase_backward_length != 0 || *erase_forward_length != 0)) {
enable_multiple_cursors = false;
......
......@@ -643,8 +643,9 @@ void Source::ClangViewParse::show_type_tooltips(const Gdk::Rectangle &rectangle)
};
VisitorData visitor_data{cursor.get_source_range().get_offsets(), cursor.get_spelling(), {}};
auto start_cursor = cursor;
for(auto parent = cursor.get_semantic_parent(); parent.get_kind() != clangmm::Cursor::Kind::TranslationUnit &&
parent.get_kind() != clangmm::Cursor::Kind::ClassDecl;
for(auto parent = cursor.get_semantic_parent();
parent.get_kind() != clangmm::Cursor::Kind::TranslationUnit &&
parent.get_kind() != clangmm::Cursor::Kind::ClassDecl;
parent = parent.get_semantic_parent())
start_cursor = parent;
clang_visitChildren(
......@@ -801,47 +802,50 @@ Source::ClangViewAutocomplete::ClangViewAutocomplete(const boost::filesystem::pa
};
// Activate argument completions
get_buffer()->signal_changed().connect([this] {
if(!interactive_completion)
return;
if(CompletionDialog::get() && CompletionDialog::get()->is_visible())
return;
if(!has_focus())
return;
if(show_parameters)
autocomplete.stop();
show_parameters = false;
delayed_show_arguments_connection.disconnect();
delayed_show_arguments_connection = Glib::signal_timeout().connect([this]() {
if(get_buffer()->get_has_selection())
return false;
if(CompletionDialog::get() && CompletionDialog::get()->is_visible())
return false;
if(!has_focus())
return false;
if(is_possible_argument()) {
autocomplete.stop();
autocomplete.run();
}
return false;
},
500);
},
false);
get_buffer()->signal_changed().connect(
[this] {
if(!interactive_completion)
return;
if(CompletionDialog::get() && CompletionDialog::get()->is_visible())
return;
if(!has_focus())
return;
if(show_parameters)
autocomplete.stop();
show_parameters = false;
delayed_show_arguments_connection.disconnect();
delayed_show_arguments_connection = Glib::signal_timeout().connect(
[this]() {
if(get_buffer()->get_has_selection())
return false;
if(CompletionDialog::get() && CompletionDialog::get()->is_visible())
return false;
if(!has_focus())
return false;
if(is_possible_argument()) {
autocomplete.stop();
autocomplete.run();
}
return false;
},
500);
},
false);
// Remove argument completions
signal_key_press_event().connect([this](GdkEventKey *event) {
if(show_parameters && CompletionDialog::get() && CompletionDialog::get()->is_visible() &&
event->keyval != GDK_KEY_Down && event->keyval != GDK_KEY_Up &&
event->keyval != GDK_KEY_Return && event->keyval != GDK_KEY_KP_Enter &&
event->keyval != GDK_KEY_ISO_Left_Tab && event->keyval != GDK_KEY_Tab &&
(event->keyval < GDK_KEY_Shift_L || event->keyval > GDK_KEY_Hyper_R)) {
get_buffer()->erase(CompletionDialog::get()->start_mark->get_iter(), get_buffer()->get_insert()->get_iter());
CompletionDialog::get()->hide();
}
return false;
},
false);
signal_key_press_event().connect(
[this](GdkEventKey *event) {
if(show_parameters && CompletionDialog::get() && CompletionDialog::get()->is_visible() &&
event->keyval != GDK_KEY_Down && event->keyval != GDK_KEY_Up &&
event->keyval != GDK_KEY_Return && event->keyval != GDK_KEY_KP_Enter &&
event->keyval != GDK_KEY_ISO_Left_Tab && event->keyval != GDK_KEY_Tab &&
(event->keyval < GDK_KEY_Shift_L || event->keyval > GDK_KEY_Hyper_R)) {
get_buffer()->erase(CompletionDialog::get()->start_mark->get_iter(), get_buffer()->get_insert()->get_iter());
CompletionDialog::get()->hide();
}
return false;
},
false);
autocomplete.is_restart_key = [this](guint keyval) {
auto iter = get_buffer()->get_insert()->get_iter();
......@@ -2060,11 +2064,12 @@ void Source::ClangView::full_reparse() {
return;
if(full_reparse_running) {
delayed_full_reparse_connection = Glib::signal_timeout().connect([this] {
full_reparse();
return false;
},
100);
delayed_full_reparse_connection = Glib::signal_timeout().connect(
[this] {
full_reparse();
return false;
},
100);
return;
}
......
......@@ -118,65 +118,70 @@ void Source::DiffView::configure() {
parse_stop = false;
monitor_changed = false;