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?
This commit is contained in:
Sergey Sharybin
2011-02-17 19:26:59 +00:00
parent 10601a70d5
commit 8bd04b4c6d
3 changed files with 32 additions and 2 deletions

View 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);

View 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);

View 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))