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).
This commit is contained in:
Daniel Eklöf 2020-01-12 11:55:22 +01:00
parent 0b30316261
commit 5a6cbb8c3e
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
5 changed files with 106 additions and 0 deletions

4
vt.c
View file

@ -9,6 +9,7 @@
#define LOG_ENABLE_DBG 0
#include "log.h"
#include "csi.h"
#include "dcs.h"
#include "grid.h"
#include "osc.h"
@ -482,16 +483,19 @@ action_osc_put(struct terminal *term, uint8_t c)
static void
action_hook(struct terminal *term, uint8_t c)
{
dcs_hook(term, c);
}
static void
action_unhook(struct terminal *term, uint8_t c)
{
dcs_unhook(term);
}
static void
action_put(struct terminal *term, uint8_t c)
{
dcs_put(term, c);
}
static void