-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #110 from f1andrew/master
changed importing of cli_keymap
- Loading branch information
Showing
3 changed files
with
40 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from pathlib import Path | ||
import json | ||
|
||
nonchars_key_map = None | ||
|
||
def load_keymap_file(config): | ||
global nonchars_key_map | ||
|
||
keymap_file = Path(__file__).resolve().parent / "cli_keymaps" / config.get("keymap_file", "us_keymap.json") | ||
if keymap_file.exists() and keymap_file.is_file(): | ||
with open(keymap_file, "r") as f: | ||
try: | ||
nonchars_key_map = json.loads(f.read()) | ||
except Exception as e: | ||
print("Invalid keymap json file:", e) | ||
return | ||
else: | ||
print("Invalid path to keymap file:", keymap_file) | ||
return False | ||
|
||
return True | ||
|
||
def char_to_keyevent_params (char): | ||
global nonchars_key_map | ||
|
||
ret = nonchars_key_map.get(char, None) | ||
if ret is not None: | ||
return ret | ||
if (char.isdigit()): | ||
return (char,[]) | ||
if (char.upper() == char): | ||
return (char.upper(),["LSHIFT"]) | ||
return (char.upper(),[]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters