aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.me.uk>2019-08-19 08:14:31 +0200
committerThomas White <taw@bitwiz.me.uk>2019-08-19 08:14:31 +0200
commit93550c8bee5e3c914b5c5a1b5993d40f0033d117 (patch)
tree1e04a225009c7c0f043d2a2985a632520875e330
parent16daa2c43091242b142074405e0beeff16d2b133 (diff)
WIPtmp
-rw-r--r--data/demo.sc9
-rw-r--r--libstorycode/gtk/gtknarrativeview.c5
-rw-r--r--libstorycode/gtk/gtkslideview.c4
-rw-r--r--libstorycode/narrative_render_cairo.c28
-rw-r--r--libstorycode/narrative_render_cairo.h4
5 files changed, 43 insertions, 7 deletions
diff --git a/data/demo.sc b/data/demo.sc
index f133b0c..8514e68 100644
--- a/data/demo.sc
+++ b/data/demo.sc
@@ -51,8 +51,8 @@ STYLES {
PRESTITLE: Hi there, welcome to Colloquium!
-: It looks like this is the first time you've used Colloquium. Keep reading to understand a little bit about how Colloquium works and how to use it.
-: Colloquium works differently to other presentation programs. Colloquium makes /narrative, not slides,/ the centre of attention. Slides come when you need to illustrate something. This window is called the /narrative editor/. Your slides are embedded into the narrative text, like this:
+: It _looks_ like this is the first time you've used Colloquium. Keep reading to understand a little bit about how Colloquium works and how to use it.
+: Colloquium works *differently* to other presentation programs. Colloquium makes /narrative, not slides,/ the centre of attention. Slides _come when you need to illustrate_ something. This window is called the /narrative editor/. Your slides are embedded into the narrative text, like this:
SLIDE {
PRESTITLE: Welcome to Colloquium
IMAGE[506.3ux520.3u+244.5u+141.3u]: colloquium.svg
@@ -95,4 +95,7 @@ SLIDE {
}
: That's enough to get you started. I hope you enjoy using Colloquium!
ENDOFPRESENTATION
-: You can also have "bonus material", not included in your presentation's timing.
+: ... by the way, anything after the "End of presentation" marker will not be included in your presentation's timing. This is where you should put "bonus material", perhaps to be referred to when answering questions after your talk.
+SLIDE {
+ SLIDETITLE: Bonus slide #1
+}
diff --git a/libstorycode/gtk/gtknarrativeview.c b/libstorycode/gtk/gtknarrativeview.c
index 83d6d23..82dd138 100644
--- a/libstorycode/gtk/gtknarrativeview.c
+++ b/libstorycode/gtk/gtknarrativeview.c
@@ -885,6 +885,11 @@ static int find_cursor(Narrative *n, double x, double y, struct edit_pos *pos)
pango_units_from_double(y - n->space_t - para_top(n, pos->para)),
&pos->pos, &pos->trail);
+ /* pos->pos is the byte index into item->layout_text */
+ //printf("click pos = %i\n", pos->pos);
+ //pos->pos = index_before_removal(item->chars_removed, item->n_chars_removed, pos->pos);
+ //printf("after adjustment: %i\n", pos->pos);
+
return 0;
}
diff --git a/libstorycode/gtk/gtkslideview.c b/libstorycode/gtk/gtkslideview.c
index 9766572..0ec1c5f 100644
--- a/libstorycode/gtk/gtkslideview.c
+++ b/libstorycode/gtk/gtkslideview.c
@@ -570,8 +570,8 @@ static int find_cursor(SlideItem *item, Stylesheet *stylesheet,
pos->para = i-1;
pango_layout_xy_to_index(item->paras[i-1].layout,
- pango_units_from_double(x),
- pango_units_from_double(y - top),
+ pango_units_from_double(x - padl),
+ pango_units_from_double(y - top - padt),
&pos->pos, &pos->trail);
return 0;
}
diff --git a/libstorycode/narrative_render_cairo.c b/libstorycode/narrative_render_cairo.c
index 17f22aa..b001132 100644
--- a/libstorycode/narrative_render_cairo.c
+++ b/libstorycode/narrative_render_cairo.c
@@ -146,7 +146,7 @@ int index_with_removal(int *chars_removed, int n_chars_removed, int idx)
int i;
for ( i=0; i<n_chars_removed; i++ ) {
- if ( chars_removed[i] > idx ) break;
+ if ( chars_removed[i] >= idx ) break;
}
return idx - i;
@@ -172,6 +172,8 @@ static void process_tags(struct narrative_item *item, PangoAttrList *attrs)
int i, j, k;
size_t len;
+ printf("Processing '%s'\n", item->text);
+
item->n_chars_removed = 0;
free(item->chars_removed);
item->chars_removed = NULL;
@@ -205,9 +207,26 @@ static void process_tags(struct narrative_item *item, PangoAttrList *attrs)
text = g_utf8_find_next_char(efend, NULL);
}
+ printf("Found %i ranges:\n", n_add);
+ for ( i=0; i<n_add; i++ ) {
+ printf("%c : %i - %i\n", add[i].type, add[i].start, add[i].end);
+ }
+
+ printf("%i characters to remove: ", item->n_chars_removed);
+ for ( i=0; i<item->n_chars_removed; i++ ) {
+ printf("%i ", item->chars_removed[i]);
+ }
+ printf("\n");
+
/* Sort the list of removed characters */
qsort(item->chars_removed, item->n_chars_removed, sizeof(int), cmpi);
+ printf("Sorted: ");
+ for ( i=0; i<item->n_chars_removed; i++ ) {
+ printf("%i ", item->chars_removed[i]);
+ }
+ printf("\n");
+
/* Go through the list of attributes, and correct the character ranges
* so that they refer to the text with characters removed, and add them
* to the PangoAttrList */
@@ -235,10 +254,13 @@ static void process_tags(struct narrative_item *item, PangoAttrList *attrs)
attr->end_index = index_with_removal(item->chars_removed,
item->n_chars_removed,
- add[i].end) + 1;
+ add[i].end);
pango_attr_list_insert(attrs, attr);
+ printf("Adding %c with indices %i - %i\n",
+ add[i].type, attr->start_index, attr->end_index);
+
}
/* Create the version of the text with characters removed */
@@ -258,6 +280,8 @@ static void process_tags(struct narrative_item *item, PangoAttrList *attrs)
}
}
+ printf("The edited text: '%s'\n", item->layout_text);
+
free(add);
}
diff --git a/libstorycode/narrative_render_cairo.h b/libstorycode/narrative_render_cairo.h
index c62d2e9..635cfed 100644
--- a/libstorycode/narrative_render_cairo.h
+++ b/libstorycode/narrative_render_cairo.h
@@ -51,4 +51,8 @@ extern int narrative_render_item_cairo(Narrative*n, cairo_t *cr, int i);
extern int narrative_render_cairo(Narrative *n, cairo_t *cr,
Stylesheet *stylesheet);
+extern int index_with_removal(int *chars_removed, int n_chars_removed, int idx);
+
+extern int index_before_removal(int *chars_removed, int n_chars_removed, int idx);
+
#endif /* NARRATIVE_RENDER_CAIRO_H */