diff options
author | Thomas White <taw@bitwiz.org.uk> | 2016-03-29 22:56:07 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2016-03-29 22:56:07 +0200 |
commit | c56a39fc9bda020f6c5c862bcf7c9455e0d83459 (patch) | |
tree | f830f6bbe42708e7fa2f4383371830c0951488d7 /src/sc_editor.c | |
parent | d7ee6bba4f775abb09836cddf1dd6a7cda5f04db (diff) |
Enable text insertion
Diffstat (limited to 'src/sc_editor.c')
-rw-r--r-- | src/sc_editor.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/sc_editor.c b/src/sc_editor.c index 6c6c281..72e90e8 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -581,7 +581,19 @@ void insert_scblock(SCBlock *scblock, SCEditor *e) static void insert_text(char *t, SCEditor *e) { - /* FIXME: Insert "t" at the cursor */ + Paragraph *para; + + if ( e->cursor_para >= e->cursor_frame->n_paras ) { + fprintf(stderr, "Cursor paragraph number is too high!\n"); + return; + } + + para = e->cursor_frame->paras[e->cursor_para]; + insert_text_in_paragraph(para, e->cursor_pos+e->cursor_trail, t); + wrap_paragraph(para, NULL, e->cursor_frame->w - e->cursor_frame->pad_l + - e->cursor_frame->pad_r); + cursor_moveh(e->cursor_frame, &e->cursor_para, + &e->cursor_pos, &e->cursor_trail, +1); sc_editor_redraw(e); } |