Enlightenment CVS committal

Author  : rbdpngn
Project : e17
Module  : libs/ewl

Dir     : e17/libs/ewl/src


Modified Files:
        ewl_entry.c 


Log Message:
Additional double/triple click selection features from Vincent Torri.
Fixed some inverted logic on the selection mode flag.

===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/ewl/src/ewl_entry.c,v
retrieving revision 1.89
retrieving revision 1.90
diff -u -3 -r1.89 -r1.90
--- ewl_entry.c 24 May 2004 19:25:20 -0000      1.89
+++ ewl_entry.c 25 May 2004 14:22:10 -0000      1.90
@@ -346,7 +346,7 @@
                index = len + 1;
        ewl_cursor_set_base(EWL_CURSOR(e->cursor), index);
 
-       e->in_select_mode = FALSE;
+       e->in_select_mode = TRUE;
 
        ewl_widget_configure(w);
 
@@ -358,6 +358,7 @@
  */
 void ewl_entry_mouse_up_cb(Ewl_Widget * w, void *ev_data, void *user_data)
 {
+       Ewl_Event_Mouse_Down *ev = ev_data;
        Ewl_Entry *e = EWL_ENTRY(w);
 
        DENTER_FUNCTION(DLEVEL_STABLE);
@@ -368,7 +369,7 @@
                e->start_time = 0.0;
        }
 
-       e->in_select_mode = TRUE;
+       e->in_select_mode = (ev->modifiers & EWL_KEY_MODIFIER_SHIFT);
 
        DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
@@ -392,7 +393,7 @@
         * Check for the button pressed state, otherwise, do nothing.
         */
        if (!(ewl_object_has_state(EWL_OBJECT(e), EWL_FLAG_STATE_PRESSED)) || 
-           (e->in_select_mode))
+           !(e->in_select_mode))
                DRETURN(DLEVEL_STABLE);
 
        if (ev->x < CURRENT_X(e->text))
@@ -437,26 +438,61 @@
 void
 ewl_entry_mouse_double_click_cb(Ewl_Widget * w, void *ev_data, void *user_data)
 {
-  Ewl_Event_Mouse_Down *ev;
-  Ewl_Entry      *e;
-  int             len = 0;
-  
-  DENTER_FUNCTION(DLEVEL_STABLE);
-  DCHECK_PARAM_PTR("w", w);
+       Ewl_Event_Mouse_Down *ev;
+       Ewl_Entry            *e;
+       char                 *s;
+       int                   len = 0;
+       int                   bp, index;
   
-  ev = ev_data;
-  e = EWL_ENTRY(w);
+       DENTER_FUNCTION(DLEVEL_STABLE);
+       DCHECK_PARAM_PTR("w", w);
   
-  len = ewl_text_length_get(EWL_TEXT(e->text));
+       ev = ev_data;
+       e = EWL_ENTRY(w);
   
-  ewl_cursor_set_base(EWL_CURSOR(e->cursor), 1);
-  ewl_cursor_select_to(EWL_CURSOR(e->cursor), len);
+       len = ewl_text_length_get(EWL_TEXT(e->text));
 
-  e->in_select_mode = TRUE;
-  
-  ewl_widget_configure(w);
-  
-  DLEAVE_FUNCTION(DLEVEL_STABLE);
+       if (ev->clicks == 2) {
+               bp = ewl_cursor_get_base_position(EWL_CURSOR(e->cursor));
+
+       s = ewl_entry_get_text(e);
+      
+               if (s[bp-1] != ' ') {
+                       if (s[bp] != ' ') {
+                               if (bp < len) {
+                                       index = bp-1;
+                                       while ((index-->0) && (s[index] != ' ')){}
+                                       ewl_cursor_set_base(EWL_CURSOR(e->cursor), 
index+2);
+                                       index = bp-1;
+                                       while ((index++<len) && (s[index] != ' ')){}
+                                       ewl_cursor_select_to(EWL_CURSOR(e->cursor), 
index);
+                               }
+                       }
+                       else
+                       {
+                               index = bp-1;
+                               while ((index-->0) && (s[index] != ' ')){}
+                               ewl_cursor_set_base(EWL_CURSOR(e->cursor), index+2);
+                               ewl_cursor_select_to(EWL_CURSOR(e->cursor), bp);
+                       }
+               }
+               else if (s[bp] != ' ') {
+                       index = bp;
+                       while ((index<len) && (s[index] != ' '))
+                               index ++;
+                       ewl_cursor_set_base(EWL_CURSOR(e->cursor), bp+1);
+                       ewl_cursor_select_to(EWL_CURSOR(e->cursor), index);
+               }
+       }
+       else {
+               ewl_cursor_set_base(EWL_CURSOR(e->cursor), 1);
+               ewl_cursor_select_to(EWL_CURSOR(e->cursor), len);
+       }
+
+       e->in_select_mode = (ev->modifiers & EWL_KEY_MODIFIER_SHIFT);
+       ewl_widget_configure(w);
+
+       DLEAVE_FUNCTION(DLEVEL_STABLE);
 }
 
 void ewl_entry_select_cb(Ewl_Widget * w, void *ev_data, void *user_data)




-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
enlightenment-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to