-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Macros #1234
Macros #1234
Conversation
Looks like the CI had a submodule fetch failure. |
I want to add recording status to the statusline but I don't think I am able to access it from the |
`helix_term::compositor::Callback` changed to take a `&mut Context` as a parameter for use by `play_macro`
When macro recording is active, the pending keys display will be shifted 3 characters left, and the register being recorded to will be displayed between brackets — e.g., `[@]` — right of the pending keys display.
I think this should be done now. |
let reg = cx.register.take().unwrap_or('@'); | ||
cx.editor.macro_recording = Some((reg, Vec::new())); | ||
cx.editor | ||
.set_status(format!("Recording to register {}", reg)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does our macro reuse the same register as the normal registers? IIRC vim macros have separate registers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We reuse the normal register since that means you can edit the macro as text (paste it in the buffer, edit, yank it back). I think vim also allowed for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Vim macros do not have separate registers.
"q" => record_macro, | ||
"Q" => play_macro, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be the reverse, Q
should record macro and q
should play macro like in vim.
Since it's a macro, it's expected to play more than record. And since play is expected to be used more frequently, it would be best use without extra shift.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, kakoune has this as well. I didn't realize it during review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In Vim, record is q
and play is @
; I changed it here because I figured it's more consistent. But yeah, swapping q
and Q
here does make sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(it's also "replay" instead of "play" but I didn't have strong opinions there)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, yeah sorry if I get stuff inconsistent with Kakoune, I've never used it and am not very familiar with it. Though in this situation, I do believe "play" makes very slightly more sense than "replay", since it is possible to play a macro without actually recording it, in which case playing it would not be a "replay".
.get(reg) | ||
.and_then(|reg| reg.read().get(0)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can just use cx.editor.registers.read(reg)
helper.
q
will begin recording to register@
"aq
will begin recording to registera
q
while recording will stop recording and save to the registerQ
will play the recording from register@
"aQ
will play the recording from registera
Macros are saved to registers as space-delimited serialized keypresses, such as
x d o 0 esc h C-a
.I've had to change
helix_term::compositor::Callback
to take&mut Context
as a parameter so thatplay_macro
would have access to thehandle_event
method.