changeset 2109:86cc8fe82da0

Enabled CTRL+{a,e,d,k} in search dialog (for start,end,del,cut)
author Jorge Arellano Cid <jcid@dillo.org>
date Mo, 27 Jun 2011 21:01:21 -0400
parents 67e81478d275
children eabfdc600c31
files src/dialog.cc
diffstat 1 files changed, 46 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/dialog.cc	Mo Jun 27 20:31:29 2011 -0400
+++ b/src/dialog.cc	Mo Jun 27 21:01:21 2011 -0400
@@ -37,6 +37,48 @@
 
 
 /*
+ * Local sub classes
+ */
+
+//----------------------------------------------------------------------------
+/*
+ * Used to enable CTRL+{a,e,d,k} in search dialog (for start,end,del,cut)
+ * TODO: bind down arrow to a search engine selection list.
+ */
+class CustInput3 : public Fl_Input {
+public:
+   CustInput3 (int x, int y, int w, int h, const char* l=0) :
+      Fl_Input(x,y,w,h,l) {};
+   int handle(int e);
+};
+
+int CustInput3::handle(int e)
+{
+   int k = Fl::event_key();
+
+   _MSG("CustInput3::handle event=%d\n", e);
+
+   // We're only interested in some flags
+   unsigned modifier = Fl::event_state() & (FL_SHIFT | FL_CTRL | FL_ALT);
+
+   if (e == FL_KEYBOARD && modifier == FL_CTRL) {
+      if (k == 'a' || k == 'e') {
+         position(k == 'a' ? 0 : size());
+         return 1;
+      } else if (k == 'k') {
+         cut(position(), size());
+         return 1;
+      } else if (k == 'd') {
+         cut(position(), position()+1);
+         return 1;
+      }
+   }
+   return Fl_Input::handle(e);
+}
+//----------------------------------------------------------------------------
+
+
+/*
  * Display a message in a popup window.
  */
 void a_Dialog_msg(const char *msg)
@@ -88,9 +130,9 @@
     box->labelsize(14);
     box->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_CLIP|FL_ALIGN_WRAP);
 
-    Fl_Input *input_wid = new Fl_Input(ih+2*gap,gap+ih/2+gap,ww-(ih+3*gap),24);
-    input_wid->labelsize(14);
-    input_wid->textsize(14);
+    CustInput3 *c_inp = new CustInput3(ih+2*gap,gap+ih/2+gap,ww-(ih+3*gap),24);
+    c_inp->labelsize(14);
+    c_inp->textsize(14);
 
     int xpos = ww-2*(gap+bw), ypos = ih+3*gap;
     Fl_Return_Button *rb = new Fl_Return_Button(xpos, ypos, bw, bh, "OK");
@@ -113,7 +155,7 @@
    if (input_answer == 1) {
       /* we have a string, save it */
       dFree(input_str);
-      input_str = dStrdup(input_wid->value());
+      input_str = dStrdup(c_inp->value());
    }
    delete window;