aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2016-05-14 23:02:34 +0200
committerThomas White <taw@bitwiz.org.uk>2016-05-14 23:02:34 +0200
commit4f64db34240d84acf0c8722dd279574ccb24f5cc (patch)
tree810133df393d2a51a88968d93c56aec5e436e65d /src
parentae4799ece4fb654759f9e499d4ebb9f3269b0f33 (diff)
Keep current paragraph centered in narrative window
Diffstat (limited to 'src')
-rw-r--r--src/sc_editor.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/sc_editor.c b/src/sc_editor.c
index 9980866..a82ffc9 100644
--- a/src/sc_editor.c
+++ b/src/sc_editor.c
@@ -1610,6 +1610,9 @@ int sc_editor_get_cursor_para(SCEditor *e)
void sc_editor_set_cursor_para(SCEditor *e, signed int pos)
{
+ double h;
+ int i;
+
if ( e->cursor_frame == NULL ) {
e->cursor_frame = e->top;
e->selection = e->top;
@@ -1623,6 +1626,15 @@ void sc_editor_set_cursor_para(SCEditor *e, signed int pos)
e->cursor_para = pos;
}
e->cursor_pos = 0;
+
+ h = 0;
+ for ( i=0; i<e->cursor_para; i++ ) {
+ h += paragraph_height(e->cursor_frame->paras[i]);
+ }
+ h += (paragraph_height(e->cursor_frame->paras[e->cursor_para]))/2;
+ e->scroll_pos = h - (e->visible_height/2);
+ set_vertical_params(e);
+
sc_editor_redraw(e);
}