Commit graph

141 commits

Author SHA1 Message Date
Daniel Eklöf
5a6cbb8c3e
dcs: initial handling of DCS in general
Add data structure to term->vt. This structure tracks the free-form
data that is passed-through, and the handler to call at the end.

Intermediates and parameters are collected by the normal VT
parser. Then, when we enter the passthrough state, we call dcs_hook().

This function checks the intermediate(s) and parameters, and selects
the appropriate unhook handler (and optionally does some execution
already).

In passthrough mode, we simply append strings to an internal
buffer. This might have to be changed in the future, if we need to
support a DCS that needs to execute as we go.

In unhook (i.e. when the DCS is terminated), we execute the unhook
handler.

As a proof-of-concept, handlers for BSU/ESU (Begin/End Synchronized
Update) has been added (but are left unimplemented).
2020-01-12 11:55:22 +01:00
Daniel Eklöf
56824e459d
Revert "vt: refactor"
This reverts commit a575204bc7.
2019-12-20 23:59:23 +01:00
Daniel Eklöf
a575204bc7
vt: refactor 2019-12-20 23:45:21 +01:00
Daniel Eklöf
1bc8562026
vt: visually compact the switch tables 2019-12-20 23:38:16 +01:00
Daniel Eklöf
5a0e27fd6c
vt: remove enum action; add separate functions for each action instead 2019-12-20 23:27:15 +01:00
Daniel Eklöf
032f478661
vt: remove debug assert 2019-12-20 23:26:18 +01:00
Daniel Eklöf
9ad9e4ccaf
vt: use a pointer that we increment, instead of indexing 2019-12-20 23:00:07 +01:00
Daniel Eklöf
914b96cc9a
vt: use break, not continue 2019-12-20 22:13:23 +01:00
Daniel Eklöf
ee8a9674c4
vt: no need to assign to term->vt.state for *every* input byte 2019-12-20 22:12:35 +01:00
Daniel Eklöf
f36752f4d0
vt: remove dead code 2019-12-20 22:11:35 +01:00
Daniel Eklöf
d29de6f90a
vt: don't special case UTF-8 collect state 2019-12-20 22:10:27 +01:00
Daniel Eklöf
2d79497093
vt: convert SOS/PM/APC string from table lookup to switch 2019-12-20 21:50:54 +01:00
Daniel Eklöf
ad1773d7bc
vt: convert DCS from table lookup to switch 2019-12-20 21:48:04 +01:00
Daniel Eklöf
dca403e100
vt: convert CSI ignore from table lookup to switch 2019-12-20 21:13:06 +01:00
Daniel Eklöf
0d6555bea9
vt: convert CSI intermediate from table lookup to switch 2019-12-20 21:09:00 +01:00
Daniel Eklöf
d325ae10ee
vt: convert CSI param from table lookup to switch 2019-12-20 21:04:47 +01:00
Daniel Eklöf
23a6c6b711
vt: add missing 'entry' actions to 'anywhere' sections 2019-12-20 20:58:02 +01:00
Daniel Eklöf
b1fd960b4b
vt: convert CSI entry from table lookup to switch 2019-12-20 20:57:38 +01:00
Daniel Eklöf
a5f238b388
vt: re-align switches 2019-12-20 20:43:31 +01:00
Daniel Eklöf
b2f091d243
vt: replace GROUND, ESCAPE and ESCAPE_INTERMEDIATE tables with switches 2019-12-20 19:16:52 +01:00
Daniel Eklöf
56faca4266
vt: use a switch instead of a top-level state lookup table
Remove the top-level state lookup table, which mapped from a state
enum to a state transition table, and replace it with a switch.
2019-12-20 18:24:32 +01:00
Daniel Eklöf
2c4af8728d
vt: add commented out cases for 8-bit C1 control characters
XTerm seems to ignore these when in UTF-8 mode. Since we _only_
support UTF-8, we don't need to recognize these control characters at
all.

However, it may be good to have them here for reference. So add them,
but commented out, along with their corresponding 7-bit
versions (which we _do_ recognize and implement).
2019-12-14 20:28:05 +01:00
Daniel Eklöf
0e5a69d869
vt: don't try to move cursor outside the terminal
When we insert an auto-newline, we must make sure we don't try to move
outside the terminal window.

This can for example happen when a scrolling region have been
configured, and the cursor is **outside** the scrolling
region (i.e. it's in the bottom margin).
2019-11-30 00:32:34 +01:00
Daniel Eklöf
88c1a8939f
vt: fix memory corruption: wcwidth() may return -1
When it did, we called print_insert() with that, which in turn
resulted in a too large size value passed to memmove.
2019-11-30 00:15:05 +01:00
Daniel Eklöf
9551be492c
csi/vt: don't bad client data as errors
This gets rid of spam when cat:ing binary data.
2019-11-30 00:12:30 +01:00
Daniel Eklöf
66f941d00a
vt: only define esc_as_string() when debug logging has been enabled 2019-11-30 00:02:19 +01:00
Daniel Eklöf
cd9510aa7b
vt: disable logging BELL 2019-11-30 00:00:41 +01:00
Daniel Eklöf
616896e2a5
csi/ocs/vt: log unhandled/unrecognized sequences as debug messages
Having them as error messages was nice when we where still missing
lots of sequences.

Now we don't anymore, and these just spam stdout as well as syslog
when e.g. cat:ing binary data.
2019-11-29 23:59:24 +01:00
Daniel Eklöf
3026b8981a
vt: there are actually many state transitions that are no-ops
In most states, most 8-bit values are no-ops. This is already handled;
action() recognizes ACTION_NONE as a no-op. Thus, all we need to do is
remove the assertion.
2019-11-29 23:38:01 +01:00
Daniel Eklöf
04cbee7593
Revert "vt: replace pre_print() with term_autowrap()"
This reverts commit fd8a399274.
2019-11-17 17:22:16 +01:00
Daniel Eklöf
fd8a399274
vt: replace pre_print() with term_autowrap() 2019-11-17 12:14:45 +01:00
Daniel Eklöf
616e506f2e
csi: fix bad implementation of CBT (back tab)
* It takes a parameter, that indicates the number of tab stops to move
  through
* Use the tab stops defined in the tab stops list, not hard coded mod
  8 columns.
2019-11-17 11:20:59 +01:00
Daniel Eklöf
045f55a8c6
vt: bug (tab regression): don't get stuck on the same tab stop
There were actually two bugs here:

* When checking for a tab stop, make sure the new tab stop is at a
  different column. Otherwise you can't tab away from a tab stop.

* When there aren't any tab stops configured, or when we're already
  beyond the last tab stop, then tab to the last column (at least I
  think that's what we're supposed to do).
2019-11-17 10:15:56 +01:00
Daniel Eklöf
c9ebd527cf
term: save/restore charsets on save/restore cursor+attributes 2019-11-17 10:02:46 +01:00
Daniel Eklöf
ce544776ab
term: move charset variables into an anonymous struct 2019-11-17 09:59:12 +01:00
Daniel Eklöf
a70fe1f5d7
term: move lcf flag into 'cursor' struct 2019-11-17 09:46:20 +01:00
Daniel Eklöf
d637b8c9ba
term: add struct cursor 2019-11-17 09:44:31 +01:00
Daniel Eklöf
c1088d77ac
term: rename: print_needs_wrap -> lcf (Last Column Flag) 2019-11-17 09:39:43 +01:00
Daniel Eklöf
65ff3656f7
vt: execute: \t: use tab stops from tab stop list
Instead of assuming hardcoded 8-width tab stops, use the tab stops
from the tab stop list.
2019-11-16 10:57:39 +01:00
Daniel Eklöf
9ff48c2015
vt: implement ESC H - set tab stop at current column 2019-11-16 10:57:11 +01:00
Daniel Eklöf
69e0e454fa
vt: remove commented out code 2019-11-16 10:55:14 +01:00
Daniel Eklöf
35c56765a4
vt: DECALN: render at bottom of terminal, not in view 2019-11-14 11:08:49 +01:00
Daniel Eklöf
f635f48078
vt: implement VT - Vertical Tab
Despite its name, it always moves down exactly one line.
2019-11-05 13:56:52 +01:00
Daniel Eklöf
df65e29d0d
vt: always use hex (not octal) 2019-11-05 13:56:44 +01:00
Daniel Eklöf
27d00b15c7
vt: log hex version of printed character too 2019-11-05 13:56:25 +01:00
Daniel Eklöf
5d763b9e12
vt: always disable state_names[] array
It isn't used anywhere, even with LOG_ENABLE_DBG
2019-11-05 13:55:43 +01:00
Daniel Eklöf
33ea88aba6
vt: esc dispatch: implement DECALN
In esc dispatch:

* Switch on private first, then final
* Recognize ESC #8 (DECALN), and implement it
2019-11-05 11:32:56 +01:00
Daniel Eklöf
15b12f45c6
scan-build: fix a couple of minor warnings from a scan-build run 2019-11-05 10:39:36 +01:00
Daniel Eklöf
9f1525aef7
Rename: vt_to_slave() -> term_to_slave() 2019-11-03 00:52:24 +01:00
Daniel Eklöf
780a346071
vt: don't log ignored execute commands
cat:ing a binary file would otherwise result in us spamming syslog.
2019-09-28 13:59:11 +02:00