diff --git a/data/geany.glade b/data/geany.glade index eb9a89f837..564d299c35 100644 --- a/data/geany.glade +++ b/data/geany.glade @@ -713,9 +713,9 @@ True - False + False gtk-new - 1 + 1 @@ -3951,17 +3951,6 @@ False 0 none - - - Show line endings - True - True - False - Shows the line ending character - True - True - - True @@ -3980,6 +3969,17 @@ + + + Show line endings + True + True + False + Shows the line ending character + True + True + + False @@ -4019,6 +4019,22 @@ 6 + + + Show fold margin + True + True + False + Shows or hides the fold margin right of the line numbers, which is used to fold code + True + True + + + False + False + 7 + + Stop scrolling at last line @@ -4032,7 +4048,7 @@ False False - 7 + 8 @@ -4073,7 +4089,7 @@ True True - 8 + 9 @@ -7500,6 +7516,16 @@ + + + True + False + Show _Fold Margin + True + True + + + True @@ -8057,10 +8083,10 @@ New from _Folder... True - False - True + False + True image7 - False + False diff --git a/doc/geany.txt b/doc/geany.txt index 9fa6600493..6f63d0b8e3 100644 --- a/doc/geany.txt +++ b/doc/geany.txt @@ -739,7 +739,9 @@ fold points. filetypes.common `Folding Settings`_. If you don't like it or don't need it at all, you can simply disable -folding support completely in the preferences dialog. +folding support completely in the preferences dialog. You can also keep +folding but hide the margin (also in the preferences dialog, or in the +View menu). The folding behaviour can be changed with the "Fold/Unfold all children of a fold point" option in the preference dialog. If activated, Geany will @@ -2369,6 +2371,10 @@ Show markers margin Show or hide the small margin right of the line numbers, which is used to mark lines. +Show fold margin + Show or hide the small margin right of the line numbers, which is used + to fold code. + Stop scrolling at last line When enabled Geany stops scrolling when at the last line of the document. Otherwise you can scroll one more page even if there are no real lines. diff --git a/src/callbacks.c b/src/callbacks.c index 5443f8cac4..c92fbee58b 100644 --- a/src/callbacks.c +++ b/src/callbacks.c @@ -739,6 +739,16 @@ static void on_markers_margin1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer } +static void on_fold_margin1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data) +{ + if (ignore_callback) + return; + + editor_prefs.show_fold_margin = ! editor_prefs.show_fold_margin; + ui_toggle_editor_features(GEANY_EDITOR_SHOW_FOLD_MARGIN); +} + + static void on_show_line_numbers1_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data) { if (ignore_callback) diff --git a/src/editor.c b/src/editor.c index 97a6d35dcd..8afb89f97e 100644 --- a/src/editor.c +++ b/src/editor.c @@ -490,7 +490,7 @@ static void on_margin_click(GeanyEditor *editor, SCNotification *nt) sci_toggle_marker_at_line(editor->sci, line, 1); /* toggle the marker */ } /* left click on the folding margin to toggle folding state of current line */ - else if (nt->margin == 2 && editor_prefs.folding) + else if (nt->margin == 2 && editor_prefs.folding && editor_prefs.show_fold_margin) { gint line = sci_get_line_from_position(editor->sci, nt->position); editor_toggle_fold(editor, line, nt->modifiers); @@ -1063,7 +1063,7 @@ static void update_margins(ScintillaObject *sci) { sci_set_line_numbers(sci, editor_prefs.show_linenumber_margin); sci_set_symbol_margin(sci, editor_prefs.show_markers_margin); - sci_set_folding_margin_visible(sci, editor_prefs.folding); + sci_set_folding_margin_visible(sci, editor_prefs.folding && editor_prefs.show_fold_margin); } @@ -5189,7 +5189,7 @@ void editor_apply_update_prefs(GeanyEditor *editor) sci_set_line_numbers(sci, editor_prefs.show_linenumber_margin); sci_set_eol_representation_characters(sci, sci_get_eol_mode(sci)); - sci_set_folding_margin_visible(sci, editor_prefs.folding); + sci_set_folding_margin_visible(sci, editor_prefs.folding && editor_prefs.show_fold_margin); /* virtual space */ SSM(sci, SCI_SETVIRTUALSPACEOPTIONS, editor_prefs.show_virtual_space, 0); diff --git a/src/editor.h b/src/editor.h index 4dffe45629..e9d98265c3 100644 --- a/src/editor.h +++ b/src/editor.h @@ -106,6 +106,7 @@ typedef struct GeanyEditorPrefs gint long_line_column; gchar *long_line_color; gboolean show_markers_margin; /* view menu */ + gboolean show_fold_margin; /* view menu */ gboolean show_linenumber_margin; /* view menu */ gboolean show_scrollbars; /* hidden pref */ gboolean scroll_stop_at_last_line; diff --git a/src/keyfile.c b/src/keyfile.c index 43fe7c2893..a2af3cd465 100644 --- a/src/keyfile.c +++ b/src/keyfile.c @@ -552,6 +552,7 @@ static void save_dialog_prefs(GKeyFile *config) g_key_file_set_boolean(config, PACKAGE, "show_line_endings", editor_prefs.show_line_endings); g_key_file_set_boolean(config, PACKAGE, "show_line_endings_only_when_differ", editor_prefs.show_line_endings_only_when_differ); g_key_file_set_boolean(config, PACKAGE, "show_markers_margin", editor_prefs.show_markers_margin); + g_key_file_set_boolean(config, PACKAGE, "show_fold_margin", editor_prefs.show_fold_margin); g_key_file_set_boolean(config, PACKAGE, "show_linenumber_margin", editor_prefs.show_linenumber_margin); g_key_file_set_boolean(config, PACKAGE, "long_line_enabled", editor_prefs.long_line_enabled); g_key_file_set_integer(config, PACKAGE, "long_line_type", editor_prefs.long_line_type); @@ -921,6 +922,7 @@ static void load_dialog_prefs(GKeyFile *config) editor_prefs.folding = utils_get_setting_boolean(config, PACKAGE, "use_folding", TRUE); editor_prefs.unfold_all_children = utils_get_setting_boolean(config, PACKAGE, "unfold_all_children", FALSE); editor_prefs.show_markers_margin = utils_get_setting_boolean(config, PACKAGE, "show_markers_margin", TRUE); + editor_prefs.show_fold_margin = utils_get_setting_boolean(config, PACKAGE, "show_fold_margin", TRUE); editor_prefs.show_linenumber_margin = utils_get_setting_boolean(config, PACKAGE, "show_linenumber_margin", TRUE); editor_prefs.disable_dnd = utils_get_setting_boolean(config, PACKAGE, "pref_editor_disable_dnd", FALSE); editor_prefs.smart_home_key = utils_get_setting_boolean(config, PACKAGE, "pref_editor_smart_home_key", TRUE); diff --git a/src/prefs.c b/src/prefs.c index 40c23ccc52..1852e2b845 100644 --- a/src/prefs.c +++ b/src/prefs.c @@ -589,6 +589,9 @@ static void prefs_init_dialog(void) widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_markers_margin"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), editor_prefs.show_markers_margin); + widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_fold_margin"); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), editor_prefs.show_fold_margin); + widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_scroll_stop_at_last_line"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), editor_prefs.scroll_stop_at_last_line); @@ -1042,6 +1045,16 @@ on_prefs_dialog_response(GtkDialog *dialog, gint response, gpointer user_data) editor_prefs.long_line_column = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(widget)); widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_folding"); + + if(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)) != editor_prefs.folding) + { + if(!editor_prefs.folding) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON( + ui_lookup_widget(ui_widgets.prefs_dialog, "check_fold_margin")), TRUE); + } else + editor_unfold_all(doc->editor); + } + editor_prefs.folding = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); ui_update_fold_items(); @@ -1067,6 +1080,9 @@ on_prefs_dialog_response(GtkDialog *dialog, gint response, gpointer user_data) widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_markers_margin"); editor_prefs.show_markers_margin = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_fold_margin"); + editor_prefs.show_fold_margin = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + widget = ui_lookup_widget(ui_widgets.prefs_dialog, "check_scroll_stop_at_last_line"); editor_prefs.scroll_stop_at_last_line = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); @@ -1527,6 +1543,7 @@ static void on_use_folding_toggled(GtkToggleButton *togglebutton, gpointer user_ gboolean sens = gtk_toggle_button_get_active(togglebutton); gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets.prefs_dialog, "check_unfold_children"), sens); + gtk_widget_set_sensitive(ui_lookup_widget(ui_widgets.prefs_dialog, "check_fold_margin"), sens); } diff --git a/src/ui_utils.c b/src/ui_utils.c index 60787c8f86..f8d76e5ee8 100644 --- a/src/ui_utils.c +++ b/src/ui_utils.c @@ -563,6 +563,7 @@ void ui_update_fold_items(void) ui_widget_show_hide(ui_lookup_widget(main_widgets.window, "menu_fold_all1"), editor_prefs.folding); ui_widget_show_hide(ui_lookup_widget(main_widgets.window, "menu_unfold_all1"), editor_prefs.folding); ui_widget_show_hide(ui_lookup_widget(main_widgets.window, "separator22"), editor_prefs.folding); + ui_widget_show_hide(ui_lookup_widget(main_widgets.window, "menu_fold_margin1"), editor_prefs.folding); } @@ -1432,6 +1433,9 @@ void ui_toggle_editor_features(GeanyUIEditorFeatures feature) case GEANY_EDITOR_SHOW_MARKERS_MARGIN: sci_set_symbol_margin(doc->editor->sci, editor_prefs.show_markers_margin); break; + case GEANY_EDITOR_SHOW_FOLD_MARGIN: + sci_set_folding_margin_visible(doc->editor->sci, editor_prefs.show_fold_margin); + break; case GEANY_EDITOR_SHOW_LINE_NUMBERS: sci_set_line_numbers(doc->editor->sci, editor_prefs.show_linenumber_margin); break; @@ -1453,6 +1457,7 @@ void ui_update_view_editor_menu_items(void) { ignore_callback = TRUE; gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ui_lookup_widget(main_widgets.window, "menu_markers_margin1")), editor_prefs.show_markers_margin); + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ui_lookup_widget(main_widgets.window, "menu_fold_margin1")), editor_prefs.show_fold_margin); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ui_lookup_widget(main_widgets.window, "menu_linenumber_margin1")), editor_prefs.show_linenumber_margin); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ui_lookup_widget(main_widgets.window, "menu_show_white_space1")), editor_prefs.show_white_space); gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(ui_lookup_widget(main_widgets.window, "menu_show_line_endings1")), editor_prefs.show_line_endings); diff --git a/src/ui_utils.h b/src/ui_utils.h index 8b71f1779f..48290e0013 100644 --- a/src/ui_utils.h +++ b/src/ui_utils.h @@ -227,6 +227,7 @@ GeanyAutoSeparator; typedef enum { GEANY_EDITOR_SHOW_MARKERS_MARGIN, + GEANY_EDITOR_SHOW_FOLD_MARGIN, GEANY_EDITOR_SHOW_LINE_NUMBERS, GEANY_EDITOR_SHOW_WHITE_SPACE, GEANY_EDITOR_SHOW_INDENTATION_GUIDES,