aboutsummaryrefslogtreecommitdiff
path: root/libstorycode/narrative.c
diff options
context:
space:
mode:
Diffstat (limited to 'libstorycode/narrative.c')
-rw-r--r--libstorycode/narrative.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/libstorycode/narrative.c b/libstorycode/narrative.c
index 3bf85f5..08c19d3 100644
--- a/libstorycode/narrative.c
+++ b/libstorycode/narrative.c
@@ -406,6 +406,23 @@ void narrative_delete_block(Narrative *n, int i1, size_t o1, int i2, size_t o2)
}
+int which_run(struct narrative_item *item, size_t item_offs, size_t *run_offs)
+{
+ int run;
+ size_t pos = 0;
+
+ for ( run=0; run<item->n_runs; run++ ) {
+ size_t npos = pos + strlen(item->runs[run].text);
+ if ( npos >= item_offs ) break;
+ pos = npos;
+ }
+ if ( run_offs != NULL ) {
+ *run_offs = item_offs - pos;
+ }
+ return run;
+}
+
+
void narrative_split_item(Narrative *n, int i1, size_t o1)
{
/* FIXME! */