From 5889675f7db09dc14cdddc189ad93b152987da7c Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Tue, 14 Dec 2010 17:07:45 +0000 Subject: 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. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8027 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Text_Display.cxx | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/Fl_Text_Display.cxx') diff --git a/src/Fl_Text_Display.cxx b/src/Fl_Text_Display.cxx index a512e477e..3891ac3be 100644 --- a/src/Fl_Text_Display.cxx +++ b/src/Fl_Text_Display.cxx @@ -3592,10 +3592,14 @@ int Fl_Text_Display::handle(int event) { 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 @@ int Fl_Text_Display::handle(int event) { 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 @@ int Fl_Text_Display::handle(int event) { } // 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 @@ int Fl_Text_Display::handle(int event) { // 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; } -- cgit v1.2.3