textarea key bindings
"corvid" <[email protected]>
| Newsgroups | gmane.comp.web.dillo.devel |
|---|---|
| Message-ID | <20121227052627.GA14922@local> |
In bug 1112, Alexander asked for ctrl-backspace to work a word at a time. I put together the attached and he reports that it's working well. _______________________________________________ Dillo-dev mailing list [email protected] http://lists.auriga.wearlab.de/cgi-bin/mailman/listinfo/dillo-dev
editor_backspace_word.diff
(text/plain, 1.2 KB)
diff -r 26a45f03421b dw/fltkui.cc
--- a/dw/fltkui.cc Mon Dec 24 16:44:55 2012 +0000
+++ b/dw/fltkui.cc Mon Dec 24 23:49:30 2012 +0000
@@ -689,6 +689,19 @@
// ----------------------------------------------------------------------
+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)
@@ -730,6 +743,9 @@
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;
}