termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
12.61k stars 2.91k forks source link

[Bug]: escape sequence issues with `vtm` #20655

Open amigojapan opened 1 week ago

amigojapan commented 1 week ago

Problem description

look at the prompt area in the terminal of this image https://x0.at/IQ6B.jpg the numbers there get in the way os uing the terminal properly...

What steps will reproduce the bug?

install vtm package run vtm under termux, and start a terminal on an amazon fire 10 HD plus

What is the expected behavior?

I expected to just see a normal prompt and not to be mixed with numbers

System information

Terminal transcript (~ $ termux-info
Termux Variables:
TERMUX_APK_RELEASE=F_DROID
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=25210
TERMUX_IS_DEBUGGABLE_BUILD=0
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.0
TERMUX__USER_ID=0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://mirrors.utermux.dev/termux/termux-main stable main
# x11-repo (sources.list.d/x11.list)
deb https://mirrors.utermux.dev/termux/termux-x11 x11 main
Updatable packages:
apt/stable 2.7.14 aarch64 [upgradable from: 2.7.12]
clang/stable 18.1.7-1 aarch64 [upgradable from: 18.1.5]
command-not-found/stable 2.4.0-30 aarch64 [upgradable from: 2.4.0-23]
curl/stable 8.8.0 aarch64 [upgradable from: 8.7.1-1]
debianutils/stable 5.19 aarch64 [upgradable from: 5.17]
git/stable 2.45.2 aarch64 [upgradable from: 2.45.0]
glib/stable 2.80.3 aarch64 [upgradable from: 2.80.2]
golang/stable 3:1.22.3 aarch64 [upgradable from: 3:1.22.2]
libandroid-shmem/stable 0.5 aarch64 [upgradable from: 0.4]
libandroid-support/stable 29 aarch64 [upgradable from: 28-3]
libcompiler-rt/stable 18.1.7-1 aarch64 [upgradable from: 18.1.5]
libcurl/stable 8.8.0 aarch64 [upgradable from: 8.7.1-1]
libdrm/stable 2.4.121 aarch64 [upgradable from: 2.4.120]
libedit/stable 20240517-3.1-0 aarch64 [upgradable from: 20221030-3.1-0]
libgcrypt/stable 1.10.3-1 aarch64 [upgradable from: 1.10.3]
libllvm/stable 18.1.7-1 aarch64 [upgradable from: 18.1.5]
liblzma/stable 5.6.2 aarch64 [upgradable from: 5.6.1+really5.4.5]
libnghttp2/stable 1.62.1 aarch64 [upgradable from: 1.61.0]
libnghttp3/stable 1.4.0 aarch64 [upgradable from: 1.3.0]
libpixman/stable 0.43.4 aarch64 [upgradable from: 0.42.2]
libsqlite/stable 3.46.0 aarch64 [upgradable from: 3.45.3]
libtirpc/stable 1.3.4-1 aarch64 [upgradable from: 1.3.4]
libxml2/stable 2.13.1-1 aarch64 [upgradable from: 2.12.6]
libxmu/x11 1.2.1 aarch64 [upgradable from: 1.1.4]
lld/stable 18.1.7-1 aarch64 [upgradable from: 18.1.5]
llvm/stable 18.1.7-1 aarch64 [upgradable from: 18.1.5]
mesa/stable 24.0.8 aarch64 [upgradable from: 24.0.7]
ncurses-ui-libs/stable 6.4.20231001-4 aarch64 [upgradable from: 6.4.20231001-3]
ncurses/stable 6.4.20231001-4 aarch64 [upgradable from: 6.4.20231001-3]
pcre2/stable 10.44 aarch64 [upgradable from: 10.43]
python-ensurepip-wheels/stable 3.11.9-2 all [upgradable from: 3.11.9]
python/stable 3.11.9-2 aarch64 [upgradable from: 3.11.9]
termux-tools/stable 1.42.4 all [upgradable from: 1.42.1]
vim-runtime/stable 9.1.0500 all [upgradable from: 9.1.0200]
vim/stable 9.1.0500 aarch64 [upgradable from: 9.1.0200]
vulkan-loader-generic/stable 1.3.288 aarch64 [upgradable from: 1.3.284]
xorg-xauth/x11 1.1.3-1 aarch64 [upgradable from: 1.1.3]
xz-utils/stable 5.6.2 aarch64 [upgradable from: 5.6.1+really5.4.5]
termux-tools version:
1.42.1
Android version:
9
Kernel build information:
Linux localhost 4.4.146+ #1 SMP PREEMPT Thu Apr 18 13:17:18 UTC 2024 aarch64 Android
Device manufacturer:
Amazon
Device model:
KFTRPWI
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
~ $)

echo $PS1  [\e[0;32m]\w[\e[0m] [\e[0;97m]\$[\e[0m]

it does not work in VTM for termux, I did PS1=A but still the strange numbers appear

twaik commented 1 week ago

Screenshot url is broken, error 404.

TomJo2000 commented 1 week ago

Screenshot url is broken, error 404.

Works on my end.

Anyway, it looks like what's being output there is a escape sequence 2::238:238:238m looks a lot like a 24bit SGR code. Although escape sequences usually use ; as the group separator, not :.

twaik commented 1 week ago

Can you please re-upload it to github?

TomJo2000 commented 1 week ago

image There you go

amigojapan commented 1 week ago

Screenshot url is broken, error 404.

this is another copy of the image on a different image sharing system:

image

TomJo2000 commented 1 week ago

You can just paste an image into the GitHub comment textbox and it will be uploaded to GitHub's CDN.

amigojapan commented 1 week ago

by the way, I thought it may be problems with PS1 environment variable, but

echo $PS1  [\e[0;32m]\w[\e[0m] [\e[0;97m]$[\e[0m]

it does not work in VTM for termux, I did PS1=A but still the strange numbers appear

amigojapan commented 1 week ago

You can just paste an image into the GitHub comment textbox and it will be uploaded to GitHub's CDN.

sorry, I cant figure out how to do it on my android tablet, I will try when I get home...

amigojapan commented 1 week ago

sorry it took me so long: here it is image

fornwall commented 2 days ago

It seems that more and more terminal emulators and terminal programs supports colon (:) as well as semicolon:

red=255 green=100 blue=0 
printf "\x1b[38;2;${red};${green};${blue}m TRUECOLOR\n" # Semicolon separated, works in Termux
printf "\x1b[38:2:${red}:${green}:${blue}m TRUECOLOR\n" # Colon separated, does not work in Termux yet

See https://github.com/termstandard/colors?tab=readme-ov-file#truecolor-support-in-output-devices, where it can be seen that multiple terminal emulators also support using a colon as delimiter nowadays:

alacritty [delimiter: colon, semicolon] - written in Rust iTerm2 [delimiter: colon, semicolon] - since v3 version kitty [delimiter: colon,semicolon] - uses OpenGL konsole [delimiter: colon, semicolon] - https://bugs.kde.org/show_bug.cgi?id=107487 All libvte based terminals (since 0.36 version) [delimiter: colon, semicolon] [..]

While we could patch our own packages to use semicolon instead of colon, it won't help when ssh:ing to other environments and similar, so it's probably best to add support for colon separated parameters also in Termux - I'll be working on that.

It's closely related to the colon parameters for underlines that neovim has started to use - https://github.com/termux/termux-packages/issues/20620#issuecomment-2185826619.