Search code examples
ubuntuvimgnu-screengnome-terminal

GNU screen mouse limitation


My typical development environment is running a GNU screen session with vim in a full screen terminal (typically gnome-terminal). The problem I've run into is that the mouse pointer is not interpreted correctly when clicking on a character in vim beyond around the 223rd character in the terminal.

I have tried the solution to another question (adding set ttymouse=sgr to my .vimrc), and this solves the problem for running vim directly in the terminal but the limitation with the mouse still exists when using vim inside a screen session.


Solution

  • After searching for GNU screen sgr support I came across a patch! Here are the steps I used to apply the patch to screen on Ubuntu 14.04. (I've modified that patch to work with the source files downloaded from apt-get here)

    1. Pull down the screen source from apt-get:

      apt-get source screen
      
    2. cd into the source directory and install the patch:

      patch -p1 < screen-sgr-patch.diff
      
    3. Integrate local changes made by the patch:

      dpkg-source --commit
      
    4. Build the new .deb files:

      dpkg-buildpackage -us -uc
      

      (NOTE: it may complain about missing build dependencies but just install any of them using apt-get and run dpkg-buildpackage again)

    5. Install the patched screen package (you'll find this beside the source directory):

      dpkg -i screen_<version>_<arch>.deb