After fixing the 16-bits integer arithmetic overflow in 286981, we
should also make sure to fix the VPA sequence. Bring HPA and VPA in sync
with how we now implement CUP.
PR: 202612
Reported by: kcwu csie org
MFC after: 1 month
When updating the row number when the cursor position escape sequence is
issued, we should make sure to store the intermediate result in a 32-bit
integer. If we fail to do this, the cursor may be set above the origin
region, which is bad.
This could cause libteken to crash when INVARIANTS is enabled, due to
the strict set of assertions that libteken has.
PR: 202540
Reported by: kcwu csie org
MFC after: 1 month
Instead of only wrapping when in the 'wrapped state', also force
wrapping when the character to be rendered does not fit on the line
anymore.
Tested by: lwhsu
Introduce a new formatting bit (TF_CJK_RIGHT) that is set when putting a
cell that is the right part of a CJK fullwidth character. This will
allow drivers like vt(9) to support fullwidth characters properly.
emaste@ has a patch to extend vt(9)'s font handling to increase the
number of Unicode -> glyph maps from 2 ({normal,bold)} to 4
({normal,bold} x {left,right}). This will need to use this formatting
bit to determine whether to draw the left or right glyph.
Reviewed by: emaste
It seems I was under the impression that a tab differs from a single
forward tabulation, namely that it blanks the underlying cells. This
seems not to be the case. They are identical.
This should fix applications like jove(1) that use tabs instead of
explicit cursor position setting.
Reported by: Brett Glass <brett lariat net>
MFC after: 3 days, after it's tested
Even though cons25 normally doesn't support origin regions, this
emulator does allow you to do it. It makes more sense to blank only the
origin region when emitting ^L instead of blanking the entire screen.
Apart from that, we should always place the cursor inside the origin
region, which doesn't happen right now.
xterm and cons25 have some incompatibilities when it comes to escape
sequences for special keys, such as F1 to F12, home, end, etc. Add a new
te_fkeystr() that can be used to override the strings.
scterm-sck won't do anything with this, but scterm-teken will use
teken_get_sequences() to obtain the proper sequence.
I thought this only had to be done when in origin mode, to ensure that
the cursor is not placed outside the origin, but it seems this is also
done when not in origin mode.
This fixes some artifacts when pressing ^L while running irssi in tmux.
(Almost) nobody noticed this, because cons25 doesn't have scrolling
regions.
These strings often contain things like:
- Window titles.
- Extended key map functionality.
- Color palette switching.
We could look at these features in the future (if people consider them
to be important enough), but we'd better discard them now. This fixes
some artifacts people reported when using TERM=xterm.
Reported by: des@, Paul B. Mahol
Right now if applications want to use the mouse on the command line,
they use sysmouse(4) and install a signal handler in the kernel to
deliver signals when mouse events arrive. This conflicts with my plan to
change to TERM=xterm, so implement proper VT200-style mouse input.
Because mouse input is now streamed through the TTY, it means you can
now SSH to another system on the console and use the mouse there as
well. The disadvantage of the VT200 mouse protocol, is that it doesn't
seem to generate events when moving the cursor. Only when pressing and
releasing mouse buttons.
There are different protocols as well, but this one seems to be most
commonly supported.
Reported by: Paul B. Mahol <onemda gmail com>
Tested with: vim(1)
It is quite inconvenient that if an application for xterm uses 256 color
mode, text suddenly starts to blink (because of ;5; in the middle).
We'd better just implement 256 color mode and add a conversion routine
from 256 to 8 color mode, which doesn't seem to be too bad in practice.
Remapping colors is done quite simple. If one of the channels is most
actively represented, primary colors are used. If two channels are most
actively represented, secondary colors are used. If all three channels
are equal (gray), it picks between black and white.
Reported by: Paul B. Mahol <onemda gmail com>
In some cases events may occur that move the cursor outside the
scrolling region while in origin mode, which is normally not possible.
Events like these include:
- Alignment test.
- Restore cursor.
Properly switch off origin mode in these cases.
MFC after: 1 month
I noticed a small inconsistency in delete and insert line between xterm
and libteken. libteken allows these actions to happen while the cursor
is placed outside the scrolling region, while xterm does not.
This behaviour seems to be VT100-like. Confirmation:
http://www.vt100.net/docs/vt102-ug/chapter5.html
"This sequence is ignored when cursor is outside scrolling region."
MFC after: 1 month
This means we can finally do things like VT100 box drawing when using
Syscons (8-bit characters). As far as I know, the only remaining issue
is the absense of proper escape sequences for special keyboard
characters (cursor, F1 to F12, etc) and xterm emulation should be ready
for general use.
Enabling xterm would have the following advantages:
- Easier possible migration to Unicode. cons25 termcap entries are very
8-bit centric. They use things like CP437 characters for box drawing,
etc.
- Better support for SSH'ing to other operating systems/devices. Most
switches use VT100-style admin interfaces.
- Reduced bandwidth, because applications can now use things like
scrolling regions.
- You can finally use applications like dtach(1) on both the console and
inside an xterm.
- Make xterm/cons25 support runtime configurable. This allows me to
share libteken between syscons and my new vt driver.
- Add a fix to print blanks after printing a double width character to
prevent rendering artifacts.
- Add some more utility functions that I use in the vt driver.
I initially committed libteken to sys/dev/syscons/teken, but now that
I'm working on a console driver myself, I noticed this was not a good
decision. Move it to sys/teken to make it easier for other drivers to
use a terminal emulator.
Also list teken.c in sys/conf/files, instead of listing it in all the
files.arch files separately.