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

Can't clear text using Backspace when you take input in tui mode #3

Closed
SharathKumarK06 opened this issue Oct 1, 2022 · 9 comments
Closed

Comments

@SharathKumarK06
Copy link

Can't backspace when you take input in tui mode

When you take input in tui mode, like take input for new note or search, you cannot backspace.
When you press backspace, it print character 'h'.
backspace-issue-brain

@SharathKumarK06
Copy link
Author

BTW Thank you for this wonderful program. This is awesome <3<3<3

robert-lag added a commit that referenced this issue Oct 2, 2022
Bug:
- When pressing 'backspace' in TUI while one of the InputModes Add,
  Remove or Search is active, a character is printed instead of
  deleting the last character.
robert-lag added a commit that referenced this issue Oct 2, 2022
Bug:
- When pressing 'backspace' in TUI while one of the InputModes Add,
  Remove or Search is active, a character is printed instead of
  deleting the last character.
@robert-lag
Copy link
Owner

BTW Thank you for this wonderful program. This is awesome <3<3<3

Always glad to hear that ;)

When you press backspace, it print character 'h'.

I just released a new version (Version 2.3.2) where I tried to solve the issue. Does it work there?

@SharathKumarK06
Copy link
Author

SharathKumarK06 commented Oct 3, 2022

I don't know if I am missing something. It still the same 😢
I git pull ed it and build using cargo build --release

@robert-lag
Copy link
Owner

Ok, then I'm not sure if this issue is really caused by brain. I repeatedly checked the section where user input is handled, but there doesn't seem to be anything wrong with it, and I also find it very unlikely that the problem lies with the IO library.😅

You could perhaps check if you are using the latest version (2.3.2) of brain using brn --version.

Also, does backspace work in your shell and other terminal applications, or does it print ^H?

@SharathKumarK06
Copy link
Author

SharathKumarK06 commented Oct 5, 2022

You could perhaps check if you are using the latest version (2.3.2) of brain using brn --version .

I git pulled and compiled from there.

I repeatedly checked the section where user input is handled, but there doesn't seem to be anything wrong with it, and I also find it very unlikely that the problem lies with the IO library.

Yeah, I looked into the source too and I'm not sure what is wrong(I just started learning rust after this project, not familiar how this library used, have some basic concepts and assumptions).
I started to think it might be from tui library or something.
Also I noticed that tui isn't refreshing after adding notes or modifying the name of a note.
Hope this small detail might help you somehow :).

Also, does backspace work in your shell and other terminal applications, or does it print ^H?

Yes, backspace works I don't have that kinda issues

@robert-lag
Copy link
Owner

Also I noticed that tui isn't refreshing after adding notes or modifying the name of a note.

Thank you for pointing this out. I'm aware of this issue but didn't solve it until now because it's only a minor issue and also a bit difficult to implement without creating new problems (e.g. How can you make sure that the notes are in the same order as before you automatically refreshed the page?). But I'm always open for Pull-Requests. ;)

Yes, backspace works I don't have that kinda issues

Could you give me the following information, so I could try to reproduce the issue:

  • Your terminal
  • The output of stty -a
  • The output of showkey -a when pressing backspace and CTRL+backspace?
  • What happens when you use CTRL+backspace instead of only backspace in brn tui?

I'm guessing that your terminal might send the character ^H instead of ^? when pressing backspace, which isn't recognized by the TUI library (crossterm).

@SharathKumarK06
Copy link
Author

SharathKumarK06 commented Oct 6, 2022

Could you give me the following information, so I could try to reproduce the issue:

So you don't have that issue?

Your terminal

qteminal default in kali linux

The output of stty -a

speed 38400 baud; rows 61; columns 237; line = 0;
intr = ^C; quit = ^\; erase = ^H; kill = ^U; eof = ^D; eol = <undef>; eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R; werase = ^W; lnext = ^V; discard = ^O; min = 1; time = 0;
-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl -ixon -ixoff -iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt echoctl echoke -flusho -extproc

The output of showkey -a when pressing backspace and CTRL+backspace?

Backspace - ^H 8 0010 0x08
CTRL+Backspace - ^? 127 0177 0x7f

What happens when you use CTRL+backspace instead of only backspace in brn tui?

Interestingly enough, it clears the text

I'm guessing that your terminal might send the character ^H instead of ^? when pressing backspace, which isn't recognized by the TUI library (crossterm).

Oh yeah, now I see the problem. That's why it prints 'h'.
So what do we do about it?

@robert-lag
Copy link
Owner

Now I'm able to reproduce the problem. It seems to occur on certain terminals which print ^H instead of ^? when pressing backspace (e.g. qterminal, xterm, etc.). This also seems to be a known issue for qterminal as seen here.

I'm now searching for a workaround for it. ;)

robert-lag added a commit that referenced this issue Oct 7, 2022
Now, brn tui will recognize the control char `^H` in addition to `^?`
as backspace.
@robert-lag
Copy link
Owner

The latest version of brn (2.3.3) should now be able to fix this issue.

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

No branches or pull requests

2 participants