diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-02-17 22:26:59 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2011-02-17 22:26:59 +0300 |
commit | 8bd04b4c6dae4dad2fa8142004860db564597ab2 (patch) | |
tree | eea0f2a0968ce8d0d321b0f289cdd542dcf43e5c /source | |
parent | 10601a70d52d8af3542c0d944ba6842162c52fdb (diff) |
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?
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/space_text/space_text.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_intern.h | 1 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_ops.c | 29 |
3 files changed, 32 insertions, 2 deletions
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c index c5a0edaed8d..85b9f1b68e6 100644 --- a/source/blender/editors/space_text/space_text.c +++ b/source/blender/editors/space_text/space_text.c @@ -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); diff --git a/source/blender/editors/space_text/text_intern.h b/source/blender/editors/space_text/text_intern.h index 7311ac37634..f18a3245f9b 100644 --- a/source/blender/editors/space_text/text_intern.h +++ b/source/blender/editors/space_text/text_intern.h @@ -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); diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 4294be121ea..55f560e6b3d 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -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)) |