From c708f5e283a9093801e4bea4b00d503a3b10c2f1 Mon Sep 17 00:00:00 2001 From: corvid Date: Tue, 22 Jan 2013 19:53:17 +0000 Subject: 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". --- dw/fltkui.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'dw/fltkui.cc') 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 (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; } -- cgit v1.2.3