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

Added key maps in config #104

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Conversation

PravithBA
Copy link

Added key maps in config.

1. Added two new functions `get_key_modifier_from_string` and `get_key_from_string`
2. Added all the possible charecters as a config for Key.
1. Added README for Key map configs.
2. Renamed the config key for next word from `space` to `next_word`.
@PravithBA PravithBA closed this Dec 29, 2023
@PravithBA PravithBA reopened this Dec 29, 2023
src/key.rs Outdated
#[serde(default)]
pub struct KeyMap {
#[serde(deserialize_with = "deseralize_key")]
pub remove_previous_word: Option<Key>,
Copy link
Owner

Choose a reason for hiding this comment

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

I think these should be named delete_word and delete_char. Ctrl-Backspace usually removes the current word.

Copy link
Author

@PravithBA PravithBA Jan 5, 2024

Choose a reason for hiding this comment

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

Usually Ctrl+Backspace, removes the word (part of the word if the cursor is between the word) before the cursor, that's why i chose it to name it remove_previous_word. In my opinion delete_word would somewhat be misleading, because delete_word indicates the its deleting the whole word, but instead it removes the word before the cursor.

src/key.rs Outdated Show resolved Hide resolved
src/key.rs Outdated Show resolved Hide resolved
}

fn get_key_modifier_from_string(string: &str) -> KeyModifiers {
match string {
Copy link
Owner

Choose a reason for hiding this comment

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

It would probably be good to support non-abbreviated modifiers for each of these also. For example, "Ctrl", "Alt", etc. Some people also call the Meta key "Super" or "Win".

Copy link
Author

Choose a reason for hiding this comment

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

I did not quite understand this?
Should I allow "Ctrl-Backspace" as an option for config?
And Meta and Super are seperate modifiers, so i dont quite get what you mean.

"W" => KeyModifiers::SUPER,
"H" => KeyModifiers::HYPER,
"M" => KeyModifiers::META,
_ => KeyModifiers::NONE,
Copy link
Owner

Choose a reason for hiding this comment

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

An unknown modifier should probably be an error, not a silent fallback to no modifier.

src/main.rs Outdated Show resolved Hide resolved
src/key.rs Outdated Show resolved Hide resolved
@PravithBA
Copy link
Author

@max-niederman thanks for the requested changes, i am new to rust, and i will work on these as soon as possible!!

@PravithBA
Copy link
Author

@max-niederman I have made the changes, can you resolve the doubts i have?

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.

None yet

2 participants