From ef1fb4982425a8df33850570348cb7d23f62d041 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Fri, 27 May 2011 21:38:08 +0200 Subject: Position caret with mouse click --- src/objects.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/objects.c') 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); -- cgit v1.2.3