aboutsummaryrefslogtreecommitdiff
path: root/src/sc_editor.c
diff options
context:
space:
mode:
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);
}