diff options
author | Thomas White <taw@bitwiz.org.uk> | 2014-04-17 00:36:52 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2014-04-17 00:36:52 +0200 |
commit | 9d4c91a795d2d39012f7d50dfa4796944987885b (patch) | |
tree | 066c69bfda8ff9e4aaf3e5b9bbd989c11b79c09a | |
parent | be29afdf7d3cf5616b74adc269a4ac2ed0548538 (diff) |
Editing stuff
-rw-r--r-- | src/mainwindow.c | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/src/mainwindow.c b/src/mainwindow.c index 96e0a82..7fbf166 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -1125,27 +1125,44 @@ static void insert_text(struct frame *fr, char *t, struct presentation *p) static void do_backspace(struct frame *fr, struct presentation *p) { -#if 0 size_t tlen, olen; + int nln, nbx; + size_t pos; + struct wrap_box *box; if ( fr == NULL ) return; /* If this is, say, the top level frame, do nothing */ - if ( fr->sc == NULL ) return; + if ( fr->boxes == NULL ) return; + + nln = p->cursor_line; + nbx = p->cursor_box; + pos = p->cursor_pos; + + if ( pos == 0 ) { + if ( nbx == 0 ) { + if ( nln == 0 ) return; + nln--; + nbx = fr->lines[nln]->n_boxes-1; /* The last box */ + } else { + nbx--; + } + pos = strlen(fr->lines[nln]->boxes[nbx].text)-1; + } + + box = &fr->lines[nln].boxes[nbx]; - if ( fr->pos == 0 ) return; + ptr = g_utf8_pointer_to_offset(box->text, pos); olen = strlen(fr->sc) - fr->pos + 1; tlen = 1; /* FIXME: Length of character before cursor */ memmove(fr->sc+fr->pos-tlen, fr->sc+fr->pos, olen); + reshape_box(box); rerender_slide(p); - fr->pos -= tlen; p->cursor_pos = fr->pos; redraw_editor(p); - fr->empty = 0; -#endif } @@ -1645,7 +1662,8 @@ static void move_cursor(struct presentation *p, signed int x, signed int y) } } while ( (line->boxes[cb].type == WRAP_BOX_SENTINEL) - || (line->boxes[cb].type == WRAP_BOX_NOTHING) ); + || (line->boxes[cb].type == WRAP_BOX_NOTHING) + || !line->boxes[cb].editable ); p->cursor_box = cb; @@ -1686,7 +1704,8 @@ static void move_cursor(struct presentation *p, signed int x, signed int y) } } while ( (line->boxes[cb].type == WRAP_BOX_SENTINEL) - || (line->boxes[cb].type == WRAP_BOX_NOTHING) ); + || (line->boxes[cb].type == WRAP_BOX_NOTHING) + || !line->boxes[cb].editable ); p->cursor_box = cb; box = &line->boxes[cb]; |