aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2017-01-10 22:15:54 +0100
committerThomas White <taw@bitwiz.org.uk>2017-01-10 22:15:54 +0100
commitae695b7c2fc41b34a6737b12532541b32801feef (patch)
treee615e659d0a354e292514ed67a6e237b8ed6abc4
parent97266236e846fedb021a37c3a418d5b79ffed6bc (diff)
Split paragraphs on enter
-rw-r--r--src/frame.c3
-rw-r--r--src/sc_editor.c11
2 files changed, 14 insertions, 0 deletions
diff --git a/src/frame.c b/src/frame.c
index 9a09ea4..6e619aa 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -1031,6 +1031,9 @@ static SCBlock *split_text_paragraph(struct frame *fr, int pn, size_t pos,
return NULL; /* Badness is coming */
}
+ /* Copy spacing */
+ for ( i=0; i<4; i++ ) pnew->space[i] = para->space[i];
+
/* First run of the new paragraph contains the leftover text */
rr = &para->runs[run];
pnew->runs[0].scblock = rr->scblock;
diff --git a/src/sc_editor.c b/src/sc_editor.c
index 1cb1761..83bb90b 100644
--- a/src/sc_editor.c
+++ b/src/sc_editor.c
@@ -641,6 +641,17 @@ static void insert_text(char *t, SCEditor *e)
return;
}
+
+ if ( strcmp(t, "\n") == 0 ) {
+ split_paragraph_at_cursor(e);
+ if ( e->flow ) update_size(e);
+ cursor_moveh(e->cursor_frame, &e->cursor_para,
+ &e->cursor_pos, &e->cursor_trail, +1);
+ check_cursor_visible(e);
+ sc_editor_redraw(e);
+ return;
+ }
+
para = e->cursor_frame->paras[e->cursor_para];
/* Is this paragraph even a text one? */