From 466bbb68dc798353d847ba60aaaf2ae8c2ba3254 Mon Sep 17 00:00:00 2001 From: bulia byak Date: Mon, 16 Feb 2009 00:23:40 +0000 Subject: utilities for getting style at cursor, placing cursor at iterator or coordinates, getting cursor iterator; display char count when editing in text tool (bzr r7299) --- src/text-editing.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/text-editing.cpp') diff --git a/src/text-editing.cpp b/src/text-editing.cpp index 2ccc91195..5b9db13d4 100644 --- a/src/text-editing.cpp +++ b/src/text-editing.cpp @@ -109,6 +109,14 @@ sp_te_get_cursor_coords (SPItem const *item, Inkscape::Text::Layout::iterator co } SPStyle const * sp_te_style_at_position(SPItem const *text, Inkscape::Text::Layout::iterator const &position) +{ + SPObject const *pos_obj = sp_te_object_at_position(text, position); + if (pos_obj) + return SP_OBJECT_STYLE(pos_obj); + return NULL; +} + +SPObject const * sp_te_object_at_position(SPItem const *text, Inkscape::Text::Layout::iterator const &position) { Inkscape::Text::Layout const *layout = te_get_layout(text); if (layout == NULL) @@ -119,8 +127,8 @@ SPStyle const * sp_te_style_at_position(SPItem const *text, Inkscape::Text::Layo pos_obj = SP_OBJECT(rawptr); if (pos_obj == 0) pos_obj = text; while (SP_OBJECT_STYLE(pos_obj) == NULL) - pos_obj = SP_OBJECT_PARENT(pos_obj); // SPStrings don't have style - return SP_OBJECT_STYLE(pos_obj); + pos_obj = SP_OBJECT_PARENT(pos_obj); // not interested in SPStrings + return pos_obj; } /* -- cgit v1.2.3