[geany/geany] d3b0bb: Merge pull request #1154 from b4n/lines-around-scroll

Colomban Wendling git-noreply at xxxxx
Sun Aug 21 11:56:25 UTC 2016


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Sun, 21 Aug 2016 11:56:25 UTC
Commit:      d3b0bbec268c7f063a2d018c9f27602f989e0d81
             https://github.com/geany/geany/commit/d3b0bbec268c7f063a2d018c9f27602f989e0d81

Log Message:
-----------
Merge pull request #1154 from b4n/lines-around-scroll

Add support for keeping the cursor a number of lines from the edges


Modified Paths:
--------------
    data/geany.glade
    doc/geany.txt
    src/editor.c
    src/editor.h
    src/keyfile.c

Modified: data/geany.glade
48 lines changed, 48 insertions(+), 0 deletions(-)
===================================================================
@@ -29,6 +29,11 @@
     <property name="step_increment">1</property>
     <property name="page_increment">158.44</property>
   </object>
+  <object class="GtkAdjustment" id="adjustment13">
+    <property name="upper">100</property>
+    <property name="step_increment">1</property>
+    <property name="page_increment">10</property>
+  </object>
   <object class="GtkAdjustment" id="adjustment2">
     <property name="lower">1</property>
     <property name="upper">99</property>
@@ -3861,6 +3866,49 @@
                                     <property name="position">6</property>
                                   </packing>
                                 </child>
+                                <child>
+                                  <object class="GtkHBox" id="hbox4">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="tooltip_markup">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.</property>
+                                    <property name="spacing">6</property>
+                                    <child>
+                                      <object class="GtkLabel" id="label25">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="label" translatable="yes">Lines visible _around the cursor:</property>
+                                        <property name="use_underline">True</property>
+                                        <property name="mnemonic_widget">spin_scroll_lines_around_cursor</property>
+                                      </object>
+                                      <packing>
+                                        <property name="expand">False</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">0</property>
+                                      </packing>
+                                    </child>
+                                    <child>
+                                      <object class="GtkSpinButton" id="spin_scroll_lines_around_cursor">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">True</property>
+                                        <property name="primary_icon_activatable">False</property>
+                                        <property name="secondary_icon_activatable">False</property>
+                                        <property name="primary_icon_sensitive">True</property>
+                                        <property name="secondary_icon_sensitive">True</property>
+                                        <property name="adjustment">adjustment13</property>
+                                      </object>
+                                      <packing>
+                                        <property name="expand">True</property>
+                                        <property name="fill">True</property>
+                                        <property name="position">1</property>
+                                      </packing>
+                                    </child>
+                                  </object>
+                                  <packing>
+                                    <property name="expand">True</property>
+                                    <property name="fill">True</property>
+                                    <property name="position">7</property>
+                                  </packing>
+                                </child>
                               </object>
                             </child>
                           </object>


Modified: doc/geany.txt
6 lines changed, 6 insertions(+), 0 deletions(-)
===================================================================
@@ -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
 ````````````````


Modified: src/editor.c
9 lines changed, 8 insertions(+), 1 deletions(-)
===================================================================
@@ -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);
 


Modified: src/editor.h
1 lines changed, 1 insertions(+), 0 deletions(-)
===================================================================
@@ -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;
 


Modified: src/keyfile.c
2 lines changed, 2 insertions(+), 0 deletions(-)
===================================================================
@@ -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,



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list