diff options
author | Thomas White <taw@bitwiz.org.uk> | 2011-05-24 23:48:02 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2011-05-24 23:48:02 +0200 |
commit | bcbdceef6e1be59a6ca1d653b6a54bf9009b4143 (patch) | |
tree | 8fc7b7ab999ffdcff0418132bc1d87fd9d7c88bc /src/objects.c | |
parent | b0770e263f6b94386aa0818b0c0f79ca486cf1b2 (diff) |
Make backspace work
Diffstat (limited to 'src/objects.c')
-rw-r--r-- | src/objects.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/objects.c b/src/objects.c index 189241c..a91b737 100644 --- a/src/objects.c +++ b/src/objects.c @@ -122,6 +122,35 @@ void insert_text(struct object *o, char *t) } +void handle_text_backspace(struct object *o) +{ + size_t ndel; + int i; + + assert(o->type == TEXT); + + if ( o->insertion_point == 0 ) return; /* Nothing to delete */ + + if ( !(o->text[o->insertion_point-1] & 0x80) ) { + /* Simple (ASCII-style) backspace */ + ndel = 1; + } else { + ndel = 0; + for ( i=1; i<=6; i++ ) { + if ( !(o->text[o->insertion_point-i] & 0xC0) ) ndel++; + } + } + + memmove(o->text+o->insertion_point-ndel, + o->text+o->insertion_point, + o->text_len-o->insertion_point); + + o->insertion_point -= ndel; + + o->parent->object_seq++; +} + + void delete_object(struct object *o) { remove_object_from_slide(o->parent, o); |