dvtm

dynamic virtual terminal manager - with my changes
git clone https://pi.duncano.de/git/dvtm.git
Log | Files | Refs | README | LICENSE

commit 96fc60e9017d673be9119d07732d91e936d61b4b
parent d25ad04fa81dd841b24f688a1a9d9099e307e982
Author: Marc Andre Tanner <mat@brain-dump.org>
Date:   Wed, 13 Mar 2013 20:48:32 +0100

Add a way to send custom escape sequences upon keypress

Signed-off-by: Marc Andre Tanner <mat@brain-dump.org>

Diffstat:
config.def.h | 4++++
dvtm.c | 1+
vt.c | 11++++++++++-
vt.h | 1+
4 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/config.def.h b/config.def.h @@ -150,3 +150,7 @@ static Cmd commands[] = { static Action actions[] = { { create, { NULL } }, }; + +static char const * const keytable[] = { + /* add your custom key escape sequences */ +}; diff --git a/dvtm.c b/dvtm.c @@ -655,6 +655,7 @@ setup() { mouse_setup(); raw(); vt_init(); + vt_set_keytable(keytable, countof(keytable)); resize_screen(); signal(SIGWINCH, sigwinch_handler); signal(SIGCHLD, sigchld_handler); diff --git a/vt.c b/vt.c @@ -156,7 +156,7 @@ struct Vt { void *data; }; -static char const * const keytable[KEY_MAX+1] = { +static const char *keytable[KEY_MAX+1] = { ['\n'] = "\r", /* for the arrow keys the CSI / SS3 sequences are not stored here * because they depend on the current cursor terminal mode @@ -2181,6 +2181,15 @@ void vt_init(void) strncat(vt_term, color_suffix, sizeof(color_suffix) - 1); } +void vt_set_keytable(const char * const keytable_overlay[], int count) +{ + for (int k = 0; k < count && k < KEY_MAX; k++) { + const char *keyseq = keytable_overlay[k]; + if (keyseq) + keytable[k] = keyseq; + } +} + void vt_shutdown(void) { free(color2palette); diff --git a/vt.h b/vt.h @@ -61,6 +61,7 @@ enum { typedef void (*vt_event_handler_t)(Vt *, int event, void *data); void vt_init(void); +void vt_set_keytable(char const * const keytable_overlay[], int count); void vt_shutdown(void); void vt_set_escseq_handler(Vt *, vt_escseq_handler_t); void vt_set_event_handler(Vt *, vt_event_handler_t);