build: define KMSCON_ENABLE_DEBUG on --enable-debug

We build several internal libraries and to keep the namespaces apart we
also need different debug constants. Therefore, introduce the new
KMSCON_ENABLE_DEBUG constant which is for every debug object in base
kmscon code.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
unicode: introduce kmscon_utf8_mach_reset()

Sometimes we need to reset the UTF8 state-machine, for instance when
resetting the VTE. This function simply resets the internal state to
KMSCON_UTF8_START so we start all over on the next input character.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
console: add kmscon_console_reset() dummy

This dummy is supposed to hard-reset the console. As the console is far
from finished, we keep it as dummy and implement this later.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
vte: support 7bit and 8bit modes

In 7bit and 8bit modes we treat incoming characters as single-byte
characters and map them directly to the corresponding value instead of
using the UTF8 state-machine.

This allows using old non-utf8 applications with this VT. However, default
value is still UTF8-mode and you must explicitely request a conformance
level to change that. If you selected such a mode once, you can only
return to UTF8-mode by performing a soft/hard-reset.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
vte: add kmscon_vte_reset()

This performs a soft reset of the VTE state machine. It does not affect
the console that is bound to the VTE, though.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
vte: select CSI flags

Correctly select CSI flags like ?, !, > or $ and more. We actually don't
care about the position of these flags as other CSI parameters are just
digits.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
vte: corectly implement DECSCL

We now select the 8bit/7bit modes if the client sends an DECSCL requesting
a conformance level.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
vte: implement DECSTR / soft-reset

On soft-reset, all internal state is reset but the screen data is kept
alive.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
vte: move long csi-handlers into separate function

Avoid making do_csi() too big. So put long csi-handlers into separate
functions.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
vte: handle XK_Find and XK_Select

Even though modern keyboard often do not include such keys, we should
handle them correctly, anyway. For the sake of backwards-compatibility.

This also comes in handy if you define these keys separately. The
functions that are implemented by many applications with these keys are
handy, indeed.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
vte: perform soft reset on initialization

Instead of copying all that initialization stuff around, we simply perform
a soft reset on initialization.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
vte: add support for GL/GR mappings

This allows mapping different charsets into GL/GR.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
vte: always perform soft reset on DECSCL

All DECSCL modes automatically perform a soft reset.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
vte: support temporary charsets and g0-g3

Temporary charsets are only used for the next graphics character that is
displayed. After that, the VTE returns to the previous charset. On
soft-reset we also reset these temporary slots.

This also adds the g0-g3 backend slots that can be set by the client and
allow mapping of arbitrary other charsets into gl/gr/glr/grt.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
vte: collect csi flags +, ( and )

All three flags are most often used with basic escape sequences and not
with CSI sequences, however, we treat them generic here to avoid more
complexity.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
vte: support designating charsets

With ESC {int} {final} you can designate G0-G3. If no {int} is given, we
fall back to the default escape sequences that replace the C1 set.
However, the user might designate other sets manually so we ignore all
escape sequences that have intermediates set.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
vte: trivial: fix switch indentation

We use kernel-style switch-case indentation.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
vte: implement charset shift in/out

This allows changing GL and GR to the values set in G0-G3. GL can also be
set temporarily, GR currently does not have such a mode.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>