diff --git a/data/geany.glade b/data/geany.glade index 224c0493..56276b4a 100644 --- a/data/geany.glade +++ b/data/geany.glade @@ -29,6 +29,11 @@ 1 158.44 + + 100 + 1 + 10 + 1 99 @@ -3861,6 +3866,49 @@ 6 + + + True + False + Number of lines to maintain between the cursor and the top and bottom edges of the view. This allows some lines of context around the cursor to always be visible. If <i>Stop scrolling at last line</i> is <b>disabled</b>, the cursor will never reach the bottom edge when this value is greater than 0. + 6 + + + True + False + Lines visible _around the cursor: + True + spin_scroll_lines_around_cursor + + + False + True + 0 + + + + + True + True + False + False + True + True + adjustment13 + + + True + True + 1 + + + + + True + True + 7 + + diff --git a/doc/geany.txt b/doc/geany.txt index 609f4c7b..27c67a2e 100644 --- a/doc/geany.txt +++ b/doc/geany.txt @@ -2254,6 +2254,12 @@ 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. +Lines visible around the cursor + The number of lines to maintain between the cursor and the top and bottom + edges of the view. This allows some lines of context around the cursor to + always be visible. If *Stop scrolling at last line* is disabled, the cursor + will never reach the bottom edge when this value is greater than 0. + Long line marker ```````````````` diff --git a/src/editor.c b/src/editor.c index 7d7131d8..3808d3fa 100644 --- a/src/editor.c +++ b/src/editor.c @@ -4908,7 +4908,7 @@ static ScintillaObject *create_new_sci(GeanyEditor *editor) sci_set_symbol_margin(sci, editor_prefs.show_markers_margin); sci_set_lines_wrapped(sci, editor->line_wrapping); sci_set_caret_policy_x(sci, CARET_JUMPS | CARET_EVEN, 0); - /*sci_set_caret_policy_y(sci, CARET_JUMPS | CARET_EVEN, 0);*/ + /* Y policy is set in editor_apply_update_prefs() */ SSM(sci, SCI_AUTOCSETSEPARATOR, '\n', 0); SSM(sci, SCI_SETSCROLLWIDTHTRACKING, 1, 0); @@ -5134,6 +5134,7 @@ void editor_set_indentation_guides(GeanyEditor *editor) void editor_apply_update_prefs(GeanyEditor *editor) { ScintillaObject *sci; + int caret_y_policy; g_return_if_fail(editor != NULL); @@ -5169,6 +5170,12 @@ void editor_apply_update_prefs(GeanyEditor *editor) /* virtual space */ SSM(sci, SCI_SETVIRTUALSPACEOPTIONS, editor_prefs.show_virtual_space, 0); + /* caret Y policy */ + caret_y_policy = CARET_EVEN; + if (editor_prefs.scroll_lines_around_cursor > 0) + caret_y_policy |= CARET_SLOP | CARET_STRICT; + sci_set_caret_policy_y(sci, caret_y_policy, editor_prefs.scroll_lines_around_cursor); + /* (dis)allow scrolling past end of document */ sci_set_scroll_stop_at_last_line(sci, editor_prefs.scroll_stop_at_last_line); diff --git a/src/editor.h b/src/editor.h index 696334eb..00d4ebc5 100644 --- a/src/editor.h +++ b/src/editor.h @@ -136,6 +136,7 @@ typedef struct GeanyEditorPrefs gint show_virtual_space; gboolean long_line_enabled; gint autocompletion_update_freq; + gint scroll_lines_around_cursor; } GeanyEditorPrefs; diff --git a/src/keyfile.c b/src/keyfile.c index 1a1e2055..a3d68d81 100644 --- a/src/keyfile.c +++ b/src/keyfile.c @@ -215,6 +215,8 @@ static void init_pref_groups(void) "autocompletion_update_freq", GEANY_MAX_SYMBOLS_UPDATE_FREQ, "spin_symbol_update_freq"); stash_group_add_string(group, &editor_prefs.color_scheme, "color_scheme", NULL); + stash_group_add_spin_button_integer(group, &editor_prefs.scroll_lines_around_cursor, + "scroll_lines_around_cursor", 0, "spin_scroll_lines_around_cursor"); /* files */ stash_group_add_spin_button_integer(group, (gint*)&file_prefs.mru_length,