Last active
June 2, 2017 19:10
-
-
Save uchidev/cd84f223779a6f5fdd0b1052611892b4 to your computer and use it in GitHub Desktop.
Keyhoc
This file contains hidden or 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
| mark_is_on = False | |
| def configure(keymap): | |
| keymap.editor = "notepad.exe" | |
| keymap.setFont( "MS Gothic", 12) | |
| keymap.setTheme("white") | |
| keymap_global = keymap.defineWindowKeymap() | |
| def delete_line_or_katakana(): | |
| global mark_is_on | |
| if keymap.getWindow().getImeStatus(): | |
| keymap.InputKeyCommand("C-K")() # IME: C-K -> IME-OFF/Katakana/.. | |
| else: | |
| keymap.InputKeyCommand("S-End","C-X")() | |
| mark_is_on = False | |
| def delete_line_and_reset_mark(): | |
| global mark_is_on | |
| keymap.InputKeyCommand("S-End","C-X")() | |
| mark_is_on = False | |
| def delete_line(): | |
| keymap.InputKeyCommand("S-End","C-X")() | |
| def toggle_mark(): | |
| global mark_is_on | |
| if mark_is_on: | |
| mark_is_on = False | |
| else: | |
| mark_is_on = True | |
| def with_mark(key): | |
| def f(): | |
| if mark_is_on: | |
| keymap.InputKeyCommand("S-" + key)() | |
| else: | |
| keymap.InputKeyCommand(key)() | |
| return f | |
| def and_reset_mark(key): | |
| def f(): | |
| global mark_is_on | |
| keymap.InputKeyCommand(key)() | |
| mark_is_on = False | |
| return f | |
| def or_reset_mark(key): | |
| def f(): | |
| global mark_is_on | |
| if (mark_is_on): | |
| mark_is_on = False | |
| else: | |
| keymap.InputKeyCommand(key)() | |
| return f | |
| def normal_app_setting(map): | |
| map[ "C-J" ] = "F7" | |
| map[ "C-A" ] = "Home" | |
| map[ "C-E" ] = "End" | |
| map[ "C-F" ] = "Right" | |
| map[ "C-B" ] = "Left" | |
| map[ "C-P" ] = "Up" | |
| map[ "C-N" ] = "Down" | |
| map[ "C-D" ] = "Delete" | |
| map[ "C-H" ] = "Back" | |
| map[ "C-M" ] = "Enter" | |
| map[ "C-S" ] = "C-F" | |
| map[ "C-G" ] = "Esc" | |
| map[ "A-W" ] = "C-C" | |
| map[ "C-Y" ] = "C-V" | |
| map[ "C-W" ] = "C-X" | |
| map[ "C-U" ] = "C-Z" | |
| map[ "C-K" ] = delete_line | |
| def markable_app_setting(map): | |
| map[ "C-J" ] = "F7" | |
| map[ "C-Space" ] = toggle_mark | |
| map[ "C-A" ] = with_mark("Home") | |
| map[ "C-E" ] = with_mark("End") | |
| map[ "C-F" ] = with_mark("Right") | |
| map[ "C-B" ] = with_mark("Left") | |
| map[ "C-P" ] = with_mark("Up") | |
| map[ "C-N" ] = with_mark("Down") | |
| map[ "C-D" ] = and_reset_mark("Delete") | |
| map[ "C-H" ] = and_reset_mark("Back") | |
| map[ "C-M" ] = and_reset_mark("Enter") | |
| map[ "Esc" ] = or_reset_mark("Esc") | |
| map[ "C-G" ] = or_reset_mark("Esc") | |
| map[ "C-S" ] = and_reset_mark("C-F") | |
| map[ "C-U" ] = and_reset_mark("C-Z") | |
| map[ "C-K" ] = delete_line_and_reset_mark | |
| map[ "C-C" ] = and_reset_mark("C-C") | |
| map[ "A-W" ] = and_reset_mark("C-C") | |
| map[ "C-X" ] = and_reset_mark("C-X") | |
| map[ "C-W" ] = and_reset_mark("C-X") | |
| map[ "C-V" ] = and_reset_mark("C-V") | |
| map[ "C-Y" ] = and_reset_mark("C-V") | |
| keymap_chrome = keymap.defineWindowKeymap( exe_name="chrome.exe" ) | |
| markable_app_setting(keymap_chrome) | |
| keymap_firefox = keymap.defineWindowKeymap( exe_name="firefox.exe" ) | |
| normal_app_setting(keymap_firefox) | |
| keymap_notepad = keymap.defineWindowKeymap( exe_name="notepad.exe" ) | |
| markable_app_setting(keymap_notepad) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment