[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34939] trunk/blender/source/blender/ editors/space_text: One more small text space usability: select work by double-click on it

Sergey Sharybin g.ulairi at gmail.com
Thu Feb 17 20:26:59 CET 2011


Revision: 34939
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34939
Author:   nazgul
Date:     2011-02-17 19:26:59 +0000 (Thu, 17 Feb 2011)
Log Message:
-----------
One more small text space usability: select work by double-click on it

- 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?

Modified Paths:
--------------
    trunk/blender/source/blender/editors/space_text/space_text.c
    trunk/blender/source/blender/editors/space_text/text_intern.h
    trunk/blender/source/blender/editors/space_text/text_ops.c

Modified: trunk/blender/source/blender/editors/space_text/space_text.c
===================================================================
--- trunk/blender/source/blender/editors/space_text/space_text.c	2011-02-17 19:03:12 UTC (rev 34938)
+++ trunk/blender/source/blender/editors/space_text/space_text.c	2011-02-17 19:26:59 UTC (rev 34939)
@@ -186,6 +186,7 @@
 
 	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 @@
 
 	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 @@
 	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);

Modified: trunk/blender/source/blender/editors/space_text/text_intern.h
===================================================================
--- trunk/blender/source/blender/editors/space_text/text_intern.h	2011-02-17 19:03:12 UTC (rev 34938)
+++ trunk/blender/source/blender/editors/space_text/text_intern.h	2011-02-17 19:26:59 UTC (rev 34939)
@@ -133,6 +133,7 @@
 
 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);

Modified: trunk/blender/source/blender/editors/space_text/text_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_text/text_ops.c	2011-02-17 19:03:12 UTC (rev 34938)
+++ trunk/blender/source/blender/editors/space_text/text_ops.c	2011-02-17 19:26:59 UTC (rev 34939)
@@ -1229,11 +1229,38 @@
 	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))




More information about the Bf-blender-cvs mailing list