Treat the XTerm specific modifyOtherKeys escape codes as putting the
disambiguate mode on/off the stack. The escape code causes XTerm to use
a (broken, naturally) variant of CSI u encoding for many keys, so we
treat it as going into the disambiguate mode.
Up to now this poorly designed and completely unnecessary escape code
was relegated to only GNOME, however, off late Apple has started using
it as well, so silently ignore it, instead of spamming error messages
for it.
For the sake of interoperability. This means that doing a DECRC without
a prior DECSC is now undefined. However, one can now issue multiple
DECRC for a single DECSC. Fixes#1264
There are two user-visible changes in here:
1. If a scroll region is set such that there is a bottom margin and no
top margin, scrolling the region forward used to discard the top
lines. Now those lines are appended to the scrollback.
```shell
# Assuming a terminal window with 24 lines.
printf '\033[H\033[J\033[3J\033[0;5r' && seq 100
```
This command used to result in an empty scrollback. Now it contains
the numbers 1-96.
2. If a scroll region is set such that there is a top margin and no bottom
margin, scrolling the region forward used to append the top lines to
the scrollback. Now these lines are discarded.
```shell
# Assuming a terminal window with 24 lines.
printf '\033[H\033[J\033[3J\033[2;24r' && seq 100
```
This command used to populate scrollback with the numbers 2-78. Now
the scrollback is empty. The numbers on the screen are the same as
before: 1 and 79-100.
Related issue: #3113.
When selecting text by dragging upwards, the "end" of the selection is above the "start". This causes the `selection_has_screen_line()` to never return `true` in this case.
In practice this bug causes the selection to not be cleared when the screen contents under the selection change if it was made by dragging upwards.
Needed for output of hyperlinks, also more efficient, since avoids
malloc per line. Also fix pagerhist not having SGR reset at the start of
every line.