Code

finally getting closer to processing axes and contexts correctly
[inkscape.git] / src / text-context.cpp
index 641d8bce29b7619fd73aad57ded7b736e09138c3..1185e08ef6053fcb593f15bf29d0d328bc2a0d31 100644 (file)
@@ -39,7 +39,9 @@
 #include "message-stack.h"
 #include "message-context.h"
 #include "pixmaps/cursor-text.xpm"
+#include "pixmaps/cursor-text.pixbuf"
 #include "pixmaps/cursor-text-insert.xpm"
+#include "pixmaps/cursor-text-insert.pixbuf"
 #include <glibmm/i18n.h>
 #include "object-edit.h"
 #include "xml/repr.h"
@@ -48,6 +50,7 @@
 #include "rubberband.h"
 #include "sp-metrics.h"
 #include "context-fns.h"
+#include "verbs.h"
 
 #include "text-editing.h"
 
@@ -122,6 +125,11 @@ sp_text_context_init(SPTextContext *tc)
     SPEventContext *event_context = SP_EVENT_CONTEXT(tc);
 
     event_context->cursor_shape = cursor_text_xpm;
+    event_context->cursor_pixbuf = gdk_pixbuf_new_from_inline(
+            -1,
+            cursor_text_pixbuf,
+            FALSE,
+            NULL);  
     event_context->hot_x = 7;
     event_context->hot_y = 7;
 
@@ -438,6 +446,11 @@ sp_text_context_item_handler(SPEventContext *ec, SPItem *item, GdkEvent *event)
                 SP_CTRLRECT(tc->indicator)->setRectangle(sp_item_bbox_desktop(item_ungrouped));
 
                 ec->cursor_shape = cursor_text_insert_xpm;
+                ec->cursor_pixbuf = gdk_pixbuf_new_from_inline(
+                        -1,
+                        cursor_text_insert_pixbuf,
+                        FALSE,
+                        NULL);  
                 ec->hot_x = 7;
                 ec->hot_y = 10;
                 sp_event_context_update_cursor(ec);
@@ -498,7 +511,8 @@ sp_text_context_setup_text(SPTextContext *tc)
     Inkscape::GC::release(rtext);
     text_item->transform = SP_ITEM(ec->desktop->currentRoot())->getRelativeTransform(ec->desktop->currentLayer());
     text_item->updateRepr();
-    sp_document_done(sp_desktop_document(ec->desktop));
+    sp_document_done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, 
+                     /* TODO: annotate */ "text-context.cpp:515");
 }
 
 /**
@@ -536,7 +550,8 @@ insert_uni_char(SPTextContext *const tc)
         tc->text_sel_start = tc->text_sel_end = sp_te_replace(tc->text, tc->text_sel_start, tc->text_sel_end, u);
         sp_text_context_update_cursor(tc);
         sp_text_context_update_text_selection(tc);
-        sp_document_done(sp_desktop_document(tc->desktop));
+        sp_document_done(sp_desktop_document(tc->desktop), SP_VERB_DIALOG_TRANSFORM, 
+                         /* TODO: annotate */ "text-context.cpp:554");
     }
 }
 
@@ -624,6 +639,11 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event)
                 tc->over_text = 0;
                 // update cursor and statusbar: we are not over a text object now
                 ec->cursor_shape = cursor_text_xpm;
+                ec->cursor_pixbuf = gdk_pixbuf_new_from_inline(
+                        -1,
+                        cursor_text_pixbuf,
+                        FALSE,
+                        NULL);  
                 ec->hot_x = 7;
                 ec->hot_y = 7;
                 sp_event_context_update_cursor(ec);
@@ -694,7 +714,8 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event)
                         SPItem *ft = create_flowtext_with_internal_frame (desktop, tc->p0, p1);
                         sp_desktop_selection(desktop)->set(ft);
                         ec->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Flowed text is created."));
-                        sp_document_done(sp_desktop_document(desktop));
+                        sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT, 
+                                         /* TODO: annotate */ "text-context.cpp:718");
                     } else {
                         ec->desktop->messageStack()->flash(Inkscape::ERROR_MESSAGE, _("The frame is <b>too small</b> for the current font size. Flowed text not created."));
                     }
@@ -805,6 +826,13 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event)
 
                         /* Neither unimode nor IM consumed key; process text tool shortcuts */
                         switch (group0_keyval) {
+                            case GDK_x:
+                            case GDK_X:
+                                if (MOD__ALT_ONLY) {
+                                    desktop->setToolboxFocusTo ("altx-text");
+                                    return TRUE;
+                                }
+                                break;
                             case GDK_space:
                                 if (MOD__CTRL_ONLY) {
                                     /* No-break space */
@@ -816,7 +844,8 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event)
                                     sp_text_context_update_cursor(tc);
                                     sp_text_context_update_text_selection(tc);
                                     ec->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("No-break space"));
-                                    sp_document_done(sp_desktop_document(ec->desktop));
+                                    sp_document_done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, 
+                                                     /* TODO: annotate */ "text-context.cpp:848");
                                     return TRUE;
                                 }
                                 break;
@@ -852,7 +881,8 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event)
                                         sp_repr_css_set_property(css, "font-weight", "normal");
                                     sp_te_apply_style(tc->text, tc->text_sel_start, tc->text_sel_end, css);
                                     sp_repr_css_attr_unref(css);
-                                    sp_document_done(sp_desktop_document(ec->desktop));
+                                    sp_document_done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, 
+                                                     /* TODO: annotate */ "text-context.cpp:885");
                                     sp_text_context_update_cursor(tc);
                                     sp_text_context_update_text_selection(tc);
                                     return TRUE;
@@ -869,7 +899,8 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event)
                                         sp_repr_css_set_property(css, "font-style", "normal");
                                     sp_te_apply_style(tc->text, tc->text_sel_start, tc->text_sel_end, css);
                                     sp_repr_css_attr_unref(css);
-                                    sp_document_done(sp_desktop_document(ec->desktop));
+                                    sp_document_done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, 
+                                                     /* TODO: annotate */ "text-context.cpp:903");
                                     sp_text_context_update_cursor(tc);
                                     sp_text_context_update_text_selection(tc);
                                     return TRUE;
@@ -900,7 +931,8 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event)
                                 tc->text_sel_start = tc->text_sel_end = sp_te_insert_line(tc->text, tc->text_sel_start);
                                 sp_text_context_update_cursor(tc);
                                 sp_text_context_update_text_selection(tc);
-                                sp_document_done(sp_desktop_document(ec->desktop));
+                                sp_document_done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, 
+                                                 /* TODO: annotate */ "text-context.cpp:935");
                                 return TRUE;
                             case GDK_BackSpace:
                                 if (tc->text) { // if nascent_object, do nothing, but return TRUE; same for all other delete and move keys
@@ -909,7 +941,8 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event)
                                     tc->text_sel_start = tc->text_sel_end = sp_te_delete(tc->text, tc->text_sel_start, tc->text_sel_end);
                                     sp_text_context_update_cursor(tc);
                                     sp_text_context_update_text_selection(tc);
-                                    sp_document_done(sp_desktop_document(ec->desktop));
+                                    sp_document_done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, 
+                                                     /* TODO: annotate */ "text-context.cpp:945");
                                 }
                                 return TRUE;
                             case GDK_Delete:
@@ -920,7 +953,8 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event)
                                     tc->text_sel_start = tc->text_sel_end = sp_te_delete(tc->text, tc->text_sel_start, tc->text_sel_end);
                                     sp_text_context_update_cursor(tc);
                                     sp_text_context_update_text_selection(tc);
-                                    sp_document_done(sp_desktop_document(ec->desktop));
+                                    sp_document_done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, 
+                                                     /* TODO: annotate */ "text-context.cpp:957");
                                 }
                                 return TRUE;
                             case GDK_Left:
@@ -934,7 +968,8 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event)
                                             sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, ec->desktop, NR::Point(-1, 0));
                                         sp_text_context_update_cursor(tc);
                                         sp_text_context_update_text_selection(tc);
-                                        sp_document_maybe_done(sp_desktop_document(ec->desktop), "kern:left");
+                                        sp_document_maybe_done(sp_desktop_document(ec->desktop), "kern:left", SP_VERB_CONTEXT_TEXT, 
+                                                               /* TODO: annotate */ "text-context.cpp:972");
                                     } else {
                                         cursor_movement_operator = MOD__CTRL ? &Inkscape::Text::Layout::iterator::cursorLeftWithControl
                                                                              : &Inkscape::Text::Layout::iterator::cursorLeft;
@@ -953,7 +988,8 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event)
                                             sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, ec->desktop, NR::Point(1, 0));
                                         sp_text_context_update_cursor(tc);
                                         sp_text_context_update_text_selection(tc);
-                                        sp_document_maybe_done(sp_desktop_document(ec->desktop), "kern:right");
+                                        sp_document_maybe_done(sp_desktop_document(ec->desktop), "kern:right", SP_VERB_CONTEXT_TEXT, 
+                                                               /* TODO: annotate */ "text-context.cpp:992");
                                     } else {
                                         cursor_movement_operator = MOD__CTRL ? &Inkscape::Text::Layout::iterator::cursorRightWithControl
                                                                              : &Inkscape::Text::Layout::iterator::cursorRight;
@@ -972,7 +1008,9 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event)
                                             sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, ec->desktop, NR::Point(0, -1));
                                         sp_text_context_update_cursor(tc);
                                         sp_text_context_update_text_selection(tc);
-                                        sp_document_maybe_done(sp_desktop_document(ec->desktop), "kern:up");
+                                        sp_document_maybe_done(sp_desktop_document(ec->desktop), "kern:up", SP_VERB_CONTEXT_TEXT, 
+                                                               /* TODO: annotate */ "text-context.cpp:1012");
+
                                     } else {
                                         cursor_movement_operator = MOD__CTRL ? &Inkscape::Text::Layout::iterator::cursorUpWithControl
                                                                              : &Inkscape::Text::Layout::iterator::cursorUp;
@@ -991,7 +1029,9 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event)
                                             sp_te_adjust_kerning_screen(tc->text, tc->text_sel_start, tc->text_sel_end, ec->desktop, NR::Point(0, 1));
                                         sp_text_context_update_cursor(tc);
                                         sp_text_context_update_text_selection(tc);
-                                        sp_document_maybe_done(sp_desktop_document(ec->desktop), "kern:down");
+                                        sp_document_maybe_done(sp_desktop_document(ec->desktop), "kern:down", SP_VERB_CONTEXT_TEXT, 
+                                                               /* TODO: annotate */ "text-context.cpp:1033");
+
                                     } else {
                                         cursor_movement_operator = MOD__CTRL ? &Inkscape::Text::Layout::iterator::cursorDownWithControl
                                                                              : &Inkscape::Text::Layout::iterator::cursorDown;
@@ -1045,7 +1085,8 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event)
                                         } else {
                                             sp_te_adjust_rotation(tc->text, tc->text_sel_start, tc->text_sel_end, ec->desktop, -90);
                                         }
-                                        sp_document_maybe_done(sp_desktop_document(ec->desktop), "textrot:ccw");
+                                        sp_document_maybe_done(sp_desktop_document(ec->desktop), "textrot:ccw", SP_VERB_CONTEXT_TEXT, 
+                                                               /* TODO: annotate */ "text-context.cpp:1089");
                                         sp_text_context_update_cursor(tc);
                                         sp_text_context_update_text_selection(tc);
                                         return TRUE;
@@ -1065,7 +1106,8 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event)
                                         } else {
                                             sp_te_adjust_rotation(tc->text, tc->text_sel_start, tc->text_sel_end, ec->desktop, 90);
                                         }
-                                        sp_document_maybe_done(sp_desktop_document(ec->desktop), "textrot:cw");
+                                        sp_document_maybe_done(sp_desktop_document(ec->desktop), "textrot:cw", SP_VERB_CONTEXT_TEXT, 
+                                                               /* TODO: annotate */ "text-context.cpp:1110");
                                         sp_text_context_update_cursor(tc);
                                         sp_text_context_update_text_selection(tc);
                                         return TRUE;
@@ -1081,13 +1123,17 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event)
                                                 sp_te_adjust_linespacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, ec->desktop, -10);
                                             else
                                                 sp_te_adjust_linespacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, ec->desktop, -1);
-                                            sp_document_maybe_done(sp_desktop_document(ec->desktop), "linespacing:dec");
+                                            sp_document_maybe_done(sp_desktop_document(ec->desktop), "linespacing:dec", SP_VERB_CONTEXT_TEXT, 
+                                                                   /* TODO: annotate */ "text-context.cpp:1127");
+
                                         } else {
                                             if (MOD__SHIFT)
                                                 sp_te_adjust_tspan_letterspacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, ec->desktop, -10);
                                             else
                                                 sp_te_adjust_tspan_letterspacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, ec->desktop, -1);
-                                            sp_document_maybe_done(sp_desktop_document(ec->desktop), "letterspacing:dec");
+                                            sp_document_maybe_done(sp_desktop_document(ec->desktop), "letterspacing:dec", SP_VERB_CONTEXT_TEXT, 
+                                                                   /* TODO: annotate */ "text-context.cpp:1135");
+
                                         }
                                         sp_text_context_update_cursor(tc);
                                         sp_text_context_update_text_selection(tc);
@@ -1104,13 +1150,17 @@ sp_text_context_root_handler(SPEventContext *const ec, GdkEvent *const event)
                                                 sp_te_adjust_linespacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, ec->desktop, 10);
                                             else
                                                 sp_te_adjust_linespacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, ec->desktop, 1);
-                                            sp_document_maybe_done(sp_desktop_document(ec->desktop), "linespacing:inc");
+                                            sp_document_maybe_done(sp_desktop_document(ec->desktop), "linespacing:inc", SP_VERB_CONTEXT_TEXT, 
+                                                                   /* TODO: annotate */ "text-context.cpp:1154");
+
                                         } else {
                                             if (MOD__SHIFT)
                                                 sp_te_adjust_tspan_letterspacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, ec->desktop, 10);
                                             else
                                                 sp_te_adjust_tspan_letterspacing_screen(tc->text, tc->text_sel_start, tc->text_sel_end, ec->desktop, 1);
-                                            sp_document_maybe_done(sp_desktop_document(ec->desktop), "letterspacing:inc");
+                                            sp_document_maybe_done(sp_desktop_document(ec->desktop), "letterspacing:inc", SP_VERB_CONTEXT_TEXT, 
+                                                                   /* TODO: annotate */ "text-context.cpp:1162");
+
                                         }
                                         sp_text_context_update_cursor(tc);
                                         sp_text_context_update_text_selection(tc);
@@ -1212,7 +1262,8 @@ sp_text_paste_inline(SPEventContext *ec)
                 tc->text_sel_start = tc->text_sel_end = sp_te_insert_line(tc->text, tc->text_sel_start);
                 begin = end + 1;
             }
-            sp_document_done(sp_desktop_document(ec->desktop));
+            sp_document_done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT, 
+                             /* TODO: annotate */ "text-context.cpp:1266");
 
             return true;
         }
@@ -1325,7 +1376,8 @@ sp_text_context_style_set(SPCSSAttr const *css, SPTextContext *tc)
         return false;    // will get picked up by the parent and applied to the whole text object
 
     sp_te_apply_style(tc->text, tc->text_sel_start, tc->text_sel_end, css);
-    sp_document_done(sp_desktop_document(tc->desktop));
+    sp_document_done(sp_desktop_document(tc->desktop), SP_VERB_CONTEXT_TEXT, 
+                     /* TODO: annotate */ "text-context.cpp:1380");
     sp_text_context_update_cursor(tc);
     sp_text_context_update_text_selection(tc);
 
@@ -1356,9 +1408,11 @@ sp_text_context_style_query(SPStyle *style, int property, SPTextContext *tc)
         if (!begin_it.prevCharacter())
             end_it.nextCharacter();
     for (Inkscape::Text::Layout::iterator it = begin_it ; it < end_it ; it.nextStartOfSpan()) {
-        SPObject const *pos_obj = NULL;
-        layout->getSourceOfCharacter(it, (void**)&pos_obj);
-        if (pos_obj == NULL) continue;
+        SPObject const *pos_obj = 0;
+        void *rawptr = 0;
+        layout->getSourceOfCharacter(it, &rawptr);
+        pos_obj = SP_OBJECT(rawptr);
+        if (pos_obj == 0) continue;
         while (SP_OBJECT_STYLE(pos_obj) == NULL && SP_OBJECT_PARENT(pos_obj))
             pos_obj = SP_OBJECT_PARENT(pos_obj);   // SPStrings don't have style
         styles_list = g_slist_prepend(styles_list, (gpointer)pos_obj);
@@ -1521,7 +1575,8 @@ sptc_commit(GtkIMContext *imc, gchar *string, SPTextContext *tc)
     sp_text_context_update_cursor(tc);
     sp_text_context_update_text_selection(tc);
 
-    sp_document_done(SP_OBJECT_DOCUMENT(tc->text));
+    sp_document_done(SP_OBJECT_DOCUMENT(tc->text), SP_VERB_CONTEXT_TEXT, 
+                     /* TODO: annotate */ "text-context.cpp:1579");
 }