From 1531b185660fd6c8c684305f3e74da6684cd9b53 Mon Sep 17 00:00:00 2001 From: iliajie Date: Mon, 5 Dec 2022 01:40:18 +0200 Subject: [PATCH 1/3] Add support to set `TERM` variable --- xterm/config | 1 + xterm/config.info | 1 + xterm/shellserver.pl | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/xterm/config b/xterm/config index a5fbd0299..f42801ced 100644 --- a/xterm/config +++ b/xterm/config @@ -1,2 +1,3 @@ base_port=555 rcfile=0 +xterm=xterm-256color diff --git a/xterm/config.info b/xterm/config.info index d7df4b8eb..c8f2a03e5 100644 --- a/xterm/config.info +++ b/xterm/config.info @@ -1,3 +1,4 @@ +xterm=Set TERM environmental variable to,4,0-xterm-256color,1-xterm-16color,2-xterm,3-vt102,3-vt100,4-vt52,5-rxvt,6-nsterm,7-dtterm,8-ansi base_port=Base port number for WebSockets connections,0,5 size=Terminal width and height in characters,3,Automatic,5,,,Static (80x24) rcfile=Execute initialization commands from file,10,0-Shell default,1-Module default,Custom diff --git a/xterm/shellserver.pl b/xterm/shellserver.pl index 41e5ab0c2..990bc24b3 100755 --- a/xterm/shellserver.pl +++ b/xterm/shellserver.pl @@ -29,7 +29,8 @@ else { &clean_environment(); # Set terminal -$ENV{'TERM'} = 'xterm-256color'; +my @terms = ('xterm-256color', 'xterm-16color', 'xterm', 'vt102', 'vt100', 'vt52', 'rxvt', 'nsterm', 'dtterm', 'ansi'); +$ENV{'TERM'} = defined($config{'xterm'}) ? $terms[$config{'xterm'}] : 'xterm-256color'; $ENV{'HOME'} = $uinfo[7]; chdir($dir || $uinfo[7] || "/"); my $shellcmd = $uinfo[8]; From 6c297057d32ab72610653488424ed1e0a2728e4a Mon Sep 17 00:00:00 2001 From: iliajie Date: Mon, 5 Dec 2022 02:16:18 +0200 Subject: [PATCH 2/3] Add support to set shell character encoding --- xterm/config | 3 ++- xterm/config.info | 1 + xterm/shellserver.pl | 10 ++++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/xterm/config b/xterm/config index f42801ced..2d40a006c 100644 --- a/xterm/config +++ b/xterm/config @@ -1,3 +1,4 @@ +xterm=xterm-256color base_port=555 rcfile=0 -xterm=xterm-256color +locale=0 diff --git a/xterm/config.info b/xterm/config.info index c8f2a03e5..13ad6dfee 100644 --- a/xterm/config.info +++ b/xterm/config.info @@ -1,4 +1,5 @@ xterm=Set TERM environmental variable to,4,0-xterm-256color,1-xterm-16color,2-xterm,3-vt102,3-vt100,4-vt52,5-rxvt,6-nsterm,7-dtterm,8-ansi base_port=Base port number for WebSockets connections,0,5 size=Terminal width and height in characters,3,Automatic,5,,,Static (80x24) +locale=Set shell character encoding,10,0-Shell default,1-en_US.UTF-8,Custom rcfile=Execute initialization commands from file,10,0-Shell default,1-Module default,Custom diff --git a/xterm/shellserver.pl b/xterm/shellserver.pl index 990bc24b3..3ec3ca8ce 100755 --- a/xterm/shellserver.pl +++ b/xterm/shellserver.pl @@ -28,6 +28,16 @@ else { &foreign_require("proc"); &clean_environment(); +# Set locale +my $lang = $config{'locale'}; +if ($lang) { + my @opts = ('LC_ALL', 'LANG', 'LANGUAGE'); + $lang = 'en_US.UTF-8' if ($lang == 1); + foreach my $opt (@opts) { + $ENV{$opt} = &trim($lang); + } + } + # Set terminal my @terms = ('xterm-256color', 'xterm-16color', 'xterm', 'vt102', 'vt100', 'vt52', 'rxvt', 'nsterm', 'dtterm', 'ansi'); $ENV{'TERM'} = defined($config{'xterm'}) ? $terms[$config{'xterm'}] : 'xterm-256color'; From edcf8841ab77b43f0cfd620bb7e419e869778e69 Mon Sep 17 00:00:00 2001 From: iliajie Date: Mon, 5 Dec 2022 19:50:54 +0200 Subject: [PATCH 3/3] Fix to set config option directly --- xterm/config.info | 2 +- xterm/shellserver.pl | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/xterm/config.info b/xterm/config.info index 13ad6dfee..b3fdaa737 100644 --- a/xterm/config.info +++ b/xterm/config.info @@ -1,4 +1,4 @@ -xterm=Set TERM environmental variable to,4,0-xterm-256color,1-xterm-16color,2-xterm,3-vt102,3-vt100,4-vt52,5-rxvt,6-nsterm,7-dtterm,8-ansi +xterm=Set TERM environmental variable to,4,xterm+256color-xterm-256color,xterm+16color-xterm-16color,xterm-xterm,vt102-vt102,vt100-vt100,vt52-vt52,rxvt-rxvt,nsterm-nsterm,dtterm-dtterm,ansi-ansi base_port=Base port number for WebSockets connections,0,5 size=Terminal width and height in characters,3,Automatic,5,,,Static (80x24) locale=Set shell character encoding,10,0-Shell default,1-en_US.UTF-8,Custom diff --git a/xterm/shellserver.pl b/xterm/shellserver.pl index 3ec3ca8ce..6258e1fba 100755 --- a/xterm/shellserver.pl +++ b/xterm/shellserver.pl @@ -39,8 +39,11 @@ if ($lang) { } # Set terminal -my @terms = ('xterm-256color', 'xterm-16color', 'xterm', 'vt102', 'vt100', 'vt52', 'rxvt', 'nsterm', 'dtterm', 'ansi'); -$ENV{'TERM'} = defined($config{'xterm'}) ? $terms[$config{'xterm'}] : 'xterm-256color'; +my $config_xterm = $config{'xterm'}; +$config_xterm = 'xterm-256color' + if (!$config_xterm); +$config_xterm =~ s/\+/-/; +$ENV{'TERM'} = $config_xterm; $ENV{'HOME'} = $uinfo[7]; chdir($dir || $uinfo[7] || "/"); my $shellcmd = $uinfo[8];