Author: manolo
Date: 2010-12-14 09:07:45 -0800 (Tue, 14 Dec 2010)
New Revision: 8027
Log:
Fix STR # 2484. Middle mouse button paste now works within an Fl_Text_Editor
and from/to other applications. Also fixed interaction between selection and 
insertion cursor.

Modified:
   branches/branch-1.3/src/Fl_Text_Display.cxx
   branches/branch-1.3/src/Fl_Text_Editor.cxx

Modified: branches/branch-1.3/src/Fl_Text_Display.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Text_Display.cxx 2010-12-13 19:48:47 UTC (rev 
8026)
+++ branches/branch-1.3/src/Fl_Text_Display.cxx 2010-12-14 17:07:45 UTC (rev 
8027)
@@ -3592,10 +3592,14 @@
         return 1;
       }
       dragType = Fl::event_clicks();
-      if (dragType == DRAG_CHAR)
+      if (dragType == DRAG_CHAR) {
         buffer()->unselect();
-      else if (dragType == DRAG_WORD)
+       Fl::copy("", 0, 0);
+      }
+      else if (dragType == DRAG_WORD) {
         buffer()->select(word_start(pos), word_end(pos));
+       dragPos = word_start(pos);
+       }
       
       if (buffer()->primary_selection()->selected())
         insert_position(buffer()->primary_selection()->end());
@@ -3667,6 +3671,8 @@
        return 1;
       } else if (Fl::event_clicks() == DRAG_LINE) {
         buffer()->select(buffer()->line_start(dragPos), 
buffer()->next_char(buffer()->line_end(dragPos)));
+       dragPos = line_start(dragPos);
+       dragType = DRAG_CHAR;
       } else {
        dragging = 0;
        if (scroll_direction) {
@@ -3675,10 +3681,10 @@
        }
        
        // convert from WORD or LINE selection to CHAR
-       if (insert_position() >= dragPos)
+       /*if (insert_position() >= dragPos)
          dragPos = buffer()->primary_selection()->start();
        else
-         dragPos = buffer()->primary_selection()->end();
+         dragPos = buffer()->primary_selection()->end();*/
        dragType = DRAG_CHAR;
       }
       
@@ -3725,6 +3731,9 @@
       // Select all ?
       if ((Fl::event_state()&(FL_CTRL|FL_COMMAND)) && Fl::event_key()=='a') {
         buffer()->select(0,buffer()->length());
+        const char *copy = buffer()->selection_text();
+        if (*copy) Fl::copy(copy, strlen(copy), 0);
+        free((void*)copy);
         return 1;
       }
       

Modified: branches/branch-1.3/src/Fl_Text_Editor.cxx
===================================================================
--- branches/branch-1.3/src/Fl_Text_Editor.cxx  2010-12-13 19:48:47 UTC (rev 
8026)
+++ branches/branch-1.3/src/Fl_Text_Editor.cxx  2010-12-14 17:07:45 UTC (rev 
8027)
@@ -283,6 +283,7 @@
   if (!selected)
     e->dragPos = e->insert_position();
   e->buffer()->unselect();
+  Fl::copy("", 0, 0);
   switch (c) {
   case FL_Home:
       e->insert_position(e->buffer()->line_start(e->insert_position()));
@@ -330,6 +331,7 @@
     e->dragPos = e->insert_position();
   if (c != FL_Up && c != FL_Down) {
     e->buffer()->unselect();
+    Fl::copy("", 0, 0);
     e->show_insert_position();
   }
   switch (c) {
@@ -369,6 +371,7 @@
     e->dragPos = e->insert_position();
   if (c != FL_Up && c != FL_Down) {
     e->buffer()->unselect();
+    Fl::copy("", 0, 0);
     e->show_insert_position();
   }
   switch (c) {
@@ -495,11 +498,15 @@
 /**  Selects all text in the current buffer.*/
 int Fl_Text_Editor::kf_select_all(int, Fl_Text_Editor* e) {
   e->buffer()->select(0, e->buffer()->length());
+  const char *copy = e->buffer()->selection_text();
+  if (*copy) Fl::copy(copy, strlen(copy), 0);
+  free((void*)copy);
   return 1;
 }
 /**  Undo last edit in the current buffer. Also deselect previous selection. */
 int Fl_Text_Editor::kf_undo(int , Fl_Text_Editor* e) {
   e->buffer()->unselect();
+  Fl::copy("", 0, 0);
   int crsr;
   int ret = e->buffer()->undo(&crsr);
   e->insert_position(crsr);
@@ -598,6 +605,11 @@
         // don't let the text_display see this event
         if (Fl_Group::handle(event)) return 1;
         dragType = DRAG_NONE;
+       if(buffer()->selected()) {
+         buffer()->unselect();
+         }
+       int pos = xy_to_position(Fl::event_x(), Fl::event_y(), CURSOR_POS);
+        insert_position(pos);
         Fl::paste(*this, 0);
         Fl::focus(this);
         set_changed();

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to