Skip to content

Commit

Permalink
Added commands for blade templates
Browse files Browse the repository at this point in the history
  • Loading branch information
TestPlan committed Sep 19, 2018
1 parent 871395c commit 85f91a7
Show file tree
Hide file tree
Showing 6 changed files with 195 additions and 42 deletions.
4 changes: 2 additions & 2 deletions google-chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 1 addition & 3 deletions jetbrains.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"com.google.android.studio",
]


ctx = Context('jetbrains', func=lambda app, win: any(
i in app.bundle for i in ides))

Expand Down Expand Up @@ -71,8 +70,7 @@

}


ctx.keymap(keymap)


def unload(): ctx.unload()
def unload(): ctx.unload()
146 changes: 141 additions & 5 deletions php-storm.py
Original file line number Diff line number Diff line change
@@ -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)': '<?php ',
Expand All @@ -28,10 +165,9 @@
'complete': Key('cmd-shift-enter'),
'definition': Key('alt-space'),

}

}

ctx.keymap(keymap)


def unload(): ctx.unload()
def unload(): ctx.unload()
49 changes: 27 additions & 22 deletions std.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from talon import ctrl, clip
from talon_init import TALON_HOME, TALON_PLUGINS, TALON_USER
import string

# from user.utils import parse_word, surround, text, sentence_text, word, parse_words

alpha_alt = 'air bat cap die each fail gone harm sit jury crash look mad near odd pit quest red sun trap urge vest ' \
Expand Down Expand Up @@ -124,34 +125,34 @@ def rot13(i, word, _):
# }

formatters = {
'cram': (True, lambda i, word, _: word if i == 0 else word.capitalize()),
'pathway': (True, lambda i, word, _: word if i == 0 else '/'+word),
'dotsway': (True, lambda i, word, _: word if i == 0 else '.'+word),
'yellsmash': (True, lambda i, word, _: word.upper()),
'yellsnik': (True, lambda i, word, _: word.upper() if i == 0 else '_'+word.upper()),
'dollcram': (True, lambda i, word, _: '$'+word if i == 0 else word.capitalize()),
'champ': (True, lambda i, word, _: word.capitalize() if i == 0 else " "+word),
'lowcram': (True, lambda i, word, _: '@'+word if i == 0 else word.capitalize()),
'cram': (True, lambda i, word, _: word if i == 0 else word.capitalize()),
'pathway': (True, lambda i, word, _: word if i == 0 else '/' + word),
'dotsway': (True, lambda i, word, _: word if i == 0 else '.' + word),
'yellsmash': (True, lambda i, word, _: word.upper()),
'yellsnik': (True, lambda i, word, _: word.upper() if i == 0 else '_' + word.upper()),
'dollcram': (True, lambda i, word, _: '$' + word if i == 0 else word.capitalize()),
'champ': (True, lambda i, word, _: word.capitalize() if i == 0 else " " + word),
'lowcram': (True, lambda i, word, _: '@' + word if i == 0 else word.capitalize()),
'criff': (True, lambda i, word, _: word.capitalize()),
'criffed': (True, lambda i, word, _: word.capitalize()),
'yeller': (False, lambda i, word, _: word.upper()),
'dunder': (True, lambda i, word, _: '__%s__' % word if i == 0 else word),
'camel': (True, lambda i, word, _: word if i == 0 else word.capitalize()),
'snake': (True, lambda i, word, _: word if i == 0 else '_'+word),
'dot': (True, lambda i, word, _: '.'+word if i == 0 else '_'+word),
'smash': (True, lambda i, word, _: word),
'dunder': (True, lambda i, word, _: '__%s__' % word if i == 0 else word),
'camel': (True, lambda i, word, _: word if i == 0 else word.capitalize()),
'snake': (True, lambda i, word, _: word if i == 0 else '_' + word),
'dot': (True, lambda i, word, _: '.' + word if i == 0 else '_' + word),
'smash': (True, lambda i, word, _: word),
# spinal or kebab?
'spine': (True, lambda i, word, _: word if i == 0 else '-'+word),
'spine': (True, lambda i, word, _: word if i == 0 else '-' + word),
# 'sentence': (False, lambda i, word, _: word.capitalize() if i == 0 else word),
'title': (False, lambda i, word, _: word.capitalize()),
'tridal': (False, lambda i, word, _: word.capitalize()),
'title': (False, lambda i, word, _: word.capitalize()),
'tridal': (False, lambda i, word, _: word.capitalize()),
'allcaps': (False, lambda i, word, _: word.upper()),
'dubstring': (False, surround('"')),
'coif': (False, surround('"')),
'string': (False, surround("'")),
'posh': (False, surround("'")),
'padded': (False, surround(" ")),
'rot-thirteen': (False, rot13),
'rot-thirteen': (False, rot13),
}


Expand Down Expand Up @@ -218,9 +219,13 @@ def FormatText(m):
'quit': Key('cmd-q'),
'kill': Key('ctrl-c'),
'screenshot page': Key('alt-shift-p'),
'screenshot manual': Key('cmd-shift-4'),

'spotlight': Key('cmd-space'),

# Yarn
'run server': ['yarn start', Key('return')],

'cut': Key('cmd-x'),
'copy': Key('cmd-c'),
'paste': Key('cmd-v'),
Expand Down Expand Up @@ -262,12 +267,14 @@ def FormatText(m):

# Selecting text
'select line': Key('cmd-right cmd-shift-left'),
'select copy': Key('cmd-right cmd-shift-left cmd-c'),
'select cut': Key('cmd-right cmd-shift-left cmd-x'),
'select start': Key('cmd-shift-left'),
'select end': Key('cmd-shift-right'),
'select word': Key('alt-shift-right'),
'select left word': Key('alt-shift-left'),
'select right': Key('shift-right'),
'select left': Key('shift-left'),
'select word left': Key('left shift-right left alt-left shift-alt-right'),
'select word [right]': Key('right shift-left right alt-right shift-alt-left'),

'slap': [Key('cmd-right enter')],
'enter': Key('enter'),
Expand All @@ -278,8 +285,7 @@ def FormatText(m):
'dollar [sign]': '$',
'(downscore | score)': '_',
'(dubscore | double downscore | behm)': '__',
'(dubscore | double dash | behmdash)': '--',

'(dubdash | double dash | behmdash)': '--',
'(semi | semicolon)': ';',
'colon': ':',
'(square | left square [bracket] | bracket)': '[', '(rsquare | are square | right square [bracket])': ']',
Expand Down Expand Up @@ -481,4 +487,3 @@ def FormatText(m):
'scroll up more': [Key('up')] * 60,
})
ctx.keymap(keymap)

6 changes: 6 additions & 0 deletions switcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
running = {}
launch = {}


def switch_app(m):
name = str(m['switcher.running'][0])
full = running.get(name)
Expand All @@ -17,18 +18,21 @@ def switch_app(m):
time.sleep(0.25)
break


def launch_app(m):
name = str(m['switcher.launch'][0])
path = launch.get(name)
if path:
ui.launch(path=path)


ctx = Context('switcher')
ctx.keymap({
'focus {switcher.running}': switch_app,
'launch {switcher.launch}': launch_app,
})


def update_lists():
global running
global launch
Expand Down Expand Up @@ -59,9 +63,11 @@ def update_lists():
launch = new
ctx.set_list('launch', launch.keys())


def ui_event(event, arg):
if event in ('app_activate', 'app_launch', 'app_close', 'win_open', 'win_close'):
update_lists()


ui.register('', ui_event)
update_lists()
Loading

0 comments on commit 85f91a7

Please sign in to comment.