gnachman/iTerm2 — pull request #166 by saitoha (2014-03-19 15:08:58+00:00)
Title: Add alternate scroll mode (xterm)

Some days ago, the "alternate scroll" feature is introduced by #164.
I think this should be also implemented as terminal mode.
This patch do it.

Additionaly, we may had better rename the hidden preference "alternateMouseScroll" to "forceAlternateMouseScroll".

*Usage*:

To use this with vim, add the following code to your .vimrc.
(This also works on mintty, xterm, TeraTerm, RLogin, mlterm, tanasinn, ...etc)

```
set mouse=
let &t_ti = &t_ti . "\e[?1007;7786h"
let &t_te = "\e[?1007;7786l" . &t_te
```

*Note*:

This patch uses the "alternate screen mode" state as the trigger of enabling/disabling alternate scrolling feature (This behavior is compatible with XTerm).
But Tera Term dares to use "application cursor mode" (DEC specific mode 1) instead of that.
This hack has the following merits:

- On some systems(such as FreeBSD), alternate scroll is not enabled by fullscreen applications such as less/vi because the default termcap for xterm is modified and does not include ti/te. But ks/ke are always invoked.

- tmux does not sends internal state of "alternate screen mode" to outer terminals. But it sends "application cursor mode" state.

- Some people disables alternate screen feature by using custom terminfo or terminal preferences.