aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2011-05-27 21:38:08 +0200
committerThomas White <taw@bitwiz.org.uk>2011-05-27 21:38:08 +0200
commitef1fb4982425a8df33850570348cb7d23f62d041 (patch)
treeab897013d27f598cff8a2e420816a4e01b576e45 /src
parentee6e029d5437146ea7edede591f4aaa8e4756379 (diff)
Position caret with mouse click
Diffstat (limited to 'src')
-rw-r--r--src/mainwindow.c1
-rw-r--r--src/objects.c18
-rw-r--r--src/objects.h1
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);