One more small text space usability: select work by double-click on it
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 17 Feb 2011 19:26:59 +0000 (19:26 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 17 Feb 2011 19:26:59 +0000 (19:26 +0000)
- Change cursor changing from mouse press to mouse click. A bit "delayed"
  UI feedback, but otherwise we'll be unable to use double-click events here
- Change clinebacks to callbacks in comment for select_line operator.
  Or it was supposed to be clinebacks?

source/blender/editors/space_text/space_text.c
source/blender/editors/space_text/text_intern.h
source/blender/editors/space_text/text_ops.c

index c5a0edaed8dcfb4ebcd3656d188c9ddbb3701735..85b9f1b68e61bd0162283e17ab43a11f816f38a3 100644 (file)
@@ -186,6 +186,7 @@ static void text_operatortypes(void)
 
        WM_operatortype_append(TEXT_OT_select_line);
        WM_operatortype_append(TEXT_OT_select_all);
+       WM_operatortype_append(TEXT_OT_select_word);
 
        WM_operatortype_append(TEXT_OT_jump);
        WM_operatortype_append(TEXT_OT_move);
@@ -296,6 +297,7 @@ static void text_keymap(struct wmKeyConfig *keyconf)
 
        WM_keymap_add_item(keymap, "TEXT_OT_select_all", AKEY, KM_PRESS, KM_CTRL, 0);
        WM_keymap_add_item(keymap, "TEXT_OT_select_line", AKEY, KM_PRESS, KM_SHIFT|KM_CTRL, 0);
+       WM_keymap_add_item(keymap, "TEXT_OT_select_word", LEFTMOUSE, KM_DBL_CLICK, 0, 0);
        
 
        WM_keymap_add_item(keymap, "TEXT_OT_indent", TABKEY, KM_PRESS, 0, 0);
@@ -343,7 +345,7 @@ static void text_keymap(struct wmKeyConfig *keyconf)
        WM_keymap_add_item(keymap, "TEXT_OT_scroll", MOUSEPAN, 0, 0, 0);
        WM_keymap_add_item(keymap, "TEXT_OT_scroll_bar", EVT_TWEAK_L, KM_ANY, 0, 0);
        WM_keymap_add_item(keymap, "TEXT_OT_selection_set", EVT_TWEAK_L, KM_ANY, 0, 0);
-       WM_keymap_add_item(keymap, "TEXT_OT_cursor_set", LEFTMOUSE, KM_PRESS, 0, 0);
+       WM_keymap_add_item(keymap, "TEXT_OT_cursor_set", LEFTMOUSE, KM_CLICK, 0, 0);
        RNA_boolean_set(WM_keymap_add_item(keymap, "TEXT_OT_selection_set", LEFTMOUSE, KM_PRESS, KM_SHIFT, 0)->ptr, "select", 1);
        RNA_int_set(WM_keymap_add_item(keymap, "TEXT_OT_scroll", WHEELUPMOUSE, KM_PRESS, 0, 0)->ptr, "lines", -1);
        RNA_int_set(WM_keymap_add_item(keymap, "TEXT_OT_scroll", WHEELDOWNMOUSE, KM_PRESS, 0, 0)->ptr, "lines", 1);
index 7311ac37634ee8276194dfdf0ac1a7ee2d3ce57f..f18a3245f9b447c395dcccb5e3c44db748914298 100644 (file)
@@ -133,6 +133,7 @@ void TEXT_OT_previous_marker(struct wmOperatorType *ot);
 
 void TEXT_OT_select_line(struct wmOperatorType *ot);
 void TEXT_OT_select_all(struct wmOperatorType *ot);
+void TEXT_OT_select_word(struct wmOperatorType *ot);
 
 void TEXT_OT_jump(struct wmOperatorType *ot);
 void TEXT_OT_move(struct wmOperatorType *ot);
index 4294be121eac0d2172108c5a21bd2d9e11c8b5b6..55f560e6b3d896030b0c46aa81df41bb7cc91a3d 100644 (file)
@@ -1229,11 +1229,38 @@ void TEXT_OT_select_line(wmOperatorType *ot)
        ot->idname= "TEXT_OT_select_line";
        ot->description= "Select text by line";
        
-       /* api clinebacks */
+       /* api callbacks */
        ot->exec= select_line_exec;
        ot->poll= text_edit_poll;
 }
 
+/******************* select word operator *********************/
+
+static int select_word_exec(bContext *C, wmOperator *UNUSED(op))
+{
+       Text *text= CTX_data_edit_text(C);
+
+       txt_jump_left(text, 0);
+       txt_jump_right(text, 1);
+
+       text_update_cursor_moved(C);
+       WM_event_add_notifier(C, NC_TEXT|NA_EDITED, text);
+
+       return OPERATOR_FINISHED;
+}
+
+void TEXT_OT_select_word(wmOperatorType *ot)
+{
+       /* identifiers */
+       ot->name= "Select Word";
+       ot->idname= "TEXT_OT_select_word";
+       ot->description= "Select word under cursor";
+
+       /* api callbacks */
+       ot->exec= select_word_exec;
+       ot->poll= text_edit_poll;
+}
+
 /******************* previous marker operator *********************/
 
 static int previous_marker_exec(bContext *C, wmOperator *UNUSED(op))