diff options
author | Thomas White <taw@physics.org> | 2018-03-11 17:25:38 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2018-03-11 17:25:38 +0100 |
commit | 2975d15b76c5321d9facae06266fbc17dc99492b (patch) | |
tree | 3c371682b1d867314851b0a9f777c5cfcd3df6ce | |
parent | 6158d0d7411a6718fab01873109067b227bfa1b8 (diff) |
Avoid crash when deleting in a non-text paragraph
Still need to implement it, though
-rw-r--r-- | src/sc_editor.c | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/src/sc_editor.c b/src/sc_editor.c index 3972f02..115e7b6 100644 --- a/src/sc_editor.c +++ b/src/sc_editor.c @@ -746,24 +746,33 @@ static void do_backspace(struct frame *fr, SCEditor *e) } else { - /* Delete one character */ - struct edit_pos p1, p2; + if ( para_type(e->cursor_frame->paras[e->cursor_para]) == PARA_TYPE_TEXT ) { - p1.para = e->cursor_para; - p1.pos = e->cursor_pos; - p1.trail = e->cursor_trail; + /* Delete one character */ + struct edit_pos p1, p2; - p2 = p1; + p1.para = e->cursor_para; + p1.pos = e->cursor_pos; + p1.trail = e->cursor_trail; - cursor_moveh(e->cursor_frame, &p2.para, &p2.pos, &p2.trail, -1); - show_edit_pos(p1); - show_edit_pos(p2); + p2 = p1; - delete_text_from_frame(e->cursor_frame, p1, p2, wrapw); + cursor_moveh(e->cursor_frame, &p2.para, &p2.pos, &p2.trail, -1); + show_edit_pos(p1); + show_edit_pos(p2); - e->cursor_para = p2.para; - e->cursor_pos = p2.pos; - e->cursor_trail = p2.trail; + delete_text_from_frame(e->cursor_frame, p1, p2, wrapw); + + e->cursor_para = p2.para; + e->cursor_pos = p2.pos; + e->cursor_trail = p2.trail; + + } else { + + /* FIXME: Implement this */ + fprintf(stderr, "Deleting non-text paragraph\n"); + + } } |