diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mainwindow.c | 1 | ||||
-rw-r--r-- | src/objects.c | 18 | ||||
-rw-r--r-- | src/objects.h | 1 |
3 files changed, 20 insertions, 0 deletions
diff --git a/src/mainwindow.c b/src/mainwindow.c index 63b78f7..64d854e 100644 --- a/src/mainwindow.c +++ b/src/mainwindow.c @@ -218,6 +218,7 @@ static gboolean button_press_sig(GtkWidget *da, GdkEventButton *event, x, y); } else { p->editing_object = clicked; + position_caret(clicked, x, y); } } diff --git a/src/objects.c b/src/objects.c index a66c3f5..730515d 100644 --- a/src/objects.c +++ b/src/objects.c @@ -200,6 +200,24 @@ void move_cursor_right(struct object *o) } +void position_caret(struct object *o, double x, double y) +{ + int idx, trail; + int xp, yp; + gboolean v; + + assert(o->type == TEXT); + + xp = (x - o->x)*PANGO_SCALE; + yp = (y - o->y)*PANGO_SCALE; + + v = pango_layout_xy_to_index(o->layout, xp, yp, &idx, &trail); + printf("%i %i %i %i %i\n", v, xp, yp, idx, trail); + + o->insertion_point = idx+trail; +} + + void delete_object(struct object *o) { remove_object_from_slide(o->parent, o); diff --git a/src/objects.h b/src/objects.h index 4decfea..bc65979 100644 --- a/src/objects.h +++ b/src/objects.h @@ -63,6 +63,7 @@ extern void insert_text(struct object *o, char *t); extern void handle_text_backspace(struct object *o); extern void move_cursor_left(struct object *o); extern void move_cursor_right(struct object *o); +extern void position_caret(struct object *o, double x, double y); extern void delete_object(struct object *o); |