mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-08 08:20:59 -04:00
dcs: sort of implement DCS passthrough
We now store the passthrough characters in a buffer, and call dcs_passthrough() on unhook. However, dcs_passthrough() doesn't do anything.
This commit is contained in:
parent
153628a217
commit
b953326768
6 changed files with 62 additions and 4 deletions
32
dcs.c
Normal file
32
dcs.c
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
#include "dcs.h"
|
||||||
|
|
||||||
|
#define LOG_MODULE "dcs"
|
||||||
|
#define LOG_ENABLE_DBG 0
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
|
void
|
||||||
|
dcs_passthrough(struct terminal *term)
|
||||||
|
{
|
||||||
|
LOG_DBG("DCS passthrough: %.*s (%zu bytes)",
|
||||||
|
(int)term->vt.dcs.idx, term->vt.dcs.data, term->vt.dcs.idx);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
dcs_ensure_size(struct terminal *term, size_t required_size)
|
||||||
|
{
|
||||||
|
if (required_size <= term->vt.dcs.size)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
size_t new_size = (required_size + 127) / 128 * 128;
|
||||||
|
assert(new_size > 0);
|
||||||
|
|
||||||
|
uint8_t *new_data = realloc(term->vt.dcs.data, new_size);
|
||||||
|
if (new_data == NULL) {
|
||||||
|
LOG_ERRNO("failed to increase size of DCS buffer");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
term->vt.dcs.data = new_data;
|
||||||
|
term->vt.dcs.size = new_size;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
7
dcs.h
Normal file
7
dcs.h
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include "terminal.h"
|
||||||
|
|
||||||
|
void dcs_passthrough(struct terminal *term);
|
||||||
|
bool dcs_ensure_size(struct terminal *term, size_t required_size);
|
||||||
1
main.c
1
main.c
|
|
@ -819,6 +819,7 @@ out:
|
||||||
xkb_context_unref(term.kbd.xkb);
|
xkb_context_unref(term.kbd.xkb);
|
||||||
|
|
||||||
free(term.vt.osc.data);
|
free(term.vt.osc.data);
|
||||||
|
free(term.vt.dcs.data);
|
||||||
for (int row = 0; row < term.normal.num_rows; row++)
|
for (int row = 0; row < term.normal.num_rows; row++)
|
||||||
grid_row_free(term.normal.rows[row]);
|
grid_row_free(term.normal.rows[row]);
|
||||||
free(term.normal.rows);
|
free(term.normal.rows);
|
||||||
|
|
|
||||||
|
|
@ -62,6 +62,7 @@ executable(
|
||||||
'config.c', 'config.h',
|
'config.c', 'config.h',
|
||||||
'commands.c', 'commands.h',
|
'commands.c', 'commands.h',
|
||||||
'csi.c', 'csi.h',
|
'csi.c', 'csi.h',
|
||||||
|
'dcs.c', 'dcs.h',
|
||||||
'font.c', 'font.h',
|
'font.c', 'font.h',
|
||||||
'grid.c', 'grid.h',
|
'grid.c', 'grid.h',
|
||||||
'input.c', 'input.h',
|
'input.c', 'input.h',
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,11 @@ struct vt {
|
||||||
size_t size;
|
size_t size;
|
||||||
size_t idx;
|
size_t idx;
|
||||||
} osc;
|
} osc;
|
||||||
|
struct {
|
||||||
|
uint8_t *data;
|
||||||
|
size_t size;
|
||||||
|
size_t idx;
|
||||||
|
} dcs;
|
||||||
struct {
|
struct {
|
||||||
uint8_t data[4];
|
uint8_t data[4];
|
||||||
size_t idx;
|
size_t idx;
|
||||||
|
|
|
||||||
20
vt.c
20
vt.c
|
|
@ -9,8 +9,9 @@
|
||||||
#define LOG_ENABLE_DBG 0
|
#define LOG_ENABLE_DBG 0
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "csi.h"
|
#include "csi.h"
|
||||||
#include "osc.h"
|
#include "dcs.h"
|
||||||
#include "grid.h"
|
#include "grid.h"
|
||||||
|
#include "osc.h"
|
||||||
|
|
||||||
/* https://vt100.net/emu/dec_ansi_parser */
|
/* https://vt100.net/emu/dec_ansi_parser */
|
||||||
|
|
||||||
|
|
@ -923,10 +924,21 @@ action(struct terminal *term, enum action _action, uint8_t c)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ACTION_HOOK:
|
case ACTION_HOOK:
|
||||||
case ACTION_UNHOOK:
|
term->vt.dcs.idx = 0;
|
||||||
|
break;
|
||||||
|
|
||||||
case ACTION_PUT:
|
case ACTION_PUT:
|
||||||
LOG_ERR("unimplemented: action %s", action_names[_action]);
|
if (!dcs_ensure_size(term, term->vt.dcs.idx + 1))
|
||||||
abort();
|
break;
|
||||||
|
term->vt.dcs.data[term->vt.dcs.idx++] = c;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ACTION_UNHOOK:
|
||||||
|
if (!dcs_ensure_size(term, term->vt.dcs.idx + 1))
|
||||||
|
break;
|
||||||
|
term->vt.dcs.data[term->vt.dcs.idx] = '\0';
|
||||||
|
dcs_passthrough(term);
|
||||||
|
break;
|
||||||
|
|
||||||
case ACTION_UTF8_2_ENTRY:
|
case ACTION_UTF8_2_ENTRY:
|
||||||
term->vt.utf8.idx = 0;
|
term->vt.utf8.idx = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue