aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2016-09-13 10:33:53 +0200
committerThomas White <taw@bitwiz.org.uk>2016-09-13 10:33:53 +0200
commitbfea1928198dc7afd42cca5e3e7b4028325dfdff (patch)
treefb9817acce9b947d08908ade9f018b004407260b /src
parent49bdd47afa1c174c751532dc8a5f01dd8d27914e (diff)
Fix text deletion
Offsets are all bytes, now.
Diffstat (limited to 'src')
-rw-r--r--src/frame.c3
-rw-r--r--src/sc_parse.c46
-rw-r--r--src/sc_parse.h1
3 files changed, 1 insertions, 49 deletions
diff --git a/src/frame.c b/src/frame.c
index 9b71a02..11c6d8f 100644
--- a/src/frame.c
+++ b/src/frame.c
@@ -831,8 +831,7 @@ void delete_text_in_paragraph(Paragraph *para, size_t offs1, size_t offs2)
/* Delete from the corresponding SC block */
scblock_offs1 = ds + run->scblock_offs_bytes;
scblock_offs2 = de + run->scblock_offs_bytes;
- sc_delete_text(run->scblock, scblock_offs1,
- run->scblock, scblock_offs2);
+ scblock_delete_text(run->scblock, scblock_offs1, scblock_offs2);
/* Fix up the offsets of the subsequent text runs */
size_t del_len = de - ds;
diff --git a/src/sc_parse.c b/src/sc_parse.c
index 4329337..ed2785a 100644
--- a/src/sc_parse.c
+++ b/src/sc_parse.c
@@ -643,52 +643,6 @@ void scblock_delete_text(SCBlock *b, size_t o1, size_t o2)
}
-static void delete_from_block(SCBlock *b, int o1, int o2)
-{
- if ( o1 == o2 ) return; /* nothing to delete */
- assert(o2 > o1);
- char *p1 = g_utf8_offset_to_pointer(b->contents, o1);
- char *p2 = g_utf8_offset_to_pointer(b->contents, o2);
- memmove(p1, p2, strlen(p2)+1);
-}
-
-
-static void delete_to_end(SCBlock *b, int offs)
-{
- char *p = g_utf8_offset_to_pointer(b->contents, offs);
- p[0] = '\0';
-}
-
-
-static void delete_from_start(SCBlock *b, int offs)
-{
- char *p = g_utf8_offset_to_pointer(b->contents, offs);
- memmove(b->contents, p, strlen(p)+1);
-}
-
-
-/* Character offsets */
-void sc_delete_text(SCBlock *b1, int o1, SCBlock *b2, int o2)
-{
- if ( b1 == b2 ) {
- delete_from_block(b1, o1, o2);
- } else if ( b2 == b1->next ) {
- delete_to_end(b1, o1);
- delete_from_start(b2, o2);
- } else {
- delete_to_end(b1, o1);
- delete_from_start(b2, o2);
- b1->next = b2;
- SCBlock *de = b1->next;
- while ( de != b2 ) {
- SCBlock *denext = de->next;
- sc_block_free(de);
- de = denext;
- }
- }
-}
-
-
/* Create a deep copy of "bl", including all its children */
SCBlock *sc_block_copy(const SCBlock *bl)
{
diff --git a/src/sc_parse.h b/src/sc_parse.h
index c9150eb..2d8b0d7 100644
--- a/src/sc_parse.h
+++ b/src/sc_parse.h
@@ -65,7 +65,6 @@ extern void sc_block_set_options(SCBlock *bl, char *opt);
extern void sc_block_set_contents(SCBlock *bl, char *con);
extern void sc_insert_text(SCBlock *b1, size_t o1, const char *t);
extern void sc_insert_block(SCBlock *b1, int o1, SCBlock *ins);
-extern void sc_delete_text(SCBlock *b1, int o1, SCBlock *b2, int o2);
extern SCBlock *sc_block_split(SCBlock *bl, size_t pos);
extern void show_sc_blocks(const SCBlock *bl);