HOAB

History of a bug

Right click paste on linux terminal with terminator

Rédigé par gorki 4 commentaires

Problem

For once, an english post as I saw many other person interest in this problem.

I just migrate from Windows to Linux, as many others, lot of little things to do to have fully functional desktop... a next post to describe this.

One of the most annoying thing was the "middle click" in terminal... Not used to, I scroll when I want to paste...

No problem, I looked for a terminal with this option.. but no one found on google !!.

Solution (since Terminator 1.0)

Just check the box "PuTTY paste mode" in the preferences, thanks for authors !

Also to display the menu on Cinnamon : shift + right click + left click (or try any of ctrl/shift + right, left, middle click)

Solution (before Terminator 1.0)

I installed Terminator, following many advices, not bad at all, except this annoying menu on right click...

I saw a feature request but author will do it maybe, one day or if someone offers this feature in option with GUI configuration, etc...

Looking for Terminator plugins system, I noticed it was coded in Python, yeah !

Few minutes later, as root :

sudo apt-get install terminator
sudo vi /usr/share/terminator/terminatorlib/terminal.py

Look for the following function :

def on_buttonpress(self, widget, event):
        """Handler for mouse events"""
        # Any button event should grab focus
        widget.grab_focus()

        if event.button == 1:
            # Ctrl+leftclick on a URL should open it
            if event.state & gtk.gdk.CONTROL_MASK == gtk.gdk.CONTROL_MASK:
                url = self.check_for_url(event)
                if url:
                    self.open_url(url, prepare=True)
        elif event.button == 2:
            # middleclick should paste the clipboard
            self.paste_clipboard(True)
            return(True)
        elif event.button == 3:
            # rightclick should display a context menu if Ctrl is not pressed
            if event.state & gtk.gdk.CONTROL_MASK == 0:
                self.popup_menu(widget, event)
                return(True)

        return(False)

I invert button test, and that's all : menu on middle click, paste on right click.

Here is the difference :

def on_buttonpress(self, widget, event):
        ...
        if event.button == 1:
            ...
        elif event.button == 3:
            ...
        elif event.button == 2:
            ...

        return(False)

With Clipman on XFCE to synchronize selection clipboard and X clipboard, it suits my needs for now.

4 commentaires

#1  - Rene a dit :

Interesting, the only thing is that you lose the possibility to use the preference settings if your second mouse button is a wheel. Or at least it becomes very unhandy. What I did is to change around the 3rd button so that it will default to paste on click. But when you hold CTRL and then right click it keeps showing you the settings menu. So keep the order 1,2 3 and make the right button multifunctional. I will show the configuration:

sudo vi /usr/share/terminator/terminatorlib/terminal.py

elif event.button == 3:
# rightclick should display a context menu if Ctrl is not pressed
if event.state & gtk.gdk.CONTROL_MASK == gtk.gdk.CONTROL_MASK:
self.popup_menu(widget, event)
return(True)
else:
self.paste_clipboard(True)
return(True)

Répondre
#2  - gorki a dit :

Thanks for the update, it's an even better solution !

In the latest version, Terminator has the "paste as Putty" option that allow the right click. Menu button is displayed by SHIFT + right click.

Répondre
#3  - harp a dit :

With "PuTTY paste mode" set, the context menu can be reached in three ways:
Shift-F10 or Shift-middle-click, or double middle click
This is terminator 1.91.

(Is there a way to show the anti-spam verification in English as well? I needed google translate to do it.)

Répondre
#4  - gorki a dit :

Thanks for comment ! I'll check the anti-spam language choice :)

Répondre

Écrire un commentaire

Quelle est le dernier caractère du mot qj31nukr ?

Fil RSS des commentaires de cet article