From 85f91a7ba8b9de0ed00566ea697aff169f13baf4 Mon Sep 17 00:00:00 2001 From: Ian Markind Date: Wed, 19 Sep 2018 14:48:13 -0400 Subject: [PATCH] Added commands for blade templates --- google-chrome.py | 4 +- jetbrains.py | 4 +- php-storm.py | 146 +++++++++++++++++++++++++++++++++++++++++++++-- std.py | 49 +++++++++------- switcher.py | 6 ++ talon-control.py | 28 +++++---- 6 files changed, 195 insertions(+), 42 deletions(-) diff --git a/google-chrome.py b/google-chrome.py index 482c14b..4d4970d 100644 --- a/google-chrome.py +++ b/google-chrome.py @@ -173,9 +173,9 @@ def jump_tab(m): 'clear cash': Key('cmd-shift-backspace'), # dev tools - 'toggle dev tools': Key('cmd-alt-i'), + '[toggle] dev tools': Key('cmd-alt-i'), 'command [menu]': Key('cmd-shift-p'), - 'element': Key('cmd-shift-c'), + 'selector': Key('cmd-shift-c'), 'mobile': Key('cmd-shift-m'), '(javascript (counsel | console) | javascript (counsel | console) close)': Key('cmd-alt-j'), 'next panel': next_panel, diff --git a/jetbrains.py b/jetbrains.py index af15e8d..c804c30 100644 --- a/jetbrains.py +++ b/jetbrains.py @@ -15,7 +15,6 @@ "com.google.android.studio", ] - ctx = Context('jetbrains', func=lambda app, win: any( i in app.bundle for i in ides)) @@ -71,8 +70,7 @@ } - ctx.keymap(keymap) -def unload(): ctx.unload() \ No newline at end of file +def unload(): ctx.unload() diff --git a/php-storm.py b/php-storm.py index cd8fd88..232f3d4 100644 --- a/php-storm.py +++ b/php-storm.py @@ -1,14 +1,151 @@ -from talon.voice import Context, Key +from talon.voice import Context, Key, Str, press ides = [ "com.jetbrains.PhpStorm", ] - ctx = Context('phpstorm', func=lambda app, win: any( i in app.bundle for i in ides)) + +def blade_switch(): + def blade_switch_function(m): + Str('@switch($)')(None) + press('return') + for x in range(0, 3): + Str('@case()')(None) + press('return') + press('return') + Str('@break')(None) + press('return') + press('return') + Str('@default')(None) + press('return') + press('return') + Str('@endswitch')(None) + press('shift-tab') + for x in range(0, 15): + press('up') + press('left') + + return blade_switch_function + + +def blade_for_each(): + def blade_for_each_function(m): + Str('@foreach($ as $)')(None) + press('return') + press('return') + Str('@endforeach')(None) + press('shift-tab') + press('up') + press('up') + press('left') + + return blade_for_each_function + + +def blade_if(): + def blade_if_function(m): + Str('@if ()')(None) + press('return') + press('return') + Str('@endif')(None) + press('shift-tab') + press('up') + press('up') + press('left') + + return blade_if_function + + +def blade_section(): + def blade_section_function(m): + Str('@section(\'\')')(None) + press('return') + press('return') + Str('@endsection')(None) + press('shift-tab') + press('up') + press('up') + press('left') + + return blade_section_function + + +def blade_if_else(): + def blade_if_else_function(m): + Str('@if ()')(None) + press('return') + press('return') + press('shift-tab') + blade_else()(None) + press('return') + Str('@endif')(None) + press('shift-tab') + for x in range(0, 4): + press('up') + press('left') + + return blade_if_else_function + + +def blade_else(): + def blade_else_function(m): + Str('@else')(None) + press('return') + + return blade_else_function + + +def blade_php(): + def blade_php_function(m): + Str('@php @endphp')(None) + for x in range(0, 8): + press('left') + + return blade_php_function + + +def blade_include(): + def blade_include_function(m): + Str('@include(\'\')')(None) + for x in range(0, 2): + press('left') + + return blade_include_function + + keymap = { + + # blade + 'blade if': blade_if(), + 'blade switch': blade_switch(), + 'blade if else': blade_if_else(), + 'blade php': blade_php(), + 'blade include': blade_include(), + 'blade else': blade_else(), + 'blade for each': blade_for_each(), + 'blade data': '{{ ', + 'blade continue': '@continue', + 'blade break': '@break', + 'blade parent': '@parent', + 'blade case': ['@case()', Key('left')], + 'blade extends': ['@extends(\'\')', Key('left'), Key('left')], + 'blade section': blade_section(), + 'blade loop': '$loop', + 'blade raw data': '{!', + + # CSS + 'with': ['width: ;', Key('left')], + 'max with': ['max-width: ;', Key('left')], + 'min with': ['min-width: ;', Key('left')], + '(hover | however)': 'hover ', + 'ram': 'rem', + + # Foundation CSS Framework + 'ramcalc': ['rem-calc()', Key('left')], + '(flip | phiz | fizz)': ['php', Key('tab')], 'party': ['phps', Key('tab')], '(start flip | start phiz | start fizz)': '> Calibrate'), 'talon mouse [control]': lambda m: on_eye_control('Eye Tracking >> Control Mouse'), - 'talon zoom [mouse]': lambda m: on_eye_control('Eye Tracking >> Control Mouse (Zoom)'), # Currently doesn't work for unknown reasons - 'talon keyboard': lambda m: on_eye_control('Eye Tracking >> Keyboard'), # Currently doesn't work for unknown reasons + 'talon zoom [mouse]': lambda m: on_eye_control('Eye Tracking >> Control Mouse (Zoom)'), + # Currently doesn't work for unknown reasons + 'talon keyboard': lambda m: on_eye_control('Eye Tracking >> Keyboard'), + # Currently doesn't work for unknown reasons 'talon eye debug': lambda m: on_eye_control('Eye Tracking >> Show Debug Overlay'), 'talon eye camera': lambda m: on_eye_control('Eye Tracking >> Show Camera Overlay'), }) # Startup. enable_talon() -context_group.load() \ No newline at end of file +context_group.load()