Skip to content

Commit

Permalink
Added python commands for pycharm
Browse files Browse the repository at this point in the history
  • Loading branch information
TestPlan committed Sep 22, 2018
1 parent 9e6648a commit d477bcf
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 18 deletions.
10 changes: 10 additions & 0 deletions google-chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ def jump_tab(m):
'search': search,
'print': print_page,
'top': scroll_to_top,

# shortkeys plugin
'bottom': Key('ctrl-b'),
'copy euro': Key('ctrl-u'),
'google it': Key('ctrl-g'),
'move tab left': Key('ctrl-l'),
'move tab right': Key('ctrl-r'),



'clear': [Key('cmd-a'), Key('backspace')],

# youtube
Expand Down
19 changes: 10 additions & 9 deletions php-storm.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ def blade_if_function(m):
return blade_if_function


def blade_else():
def blade_else_function(m):
Str('@else')(None)
press('return')

return blade_else_function


def blade_section():
def blade_section_function(m):
Str('@section(\'\')')(None)
Expand Down Expand Up @@ -90,14 +98,6 @@ def blade_if_else_function(m):
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)
Expand Down Expand Up @@ -126,13 +126,13 @@ def blade_include_function(m):
'blade include': blade_include(),
'blade else': blade_else(),
'blade for each': blade_for_each(),
'blade section': blade_section(),
'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': '{!',

Expand All @@ -145,6 +145,7 @@ def blade_include_function(m):

# Foundation CSS Framework
'ramcalc': ['rem-calc()', Key('left')],
'breakpoint': '@include breakpoint() {',

'(flip | phiz | fizz)': ['php', Key('tab')],
'party': ['phps', Key('tab')],
Expand Down
46 changes: 46 additions & 0 deletions pycharm.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
from talon.voice import Context, Key, Str, press

ctx = Context('pycharm', func=lambda app, win: app.bundle == 'com.jetbrains.pycharm')

PYTHON = '[(pie | pi | py | python)]'

keymap = {
# Basic Python
f'{PYTHON} self': 'self',
f'{PYTHON} from': 'from ',
f'{PYTHON} import': 'import ',
f'{PYTHON} break': 'break',
f'{PYTHON} continue': 'continue',
f'{PYTHON} return': 'return ',
f'{PYTHON} jason': 'json',
f'{PYTHON} true': 'True',
f'{PYTHON} false': 'False',
f'{PYTHON} none': 'None',
f'{PYTHON} if': ['if :', Key('left')],
f'{PYTHON} else': ['else :', Key('left')],
f'{PYTHON} else if': ['elif :', Key('left')],
f'{PYTHON} while': ['while :', Key('left')],
f'{PYTHON} for loop': ['for x in :', Key('left')],
f'{PYTHON} print': ['print()', Key('left')],
f'{PYTHON} range': ['range()', Key('left')],
f'{PYTHON} (def | deaf | deft)': ['def :', Key('left')],
f'{PYTHON} in it': ['def __init__(self, ):', Key('left left')],

# list methods
f'{PYTHON} append': ['append()', Key('left')],
f'{PYTHON} count': ['count()', Key('left')],
f'{PYTHON} index': ['index()', Key('left')],
f'{PYTHON} pop': ['pop()', Key('left')],
f'{PYTHON} insert': ['insert()', Key('left')],
f'{PYTHON} remove': ['remove()', Key('left')],
f'{PYTHON} extend': ['extend()', Key('left')],
f'{PYTHON} sort': ['sort()', Key('left')],

# Python: relies on custom PyCharm live templates
f'{PYTHON} class': ['pyclass', Key('tab')],
}

ctx.keymap(keymap)


def unload(): ctx.unload()
11 changes: 2 additions & 9 deletions std.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ def FormatText(m):
'right': Key('right'),
'up': Key('up'),
'down': Key('down'),
'dot (calm | com)': '.com',

'puter sleep': Key('ctrl-alt-shift-cmd-s'),
'puter down': Key('ctrl-alt-shift-cmd-d'),
Expand All @@ -215,7 +216,7 @@ def FormatText(m):
# 'exit talent': Key('ctrl-alt-shift-cmd-t'),

'delete': Key('backspace'),

'slurp': Key('right backspace'),
'run quit': Key('cmd-q'),
'kill': Key('ctrl-c'),
'screenshot page': Key('alt-shift-p'),
Expand Down Expand Up @@ -378,18 +379,10 @@ def FormatText(m):
# 'brace': [' else if ()', Key('left')],

# python
'state (def | deaf | deft)': 'def ',
'state else if': 'elif ',
'state if': 'if ',
'state else if': [' else if ()', Key('left')],
'state while': ['while ()', Key('left')],
'state for': ['for ()', Key('left')],
'state for': 'for ',
'state switch': ['switch ()', Key('left')],
'state case': ['case \nbreak;', Key('up')],
'state goto': 'goto ',
'state import': 'import ',
'state class': 'class ',

'state include': '#include ',
'state include system': ['#include <>', Key('left')],
Expand Down

0 comments on commit d477bcf

Please sign in to comment.