diff --git a/jetbrains.py b/jetbrains.py index c804c30..f603d97 100644 --- a/jetbrains.py +++ b/jetbrains.py @@ -44,8 +44,8 @@ 'grab left': Key('cmd-shift-left'), 'grab right': Key('cmd-shift-right'), 'close': Key('cmd-w'), - 'top': Key('cmd-home'), - 'bottom': Key('cmd-end'), + 'go top': Key('cmd-home'), + 'go bottom': Key('cmd-end'), 'grab up': Key('shift-cmd-pageup'), 'grab down': Key('shift-cmd-pagedown'), # 'rename': Key('shift-f6'), diff --git a/php-storm.py b/php-storm.py index ca51587..5c88d95 100644 --- a/php-storm.py +++ b/php-storm.py @@ -143,6 +143,55 @@ def blade_include_function(m): return blade_include_function +def php_explode(): + def php_explode_function(m): + Str('explode(, );')(None) + for x in range(4): + press('left') + + return php_explode_function + + +def sass_mixin(): + def sass_mixin_function(m): + Str('@mixin () {')(None) + press('return') + press('up') + for x in range(7): + press('right') + + return sass_mixin_function + + +def sass_if(): + def sass_if_function(m): + Str('@if {')(None) + press('return') + press('up') + for x in range(2): + press('right') + + return sass_if_function + + +def sass_else(): + def sass_else_function(m): + Str('@else {')(None) + press('return') + press('up') + + return sass_else_function + + +def wordpress_template_part(): + def wordpress_template_part_function(m): + Str('get_template_part(\'\');')(None) + for x in range(3): + press('left') + + return wordpress_template_part_function + + keymap = { # PHP 'echo': ['echo ;', Key('left')], @@ -162,7 +211,11 @@ def blade_include_function(m): 'horse markup': ['formk', Key('tab')], 'chop': ['forek', Key('tab')], 'eagles': ['?=', Key('tab')], - 'index': '$i', + 'array': ['array()', Key('left')], + 'explode': php_explode(), + + # WordPress + 'template part': wordpress_template_part(), # blade 'blade if': blade_if(), @@ -194,22 +247,87 @@ def blade_include_function(m): 'href': 'href=', 'id': 'id=', 'class': 'class=', - # Emmet - 'section': ['section', Key('tab')], - 'paragraph': ['p', Key('tab')], - 'image': ['img', Key('tab')], - 'div': ['div', Key('tab')], - 'anchor': ['a', Key('tab')], - 'break': ['br', Key('tab')], - 'footer': ['footer', Key('tab')], - 'body': ['body', Key('tab')], + # HTML Using Emmet + 'tag section': ['section', Key('tab')], + '[tag] paragraph': ['p', Key('tab')], + 'tag image': ['img', Key('tab')], + 'tag div': ['div', Key('tab')], + '[tag] anchor': ['a', Key('tab')], + 'tag break': ['br', Key('tab')], + 'tag footer': ['footer', Key('tab')], + 'tag body': ['body', Key('tab')], + 'lorem': ['lorem', Key('tab')], # CSS - 'with': ['width: ;', Key('left')], - 'max with': ['max-width: ;', Key('left')], - 'min with': ['min-width: ;', Key('left')], - '(hover | however)': 'hover ', - 'ram': 'rem', + # Properties + '(width | with)': ['width: ;', Key('left')], + 'height': ['height: ;', Key('left')], + 'max (width | with)': ['max-width: ;', Key('left')], + 'max height': ['max-height: ;', Key('left')], + 'min (width | with)': ['min-width: ;', Key('left')], + 'align items': ['align-items: ;', Key('left')], + 'justify content': ['justify-content: ;', Key('left')], + 'display': ['display: ;', Key('left')], + 'margin': ['margin: ;', Key('left')], + '(padding | patty)': ['padding: ;', Key('left')], + 'font family': ['font-family: ;', Key('left')], + 'font weight': ['font-weight: ;', Key('left')], + 'font size': ['font-size: ;', Key('left')], + 'line height': ['line-height: ;', Key('left')], + 'color': ['color: ;', Key('left')], + 'background color': ['background-color: ;', Key('left')], + 'background size': ['background-size: ;', Key('left')], + 'background repeat': ['background-repeat: ;', Key('left')], + 'background position': ['background-position: ;', Key('left')], + 'background image': ['background-image: ;', Key('left')], + 'flex direction': ['flex-direction: ;', Key('left')], + 'transform': ['transform: ;', Key('left')], + 'text transform': ['text-transform: ;', Key('left')], + 'position': ['position: ;', Key('left')], + 'top': ['top: ;', Key('left')], + 'zindex': ['z-index: ;', Key('left')], + 'visibility': ['visibility: ;', Key('left')], + 'bottom': ['bottom: ;', Key('left')], + 'text align': ['text-align: ;', Key('left')], + 'overflow': ['overflow: ;', Key('left')], + 'border': ['border: ;', Key('left')], + 'cursor': ['cursor: ;', Key('left')], + 'letter spacing': ['letter-spacing: ;', Key('left')], + 'border bottom': ['border-bottom: ;', Key('left')], + 'prop left': ['left: ;', Key('left')], + 'prop right': ['right: ;', Key('left')], + + # Pseudo Elements + 'after': '::after', + 'active': '::active', + 'visited': '::visited', + 'before': '::before', + 'first child': ':first-child', + 'last child': ':last-child', + 'first of type': ':first-of-type', + 'last of type': ':last-of-type', + '(hover | however)': ':hover', + 'focus': ':focus', + 'checked': ':checked', + 'valid': ':valid', + 'target': ':target', + 'not': [':not()', Key('left')], + 'nth child': [':nth-child()', Key('left')], + + # Units + '(rem | ram | rems | rams)': 'rem', + '(em | ems)': 'em', + '(px | pixel | pixels)': 'px', + '(vh | viewport height)': 'vh', + '(viewport width | viewport with)': 'vw', + # Values + 'linear gradient': ['linear-gradient();', Key('left'), Key('left')], + + # SASS + '[sass] (mixon | mixing | mix in)': sass_mixin(), + 'sass include': ['@include ;', Key('left')], + 'sass if': sass_if(), + 'sass else': sass_else(), # Foundation CSS Framework 'ramcalc': ['rem-calc()', Key('left')], @@ -217,8 +335,12 @@ def blade_include_function(m): 'complete': Key('cmd-shift-enter'), 'definition': Key('alt-space'), 'medium': 'medium', - '(padding | patty)': 'padding', + # Sage theme + 'sage production': ['yarn run build:production', Key('return')], + + # Next Level + 'Next Level': ['nextlevel', Key('return')], } ctx.keymap(keymap) diff --git a/show.py b/show.py new file mode 100644 index 0000000..a634205 --- /dev/null +++ b/show.py @@ -0,0 +1,77 @@ +import string +from talon.voice import Context +from talon import canvas +from talon import ui +from talon.skia import Rect + +ctx = Context('show') +alphabet_context = Context('alphabet_context') + +# font size of the overlay +font_size = 18 +# left padding of the font in the overlay +padding_left = 20 + + +def draw_alphabet(canvas): + paint = canvas.paint + paint.textsize = font_size + paint.color = '333' + paint.style = paint.Style.FILL + canvas.draw_rect(Rect(canvas.x, canvas.y, canvas.width, canvas.height)) + + line_height = paint.get_fontmetrics(1.5)[0] + + paint.color = 'dedede' + + try: + from user import std + alnum = std.alpha_alt + except: + # TODO log an error + alnum = [] + + num = 1 + for k, v in zip(alnum, string.ascii_lowercase): + canvas.draw_text('%s - %s' % (k, v), canvas.x + padding_left, canvas.y + (num * line_height)) + num += 1 + + +# initialize the overlay +screen = ui.main_screen() +w, h = screen.width, screen.height + +x_position = w / 3 +y_position = h / 4 +x_dimension = w / 6 +y_dimension = h / 1.5 + +panel = canvas.Canvas(x_position, y_position, x_dimension, y_dimension) +panel.register('draw', draw_alphabet) +panel.hide() + + +def show_alphabet(_): + global alphabet_context + + panel.show() + panel.freeze() + + keymap = { + '(0 | exit | escape)': lambda x: close_alphabet(), + } + + alphabet_context.keymap(keymap) + alphabet_context.load() + + +def close_alphabet(): + panel.hide() + alphabet_context.unload() + + +keymap = { + 'show alphabet': show_alphabet, +} + +ctx.keymap(keymap) diff --git a/spectacle.py b/spectacle.py index 25a7ce6..83d22a4 100644 --- a/spectacle.py +++ b/spectacle.py @@ -3,8 +3,7 @@ ctx = Context('spectacle') keymap = { - - 'center': Key('alt-cmd-c'), + 'snap center': Key('alt-cmd-c'), '(fullscreen | full)': Key('cmd-alt-f'), 'snapleft': Key('cmd-alt-left'), 'snapright': Key('cmd-alt-right'), @@ -22,7 +21,6 @@ 'make smaller': Key('ctrl-alt-shift-left'), 'speck undo': Key('alt-cmd-z'), 'speck redo': Key('alt-shift-cmd-z'), - } ctx.keymap(keymap) diff --git a/std.py b/std.py index 359b642..5af2e66 100644 --- a/std.py +++ b/std.py @@ -5,7 +5,7 @@ # 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 ' \ +alpha_alt = 'air bat cap die each fail gone harm sit jury crash look mad near owl pit quest red sun trap urge vest ' \ 'whale box yes zip'.split() alnum = list(zip(alpha_alt, string.ascii_lowercase)) + [(str(i), str(i)) for i in range(0, 10)] @@ -207,7 +207,9 @@ def FormatText(m): 'right': Key('right'), 'up': Key('up'), 'down': Key('down'), - 'dot (calm | com)': '.com', + 'dot (calm | com)': '.comffset-key="ba538d3bb2', + 'protocol': 'http://', + 'secure protocol': 'https://', 'puter sleep': Key('ctrl-alt-shift-cmd-s'), 'puter down': Key('ctrl-alt-shift-cmd-d'),