diff options
author | Thomas White <taw@bitwiz.org.uk> | 2011-05-27 21:38:08 +0200 |
---|---|---|
committer | Thomas White <taw@bitwiz.org.uk> | 2011-05-27 21:38:08 +0200 |
commit | ef1fb4982425a8df33850570348cb7d23f62d041 (patch) | |
tree | ab897013d27f598cff8a2e420816a4e01b576e45 /src/objects.c | |
parent | ee6e029d5437146ea7edede591f4aaa8e4756379 (diff) |
Position caret with mouse click
Diffstat (limited to 'src/objects.c')
-rw-r--r-- | src/objects.c | 18 |
1 files changed, 18 insertions, 0 deletions
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); |