aboutsummaryrefslogtreecommitdiff
path: root/src/sc_editor.c
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2016-03-31 22:48:43 +0200
committerThomas White <taw@bitwiz.org.uk>2016-03-31 22:48:43 +0200
commit37468b97fc8acff0948498da0996bf0835d3365a (patch)
treec23f5c92c0a1157f1ac6b2f0af9eeb189e6ad645 /src/sc_editor.c
parent554a3d38045a2c563342b534084462771621e079 (diff)
Make backspace work (pretty minimally)
Diffstat (limited to 'src/sc_editor.c')
-rw-r--r--src/sc_editor.c26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/sc_editor.c b/src/sc_editor.c
index ca37853..c75c8ac 100644
--- a/src/sc_editor.c
+++ b/src/sc_editor.c
@@ -605,7 +605,31 @@ static void insert_text(char *t, SCEditor *e)
static void do_backspace(struct frame *fr, SCEditor *e)
{
- /* FIXME: Delete at the cursor */
+ int old_pos = e->cursor_pos;
+ int old_para = e->cursor_para;
+ int old_trail = e->cursor_trail;
+
+ int new_para = old_para;
+ int new_pos = old_pos;
+ int new_trail = old_trail;
+
+ Paragraph *para = e->cursor_frame->paras[old_para];
+
+ cursor_moveh(e->cursor_frame, &new_para, &new_pos, &new_trail, -1);
+ cursor_moveh(e->cursor_frame, &e->cursor_para, &e->cursor_pos,
+ &e->cursor_trail, -1);
+ if ( e->cursor_para != old_para ) {
+ /* FIXME: Implement this case */
+ printf("Merge paragraphs!\n");
+ return;
+ }
+
+ delete_text_in_paragraph(para, e->cursor_pos+e->cursor_trail,
+ old_pos+old_trail);
+
+ wrap_paragraph(para, NULL, e->cursor_frame->w - e->cursor_frame->pad_l
+ - e->cursor_frame->pad_r);
+
sc_editor_redraw(e);
}