diff options
author | Thomas White <taw@bitwiz.org.uk> | 2016-09-18 10:55:21 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2016-09-18 10:55:21 +0200 |
commit | 0de6299db5cd5cb6754881633ed9f14aaa57fdf8 (patch) | |
tree | 1cbee916391b49a63cbfee30aca07b1b18657ebd /src/sc_editor.c | |
parent | 7f6c1ec06940551210b7a8bd3d6d6b1dafeed5cc (diff) |
Set scroll position to top if whole document can be shown
Diffstat (limited to 'src/sc_editor.c')
-rw-r--r-- | src/sc_editor.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/sc_editor.c b/src/sc_editor.c index db0ac87..c050cea 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -89,10 +89,20 @@ static void vertical_adjust(GtkAdjustment *adj, SCEditor *e) static void set_vertical_params(SCEditor *e) { if ( e->vadj == NULL ) return; + + /* Ensure we do not scroll off the top of the document */ if ( e->scroll_pos < 0.0 ) e->scroll_pos = 0.0; + + /* Ensure we do not scroll off the bottom of the document */ if ( e->scroll_pos > e->h - e->visible_height ) { e->scroll_pos = e->h - e->visible_height; } + + /* If we can show the whole document, show it at the top */ + if ( e->h < e->visible_height ) { + e->scroll_pos = 0.0; + } + gtk_adjustment_configure(e->vadj, e->scroll_pos, 0, e->h, 100, e->visible_height, e->visible_height); } |