Commit Graph

32 Commits

Author SHA1 Message Date
Ed Schouten
97b48ffc93 Link the demo application against ncursesw to make Unicode work. 2011-10-13 14:20:27 +00:00
Ed Schouten
231c19b1e3 Properly use the cursor to bound the position for CUP.
We must take the origin region into account when clamping the cursor
position.

MFC after:	3 days
2011-10-10 06:13:27 +00:00
Ed Schouten
3a28b8a49f Fix whitespace inconsistencies found in homegrown Symbol.maps. 2011-10-07 15:05:24 +00:00
Ed Schouten
073e2d2c93 Simply let teken_stress use arc4random.
This makes it run quite a bit faster, since it makes system calls less
often.
2011-10-07 12:42:03 +00:00
Ed Schouten
d8554e5c77 Tab should not blank cells.
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
2011-10-07 12:21:50 +00:00
Ed Schouten
aaa232d41d Fix various whitespace inconsistencies in sys/teken. 2011-06-26 18:25:10 +00:00
Ulrich Spörlein
135bce2a9e mdoc: reorder sections consistently 2011-06-02 09:56:53 +00:00
Ed Schouten
ecc16c8d3a Add proper build infrastructure for teken.
I'm not sure whether we should install teken as a library on any stock
FreeBSD installation, but I can imagine people want to tinker around
with it now and then. Create a /sys/teken/libteken, which holds a
Makefile to install a shared library version of the terminal emulator,
complete with a manpage.

Also add Makefiles for the demo/stress applications, to build it against
the shared library.
2011-05-09 16:27:39 +00:00
Ed Schouten
9d67d2214f Use proper bounds checking on VPA.
We must check against tp->t_cursor.tp_row, not row, to figure out
whether we must clamp the cursor position.

Submitted by:	luigi
MFC after:	3 weeks
2010-12-05 10:15:23 +00:00
Ed Schouten
68fdfe2926 Partially implement the mysterious cons25 \e[x escape sequence.
It seems the terminfo library on some systems (OS X, Linux) may emit the
sequence \e[x to reset to default attributes. Apart from using the
zero-command, this escape sequence allows many more operations, such as
setting ANSI colors. I don't see this used anywhere, so this should be
sufficient for now.

This deficiency was spotted by the Debian GNU/kFreeBSD. They have their
own patch, which is slightly flawed in my opinion. I don't know why they
never reported this issue to us.

MFC after:	1 week
2010-11-05 00:56:21 +00:00
Ed Schouten
0abe3145c3 Make ^L with cons25 and origin mode bit more sane.
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.
2010-08-09 18:07:15 +00:00
Ed Schouten
a54dd632ab Just use <stdint.h> instead of <inttypes.h>. We don't need it here. 2010-04-03 17:22:28 +00:00
Ed Schouten
e7fe3cf158 Fall back to ASCII codepoints for box drawing.
Even though the default VGA font provides box drawing fonts, there is no
guarantee any font will provide these as well (i.e. ISO-8859-*, KOI8-R).
Just use ASCII characters for box drawing.

PR:		kern/141633
2010-02-08 09:16:59 +00:00
Ed Schouten
d80a1e6c1b Place home and end before insert and delete.
These keys have different sequences when using cursorkeys, while insert
and delete stay the same. If they are placed like this, libteken will
return NULL instead of a proper sequence for these characters.
2009-11-11 09:43:26 +00:00
Ed Schouten
3a8a07eadd Allow Syscons terminal emulators to provide function key strings.
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.
2009-11-11 08:20:19 +00:00
Ed Schouten
0475bba7f5 Always home the cursor when changing the scrolling region.
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.
2009-11-11 08:11:21 +00:00
Ed Schouten
4a11e7f142 Discard Device Control Strings and Operating System Commands.
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
2009-10-08 10:26:49 +00:00
Ed Schouten
53e69c0c2a Add support for VT200-style mouse input.
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)
2009-09-27 18:19:41 +00:00
Ed Schouten
56a4365bde Add 256 color support.
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>
2009-09-26 15:26:32 +00:00
Ed Schouten
f311d56014 Properly get out of origin mode if the cursor has to move outside of it.
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
2009-09-26 15:07:11 +00:00
Ed Schouten
cd531e74e9 Get rid of now deprecated SCS wrappers.
We always build SCS, even when processing 8-bit data. There is no reason
why we should be able to disable it now.
2009-09-26 15:03:42 +00:00
Ed Schouten
a78f7fafc0 Make the fuzzer a bit more useful by forcing 7-bit data into it.
Getting valid UTF-8 sequences is quite unlikely, so we'd better just
convert data to 7 bits and make it extra likely for escape sequences to
occur.
2009-09-26 15:00:42 +00:00
Ed Schouten
2c549cc439 Add a new escape sequence to switch between cons25 and xterm.
Just run this to switch to xterm:

	printf '\e[=T'

If you get bored and want to switch back to cons25, run this:

	printf '\e[=1T'

I can now send an email to the lists, asking whether people are
interested in trying the xterm emulator.
2009-09-25 13:51:01 +00:00
Ed Schouten
c56bcdbb96 Conformance: ignore {delete,insert} line while outside the scrolling region.
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
2009-09-25 11:58:51 +00:00
Ed Schouten
64d0447d4e Add __unused.
It turns out my previous commit does survive a buildkernel, but not
compilation of the individual test tools that use WARNS=6.
2009-09-24 20:34:44 +00:00
Ed Schouten
fbcd1b6eac Make SCS work in 8-bit mode.
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.
2009-09-24 20:33:14 +00:00
Ed Schouten
eba77f5c40 Commit all local modifications I have to libteken:
- 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.
2009-09-12 12:44:21 +00:00
Ed Schouten
5e666eb395 Small style(9) bug introduced in the previous commit. 2009-09-12 10:41:32 +00:00
Ed Schouten
e06d84fc49 Make 8-bit support run-time configurable.
Now to do the same for xterm support. This means people can eventually
toy around with xterm+UTF-8 without recompiling their kernel.
2009-09-12 10:34:34 +00:00
Ed Schouten
b03552b5e2 Make resizing of teken terminals a bit more safe.
Just perform a full reset when resizing the terminal. This means the
cursor, scrolling region, etc. are never positioned outside the
terminal.
2009-09-12 08:19:24 +00:00
Ed Schouten
4a6ecf078b Expose the TF_REVERSE flag to the console driver.
Right now libteken processes TF_REVERSE internally and returns the
toggled colors to the console driver. This isn't entirely correct. This
means that the bold flag is always processed by the foreground color,
while reversing should be done after the foreground color has been set
to a brighter version by the bold flag.

This is no problem with the syscons driver, because with VGA it only
supports 16 foreground and 8 background colors. My WIP console driver
reconfigures the graphics hardware to disable the blink functionality
and uses 16 foreground and 16 background colors. This means that this
driver will handle the TF_REVERSE flag a little different from what
syscons does right now.
2009-09-03 16:31:11 +00:00
Ed Schouten
9b934d0930 Move libteken out of the syscons directory.
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.
2009-09-03 09:33:57 +00:00