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

Add support for clearing the count repetitions by pressing Esc #39

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

yarbelk
Copy link

@yarbelk yarbelk commented Jun 29, 2014

Moved the check for pressing Esc to before where the command event keys are processed - and it will clear out the number of repetitions entered.

This was going to be part of implementing F and f as commands: Both of which require you to be able to enter addtional characters after the command.

First pass didn't work so well, so here is just the escape part.

switch ev.Ch {
case 0x0:
switch ev.Key {
case termbox.KeyEsc:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's put this in func (*m normalMode) Reset() and also call that at L231

@yarbelk
Copy link
Author

yarbelk commented Jul 1, 2014

Did so, but let me make more changes before pulling in - I want to make it part of command

- It is used in multiple places, so refactor to new function on
  normalMode.
- need some way of dealing with streams of commands comming in that lets
  us assemble composite commands - seperating out the implementation of
  parsing what a event results in helps going that way
- Reset then needs to be used across multiple modes, but it means
  something different in each - so we introduce the EditorMode interface

- NOTE: broken atm
@yarbelk
Copy link
Author

yarbelk commented Jul 3, 2014

ready @kisielk

}

func (m insertMode) Enter(editor *editor.Editor) {
func NewInsertMode(editor *editor.Editor, count int) (m *InsertMode) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to avoid named return variables unless necessary for clarity

@kisielk
Copy link
Owner

kisielk commented Jul 3, 2014

Thanks, I think it's looking good, but I think we may still be conflating the usage of "Reset" and "Exit" in some places. I think we should probably use "Reset" to mean reset the state of the current mode and stay there, such as when you push esc during a key sequence in normal mode. "Exit" should return you to the previous mode. What do you think?

@yarbelk
Copy link
Author

yarbelk commented Jul 4, 2014

I think you're on to something. the question is confused by the use of the 'Esc' key. Sometimes its one, sometimes the other.

example:

Esc in normal mode with digitts typed in -> Reset
Esc in command mode -> Escape.

I will do a pass through and see if i'm crossing these and clean up your comments

 - they were backwards
 - Add some comments to Exit, Reset (generally these seem to be NOOP)
 - Note - there are known bugs in this that are fixed in other pull
   requests
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

Successfully merging this pull request may close these issues.

2 participants