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.

Fil RSS des articles de ce mot clé