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

Move cursor one word left or right #63

Closed
chyroc opened this issue Mar 27, 2018 · 4 comments
Closed

Move cursor one word left or right #63

chyroc opened this issue Mar 27, 2018 · 4 comments

Comments

@chyroc
Copy link
Contributor

chyroc commented Mar 27, 2018

Suggestions

Please write your suggestion here and removed "Bug reports section".

in : https://stackoverflow.com/questions/6205157/iterm-2-how-to-set-keyboard-shortcuts-to-jump-to-beginning-end-of-line

i can change iTerm2 setting:

  • 0x1b 0x62 to Move cursor one word left
  • 0x1b 0x66 to Move cursor one word right

how can i do this same with go-prompt

  • Operating System:
    osx

  • Terminal Emulator:
    iTerm2

  • tag of go-prompt or commit revision:
    master

@chyroc chyroc changed the title Move cursor one word left Move cursor one word left or right Mar 27, 2018
@c-bata
Copy link
Owner

c-bata commented Mar 27, 2018

It is possible by adding custom keybinds via OptionAddKeyBind. But go-prompt needs to define 0x1b 0x62 and 0x1b 0x66 keys at posix_input.go

By the way, the answer of stackoverflow says:

  • 0x1b 0x62 means Option/Alt + Left
  • 0x1b 0x66 means Option/Alt + Right

But in my environment(macOS Sierra and iTerm2):

  • Option/Alt + Left returns 0x1b, 0x1b, 0x5b, 0x44
  • Option/Alt + Right returns 0x1b, 0x1b, 0x5b, 0x43.

Is this behavior different with OSX?

@chyroc
Copy link
Contributor Author

chyroc commented Apr 11, 2018

the answer of stackoverflow says is to set such key, not the real key.

@chyroc
Copy link
Contributor Author

chyroc commented Apr 11, 2018

i make a pr , and add the follow code in my project to move cursor one word left or right

		prompt.OptionAddASCIICodeBind(prompt.ASCIICodeBind{
			ASCIICode: []byte{0x1b, 0x62},
			Fn:        prompt.GoLeftWord,
		}),
		prompt.OptionAddASCIICodeBind(prompt.ASCIICodeBind{
			ASCIICode: []byte{0x1b, 0x66},
			Fn:        prompt.GoRightWord,
		}),

@c-bata c-bata closed this as completed in 8f99fdf Jun 8, 2018
@chriswalz
Copy link

Thank you @chyroc this is super helpful for bit CLI!

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

3 participants