diff options
author | corvid <corvid@lavabit.com> | 2013-01-22 19:53:17 +0000 |
---|---|---|
committer | corvid <corvid@lavabit.com> | 2013-01-22 19:53:17 +0000 |
commit | c708f5e283a9093801e4bea4b00d503a3b10c2f1 (patch) | |
tree | 606fcbfa6c123e9df0aa66d9886ad3df89651d14 /dw | |
parent | 6ee418dcdc1a162da26d5bd700c8ad5d7827ae77 (diff) |
In textarea, ctrl-backspace deletes a word.
Alexander asked for this a while back to make the behaviour more
consistent -- it seems that ctrl tends to mean "a word at a time".
Diffstat (limited to 'dw')
-rw-r--r-- | dw/fltkui.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/dw/fltkui.cc b/dw/fltkui.cc index 69473cb9..c25fbf7a 100644 --- a/dw/fltkui.cc +++ b/dw/fltkui.cc @@ -700,6 +700,20 @@ void FltkEntryResource::setMaxLength (int maxlen) // ---------------------------------------------------------------------- +static int kf_backspace_word (int c, Fl_Text_Editor *e) +{ + int p1, p2 = e->insert_position(); + + e->previous_word(); + p1 = e->insert_position(); + e->buffer()->remove(p1, p2); + e->show_insert_position(); + e->set_changed(); + if (e->when() & FL_WHEN_CHANGED) + e->do_callback(); + return 0; +} + FltkMultiLineTextResource::FltkMultiLineTextResource (FltkPlatform *platform, int cols, int rows): FltkSpecificResource <dw::core::ui::MultiLineTextResource> (platform) @@ -741,6 +755,9 @@ Fl_Widget *FltkMultiLineTextResource::createNewWidget (core::Allocation allocation->ascent + allocation->descent); text->wrap_mode(Fl_Text_Display::WRAP_AT_BOUNDS, 0); text->buffer (buffer); + text->remove_key_binding(FL_BackSpace, FL_TEXT_EDITOR_ANY_STATE); + text->add_key_binding(FL_BackSpace, 0, Fl_Text_Editor::kf_backspace); + text->add_key_binding(FL_BackSpace, FL_CTRL, kf_backspace_word); return text; } |