-
Notifications
You must be signed in to change notification settings - Fork 720
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
Enable remapping of Ctrl-C and Ctrl-G #5107
base: master
Are you sure you want to change the base?
Changes from 3 commits
3d14582
a7a3451
6ecf6bc
862718d
13e0054
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -79,6 +79,11 @@ are exclusively available to built-in options. | |
as a string but the set commands will complain if the entered text | ||
is not a valid regex | ||
|
||
*key*:: | ||
a single keypress using the same syntax as `map` (see | ||
<<mapping#mappable-keys,`:doc mapping mappable-keys`>>). If | ||
multiple keys are entered, only the first will be used. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think it's better to throw a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I changed it to require exactly 1, following the example of codepoint. However, I just realized that does prevent determined users from disabling it altogether if they want. Should |
||
|
||
*coord*:: | ||
a line, column pair (separated by a comma) | ||
Cannot be used with `declare-option` | ||
|
@@ -312,6 +317,15 @@ are exclusively available to built-in options. | |
*debug* `flags(hooks|shell|profile|keys|commands)`:: | ||
dump various debug information in the '\*debug*' buffer | ||
|
||
*interrupt_key* `key`:: | ||
_default_ <c-c> + | ||
key used to interrupt any running external processes | ||
|
||
*cancel_key* `key`:: | ||
_default_ <c-g> + | ||
key used to cancel long-running Kakoune operations and clear the input | ||
buffer | ||
|
||
*idle_timeout* `int`:: | ||
_default_ 50 + | ||
timeout, in milliseconds, with no user input that will trigger the | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -47,13 +47,14 @@ Client::Client(std::unique_ptr<UserInterface>&& ui, | |
m_ui->set_ui_options(m_window->options()["ui_options"].get<UserInterface::Options>()); | ||
m_ui->set_on_key([this](Key key) { | ||
kak_assert(key != Key::Invalid); | ||
if (key == ctrl('c')) | ||
auto opts = context().options(); | ||
djpohly marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (key == opts["interrupt_key"].get<Key>()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so this means that if a user really wants to, they can map it to different There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If a good way to sugar it occurs to us later, it could be added at that point, right? |
||
{ | ||
auto prev_handler = set_signal_handler(SIGINT, SIG_IGN); | ||
killpg(getpgrp(), SIGINT); | ||
set_signal_handler(SIGINT, prev_handler); | ||
} | ||
else if (key == ctrl('g')) | ||
else if (key == opts["cancel_key"].get<Key>()) | ||
{ | ||
m_pending_keys.clear(); | ||
print_status({"operation cancelled", context().faces()["Error"]}); | ||
|
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.
So this allows us to maybe make commands like
map global normal <c-c> ...
throw an error if
cancel_key=<c-c>
, and point to that option.Not sure if we want to do this; it would be a bit more user friendly on one
hand but also enforce an ordering of map/set-option commands in kakrc which
would be weird.
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.
Yeah, this sounds like it would introduce a little more complexity on both the user's and Kakoune's side. I do wonder if maybe the pointer about "warning, these two behave differently" belongs near the top of
:doc mapping
rather than at the very bottom of:doc keys
?