-
Notifications
You must be signed in to change notification settings - Fork 287
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
Intenational key binding fixes #234
Conversation
@@ -232,59 +232,59 @@ class TextAreaInput extends React.Component<{ screen: Screen; onHeightChange: () | |||
} | |||
inputModel.closeAIAssistantChat(); | |||
return; | |||
} | |||
if (e.code == "KeyE" && e.getModifierState("Meta")) { | |||
} |
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.
should I call this meta instead of command?
I think your CopyFile code got merged into this PR somehow? |
e.preventDefault(); | ||
inputModel.resetInput(); | ||
return; | ||
} | ||
if ( | ||
e.code == "KeyR" && | ||
(e.getModifierState("Meta") || e.getModifierState("Control")) && |
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.
some or key bindings here
I feel like we should make these either Ctrl or Cmd, rather than both
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 it should just be control?
Looking at this though I understand why or is used here since it's a really important command
Adds job status indicators that will show any updates to running commands while you are focused away from a tab. These will show up as status icons in the tab view. These indicators will reset for a given tab when you focus back to it. I've updated the inner formatting of the tab to use flexboxes, allowing the title to display more text when there are no icons to display. Also includes some miscellaneous for-loop pattern improvements in model.ts and removing of unused variables, etc. --------- Co-authored-by: sawka <[email protected]>
635f5dc
to
202ee84
Compare
@@ -95,29 +96,33 @@ function formatSessionName(snames: Record<string, string>, sessionId: string): s | |||
} | |||
|
|||
@mobxReact.observer | |||
class HistoryCheckbox extends React.Component<{ checked: boolean, partialCheck?: boolean, onClick?: () => void }, {}> { | |||
class HistoryCheckbox extends React.Component<{ checked: boolean; partialCheck?: boolean; onClick?: () => void }, {}> { |
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.
prettier related changes, not rebase artifacts I'm pretty sure
e.preventDefault(); | ||
e.stopPropagation(); | ||
inputModel.closeAIAssistantChat(); | ||
} | ||
if (e.code == "KeyL" && e.getModifierState("Control")) { | ||
|
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.
maybe remove space here
Idk what is your thought on spacing?
Apple was super strict on spacing inside of functions for some reason, so I'm hardwired to get rid of them
src/util/keyutil.ts
Outdated
|
||
function parseKeyDescription(keyDescription: string): KeyPressDecl { | ||
let rtn = { key: "", mods: {} } as KeyPressDecl; | ||
rtn.mods.Cmd = false; |
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.
is it ugly to init this way? wasn't sure how to properly init a record type
seems I have to set each of the values otherwise they end up as none
} | ||
let eventKey = event.key; | ||
let descKey = keyPress.key; | ||
if (eventKey.length == 1 && /[A-Z]/.test(eventKey.charAt(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.
So this accepts shift:e, shift:E or E all as the same thing
it also accepts "Space" or " " to mean space
Thoughts?
Also I'm wondering if I should move this logic to the adapt keyboard event functions so that WaveKeyboardEvent has a standardized key value in these cases
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 should add unicode checks in here. instead of checking for [A-Z] you can use \p{Lu} (unicode uppercase characters). https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions/Unicode_character_class_escape . I think you also need to set the v
flag on the regexp.
see also https://unicode.org/reports/tr18/#General_Category_Property
For event.key, I think space bar actually comes back as " " and not "Space" . https://developer.mozilla.org/en-US/docs/Web/API/UI_Events/Keyboard_event_key_values#whitespace_keys |
|
||
type ModKeyStrs = "Cmd" | "Option" | "Shift" | "Ctrl"; | ||
|
||
interface WaveKeyboardEvent { |
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.
maybe cut down the number of lines of comments here. since they are single line, just use //
I think for WaveKeyboardEvent, it shouldn't have put the special |
This PR creates a new function in the global model for checking key presses, and it creates a special key press syntax
An example of this syntax: if you want to check for ctrl + shift + e, you would write "ctrl:shift:e"
We also now use event.key instead of event.code for checking key presses
There are a lot of considerations here
Event.key changes depending on modifiers - if user presses shift + e, event.key = "E" and if user pre sses option + e, on Mac event.key = "´"
I have handled the shift case, basically any of the above work - "Shift:e" == "Shift:E" == "E"
The option case however is still around, not sure how to go about handling that one
For now option keys aren't really going to work
I guess the way is to go by event code rather than key, but then people have to write their option commands with different syntax, ie "Alt:KeyR" rather than "Alt:r"
We could also do some string conversions on the event code, like we can map "KeyR" to "r", and a lot of the non character keys like "Escape" or "Enter" or "ArrowDown" are the same both key and code. There will be a few special cases though, like "[" = "LeftBracket"
or we can just roll with the punches and make users do "Alt:®" for Alt + r (this is how it is working right now), or maybe there's a tool out there for finding the un optioned version of an option key