Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sngrep in Different TERM Environments #495

Open
pksml85 opened this issue Jul 26, 2024 · 4 comments
Open

Sngrep in Different TERM Environments #495

pksml85 opened this issue Jul 26, 2024 · 4 comments

Comments

@pksml85
Copy link

pksml85 commented Jul 26, 2024

From: #494 (comment)

I'm using putty with pretty much the default settings on Windows 8.1 and Windows 10. I'm SSH-ing into a Debian 12 box. When pressing the Home and End keys on my keyboard, sngrep asks me if I want to quit. The 7 & 1 on the numeric keypad, which are labeled Home and End, do nothing. Page Up/Down skips down a few dialogs as expected, while the 9 & 3, which are labeled PgUp and PgDn, do nothing.

Is there a way that you know of where the Home and End keys will go to the beginning and the end of the dialogs in sngrep?
(BTW, the Home and End keys work properly in other applications, like nano.)

Reply from @Kaian

I'll try to reproduce this, but some fast google searchs mention TERM environment variable as something relevant. We could also create a new issue with Home and End keys not working in Putty for future reference.

Thanks for these links! I'll check them out.

@pksml85
Copy link
Author

pksml85 commented Jul 26, 2024

Apparently Debian 12's default terminal in bash is xterm (in simple command line environment without a GUI) when I log in using Putty. By simply entering the command TERM=putty, the Home and End keys work as they should.

Is it possible for sngrep to utilize the Home and End keys in xterm? Thanks!

Edit: linux is the Debian 12 default terminal. When opening an ssh connection in putty, it's xterm.

@jdiegmueller
Copy link

Apparently Debian 12's default terminal in bash is xterm (in simple command line environment without a GUI) when I log in using Putty. By simply entering the command TERM=putty, the Home and End keys work as they should.

Is it possible for sngrep to utilize the Home and End keys in xterm? Thanks!

Edit: linux is the Debian 12 default terminal. When opening an ssh connection in putty, it's xterm.

I vote for 'xterm-256color', as well. Same problem as you, except SecureCRT.

Since you suggest you use bash, you can do "TERM=putty sngrep" and not affect anything else beyond sngrep.

@sergey-safarov
Copy link
Contributor

Proable you can place this content into /etc/profile.d/sngrep.sh

alias sngrep="TERM=putty sngrep"

Next time you open a shell and execute sngrep this will set the required term.

@Kaian
Copy link
Member

Kaian commented Nov 19, 2024

Hi!

I've found some sngrep code that redefines key parsing codes for some terminals, and maybe that's causing the problem (or could be part of the solution).

// Redefine some keys
term = getenv("TERM");
if (term
&& (!strcmp(term, "xterm") || !strcmp(term, "xterm-color") || !strcmp(term, "vt220"))) {
define_key("\033[H", KEY_HOME);
define_key("\033[F", KEY_END);
define_key("\033OP", KEY_F(1));
define_key("\033OQ", KEY_F(2));
define_key("\033OR", KEY_F(3));
define_key("\033OS", KEY_F(4));
define_key("\033[11~", KEY_F(1));
define_key("\033[12~", KEY_F(2));
define_key("\033[13~", KEY_F(3));
define_key("\033[14~", KEY_F(4));
define_key("\033[17;2~", KEY_F(18));
}

We could add a setting to disable that block, so you just configure to skip this code in your sngreprc

There is also a configuration option to remap some actions keybindings, not sure if it may help here.

Best regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants