Copy by selection & clipboard managers

58 views
Skip to first unread message

Steinar Haugen

unread,
Jan 19, 2011, 8:45:34 AM1/19/11
to terminat...@googlegroups.com
Hi,

When selecting text in terminator with the mouse, the text is conveniently entered into the clipboard copy buffer.
This, however, does not work particularly well with clipboard managers.
The reason for this is that the clipboard is updated for each new character that is selected, regardless of whether the mouse button is released.

Example:
selecting the text "Hello" results in the following clipboard history
H
He
Hel
Hell
Hello

Is it possible to change this feature to copy the text on mouse button release?
That way, the clipboard manager history does not fill up with useless entries.

Regards,
Steinar

--
Steinar Haugen
Gausengate 12
3080 Holmestrand

Phone: +47 932 08 373
Email (p): steinar...@gmail.com
Email (w): ste...@haugenconsulting.no
Web: http://www.haugenconsulting.no

Martin Dorey

unread,
Jan 19, 2011, 2:30:37 PM1/19/11
to terminat...@googlegroups.com, Steinar Haugen

This seems to make us behave more like gnome-terminal, in the timing of the setting of the selection.  With the patch, we don't set the selection on the initial multiple click, nor on each drag.  Nor does gnome-terminal.

 

The behavior when we end up with the empty selection may appear, from the patch, to have changed but it hasn't, as updateSystemSelection and copyToClipboard are both guarded by:

 

        if (!hasSelection()) {

            // Almost all X11 applications leave the selection alone in this case.

            return;

        }

 

The condition in mouseReleased is now the same as the one in mouseDragged, guarding us from changing the selection when the wrong mouse button is released.

 

Sheep eat?

 

--- /home/martind/software.jessies.org/work/terminator/src/terminator/view/highlight/SelectionHighlighter.java (revision 1632)

+++ /home/martind/software.jessies.org/work/terminator/src/terminator/view/highlight/SelectionHighlighter.java (working copy)

@@ -96,7 +96,10 @@ SelectionHighlighter.mouseClicked
     }
     
     public void mouseReleased(MouseEvent event) {
-        dragHandler = null;
+        if (SwingUtilities.isLeftMouseButton(event) && (dragHandler != null)) {
+            selectionChanged();
+            dragHandler = null;
+        }
     }
     
     public void mouseDragged(MouseEvent event) {
@@ -217,6 +220,7 @@ SelectionHighlighter.clearSelection SelectionHighlighter.selectAll
         Location start = new Location(0, 0);
         Location end = new Location(view.getModel().getLineCount(), 0);
         setHighlight(start, end);
+        selectionChanged();
     }
     
     /**
@@ -296,7 +300,6 @@ SelectionHighlighter.setHighlight
         } else {
             highlightStart = start;
             highlightEnd = end;
-            selectionChanged();
         }
         view.repaint();
     }

 


--
You received this message because you are subscribed to the Google Groups "terminator-users" group.
To post to this group, send email to terminat...@googlegroups.com.
To unsubscribe from this group, send email to terminator-use...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/terminator-users?hl=en.

Steinar Haugen

unread,
Jan 19, 2011, 4:22:00 PM1/19/11
to Martin Dorey, terminat...@googlegroups.com
That was quick! :)

I had to download the source, apply the patch and try it out.
It seems to works just fine. Thanks. 

Will this change be submitted to subversion after it has been tested?

-Steinar

Elliott Hughes

unread,
Jan 19, 2011, 5:22:36 PM1/19/11
to terminat...@googlegroups.com, Steinar Haugen
looks good to me. hard to imagine the current behavior isn't an
accidental bug. the new code looks like what i'd have expected us to
do.

--
Elliott Hughes - http://www.jessies.org/~enh/

Martin Dorey

unread,
Jan 19, 2011, 6:10:30 PM1/19/11
to terminat...@googlegroups.com, Steinar Haugen
Ta, committed.
Reply all
Reply to author
Forward
0 new messages