-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for key combinations
- Loading branch information
diazvictor
committed
Jan 26, 2021
1 parent
8e663af
commit aa1b2ee
Showing
3 changed files
with
48 additions
and
1 deletion.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
--[[-- | ||
@package MoonTerm | ||
@filename moonterm-keybinds.lua | ||
@version 1.0 | ||
@author Díaz Urbaneja Víctor Eduardo Diex <victor.vector008@gmail.com> | ||
@date 26.01.2021 00:40:09 -04 | ||
--]] | ||
|
||
function toggle_fullscreen() | ||
fullscreen = not fullscreen | ||
if ( fullscreen ) then | ||
main_window:fullscreen() | ||
else | ||
main_window:unfullscreen() | ||
end | ||
end | ||
|
||
keybindings = { | ||
-- alphanumeric keys | ||
{ | ||
[Gdk.KEY_C] = function () term:copy_clipboard() end, | ||
[Gdk.KEY_V] = function () term:paste_clipboard() end | ||
}, | ||
-- function keys | ||
{ | ||
[Gdk.KEY_F11] = function () toggle_fullscreen() end | ||
} | ||
} | ||
|
||
function main_window:on_key_press_event(event) | ||
local ctrl_on = event.state.CONTROL_MASK | ||
local shift_on = event.state.SHIFT_MASK | ||
alphanumeric_keys = keybindings[1][event.keyval] | ||
function_keys = keybindings[2][event.keyval] | ||
|
||
if ( alphanumeric_keys and shift_on and ctrl_on ) then | ||
alphanumeric_keys() | ||
elseif ( function_keys and not shift_on and not ctrl_on ) then | ||
function_keys() | ||
else | ||
return false | ||
end | ||
return true | ||
end |