Module: TopinambourShortcuts
- Defined in:
- lib/shortcuts.rb
Overview
Copyright 2016-2018 Cedric LE MOIGNE, [email protected] This file is part of Topinambour.
Topinambour is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
Topinambour is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with Topinambour. If not, see <www.gnu.org/licenses/>.
Class Method Summary collapse
- .ctrl_shift?(event) ⇒ Boolean
- .handle_ctrl_shift(event, window) ⇒ Object
- .handle_key_press(window, event) ⇒ Object
- .handle_simple(event, window) ⇒ Object
Class Method Details
.ctrl_shift?(event) ⇒ Boolean
18 19 20 21 22 |
# File 'lib/shortcuts.rb', line 18 def self.ctrl_shift?(event) (event.state & (Gdk::ModifierType::CONTROL_MASK | Gdk::ModifierType::SHIFT_MASK)) == (Gdk::ModifierType::CONTROL_MASK | Gdk::ModifierType::SHIFT_MASK) end |
.handle_ctrl_shift(event, window) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/shortcuts.rb', line 35 def self.handle_ctrl_shift(event, window) case event.keyval when Gdk::Keyval::KEY_Q # Quit window.quit_gracefully true when Gdk::Keyval::KEY_C window.show_color_selector true when Gdk::Keyval::KEY_F window.show_font_selector true when Gdk::Keyval::KEY_Page_Up window.opacity = window.opacity + 0.05 true when Gdk::Keyval::KEY_Page_Down window.opacity = window.opacity - 0.05 true end end |
.handle_key_press(window, event) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/shortcuts.rb', line 55 def self.handle_key_press(window, event) if ctrl_shift?(event) handle_ctrl_shift(event, window) else handle_simple(event, window) end end |
.handle_simple(event, window) ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/shortcuts.rb', line 24 def self.handle_simple(event, window) case event.keyval when Gdk::Keyval::KEY_Escape # escape from overlay mode if window.. window.. window.terminal.grab_focus true end end end |