termptyesc: export DA handler to its own function + tests

Also support DA3.
This commit is contained in:
Boris Faure 2019-01-19 23:50:31 +01:00
parent b7e84963c7
commit 96bbfd054b
3 changed files with 123 additions and 29 deletions

View File

@ -2869,6 +2869,77 @@ _handle_esc_csi_rep(Termpty *ty, Eina_Unicode **ptr)
}
}
static void
_handle_esc_csi_da(Termpty *ty, Eina_Unicode **ptr)
{
Eina_Unicode *b = *ptr;
char bf[32];
char start = 'X';
int arg;
int len;
if (b)
{
start = *b;
}
arg = _csi_arg_get(ty, &b);
if ((arg == -CSI_ARG_ERROR) || (arg > 0))
return;
DBG("DA - Device Attributes");
switch (start)
{
case '=':
/* Tertiary device attributes
* Device ID is set to ~~TY in ascii:
* - '~' is 7E
* - 'T' is 54
* - 'Y' is 59
*/
len = snprintf(bf, sizeof(bf), "\033P!|7E7E5459\033\\");
break;
case '>':
/* Secondary device attributes
* 0 VT100
* 1 VT220
* 2 VT240
* 18 VT330
* 19 VT340
* 24 VT320
* 41 VT420
* 61 VT510
* 64 VT520
* 65 VT525
*/
len = snprintf(bf, sizeof(bf), "\033[>61;337;%ic", 0);
break;
default:
/* Primary device attributes
* 1 132 columns
* 2 Printer port
* 4 Sixel
* 6 Selective erase
* 7 Soft character set (DRCS)
* 8 User-defined keys (UDKs)
* 9 National replacement character sets (NRCS) (International terminal only)
* 12 Yugoslavian (SCS)
* 15 Technical character set
* 18 Windowing capability
* 21 Horizontal scrolling
* 22 Color
* 23 Greek
* 24 Turkish
* 42 ISO Latin-2 character set
* 44 PCTerm
* 45 Soft key map
* 46 ASCII emulation
*/
len = snprintf(bf, sizeof(bf), "\033[?64;1;9;15;18;21;22c");
}
termpty_write(ty, bf, len);
}
static int
_handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
{
@ -2985,32 +3056,8 @@ _handle_esc_csi(Termpty *ty, const Eina_Unicode *c, const Eina_Unicode *ce)
case 'b':
_handle_esc_csi_rep(ty, &b);
break;
case 'c': // query device attributes
DBG("query device attributes");
{
char bf[32];
if (b && *b == '>')
{
// Primary device attributes
// 0 → VT100
// 1 → VT220
// 2 → VT240
// 18 → VT330
// 19 → VT340
// 24 → VT320
// 41 → VT420
// 61 → VT510
// 64 → VT520
// 65 → VT525
snprintf(bf, sizeof(bf), "\033[>41;337;%ic", 0);
}
else
{
// Secondary device attributes
snprintf(bf, sizeof(bf), "\033[?64;1;9;15;18;21;22c");
}
termpty_write(ty, bf, strlen(bf));
}
case 'c':
_handle_esc_csi_da(ty, &b);
break;
case 'd': // to row N
arg = _csi_arg_get(ty, &b);

46
tests/da.sh Executable file
View File

@ -0,0 +1,46 @@
#!/bin/sh
# fill space with E
printf '\033[69;1;1;25;80\044x'
#set color
printf '\033[46;31;3m'
# move
printf '\033[H'
#
# Primary attributes
#
# default value
printf '\033[c'
# 0
printf '\033[0c'
# invalid value
printf '\033[42c'
#
# Secondary attributes
#
# default value
printf '\033[>c'
# 0
printf '\033[>0c'
# invalid value
printf '\033[>42c'
#
# Tertiary attributes
#
# default value
printf '\033[=c'
# 0
printf '\033[=0c'
# invalid value
printf '\033[=42c'
# let it print
sleep 1

View File

@ -16,9 +16,9 @@ cursor-shape-5.sh 21332951c006a2d91cf0f227758ff477
cursor-shape-6.sh 21332951c006a2d91cf0f227758ff477
cursor-shape-7.sh 5d0dadf7273d918cbcd99df95e56795e
tabs.sh 960b74686e23e8e39c3446768b9efc75
xterm-osc-0-title-icon.sh edae688004c15739bcc5a10f51faa6ed
xterm-osc-1-icon.sh be549a661504e4dcfb974dcccd7b0bdf
xterm-osc-2-title.sh e8485fd460aba2a2ae1d4e63a1143b32
xterm-osc-0-title-icon.sh 020e0953ecb230afdb4c28a8012556bb
xterm-osc-1-icon.sh 36bd475d00e0ad408063dce8c8ea6fbd
xterm-osc-2-title.sh 957a0748020027e6723a04aaff3acd3a
dsr-cpr.sh a03cfba07a7b76075a4126f452d48ad5
dsr-dir.sh 28b0d8b4b60f3c61d49cee69895a07b2
dsr-kbd.sh 1c474c101697080a85563d9b5bc1505c
@ -70,3 +70,4 @@ text_append_after_right_margin.sh 26b334188d39e2b12538a6ca91ca168c
cbt.sh 417cd352d3eba45d6016df67a0314444
hpa.sh 0f86ca83e072d41b89dd1a012f0749a7
rep.sh b91ebb46fb5ebd95aa2cb87ad12bb4ba
da.sh 3083fbec33befe5299ca3726a19fcff2