callum-oakley / gotta-go-fast

A command line utility for practicing typing and measuring your WPM and accuracy.
BSD 3-Clause "New" or "Revised" License
285 stars 16 forks source link

Ctrl+Backspace to delete previous word #9

Closed gyvess closed 4 years ago

gyvess commented 4 years ago

Any chance you could add this feature? Ctrl+Backspace is a fairly common way to quickly remove multiple characters. Sometimes correcting yourself from the beginning of a word makes more sense, so as to get a better handle on the typing rhythm of a word.

callum-oakley commented 4 years ago

Great idea. I'll definitely do this when I get a chance.

callum-oakley commented 4 years ago

@gyvess v0.2.1.0 supports backspacing by word. You can backspace word with ctrl+backspace, alt+backspace, or ctrl+w.

Enjoy!

gyvess commented 4 years ago

I've just update to the latest release and neither Ctrl+Backspace nor Alt+Backspace seem to work, however Ctrl+w does.

Hopefully someone else can verify and this isn't simply a problem on my end.

gyvess commented 4 years ago

I'm not a coder, but I added KChar 'h' -> continue $ applyBackspaceWord s in the appropriate places within UI.hs and that doesn't work either. ^H or Ctrl+h is what's commonly used for backward-kill-word in terminal, and Ctrl+Backspace essentially puts out the same code. So there appears to be some sort of modifier plus keycode conflict going on since neither work. I added and tested other characters which functioned, so I'm fairly certain this may be the case.

Tested in both ST and urxvt, using ZSH as my shell. ZSH allows you to bind Ctlr+Backspace to backward-kill-word and that works fine. I also use fzf, and had to bind Ctrl+h to backward-kill-word during a search. As a result, since Ctrl+Backspace and Ctrl+h are essentially the same, Ctrl+Backspace works as expected within fzf as well.

callum-oakley commented 4 years ago

Hmm interesting. To double check you're on the correct version, what do you get for gotta-go-fast --version? (should be 0.2.1.0)

I suspect it might be as you said and there's some sort of conflict. If you feel like getting your hands dirty one way to debug it could be to log out the keycode that is actually produced when you hit ctrl+backspace (using Debug.Trace), otherwise I'll have a bit of a play to see if I can reproduce it myself (it's working okay on my machine unfortunately 😬).

gyvess commented 4 years ago

I'm on the latest version, Gotta Go Fast 0.2.1.0. How do I properly invoke this debug? Again, I'm not a coder but I'd be happy to help so no one else runs into this problem.

In the meantime I have a workaround for anyone using urxvt. In your .Xresources file add URxvt.keysym.Control-BackSpace: ^W, where the ^W is invoked by pressing Ctrl+v followed by Ctrl+w. Now xrdb .Xresources and open a fresh new terminal. It should now function in gotta-go-fast now and because Ctrl+w is commonly used the same way Ctrl+Backspace is, I haven't found any conflicts.