gnachman/iTerm2 — pull request #141 by saitoha (2013-08-02 18:39:49+00:00)
Title: Issue 2465: Add Left-Right Margin Mode (Vertical Split-Screen Mode)

Issue 2465: http://code.google.com/p/iterm2/issues/detail?id=2465

This patch adds the left-right margin feature (VT class 4+ feature) to iTerm2.
This change affects many existing sequences such as NL, SU, SD, IND, RI, CUP, BS, VPA, DCH, ICH, HVP, RIS, CHA, DECALN, ...etc., so we should test it with the utmost care and attention. I debugged it for two months.
During I was writing this patch, TeraTerm developer IWAMOTO Kouichi gave me some useful advice about real VT-525's left-right margin behavior.

- Motivation

I have frequently heard that "vertical split scrolling on Vim is too slow.", and I guessed one of reasons for that is I/O latency problem.

- Solution

This problem is solved by using class 4+ featured terminal (DECLRMM/DECSLRM are implemented on them) and adding the following settings on your .vimrc.

> let &t_ti = &t_ti . "\e[?69h"
> let &t_te = "\e[?69l" . &t_te
> let &t_CV = "\e[%i%p1%d;%p2%ds"

This settings accelarate Vim vsplit scrolling over a narrow band connection.
This movie explains the drastic effect of DECSLRM with 9600bps serial port connection (captions are written in Japanese).
http://www.youtube.com/watch?v=KQfOArRJkYI

As far as I know, DECLRMM/DECSLRM are supported by the following terminals.

- xterm (the patch is needed: https://gist.github.com/ttdoda/5720732)
- RLogin (http://nanno.dip.jp/softlib/man/rlogin/ctrlcode.html)
- pangoterm (https://code.launchpad.net/pangoterm)
- tanasinn
- mlterm (partially)
- TeraTerm (from next version)
- DEC VT 4xx-5xx (for working with vim, this patch is needed: https://gist.github.com/ttdoda/5726992)

- Performance test

I did the following operation with patched iTerm2.

- Open iTerm2 and resize it to 339 (width) x 79 (height).

- Start script(1) session.

> $ script

- Open Vim's src/term.c(http://code.google.com/p/vim/source/browse/src/term.c?r=4ffb6f9b58e0b51923fe6a71e6af158b6e3f7864).

> $ vim src/term.c

- Split the pane vertically.

> :vsp

- scroll from the top position to the end of file with pressing "J" key.

- Quit Vim

> :q

- Measure the size of $HOME/typescript

> du ~/typescript

- Result

With normal settings -> 82M bytes
With the settings using t_CV -> 603K bytes (99.3 percent cut-off!!)