diff --git a/.gitignore b/.gitignore index 9c8896593..f8f5b9181 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,12 @@ complexity_report* *.*\# *.*~ +# Ignore Rope +.ropeproject/ + +# Ignoring Visual Studio (Code) +.vs/ +.vscode/ # Ignore Natlink /core/ diff --git a/.style.yapf b/.style.yapf new file mode 100644 index 000000000..025bd206d --- /dev/null +++ b/.style.yapf @@ -0,0 +1,6 @@ +[style] +based_on_style=pep8 +column_limit=90 +indent_dictionary_value=True +split_complex_comprehension=True +no_spaces_around_selected_binary_operators=*,/ diff --git a/caster/apps/atom.py b/caster/apps/atom.py index 8d0e54905..c2bfdc955 100644 --- a/caster/apps/atom.py +++ b/caster/apps/atom.py @@ -1,351 +1,662 @@ """ -__author__ = 'Zone22' +__author__ = 'LexiconCode' Command-module for Atom Official Site "https://atom.io/" """ -from dragonfly import (Grammar, AppContext, MappingRule, - Dictation, IntegerRef, - Key, Text, Repeat, Pause) +from dragonfly import (AppContext, Dictation, Grammar, IntegerRef, Key, + MappingRule, Pause, Repeat, Text) from dragonfly.actions.action_mimic import Mimic -from caster.lib import control -from caster.lib import settings +from caster.lib import control, settings from caster.lib.dfplus.additions import IntegerRefST from caster.lib.dfplus.merge import gfilter from caster.lib.dfplus.merge.mergerule import MergeRule from caster.lib.dfplus.state.short import R - # How long to wait for the Atom palette to load before hitting the enter key atom_palette_wait = "30" if settings.SETTINGS["miscellaneous"]["atom_palette_wait"]: atom_palette_wait = settings.SETTINGS["miscellaneous"]["atom_palette_wait"] +# Utilizes the Palette UI to leverage commands. +def palettized(function_text): + return Key("cs-p") + Text(function_text) + Pause(atom_palette_wait) + Key("enter") + + class AtomRule(MergeRule): pronunciation = "atom" mapping = { -# Spoken commands that are commented out do not have assigned default shortcut keys or are incompatible. -# The '#extra' subsection of commands that fit within the category but are not displayed by the menu or UI -# Legend: '#' for not assigned, '##' for shortcut or functional duplicate. -# ----------Spoken Command/Action------------------> Shortcut keys----------> #Displayed Text + # Spoken commands that are commented out do not have assigned default shortcut keys or are incompatible. + # The '#extra' subsection of commands that fit within the category but are not displayed by the menu or UI + # Legend: '#' for not assigned, '##' for shortcut or functional duplicate. + # ----------Spoken Command/Action------------------> Shortcut keys----------> #Displayed Text - #Basic Cursor Navigation - "up []": R(Key("up"), rdescript="Atom: Move Cursor Up #") * Repeat(extra="n"), - "down []": R(Key("down"), rdescript="Atom: Move Cursor Down #") * Repeat(extra="n"), - "right []": R(Key("right"), rdescript="Atom: Move Cursor Right #") * Repeat(extra="n"), - "left []": R(Key("left"), rdescript="Atom: Move Cursor Left #") * Repeat(extra="n"), - #Basic White Text Manipulation - "tab|indent []": R(Key("tab"), rdescript="Atom: Press Tab Key #") * Repeat(extra="n"), - "space []": R(Key("space"), rdescript="Atom: Press Tab Key #") * Repeat(extra="n"), -# Menu UI------------------------------------------------------------------------------------------- - #File Menu - "[open] new window": R(Key("cs-n"), rdescript="Atom: New Window"), - "new file": R(Key("c-n"), rdescript="Atom: New File"), - "open file": R(Key("c-o"), rdescript="Atom: Open File"), - "open folder": R(Key("cs-o"), rdescript="Atom: Open Folder"), - "add project folder": R(Key("ac-o"), rdescript="Atom: Add Project Folder"), - "open settings": R(Key("c-comma"), rdescript="Atom: Open Settings"), - "[open] last tab": R(Key("cs-t"), rdescript="Atom: Reopen Last File or Tab"), - "reopen closed item": R(Key("cs-p") + Text("Reopen Closed Item") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Reopen Last File or Tab"), - "open [your] config": R(Key("cs-p") + Text("Open Your Config") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Open Your Config"), - "open [your] int script": R(Key("cs-p") + Text("Open Your Int Script") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Open Your Int Script"), - "open [your] key map": R(Key("cs-p") + Text("Open Your Key Map") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Open Your Key Map"), - "open [your] snippet": R(Key("cs-p") + Text("Open Your Snippet") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Open Your Snippet"), - "open [your] stylesheet": R(Key("cs-p") + Text("Open your Stylesheet") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Open Your Stylesheet"), - "save": R(Key("c-s"), rdescript="Atom: Save"), - "save as": R(Key("cs-s"), rdescript="Atom: Save As"), - "save all": R(Key("cs-p") + Text("Save All") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Save All"), - "close pane": R(Key("cs-p") + Text("Pane Close") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Close Pane"), - "close pane others": R(Key("cs-p") + Text("Pane Close Other Items") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Close Pane"), - "close window": R(Key("cs-w"), rdescript="Atom: Close Window"), + #Basic Cursor Navigation + "up []": + R(Key("up"), rdescript="Atom: Move Cursor Up #") * Repeat(extra="n"), + "down []": + R(Key("down"), rdescript="Atom: Move Cursor Down #") * Repeat(extra="n"), + "right []": + R(Key("right"), rdescript="Atom: Move Cursor Right #") * Repeat(extra="n"), + "left []": + R(Key("left"), rdescript="Atom: Move Cursor Left #") * Repeat(extra="n"), + #Basic White Text Manipulation + "tab|indent []": + R(Key("tab"), rdescript="Atom: Press Tab Key #") * Repeat(extra="n"), + "space []": + R(Key("space"), rdescript="Atom: Press Tab Key #") * Repeat(extra="n"), + # Menu UI------------------------------------------------------------------------------------------- + #File Menu + "[open] new window": + R(Key("cs-n"), rdescript="Atom: New Window"), + "new file": + R(Key("c-n"), rdescript="Atom: New File"), + "open file": + R(Key("c-o"), rdescript="Atom: Open File"), + "open folder": + R(Key("cs-o"), rdescript="Atom: Open Folder"), + "add project folder": + R(Key("ac-o"), rdescript="Atom: Add Project Folder"), + "open settings": + R(Key("c-comma"), rdescript="Atom: Open Settings"), + "reopen closed item": + R(palettized("Reopen Closed Item"), + rdescript="Atom: Reopen Last File or Tab"), + "open [your] config": + R(palettized("Open Your Config"), rdescript="Atom: Open Your Config"), + "open [your] int script": + R(palettized("Open Your Int Script"), rdescript="Atom: Open Your Int Script"), + "open [your] key map": + R(palettized("Open Your Key Map"), rdescript="Atom: Open Your Key Map"), + "open [your] snippet": + R(palettized("Open Your Snippet"), rdescript="Atom: Open Your Snippet"), + "open [your] stylesheet": + R(palettized("Open your Stylesheet"), rdescript="Atom: Open Your Stylesheet"), + #"save": R(Key("c-s"), rdescript="Atom: Save"), + "save as": + R(Key("cs-s"), rdescript="Atom: Save As"), + "save all": + R(palettized("Save All"), rdescript="Atom: Save All"), + "close pane": + R(palettized("Pane Close"), rdescript="Atom: Close Pane"), + "close pane others": + R(Key("ca-w"), rdescript="Atom: Close Pane"), + "close window": + R(Key("cs-w"), rdescript="Atom: Close Window"), #Extra - #Edit Menu - "cut": R(Key("s-delete"), rdescript="Atom: Cut"), - "copy ": R(Key("c-insert"), rdescript="Atom: Copy"), - "paste []": R(Key("s-insert"), rdescript="Atom: Paste") * Repeat(extra="n"), - "copy path": R(Key("cs-c"), rdescript="Atom: Copy Path"), - "select all": R(Key("c-a"), rdescript="Atom: Select All"), - "[toggle] comments": R(Key("c-slash"), rdescript="Atom: Toggle Comments"), - "reflow section": R(Key("ac-q"), rdescript="Atom: Reflow Section"), - "select encoding": R(Key("cs-u"), rdescript="Atom: Select Encoding"), - "[go to] line ": R(Key("c-g") + Pause("10") + Text("%(n)s") + Key("enter"), rdescript="Atom: Go to Line #"), - "select grammar": R(Key("cs-l"), rdescript="Atom: Select Grammar"), + #Edit Menu + #"cut": R(Key("s-delete"), rdescript="Atom: Cut"), + "copy ": + R(Key("c-insert"), rdescript="Atom: Copy"), + "paste []": + R(Key("s-insert"), rdescript="Atom: Paste") * Repeat(extra="n"), + "copy path": + R(Key("cs-c"), rdescript="Atom: Copy Path"), + "select all": + R(Key("c-a"), rdescript="Atom: Select All"), + "[toggle] comments": + R(Key("c-slash"), rdescript="Atom: Toggle Comments"), + "reflow section": + R(Key("ac-q"), rdescript="Atom: Reflow Section"), + "select encoding": + R(Key("cs-u"), rdescript="Atom: Select Encoding"), + "[go to] line ": + R(Key("c-g") + Pause("10") + Text("%(n)s") + Key("enter"), + rdescript="Atom: Go to Line #"), + "select grammar": + R(Key("cs-l"), rdescript="Atom: Select Grammar"), #Lines Submenu - ##"indent": R(Key("c-lbrace"), rdescript="Atom: Indent"), # Rework Dragonfly Keymapping - "outdent": R(Key("c-rightbrace"), rdescript="Atom: Outdent"), - "auto indent editor": R(Key("cs-p") + Text("Editor Auto Indent") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Auto Indent"), - "auto indent windows": R(Key("cs-p") + Text("Window Auto Indent") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Auto Indent"), - "[move] line up []": R(Key("c-up"), rdescript="Atom: Move Line Up #") * Repeat(extra="n"), - "[move] line down []": R(Key("c-down"), rdescript="Atom: Move Line Down #") * Repeat(extra="n"), - "duplicate line []": R(Key("cs-d"), rdescript="Atom: Duplicate Line") * Repeat(extra="n"), #Unless remapped the command triggers Dragon NaturallySpeaking dictation box - "delete line []": R(Key("cs-k"), rdescript="Atom: Delete Line or # Lines Below") * Repeat(extra="n"), - "join line": R(Key("c-j"), rdescript="Atom: Join Line"), + ##"indent": R(Key("c-lbrace"), rdescript="Atom: Indent"), # Rework Dragonfly Keymapping + "toggle outdent": + R(Key("c-rightbrace"), rdescript="Atom: Toggle Auto Outdent"), + "auto indent windows": + R(palettized("Window Auto Indent"), rdescript="Atom: Auto Indent"), + "[move] line up []": + R(Key("c-up"), rdescript="Atom: Move Line Up #") * Repeat(extra="n"), + "[move] line down []": + R(Key("c-down"), rdescript="Atom: Move Line Down #") * Repeat(extra="n"), + "duplicate line []": + R(Key("cs-d"), rdescript="Atom: Duplicate Line") * Repeat( + extra="n" + ), #Unless remapped the command triggers Dragon NaturallySpeaking dictation box + "delete line []": + R(Key("cs-k"), rdescript="Atom: Delete Line or # Lines Below") * + Repeat(extra="n"), + "join line": + R(Key("c-j"), rdescript="Atom: Join Line"), + "comment line": + R(Key("c-slash"), rdescript="Atom: Toggle Comment Line"), #Text Submenu - "uppercase": R(Key("cs-p") + Text("Editor Upper Case") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Convert Uppercase"), - "lowercase": R(Key("cs-p") + Text("Editor Lower Case") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Convert lowercase"), - "delete [to] end of word []": R(Key("c-delete"), rdescript="Atom: Delete to End oF Word") * Repeat(extra="n"), - "delete sub word []": R(Key("a-backspace"), rdescript="Atom: Delete to End of Subword") * Repeat(extra="n"), - "delete [to] previous word []": R(Key("cs-p") + Text("Delete to Previous Word boundary") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Delete to previous word boundary") * Repeat(extra="n"), - "delete [to] next word []": R(Key("cs-p") + Text("Delete to Next Word Boundary") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Delete to next word boundary") * Repeat(extra="n"), - ##"delete line": R(Key("cs-k"), rdescript="Atom: Delete Line"), - "transpose": R(Key("cs-p") + Text("Transpose") + Key("enter"), rdescript="Atom: Transpose"), + "uppercase": + R(palettized("Editor Upper Case"), rdescript="Atom: Convert Uppercase"), + "lowercase": + R(palettized("Editor Lower Case"), rdescript="Atom: Convert lowercase"), + "delete [to] end [of word] []": + R(Key("c-delete"), rdescript="Atom: Delete to End oF Word") * + Repeat(extra="n"), + "delete sub [word] []": + R(Key("a-backspace"), rdescript="Atom: Delete to End of Subword") * + Repeat(extra="n"), + "delete [to] previous [word] []": + R(palettized("Delete to Previous Word boundary"), + rdescript="Atom: Delete to previous word boundary") * Repeat(extra="n"), + "delete [to] next [word] []": + R(palettized("Delete to Next Word Boundary"), + rdescript="Atom: Delete to next word boundary") * Repeat(extra="n"), + ##"delete line": R(Key("cs-k"), rdescript="Atom: Delete Line"), + "transpose": + R(palettized("Transpose") + Key("enter"), rdescript="Atom: Transpose"), #Folding Submenu - "make fold": R(Key("acw-f"), rdescript="Atom: Make Fold"), - "fold": R(Key("ac-lbrace"), rdescript="Atom: Fold"), - "unfold": R(Key("ac-rightbrace"), rdescript="Atom: Unfold"), - "unfold all": R(Key("acs-rightbrace"), rdescript="Atom: Unfold All"), - "fold [level] []": R(Key("c-%(n)s"), rdescript="Atom: Fold Level 1-9"), + "make fold": + R(Key("acw-f"), rdescript="Atom: Make Fold"), + "fold": + R(Key("ac-lbrace"), rdescript="Atom: Fold"), + "unfold": + R(Key("ac-rightbrace"), rdescript="Atom: Unfold"), + "unfold all": + R(Key("acs-rightbrace"), rdescript="Atom: Unfold All"), + "fold [level] []": + R(Key("c-%(n)s"), rdescript="Atom: Fold Level 1-9"), #Bookmarks Submenu - "view all": R(Key("c-f2"), rdescript="Atom: Reflow Section"), - "bookmark | book": R(Key("ca-f2"), rdescript="Atom: Toggle Bookmark"), - "next bookmark | next book": R(Key("f2"), rdescript="Atom: Jump to Next Bookmark"), - "previous bookmark | previous book": R(Key("s-f2"), rdescript="Atom: Jump to Previous Bookwork"), - #View Menu - "reload file": R(Key("ac-r"), rdescript="Atom: Reload File"), - "fullscreen": R(Key("f11"), rdescript="Atom: Toggle Fullscreen"), - "toggle menubar": R(Key("cs-p") + Text("Toggle Menu Bar") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Toggle Menubar"), - "increase font [size] []": R(Key("cs-equals"), rdescript="Atom: Increase Font Size") * Repeat(extra="n"), - "decrease font [size] []": R(Key("cs-minus"), rdescript="Atom: Decrease Font size") * Repeat(extra="n"), - "reset font [size]": R(Key("c-0"), rdescript="Atom: Reset Font Size"), - "toggle soft wrap": R(Key("cs-p") + Text("Toggle Soft Wrap") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Toggle Soft Wrap"), - ##"toggle command palette": R(Key(""), rdescript="Atom: Toggle Command Palette"), - "[toggle] treeview": R(Key("c-backslash"), rdescript="Atom: Toggle Treeview"), + "view all": + R(Key("c-f2"), rdescript="Atom: Reflow Section"), + "bookmark | book": + R(Key("ca-f2"), rdescript="Atom: Toggle Bookmark"), + "next bookmark | next book": + R(Key("f2"), rdescript="Atom: Jump to Next Bookmark"), + "previous bookmark | previous book": + R(Key("s-f2"), rdescript="Atom: Jump to Previous Bookwork"), + #View Menu + "reload file": + R(Key("ac-r"), rdescript="Atom: Reload File"), + "fullscreen": + R(Key("f11"), rdescript="Atom: Toggle Fullscreen"), + "toggle menubar": + R(palettized("Toggle Menu Bar"), rdescript="Atom: Toggle Menubar"), + "increase font [size] []": + R(Key("cs-equals"), rdescript="Atom: Increase Font Size") * Repeat(extra="n"), + "decrease font [size] []": + R(Key("cs-minus"), rdescript="Atom: Decrease Font size") * Repeat(extra="n"), + "reset font [size]": + R(Key("c-0"), rdescript="Atom: Reset Font Size"), + "toggle soft wrap": + R(palettized("Toggle Soft Wrap"), rdescript="Atom: Toggle Soft Wrap"), + ##"toggle command palette": R(Key(""), rdescript="Atom: Toggle Command Palette"), + "[toggle] treeview": + R(Key("c-backslash"), rdescript="Atom: Toggle Treeview"), #Panes Submenu - "split above": R(Key("cs-p") + Text("Pane: Split Up") + Pause(atom_palette_wait) + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Split Up"), - "split below": R(Key("cs-p") + Text("Pane: Split Down") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Split Down"), - "split left": R(Key("cs-p") + Text("Pane: Split Left") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Split Left"), - "split right": R(Key("cs-p") + Text("Pane: Split Right") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Split Right"), - "focus [on] next [pane]": R(Key("cs-p") + Text("Window: Focus Next Pane") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Focus Next Pane"), - "focus [on] previous [pane]": R(Key("cs-p") + Text("Window: Focus Previous Pane") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Focus Previous Pane"), - "focus [pane] [on] above": R(Key("cs-p") + Text("Window: Focus Pane Above") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Focused Pane Above"), - "focus [pane] [on] below": R(Key("cs-p") + Text("Window: Focus Pane Below") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Focus Pane Below"), - "focus [pane] [on] left": R(Key("cs-p") + Text("Window: Focus Pane on Left") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Focus On left"), - "focus [pane] [on] right": R(Key("cs-p") + Text("Window: Focus Pane on Right") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Focus Pane on Right"), - ##"close pane": R(Key("cs-p") + Text("Window: pane close") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Close Pane"), + "split above": + R(palettized("Pane: Split Up"), rdescript="Atom: Split Up"), + "split below": + R(palettized("Pane: Split Down"), rdescript="Atom: Split Down"), + "split left": + R(palettized("Pane: Split Left"), rdescript="Atom: Split Left"), + "split right": + R(palettized("Pane: Split Right"), rdescript="Atom: Split Right"), + "focus [on] next [pane]": + R(palettized("Window: Focus Next Pane"), rdescript="Atom: Focus Next Pane"), + "focus [on] previous [pane]": + R(palettized("Window: Focus Previous Pane"), + rdescript="Atom: Focus Previous Pane"), + "focus [pane] [on] above": + R(palettized("Window: Focus Pane Above"), + rdescript="Atom: Focused Pane Above"), + "focus [pane] [on] below": + R(palettized("Window: Focus Pane Below"), rdescript="Atom: Focus Pane Below"), + "focus [pane] [on] left": + R(palettized("Window: Focus Pane on Left"), rdescript="Atom: Focus On left"), + "focus [pane] [on] right": + R(palettized("Window: Focus Pane on Right"), + rdescript="Atom: Focus Pane on Right"), + ##"close pane": R(palettized("Window: pane close"), rdescript="Atom: Close Pane"), #extras - "[go to] pane []": R(Key("a-%(n)s"), rdescript="Atom: Go to Pane 1-9"), - "focus previous": R(Key("cs-p") + Text("Core: Focus Previous") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Focus Previous"), - "next pane": R(Key("cs-p") + Text("Window: Focus Previous Pane") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Next Pane"), - "previous pane": R(Key("cs-p") + Text("Window: Focus Next Pane") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Previous Pane"), + "[go to] pane []": + R(Key("a-%(n)s"), rdescript="Atom: Go to Pane 1-9"), + "focus previous": + R(palettized("Core: Focus Previous"), rdescript="Atom: Focus Previous"), + "next pane": + R(palettized("Window: Focus Previous Pane"), rdescript="Atom: Next Pane"), + "previous pane": + R(palettized("Window: Focus Next Pane"), rdescript="Atom: Previous Pane"), #Developer Submenu - #"open in development mode": R(Key(""), rdescript="Open in Development Mode"), - "run atom [specs]": R(Key("ac-s"), rdescript="Atom: Run Atoms Specs"), - "run package [specs]": R(Key("ac-p"), rdescript="Atom: Run Package Specs "), - "[toggle] developer tools": R(Key("ac-i"), rdescript="Atom: Toggle Developer Tools"), - #Selection Menu - "[add] selection above []": R(Key("ac-up"), rdescript="Atom: Add Selection Above #") * Repeat(extra="n"), - "[add] selection below []": R(Key("ac-down"), rdescript="Atom: Add Selection Below #") * Repeat(extra="n"), - "split into lines": R(Key("cs-p") + Text("Split Into Lines") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Split Into lines"), - "single Section": R(Key("escape"), rdescript="Atom: Single Section"), - "select [to] top": R(Key("cs-home"), rdescript="Atom: Select to Top"), - "select [to] bottom": R(Key("cs-end"), rdescript="Atom: Select to Bottom"), - "select line": R(Key("c-l"), rdescript="Atom: Select Line"), - "select word []": R(Key("cs-p") + Text("Editor: Word") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Select Word") * Repeat(extra="n"), - "[select] [to] beginning [of] word []": R(Key("cs-left"), rdescript="Atom: Select to Beginning of Word #") * Repeat(extra="n"), - "[select] [to] end of word []": R(Key("cs-right"), rdescript="Atom: Select to End of Word #") * Repeat(extra="n"), - "[select] [to] beginning [of] line": R(Key("cs-p") + Text("Editor: Select to Beginning of Line") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Select to Beginning of line"), - "[select] [to] first character of line": R(Key("s-home"), rdescript="Atom: Select to First Character of Line"), - "[select] [to] end of line": R(Key("s-end"), rdescript="Atom: Select to End of line"), - "[select] inside brackets": R(Key("ac-m"), rdescript="Atom: Select Inside Brackets"), - #Find Menu - "find in buffer": R(Key("c-f"), rdescript="Atom: Find in Buffer"), - "replacing in buffer": R(Key("ac-f"), rdescript="Atom: Replacing in Buffer"), - "select next": R(Key("c-d"), rdescript="Atom: Select Next"), - "find select all": R(Key("a-f3"), rdescript="Atom: Select All"), - "find replace next": R(Key("cs-p") + Text("Find and Replace: Replace Next") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Replace Next"), - "find replace all": R(Key("cs-p") + Text("Find and Replace: Replace All") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Replace All"), - "find buffer": R(Key("c-b"), rdescript="Atom: Find Buffer"), - "find file": R(Key("c-p"), rdescript="Atom: Find File"), - "find modified file": R(Key("cs-b"), rdescript="Atom: Find Modified File"), - #Packages Menu + #"open in development mode": R(Key(""), rdescript="Open in Development Mode"), + "run atom [specs]": + R(Key("ac-s"), rdescript="Atom: Run Atoms Specs"), + "run package [specs]": + R(Key("ac-p"), rdescript="Atom: Run Package Specs "), + "[toggle] developer tools": + R(Key("ac-i"), rdescript="Atom: Toggle Developer Tools"), + #Selection Menu + "[add] select above []": + R(Key("ac-up"), rdescript="Atom: Add Selection Above #") * Repeat(extra="n"), + "[add] select below []": + R(Key("ac-down"), rdescript="Atom: Add Selection Below #") * + Repeat(extra="n"), + "split into lines": + R(palettized("Split Into Lines"), rdescript="Atom: Split Into lines"), + "single section": + R(Key("escape"), rdescript="Atom: Single Section"), + "select [to] top": + R(Key("cs-home"), rdescript="Atom: Select to Top"), + "select [to] bottom": + R(Key("cs-end"), rdescript="Atom: Select to Bottom"), + #"select line": R(Key("c-l"), rdescript="Atom: Select Line"), + #"select word []": R(palettized("Editor: Word"), rdescript="Atom: Select Word") * Repeat(extra="n"), + "[select] [to] begin [of] word []": + R(Key("cs-left"), rdescript="Atom: Select to Beginning of Word #") * + Repeat(extra="n"), + "[select] [to] end word []": + R(Key("cs-right"), rdescript="Atom: Select to End of Word #") * + Repeat(extra="n"), + "[select] [to] begin line": + R(palettized("Editor: Select to Beginning of Line"), + rdescript="Atom: Select to Beginning of line"), + "[select] [to] first character": + R(Key("s-home"), rdescript="Atom: Select to First Character of Line"), + "[select] [to] end line": + R(Key("s-end"), rdescript="Atom: Select to End of line"), + "[select] inside brackets": + R(Key("ac-m"), rdescript="Atom: Select Inside Brackets"), + #Find Menu + #"find in buffer": R(Key("c-f"), rdescript="Atom: Find in Buffer"), + "replacing in buffer": + R(Key("ac-f"), rdescript="Atom: Replacing in Buffer"), + "select next": + R(Key("a-f3"), rdescript="Atom: Select All"), + "find replace next": + R(palettized("Find and Replace: Replace Next"), + rdescript="Atom: Replace Next"), + "find replace all": + R(palettized("Find and Replace: Replace All"), rdescript="Atom: Replace All"), + "find buffer": + R(Key("c-b"), rdescript="Atom: Find Buffer"), + "find file": + R(Key("c-p"), rdescript="Atom: Find File"), + "find modified file": + R(Key("cs-b"), rdescript="Atom: Find Modified File"), + #Packages Menu #Bracket Matcher Submenu - "bracket [go to] match": R(Key("c-m"), rdescript="Atom: Go To Matching Bracket"), - ##"select inside bracket": R(Key("ac-m"), rdescript="Atom: Select inside bracket"), - "bracket remove [from] selection": R(Key("c-lbrace"), rdescript="Atom: Remove Bracket from Selection"), - "close [current] tag": R(Key("cs-p") + Text("Bracket Matcher: Close Tag") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Close current tag"), - "bracket remove matching": R(Key("ac-backspace"), rdescript="Atom: Remove matching brackets"), + "bracket [go to] match": + R(Key("c-m"), rdescript="Atom: Go To Matching Bracket"), + ##"select inside bracket": R(Key("ac-m"), rdescript="Atom: Select inside bracket"), + "bracket remove [from] selection": + R(Key("c-lbrace"), rdescript="Atom: Remove Bracket from Selection"), + "close [current] tag": + R(palettized("Bracket Matcher: Close Tag"), + rdescript="Atom: Close current tag"), + "bracket remove matching": + R(Key("ac-backspace"), rdescript="Atom: Remove matching brackets"), #Command Palette Submenu - "[toggle] [command] palette": R(Key("cs-p"), rdescript="Atom: Toggle Command Palette"), + "[toggle] [command] palette": + R(Key("cs-p"), rdescript="Atom: Toggle Command Palette"), #Dev Live Reload Submenu - "reload [all] styles": R(Key("acs-r"), rdescript="Atom: Reload All Styles"), + "reload [all] styles": + R(Key("acs-r"), rdescript="Atom: Reload All Styles"), #Git Diff Submenu - "move to next diff [different]": R(Key("cs-p") + Text("Move to Next Diff") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Move to Next Diff"), - "move to previous diff [different]": R(Key("cs-p") + Text("Move to Previous Diff") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Move to Previous Different"), - "[toggle] diff List": R(Key("cs-p") + Text("Toggle Diff List") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Toggle Diff List"), + "move to next diff [different]": + R(palettized("Move to Next Diff"), rdescript="Atom: Move to Next Diff"), + "move to previous diff [different]": + R(palettized("Move to Previous Diff"), + rdescript="Atom: Move to Previous Different"), + "[toggle] diff List": + R(palettized("Toggle Diff List"), rdescript="Atom: Toggle Diff List"), #Keybinding Resolver Submenu - "toggle key [binding] resolver": R(Key("cs-p") + Text("Key Binding Resolver: Toggle") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Toggle Keybinding Resolver"), + "toggle key [binding] resolver": + R(palettized("Key Binding Resolver: Toggle"), + rdescript="Atom: Toggle Keybinding Resolver"), #Markdown Preview Submenu - "markdown preview": R(Key("cs-m"), rdescript="Atom: Markdown Toggle Preview"), + "markdown preview": + R(Key("cs-m"), rdescript="Atom: Markdown Toggle Preview"), #Extras - "markdown copy html": R(Key("cs-p") + Text("Markdown Preview: Copy HTML") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Markdown Preview: Copy HTML"), - "markdown toggle break on newline": R(Key("cs-p") + Text("Markdown Preview: Toggle Break On Single Newline") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Markdown Preview: Toggle Break On Single Newline"), + "markdown copy html": + R(palettized("Markdown Preview: Copy HTML"), + rdescript="Atom: Markdown Preview: Copy HTML"), + "markdown toggle break on newline": + R(palettized("Markdown Preview: Toggle Break On Single Newline"), + rdescript="Atom: Markdown Preview: Toggle Break On Single Newline"), #Package Generator Submenu - "make|generate package": R(Key("cs-p") + Text("Package Generator: Generate Package") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Generate Atom Package"), - "make|generate syntax theme": R(Key("cs-p") + Text("Package Generator: Generate Syntax Theme") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Generate Atom Syntax Theme"), + "make|generate package": + R(palettized("Package Generator: Generate Package"), + rdescript="Atom: Generate Atom Package"), + "make|generate syntax theme": + R(palettized("Package Generator: Generate Syntax Theme"), + rdescript="Atom: Generate Atom Syntax Theme"), #Settings View Submenu - ##"open setting": R(Key("c-comma"), rdescript="Atom: Open Setting"), - "show key bindings": R(Key("cs-p") + Text("Settings View: Show Key Bindings") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Show Keybindings"), - "installed themes": R(Key("cs-p") + Text("Settings View: Installed Themes") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Install Themes"), - "uninstalled themes": R(Key("cs-p") + Text("Settings View: Uninstall Themes") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Uninstall Themes"), - "installed packages": R(Key("cs-p") + Text("Settings View: Installed Packages") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Install Packages"), - "uninstalled packages": R(Key("cs-p") + Text("Settings View: Uninstalled Packages") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Uninstall packages/themes"), - "search packages|themes": R(Key("cs-p") + Text("Settings View: Install Packages and Themes") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Install Packages/Themes"), - "update packages": R(Key("cs-p") + Text("Settings View: Check for Package Update") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Check for Packages"), + ##"open setting": R(Key("c-comma"), rdescript="Atom: Open Setting"), + "show key bindings": + R(palettized("Settings View: Show Key Bindings"), + rdescript="Atom: Show Keybindings"), + "installed themes": + R(palettized("Settings View: Installed Themes"), + rdescript="Atom: Install Themes"), + "uninstalled themes": + R(palettized("Settings View: Uninstall Themes"), + rdescript="Atom: Uninstall Themes"), + "installed packages": + R(palettized("Settings View: Installed Packages"), + rdescript="Atom: Install Packages"), + "uninstalled packages": + R(palettized("Settings View: Uninstalled Packages"), + rdescript="Atom: Uninstall packages/themes"), + "search packages|themes": + R(palettized("Settings View: Install Packages and Themes"), + rdescript="Atom: Install Packages/Themes"), + "update packages": + R(palettized("Settings View: Check for Package Update"), + rdescript="Atom: Check for Packages"), #Snippets Submenu - "expand snippets": R(Key("cs-p") + Text("Snippets: Expand") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Expand Snippets"), - "next snippet": R(Key("tab"), rdescript="Atom: Next Stop|Snippet"), - "previous snippet": R(Key("a-tab"), rdescript="Atom: Previous Stop|Snippet"), - "available snippet": R(Key("as-tab"), rdescript="Atom: Available Snippets"), + "expand snippets": + R(palettized("Snippets: Expand"), rdescript="Atom: Expand Snippets"), + "next snippet": + R(Key("tab"), rdescript="Atom: Next Stop|Snippet"), + "previous snippet": + R(Key("a-tab"), rdescript="Atom: Previous Stop|Snippet"), + "available snippet": + R(Key("as-tab"), rdescript="Atom: Available Snippets"), #Styleguide Submenu - "show style [guide]": R(Key("cs-g"), rdescript="Atom: Show Styleguide"), - #Symbol - "find symbol": R(Key("c-r"), rdescript="Atom: Find Symbol"), - "project symbol": R(Key("cs-r"), rdescript="Atom: Project Symbol"), + "show style [guide]": + R(Key("cs-g"), rdescript="Atom: Show Styleguide"), + #Symbol + "find symbol": + R(Key("c-r"), rdescript="Atom: Find Symbol"), + "project symbol": + R(Key("cs-r"), rdescript="Atom: Project Symbol"), #Timecop Submenu - "timecop": R(Key("cs-p") + Text("Timecop: View") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Show Timecop"), + "timecop": + R(palettized("Timecop: View"), rdescript="Atom: Show Timecop"), #Tree View Submenu - "tree focus": R(Key("c-0"), rdescript="Atom: Toggle Focus on TreeView"), - "tree [View] [toggle] view": R(Key("c-backslash"), rdescript="Atom: Toggle"), - "tree [View] [reveal] active file": R(Key("cs-backslash"), rdescript="Atom: Reveal Active File"), - "tree [View] [toggle] side": R(Key("cs-p") + Text("Tree View: show") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Toggle Tree Side"), + "tree focus": + R(Key("c-0"), rdescript="Atom: Toggle Focus on TreeView"), + "tree [View] [toggle] view": + R(Key("c-backslash"), rdescript="Atom: Toggle"), + "tree [View] [reveal] active file": + R(Key("cs-backslash"), rdescript="Atom: Reveal Active File"), + "tree [View] [toggle] side": + R(palettized("Tree View: show"), rdescript="Atom: Toggle Tree Side"), #Extras - "tree show": R(Key("cs-p") + Text("Tree View: Show") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Tree View: Show"), - "tree rename": R(Key("cs-p") + Text("Tree View: Rename") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Tree View: Rename"), - "tree remove": R(Key("cs-p") + Text("Tree View: Remove") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Tree View: Remove"), - "tree add file": R(Key("cs-p") + Text("Tree View: Add File") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Tree View: Add File"), - "tree duplicate": R(Key("cs-p") + Text("Tree View: Duplicate") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Tree View: Duplicate"), - "tree add folder": R(Key("cs-p") + Text("Tree View: Add Folder") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Tree View: Add Folder"), + "tree show": + R(palettized("Tree View: Show"), rdescript="Atom: Tree View: Show"), + "tree rename": + R(palettized("Tree View: Rename"), rdescript="Atom: Tree View: Rename"), + "tree remove": + R(palettized("Tree View: Remove"), rdescript="Atom: Tree View: Remove"), + "tree add file": + R(palettized("Tree View: Add File"), rdescript="Atom: Tree View: Add File"), + "tree duplicate": + R(palettized("Tree View: Duplicate"), rdescript="Atom: Tree View: Duplicate"), + "tree add folder": + R(palettized("Tree View: Add Folder"), + rdescript="Atom: Tree View: Add Folder"), #Whitespaces Submenu - "remove trailing [white] spaces": R(Key("cs-p") + Text("Whitespace: Remove Trailing Whitespace") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Remove Trailing White Spaces"), - "convert tabs [to] spaces": R(Key("cs-p") + Text("Whitespace: Convert Tabs to Spaces") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Convert Tabs to Spaces"), - "convert spaces [to] tabs": R(Key("cs-p") + Text("Whitespace: Convert Spaces to Tabs") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Convert Spaces to Tabs"), - #Merge Conflicts Submenu - "git [detect] [merge] conflicts": R(Key("cs-p") + Text("Merge Conflicts Detect") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Detect"), + "remove trailing [white] spaces": + R(palettized("Whitespace: Remove Trailing Whitespace"), + rdescript="Atom: Remove Trailing White Spaces"), + "convert tabs [to] spaces": + R(palettized("Whitespace: Convert Tabs to Spaces"), + rdescript="Atom: Convert Tabs to Spaces"), + "convert spaces [to] tabs": + R(palettized("Whitespace: Convert Spaces to Tabs"), + rdescript="Atom: Convert Spaces to Tabs"), + #Open on GitHub + "github [open] blame": + R(palettized("Open on GitHub: Blame"), + rdescript="Atom: Open On Github @ Blame"), + "github [open] [branch] compare": + R(palettized("Open on GitHub: Branch Compare"), + rdescript="Atom: Open On Github @ Branch Compare"), + "github [open] [copy] URL": + R(palettized("Open on GitHub: Copy URL"), + rdescript="Atom: Open On Github @ Copy URL"), + "github [open] file": + R(palettized("Open on GitHub: File"), + rdescript="Atom: Open On Github @ File"), + "github [open] history": + R(palettized("Open on GitHub: History"), + rdescript="Atom: Open On Github @ History"), + "github [open] issues": + R(palettized("Open on GitHub: Issues"), + rdescript="Atom: Open On Github @ Issues"), + "github [open] repository": + R(palettized("Open on GitHub: Repository"), + rdescript="Atom: Open On Github @ Repository"), + #Open on GitHub + "github close different": + R(palettized("GitHub: Close All Diff Views"), + rdescript="Atom: GitHub Close All Diff Views"), + "github empty different": + R(palettized("GitHub: Close Empty Diff Views"), + rdescript="Atom: GitHub Close Empty Diff Views"), + "github [show waterfall] diagnostics": + R(palettized("GitHub:Okay Show Waterfall Diagnostics"), + rdescript="Atom: GitHub Show Waterfall Diagnostics"), + "github [open] issues | pull request": + R(palettized("GitHub: Open Issue or Pull Request"), + rdescript="Atom: GitHub Open Issue or Pull Request"), + "github view staged changes [for current file]": + R(palettized("GitHub: View Staged Changes for Current File"), + rdescript="Atom: GitHub View Staged Changes for Current File"), + "github view unstaged changes [for current file]": + R(palettized("GitHub: View Unstaged Changes for Current File"), + rdescript="Atom: GitHub View Unstaged Changes for Current File"), + #Open on GitHub + "github pull": + R(Key("s-g"), rdescript="Atom: GitHub Pull"), + "github push": + R(Key("a-g") + Key("p"), rdescript="Atom: GitHub Push"), + "github clone": + R(Key("a-g") + Key("equal"), rdescript="Atom: GitHub Clone"), + "github fetch": + R(Key("a-g") + Key("f"), rdescript="Atom: GitHub Fetch"), + "github logout": + R(palettized("GitHub: Logout"), rdescript="Atom: GitHub Logout"), + "github force push": + R(Key("a-g"), rdescript="Atom: GitHub Force Push"), + "github tab [toggle]": + R(Key("c-8"), rdescript="Atom: Github Toggle Github Tab"), + "github focus [tab]": + R(Key("c-9") + Key("enter"), rdescript="Atom:Toggle Github Focus"), + # Adom Development + "dev restart | reload [atom]": + R(palettized("Window: Reload"), rdescript="Atom: Restart/Reload Atom"), -# ----Atom Optional Third-Party Packages and Dependencies----------------------------------------------------------------------------- - #Install through command prompt, Atom install manager or a .bat file at http://tinyurl.com/Atom-Dependencies - # pip install --upgrade autopep8T - # apm install project-sidebar - # apm install project-manager - # apm install git-plus - # apm install script - # apm install atom-beautify - # apm install goto-last-edit - # apm install tab-numbers - # apm install menu-manager - # apm install string-looper - # apm install toggle-quotes - # apm install delete-Plus - # apm install expand-selection-to-quotes - # apm install highlight-selected - # apm install sublime-style-column-selection + # ----Atom Optional Third-Party Packages and Dependencies----------------------------------------------------------------------------- + #Install through command prompt, Atom install manager or a .bat file at http://tinyurl.com/Atom-Dependencies + # pip install --upgrade autopep8T + # apm install project-sidebar + # apm install project-manager + # apm install git-plus + # apm install script + # apm install atom-beautify + # apm install goto-last-edit + # apm install tab-numbers + # apm install menu-manager + # apm install string-looper + # apm install toggle-quotes + # apm install delete-Plus + # apm install expand-selection-to-quotes + # apm install highlight-selected + # apm install sublime-style-column-selection -#Atom Third-Party Package Commands------------------------------------------------------------------------------------------------- + #Atom Third-Party Package Commands------------------------------------------------------------------------------------------------- #Atom Beautify - "beautify editor": R(Key("cs-p") + Text("Atom Beautify: Beautify Editor") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom : Beautify Editor"), - "beautify migrate settings": R(Key("cs-p") + Text("Atom Beautify: Migrate Settings") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Beautify: Migrate Settings"), - "beautify debug editor": R(Key("cs-p") + Text("Atom Beautify: Help Debug Editor") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Beautify: Debug Editor"), + "beautify editor": + R(palettized("Atom Beautify: Beautify Editor"), + rdescript="Atom : Beautify Editor"), + "beautify migrate settings": + R(palettized("Atom Beautify: Migrate Settings"), + rdescript="Atom: Beautify: Migrate Settings"), + "beautify debug editor": + R(palettized("Atom Beautify: Help Debug Editor"), + rdescript="Atom: Beautify: Debug Editor"), #Toggle Quotes - "toggle quotes": R(Key("cs-apostrophe"), rdescript="Atom: Toggle Quotes: Single or Double"), + "toggle quotes": + R(Key("cs-apostrophe"), rdescript="Atom: Toggle Quotes: Single or Double"), #Script - "script run": R(Key("cs-p") + Text("Script: Run") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Script: run"), - "script [run] options": R(Key("cs-p") + Text("Script: Run Options") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Script: Run Options or Configure"), - "script [run] profile": R(Key("cs-p") + Text("Script: Run With Profile") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Script: Run With Profile"), - "script run [by] line": R(Key("cs-p") + Text("Script: Run By Line Number") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Script: Run Script by Line"), - "script kill [process]": R(Key("cs-p") + Text("Script: Kill Process") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Script: Kill Process"), - "script close view": R(Key("cs-p") + Text("Script: Close View") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Script: Close View"), - "script copy [run] [results]": R(Key("cs-p") + Text("Script: Copy Run Results") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Script: Copy Run Results"), - #"script close window and stop script": R(Key("cs-p") + Text("Script: Close Window and Stop Script") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Script: Close Window and Stop Script"), + "script run": + R(palettized("Script: Run"), rdescript="Atom: Script: run"), + "script [run] options": + R(palettized("Script: Run Options"), + rdescript="Atom: Script: Run Options or Configure"), + "script [run] profile": + R(palettized("Script: Run With Profile"), + rdescript="Atom: Script: Run With Profile"), + "script run [by] line": + R(palettized("Script: Run By Line Number"), + rdescript="Atom: Script: Run Script by Line"), + "script kill [process]": + R(palettized("Script: Kill Process"), rdescript="Atom: Script: Kill Process"), + "script close view": + R(palettized("Script: Close View"), rdescript="Atom: Script: Close View"), + "script copy [run] [results]": + R(palettized("Script: Copy Run Results"), + rdescript="Atom: Script: Copy Run Results"), + #"script close window and stop script": R(palettized("Script: Close Window and Stop Script"), rdescript="Atom: Script: Close Window and Stop Script"), #Delete Plus - "delete words": R(Key("cs-p") + Text("Delete Plus: Delete") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Delete Plus"), + "delete words": + R(palettized("Delete Plus: Delete"), rdescript="Atom: Delete Plus"), #Last Edit - "back edit": R(Key("c-i"), rdescript="Atom: Previous Edit"), - "next edit": R(Key("ca-i"), rdescript="Atom: Next Last Edit"), + "back edit": + R(Key("c-i"), rdescript="Atom: Previous Edit"), + "next edit": + R(Key("ca-i"), rdescript="Atom: Next Last Edit"), #Looper - #"cursor loud|capitalize []": R(Key("a-down"), rdescript="Atom: Looper Capitalize") * Repeat(extra="n"), # Not fully implemented - #"cursor camel []": R(Key("a-down"), rdescript="Atom: Looper Camelcase") * Repeat(extra="n"), # Not fully implemented - #"cursor lowercase []": R(Key("a-down"), rdescript="Atom: Looper Lowercase") * Repeat(extra="n"), # Not fully implemented - "looping down cursor": R(Key("a-down"), rdescript="Atom: Looping Down at Cursor"), - "looping up cursor": R(Key("a-up"), rdescript="Atom: Looping Up at Cursor"), - "looping up": R(Key("wa-up"), rdescript="Atom: Looping Up"), - "looping down": R(Key("wa-down"), rdescript="Atom: Looping Down"), - #Open on GitHub - "github [open] blame": R(Key("cs-p") + Text("Open on GitHub: Blame") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Open On Github @ Blame"), - "github [open] [branch] compare": R(Key("cs-p") + Text("Open on GitHub: Branch Compare") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Open On Github @ Branch Compare"), - "github [open] [copy] URL": R(Key("cs-p") + Text("Open on GitHub: Copy URL") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Open On Github @ Copy URL"), - "github [open] file": R(Key("cs-p") + Text("Open on GitHub: File") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Open On Github @ File"), - "github [open] history": R(Key("cs-p") + Text("Open on GitHub: History") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Open On Github @ History"), - "github [open] issues": R(Key("cs-p") + Text("Open on GitHub: Issues") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Open On Github @ Issues"), - "github [open] repository": R(Key("cs-p") + Text("Open on GitHub: Repository") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Open On Github @ Repository"), - #Git Plus - "git custom|run": R(Key("cs-p") + Text("Git Plus: Run") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Run"), - "git log": R(Key("cs-p") + Text("Git Plus: Log") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Log"), - "git log current [file]": R(Key("cs-p") + Text("Git Plus: Log Current File") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Current File"), - "git status": R(Key("cs-p") + Text("Git Plus: Status") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Status"), - "git show": R(Key("cs-p") + Text("Git Plus: Show") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Show"), - "git tags": R(Key("cs-p") + Text("Git Plus: Tags") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Tags"), - "git open changed files": R(Key("cs-p") + Text("Git Plus: Git Open Changed Files") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Open Changed Files"), - "git checkout [branch|tag]": R(Key("cs-p") + Text("Git Plus: Checkout") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Checkout Branch|Tag"), - "git menu": R(Key("cs-p") + Text("Git Plus: Menu") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Menu"), - "git pull": R(Key("cs-p") + Text("Git Plus: Pull") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Pull"), - "git pull [using] rebase": R(Key("cs-p") + Text("Git Plus: Pull Using Rebase") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Pull Using Rebase"), - "git push": R(Key("cs-p") + Text("Git Plus: Push") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Push"), - "git commit": R(Key("cs-p") + Text("Git Plus: Commit") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Commit"), - "git commit amend": R(Key("cs-p") + Text("Git Plus: Commit Amend") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Commit Amend"), - "git merge": R(Key("cs-p") + Text("Git Plus: Merge") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Merge"), - "git merge remote": R(Key("cs-p") + Text("Git Plus: Merge Remote") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Merge Remote"), - "git diff": R(Key("cs-p") + Text("Git Plus: Diff") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Diff"), - "git diff all": R(Key("cs-p") + Text("Git Plus: Diff All") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Diff All"), - "git add": R(Key("cs-p") + Text("Git Plus: Add") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Add"), - "git add all": R(Key("cs-p") + Text("Git plus: Add All") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Add All"), - "git add [and] commit": R(Key("cs-p") + Text("Git Plus: Add And Commit") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Add And Commit"), - "git add all [and] commit": R(Key("cs-p") + Text("Git Plus: Add All and Commit") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Add All and Commit"), - "git add all commit [and] push": R(Key("cs-p") + Text("Git Plus: Add All Commit And Push") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Add All Commit Push"), - "git new branch": R(Key("cs-p") + Text("Git Plus: New Branch") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git New Branch"), - "git rm|remove": R(Key("cs-p") + Text("Git Plus: Remove") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Git Remove"), - #Project Manager - "project manager [list]": R(Key("cs-p") + Text("Project Manager:List") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Project Manager: Toggle"), - "project manager save": R(Key("cs-p") + Text("Project Manager:Save Project") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Project Manager: Save Project"), - "project manager edit": R(Key("cs-p") + Text("Project Manager:Edit Project") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Project Manager: Edit Project"), - #Menu Sidebar - "[project manager] sidebar": R(Key("cs-p") + Text("Project Sidebar: Toggle") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: Project Sidebar: Toggle"), - #Expand Selection to Quotes - "expand|fill quotes": R(Key("c-apostrophe"), rdescript="Atom: Expand Selection to Quotes"), - #Auto Complete - "auto [complete]": R(Key("c-space"), rdescript="Atom: Show Auto Complete Menu"), - #Highlight Selected---- #Placeholder - #Sublime Style Column Selection---- #Placeholder + #"cursor loud|capitalize []": R(Key("a-down"), rdescript="Atom: Looper Capitalize") * Repeat(extra="n"), # Not fully implemented + #"cursor camel []": R(Key("a-down"), rdescript="Atom: Looper Camelcase") * Repeat(extra="n"), # Not fully implemented + #"cursor lowercase []": R(Key("a-down"), rdescript="Atom: Looper Lowercase") * Repeat(extra="n"), # Not fully implemented + "looping down cursor": + R(Key("a-down"), rdescript="Atom: Looping Down at Cursor"), + "looping up cursor": + R(Key("a-up"), rdescript="Atom: Looping Up at Cursor"), + "looping up": + R(Key("wa-up"), rdescript="Atom: Looping Up"), + #Git Plus + "git custom|run": + R(palettized("Git Plus: Run"), rdescript="Atom: Git Run"), + "git log": + R(palettized("Git Plus: Log"), rdescript="Atom: Git Log"), + "git log current [file]": + R(palettized("Git Plus: Log Current File"), + rdescript="Atom: Git Current File"), + "git status": + R(palettized("Git Plus: Status"), rdescript="Atom: Git Status"), + "git show": + R(palettized("Git Plus: Show"), rdescript="Atom: Git Show"), + "git tags": + R(palettized("Git Plus: Tags"), rdescript="Atom: Git Tags"), + "git open changed files": + R(palettized("Git Plus: Git Open Changed Files"), + rdescript="Atom: Git Open Changed Files"), + "git checkout [branch|tag]": + R(palettized("Git Plus: Checkout"), + rdescript="Atom: Git Checkout Branch|Tag"), + "git menu": + R(palettized("Git Plus: Menu"), rdescript="Atom: Git Menu"), + "git pull": + R(palettized("Git Plus: Pull"), rdescript="Atom: Git Pull"), + "git pull [using] rebase": + R(palettized("Git Plus: Pull Using Rebase"), + rdescript="Atom: Git Pull Using Rebase"), + "git push": + R(palettized("Git Plus: Push"), rdescript="Atom: Git Push"), + "git commit": + R(palettized("Git Plus: Commit"), rdescript="Atom: Git Commit"), + "git commit amend": + R(palettized("Git Plus: Commit Amend"), rdescript="Atom: Git Commit Amend"), + "git merge": + R(palettized("Git Plus: Merge"), rdescript="Atom: Git Merge"), + "git merge remote": + R(palettized("Git Plus: Merge Remote"), rdescript="Atom: Git Merge Remote"), + "git diff": + R(palettized("Git Plus: Diff"), rdescript="Atom: Git Diff"), + "git diff all": + R(palettized("Git Plus: Diff All"), rdescript="Atom: Git Diff All"), + "git add": + R(palettized("Git Plus: Add"), rdescript="Atom: Git Add"), + "git add all": + R(palettized("Git plus: Add All"), rdescript="Atom: Git Add All"), + "git add [and] commit": + R(palettized("Git Plus: Add And Commit"), + rdescript="Atom: Git Add And Commit"), + "git add all [and] commit": + R(palettized("Git Plus: Add All and Commit"), + rdescript="Atom: Git Add All and Commit"), + "git add all commit [and] push": + R(palettized("Git Plus: Add All Commit And Push"), + rdescript="Atom: Git Add All Commit Push"), + "git new branch": + R(palettized("Git Plus: New Branch"), rdescript="Atom: Git New Branch"), + "git rm|remove": + R(palettized("Git Plus: Remove"), rdescript="Atom: Git Remove"), + #Project Manager + "project manager [list]": + R(palettized("Project Manager:List"), + rdescript="Atom: Project Manager: Toggle"), + "project manager save": + R(palettized("Project Manager:Save Project"), + rdescript="Atom: Project Manager: Save Project"), + "project manager edit": + R(palettized("Project Manager:Edit Project"), + rdescript="Atom: Project Manager: Edit Project"), + #Menu Sidebar + "[project manager] sidebar": + R(palettized("Project Sidebar: Toggle"), + rdescript="Atom: Project Sidebar: Toggle"), + #Expand Selection to Quotes + "expand|fill quotes": + R(Key("c-apostrophe"), rdescript="Atom: Expand Selection to Quotes"), + #Auto Complete + "auto [complete]": + R(Key("c-space"), rdescript="Atom: Show Auto Complete Menu"), + #Highlight Selected---- #Placeholder + #Sublime Style Column Selection---- #Placeholder -#Atom | Dragonfly Development-------------------------------------------------------------------------------------------------------------------------------------------------------- - # Template to create more commands. Documentation: https://dragonfly.readthedocs.org/en/latest/actions.html and http://caster.readthedocs.io/en/latest/caster/doc/Intro/ + #Atom | Dragonfly Development-------------------------------------------------------------------------------------------------------------------------------------------------------- + # Template to create more commands. Documentation: https://dragonfly.readthedocs.org/en/latest/actions.html and http://caster.readthedocs.io/en/latest/caster/doc/Intro/ # Used for basic key shortcuts - #"text for voice command": R(Key("modifier-key"), rdescript="program name: command name/description"), - #"": R(Key(""), rdescript="Atom: "), + #"text for voice command": R(Key("modifier-key"), rdescript="program name: command name/description"), + #"": R(Key(""), rdescript="Atom: "), # Used for command that utilizes the "command palette" shortcut in the absence of assigned keyboard shortcut. - #"text for voice command": R(Key("cs-p") + Text("text as described in command palette") + Pause(atom_palette_wait) + Key("enter"), rdescript="command name/description"), - #"": R(Key("cs-p") + Text("") + Pause(atom_palette_wait) + Key("enter"), - #Atom Shortcut Snippets - "dev keys [input] []": R(Text(' #"": R(Key("-"), rdescript="Atom: "),') + Key("enter"), rdescript="Macro: Dev Keys #") * Repeat(extra="n"), - "dev [command] palette []": R(Text(' #"": R(Key("cs-p") + Text("") + Pause(atom_palette_wait) + Key("enter"), rdescript="Atom: "),') + Key("enter"), rdescript="Macro: Dev Command Palette #") * Repeat(extra="n"), - "dev convert": Text('R(Key("cs-p") + Text("") + Pause(atom_palette_wait) + Key("enter"),') + Key("delete"), + #"text for voice command": R(palettized("text as described in command palette"), rdescript="command name/description"), + #"": R(palettized(""), + #Atom Shortcut Snippets + "dev keys [input] []": + R(Text('#"": R(Key("-"), rdescript="Atom: "),') + Key("enter"), + rdescript="Macro: Dev Keys #") * Repeat(extra="n"), + "dev [command] palette []": + R(Text('#"": R(palettized(""), rdescript="Atom: "),') + Key("enter"), + rdescript="Macro: Dev Command Palette #") * Repeat(extra="n"), #Repeatable Snippets - "dev numb keys [input] []": R(Text('#" []": R(Key("-"), rdescript="Atom: ") * Repeat(extra="n"),') + Key("enter"), rdescript="Macro: Numb Dev Keys #") * Repeat(extra="n"), - "dev numb [command] palette []": R(Text('#" []": R(Key("cs-p") + Text("") + Pause(atom_palette_wait) + Key("enter") + Pause(atom_palette_wait), rdescript="Atom: ") * Repeat(extra="n"),') + Key("enter"), rdescript="Macro: Dev Numb Command Palette #") * Repeat(extra="n"), - #Basic Dragonfly Snippets - "dev key []": R(Text('"": Key(""),'), rdescript="Dragonfly: Print Dev Key #") * Repeat(extra="n"), - "dev text []": R(Text('"": Text(""),'), rdescript="Dragonfly: Print Dev Text #") * Repeat(extra="n"), - } + "dev numb keys [input] []": + R(Text('#" []": R(Key("-"), rdescript="Atom: ") * Repeat(extra="n"),') + + Key("enter"), + rdescript="Macro: Numb Dev Keys #") * Repeat(extra="n"), + "dev numb [command] palette []": + R(Text('#" []": R(palettized(""), rdescript="Atom: ") * Repeat(extra="n"),' + ) + Key("enter"), + rdescript="Macro: Dev Numb Command Palette #") * Repeat(extra="n"), + #Basic Dragonfly Snippets + "dev key []": + R(Text('"": Key(""),'), rdescript="Dragonfly: Print Dev Key #") * + Repeat(extra="n"), + "dev text []": + R(Text('"": Text(""),'), rdescript="Dragonfly: Print Dev Text #") * + Repeat(extra="n"), + "send command []": + R(Text('"": R(Function(SendJsonCommands, a_command=""), rdescript=""),'), + rdescript="Macro: Print SendJsonCommands Template #") * Repeat(extra="n"), + } + extras = [ - Dictation("text"), - Dictation("mim"), - IntegerRefST("n", 1, 10000), - IntegerRefST("n2", 1, 9), + Dictation("text"), + Dictation("mim"), + IntegerRefST("n", 1, 10000), + IntegerRefST("n2", 1, 9), + ] + defaults = {"n": 1, "mim": ""} - ] - defaults = {"n": 1, "mim":""} #--------------------------------------------------------------------------- diff --git a/caster/apps/gitter.py b/caster/apps/gitter.py new file mode 100644 index 000000000..1db759c1b --- /dev/null +++ b/caster/apps/gitter.py @@ -0,0 +1,59 @@ +""" +__author__ = 'LexiconCode' +Command-module for Gitter +Official Site "https://gitter.im/" +""" +#--------------------------------------------------------------------------- + +from dragonfly import AppContext, Dictation, Grammar, Key, MappingRule, Text + +from caster.lib import control, settings +from caster.lib.dfplus.merge import gfilter +from caster.lib.dfplus.merge.mergerule import MergeRule +from caster.lib.dfplus.state.short import R + + +class GitterRule(MergeRule): + pronunciation = "Gitter" + + mapping = { + "bold": + R(Text("****") + Key("left:2"), rdescript="Gitter: Bold"), + "emphasize": + R(Text("**") + Key("left"), rdescript="Gitter: Italicize"), + # "header": R(Text( "" ), rdescript="Gitter: Header"), # H1 ## H2 ### H3 + "insert item": + R(Text("* "), rdescript="Gitter: Insert Item"), + "block quote": + R(Text("> "), rdescript="Gitter: Block Quote"), + "mention": + R(Text("@"), rdescript="Gitter: Mention"), + "insert link": + R(Text("[]()") + Key("left:3"), rdescript="Gitter: Insert Link"), + "insert image": + R(Text("![]()") + Key("left:3"), rdescript="Gitter: Insert Image"), + "insert code": + R(Text("``") + Key("left"), rdescript="Gitter: Insert Code"), + "formatted code": + R(Text("```") + Key("s-enter"), rdescript="Gitter: Formatted Code"), + } + extras = [ + Dictation("text"), + ] + Defaults = {} + + +#--------------------------------------------------------------------------- + +context = AppContext(executable="gitter") +grammar = Grammar("gitter", context=context) + +if settings.SETTINGS["apps"]["gitter"]: + if settings.SETTINGS["miscellaneous"]["rdp_mode"]: + control.nexus().merger.add_global_rule(GitterRule()) + print("added Gitter") + else: + rule = GitterRule(name="gitter") + gfilter.run_on(rule) + grammar.add_rule(rule) + grammar.load() diff --git a/caster/apps/vscode.py b/caster/apps/vscode.py new file mode 100644 index 000000000..35157b858 --- /dev/null +++ b/caster/apps/vscode.py @@ -0,0 +1,97 @@ +from dragonfly import (Grammar, AppContext, Dictation, Key, Text, Repeat, Function) + +from caster.lib import control +from caster.lib import settings +from caster.lib.dfplus.additions import IntegerRefST +from caster.lib.dfplus.merge import gfilter +from caster.lib.dfplus.merge.mergerule import MergeRule +from caster.lib.dfplus.state.short import R + +def findNthToken(text, n, direction): + Key("c-f").execute() + Text("%(text)s").execute({"text": text}) + if direction == "reverse": + print("yeah? %(n)d") + Key("s-enter:%(n)d").execute() + else: + Key("enter:%(n)d").execute() + print("no? %(n)d") + Key('escape').execute() + +class VisualStudioCodeRule(MergeRule): + pronunciation = "visual studio code" + + mapping = { + ### ported from my dragonfly scripts + # File management + "[open] command palette": R(Key("cs-p"), rdescript="Visual Studio Code: Command Palette"), + "(Open [file] | Go to [tab]) []": R(Key("c-p") + Text("%(text)s"), rdescript="Visual Studio Code: Go To File"), + "Close tab": R(Key("c-w"), rdescript="Visual Studio Code: Close Tab"), + "Save file": R(Key("c-s"), rdescript="Visual Studio Code: Save File"), + "Save and close": R(Key("c-s/10, c-w"), rdescript="Visual Studio Code: Save And Close File"), + + # Search + "(search | find in) [all] (files | codebase)": R(Key("cs-f"), rdescript="Visual Studio Code: Find in Codebase"), + "(search | find) [file]": R(Key("c-f"), rdescript="Visual Studio Code: Find in File"), + "(Find | Jump [to]) next ": R(Function(findNthToken, n=1, direction="forward"), rdescript="Visual Studio Code: Find Next"), + "(Find | Jump [to]) previous ": R(Function(findNthToken, n=1, direction="reverse"), rdescript="Visual Studio Code: Find Previous"), + + # Tab management + "nexta []": R(Key("c-pgdown"), rdescript="Visual Studio Code: Next Tab") * Repeat(extra="n"), # These would be next and previous tab but i have a conflict with chrome + "prexta []": R(Key("c-pgup"), rdescript="Visual Studio Code: Previous Tab") * Repeat(extra="n"), + "Close tab": R(Key("c-f4"), rdescript="Visual Studio Code: Close Tab"), + "Exit preview": R(Key("space, c-z"), rdescript="Visual Studio Code: Exit Preview"), + + # moving around a file + "(go to | jump | jump to) line ": R(Key("c-g") + Text("%(n)d") + Key("enter"), rdescript="Visual Studio Code: Go to Line"), + "Go to definition": R(Key("f12"), rdescript="Visual Studio Code: Go to Definition"), + "Go to required definition": R(Key("c-f12:2, c-right:5, left/50, f12"), rdescript="Visual Studio Code: Go to Required Definition"), + "Go to (top | first line)": R(Key("c-home"), rdescript="Visual Studio Code: Go to Top"), + "Go to ( bottom | last line)": R(Key("c-end"), rdescript="Visual Studio Code: Go to Bottom"), + "ee-ol": R(Key("end"), rdescript="Visual Studio Code: End Of Line"), + "beol": R(Key("home"), rdescript="Visual Studio Code: Beginning of Line"), + "Go back []": R(Key("a-left"), rdescript="Visual Studio Code: Go Back") * Repeat(extra="n"), + "Go forward []": R(Key("a-right"), rdescript="Visual Studio Code: Go Forward") * Repeat(extra="n"), + + # Formatting + "indent []": R(Key("tab"), rdescript="Visual Studio Code: Indent") * Repeat(extra="n"), + "Unindent []": R(Key("s-tab"), rdescript="Visual Studio Code: Unindent") * Repeat(extra="n"), + "Comment": R(Key("c-slash"), rdescript="Visual Studio Code: Line Comment"), + "Block comment": R(Key("sa-a"), rdescript="Visual Studio Code: Block Comment"), + + # Window Management + "[toggle] full screen": R(Key("f11"), rdescript="Visual Studio Code:Fullscreen"), + "[toggle] Zen mode": R(Key("c-k/3, z")), + + + # Debugging + "[toggle] breakpoint": R(Key("f9"), rdescript="Visual Studio Code:Breakpoint"), + "step over []": R(Key("f10/50") * Repeat(extra="n"), rdescript="Visual Studio Code:Step Over"), + "step into": R(Key("f11"), rdescript="Visual Studio Code:Step Into"), + "step out [of]": R(Key("s-f11"), rdescript="Visual Studio Code:Step Out"), + "resume": R(Key("f5"), rdescript="Visual Studio Code:Resume"), + } + extras = [ + Dictation("text"), + Dictation("mim"), + IntegerRefST("n", 1, 1000), + + ] + defaults = { + "n": 1, + "mim":"", + "text": "" + } + +#--------------------------------------------------------------------------- + +context = AppContext(executable="code") +grammar = Grammar("Visual Studio Code", context=context) +if settings.SETTINGS["apps"]["visualstudiocode"]: + if settings.SETTINGS["miscellaneous"]["rdp_mode"]: + control.nexus().merger.add_global_rule(VisualStudioCodeRule()) + else: + rule = VisualStudioCodeRule(name="visualstudiocode") + gfilter.run_on(rule) + grammar.add_rule(rule) + grammar.load() \ No newline at end of file diff --git a/caster/lib/ccr/__init__.py b/caster/lib/ccr/__init__.py index 347ecf8a4..234168dfc 100644 --- a/caster/lib/ccr/__init__.py +++ b/caster/lib/ccr/__init__.py @@ -11,4 +11,6 @@ from javascript.javascript import Javascript from python.python import Python from rust.rust import Rust -from sql.sql import SQL \ No newline at end of file +from sql.sql import SQL +from vhdl.vhdl import VHDL +from prolog.prolog import Prolog diff --git a/caster/lib/ccr/core/nav.py b/caster/lib/ccr/core/nav.py index 748695d64..86b270937 100644 --- a/caster/lib/ccr/core/nav.py +++ b/caster/lib/ccr/core/nav.py @@ -148,7 +148,7 @@ class Navigation(MergeRule): "peek format": R(Function(textformat.peek_text_format), rdescript="Peek Format"), "( | | ) (bow|bowel) [brunt]": R(Function(textformat.master_format_text), rdescript="Text Format"), "format ": R(Function(textformat.prior_text_format), rdescript="Last Text Format"), - + " format ": R(Function(textformat.partial_format_text), rdescript="Partial Text Format"), "dredge": R(Key("a-tab"), rdescript="Alt-Tab"), } @@ -167,6 +167,7 @@ class Navigation(MergeRule): Choice("semi", {"dock": ";", "doc": ";", "sink": "" }), + Choice("word_limit",{"single": 1,"double": 2,"triple":3,"Quadra":4}), diff --git a/caster/lib/ccr/core/punctuation.py b/caster/lib/ccr/core/punctuation.py index 44bcef4f8..b79b1ea04 100644 --- a/caster/lib/ccr/core/punctuation.py +++ b/caster/lib/ccr/core/punctuation.py @@ -37,7 +37,7 @@ class Punctuation(MergeRule): "comma": R(Text(","), rdescript="Comma"), "carrot": R(Text("^"), rdescript="Carat"), "(period | dot)": R(Text("."), rdescript="Dot"), - "at sign": R(Text("@"), rdescript="At Sign"), + "atty": R(Text("@"), rdescript="At Sign"), "hash tag": R(Text("#"), rdescript="Hash Tag"), "apostrophe": R(Text("'"), rdescript="Apostrophe"), "underscore": R(Text("_"), rdescript="Underscore"), @@ -59,4 +59,4 @@ class Punctuation(MergeRule): "npunc": 1, } -control.nexus().merger.add_global_rule(Punctuation()) \ No newline at end of file +control.nexus().merger.add_global_rule(Punctuation()) diff --git a/caster/lib/ccr/javascript/javascript.py b/caster/lib/ccr/javascript/javascript.py index 04a8fd350..61dbf05c6 100644 --- a/caster/lib/ccr/javascript/javascript.py +++ b/caster/lib/ccr/javascript/javascript.py @@ -3,13 +3,12 @@ @author: synkarius ''' -from dragonfly import Key, Text - from caster.lib import control from caster.lib.ccr.standard import SymbolSpecs from caster.lib.dfplus.additions import SelectiveAction from caster.lib.dfplus.merge.mergerule import MergeRule from caster.lib.dfplus.state.short import R +from dragonfly import Key, Text class Javascript(MergeRule): @@ -59,12 +58,9 @@ class Javascript(MergeRule): # JavaScript specific - "anon funk": R(Text("function () {}") + Key("left:1, enter") - + SelectiveAction(Key("enter, up"), ["AptanaStudio3.exe"]), - rdescript="Javascript: Anonymous Function"), + "anon funk": R(Text("() => {}") + Key("left:1, enter"), rdescript="Javascript: Anonymous Function"), "timer": R(Text("setInterval()") + Key("left"), rdescript="Javascript: Timer"), "timeout": R(Text("setTimeout()") + Key("left"), rdescript="Javascript: Timeout"), - "sue iffae": R(Text("if()") + Key("left"), rdescript="Javascript: Short If"), "document": R(Text("document"), rdescript="Javascript: Document"), "index of": R(Text("indexOf()") + Key("left"), rdescript="Javascript: Index Of"), "has own property": R(Text("hasOwnProperty()") + Key("left"), rdescript="Javascript: Has Own Property"), @@ -82,10 +78,10 @@ class Javascript(MergeRule): "throw": R(Text("throw "), rdescript="Javascript: Throw"), "instance of": R(Text("instanceof "), rdescript="Javascript: Instance Of"), - "(far | variable)": R(Text("var "), rdescript="Javascript: Variable"), - "sue iffae": R(Text("if ()") + Key("left"), rdescript="Javascript: Short If"), - "sue shells": R(Text("else") + Key("enter"), rdescript="Javascript: Short Else"), - + "var": R(Text("var "), rdescript="Javascript: Var"), + "const": R(Text("const "), rdescript=" JavaScript: Const"), + "Let": R(Text("let "), rdescript=" JavaScript: Let"), + "shell iffae": R(Text("else if ()") + Key("left"), rdescript="Javascript: Else If"), } diff --git a/caster/lib/ccr/prolog/__init__.py b/caster/lib/ccr/prolog/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/caster/lib/ccr/prolog/prolog.py b/caster/lib/ccr/prolog/prolog.py new file mode 100644 index 000000000..229d84341 --- /dev/null +++ b/caster/lib/ccr/prolog/prolog.py @@ -0,0 +1,42 @@ +''' +Created on Sep 2, 2015 + +@author: Gerrish +''' +from dragonfly import Key, Text, Dictation, MappingRule +from dragonfly.actions.action_text import Text + +from caster.lib import control +from caster.lib.dfplus.merge.mergerule import MergeRule +from caster.lib.dfplus.state.short import R +from caster.lib.ccr.standard import SymbolSpecs + +class PrologNon(MappingRule): + mapping = { + "Rule": R(Text("() :-.")+Key("left/6"),rdescript="Prolog: rule"), + SymbolSpecs.IF: R(Text("( ")+Key("enter")+Text(";")+Key("enter")+Text(")"),rdescript="Prolog: IF"), + } + + + +class Prolog(MergeRule): + pronunciation = "prolog" + + non = PrologNon + + mapping = { + "implies": R(Text(":-"), rdescript="Prolog: Select"), + "comment": R(Text("%"), rdescript="Prolog: Line Comment"), + "Open Block comment": R(Text("/* "),rdescript="Prolog: Line Comment"), + "Close Block comment": R(Text("*\ "),rdescript="Prolog: Line Comment"), + "Anonymous": R(Text("_"), rdescript="Prolog: Anonymous"), + "Not": R(Text("\+"), rdescript="Prolog: Not"), + "cut": R(Text("!"), rdescript="Prolog: cut "), + "Or": R(Text(";"), rdescript="Prolog: Or"), + "Fail": R(Text("Fail"), rdescript="Prolog: Fail") + } + + extras = [] + defaults = {} + +control.nexus().merger.add_global_rule(Prolog()) \ No newline at end of file diff --git a/caster/lib/ccr/vhdl/__init__.py b/caster/lib/ccr/vhdl/__init__.py new file mode 100644 index 000000000..e69de29bb diff --git a/caster/lib/ccr/vhdl/vhdl.py b/caster/lib/ccr/vhdl/vhdl.py new file mode 100644 index 000000000..14b6a7302 --- /dev/null +++ b/caster/lib/ccr/vhdl/vhdl.py @@ -0,0 +1,147 @@ +''' +Created on 18 Mar 2018 + +@author: gerrish +''' +from dragonfly import Key, Mimic, Text,MappingRule,Function,Choice +from caster.lib.dfplus.additions import IntegerRefST +from caster.lib import control +from caster.lib.ccr.standard import SymbolSpecs +from caster.lib.dfplus.merge.mergerule import MergeRule +from caster.lib.dfplus.state.short import R + + +from vhdl_strings import * + + +def binary_string(digit,amount): + return Text(str(digit)*amount).execute() + + +class VHDLnon(MappingRule): + mapping= { + "entity": R(entity_string,rdescript="Vhdl: Entity"), + "Architecture": R(architecture_string,rdescript="Vhdl: Entity"), + + "component": R(component_string,rdescript="VHDL: component"), + "component declaration": R(component_declaration_string,rdescript="VHDL: component"), + SymbolSpecs.SWITCH: R(case_string,rdescript="VHDL: case statement"), + SymbolSpecs.CASE: R(Text("case TOKEN is")), + "process": R(process_string,rdescript="VHDL: process"), + "generate components": R(for_generate_string,rdescript="VHDL: generate block"), + "conditional component": R(if_generate_string,rdescript="VHDL: generate block"), + + + + + } + + + + +class VHDL(MergeRule): + + pronunciation = "VHDL" + non=VHDLnon + + mapping = { + SymbolSpecs.COMMENT: R(Text("--"),rdescript="VHDL: Comment"), + + + SymbolSpecs.IF: R(Text("if () then ")+Key("enter,enter")+Text("end if;")+Key("home,up,up"),rdescript="VHDL: If"), + + + + SymbolSpecs.ELSE: R(Key("e,l,s,e,enter"),rdescript="VHDL: If"), + "alternate": R(Key("e,l,s,i, f,space,T,O,K,E,N,space,t,h,e,n,enter,tab"), rdescript="VHDL: If"), + SymbolSpecs.CASE: R(Text("case TOKEN is")+Key("enter,tab"),rdescript="VHDL: case"), + "when": R(Text("when "), rdescript="VHDL: when"), + + SymbolSpecs.FOR_LOOP: R(Text("for in to loop")+Key("left:12"),rdescript="VHDL: For loop"), + "generate": R(Text("GENERATE"),rdescript="VHDL: generate"), + + + + + "Input": R(Text("in"),rdescript="VHDL: In"), + "Output": R(Text("out"),rdescript="VHDL: Output"), + "Standard Logic": R(Text("std_logic"),rdescript="VHDL: Standard Logic"), + "Standard Logic Vector": R(Text("std_logic_vector"),rdescript="VHDL: Standard Logic Vector"), + + "Constant": R(Text("constant : ")+Key("left,left"),rdescript="VHDL: Constant"), + "Signal": R(Text("signal : ")+Key("left,left"),rdescript="VHDL: Signal"), + "integer": R(Text("integer TOKEN to TOKEN"),rdescript="VHDL: integer"), + "type": R(Text("type :")+Key("left"),rdescript="VHDL: type"), + # Operators + "Not Equal": R(Text("/="),rdescript="VHDL: Not Equal"), + SymbolSpecs.NOT: R(Text("not"),rdescript="VHDL: NOT"), + SymbolSpecs.OR: R(Text("or"),rdescript="VHDL: OR"), + "not and": R(Text("nand"),rdescript="VHDL: NAND"), + "XOR": R(Text("xor"),rdescript="VHDL: XOR"), + "X NOR": R(Text("xnor"),rdescript="VHDL: XNOR"), + + + + "Assignment": R(Text(" <= ")+Key("left"),rdescript="VHDL: Assignment"), + "Association": R(Text(' => ')+Key("left"),rdescript="VHDL: Association"), + "Concatenate": R(Text(" & "),rdescript="VHDL: Concatenate"), + + "Down To": R(Text("downto"),rdescript="VHDL: DownTo"), + "Up To": R(Text("upto"),rdescript="VHDL: UpTo"), + + "Input": R(Text("in"),rdescript="VHDL: In"), + "Output": R(Text("out"),rdescript="VHDL: Output"), + "Standard Logic": R(Text("std_logic"),rdescript="VHDL: Standard Logic"), + "Standard Logic Vector": R(Text("std_logic_vector"),rdescript="VHDL: Standard Logic Vector"), + + "Constant": R(Text("constant : ")+Key("left,left"),rdescript="VHDL: Constant"), + "Signal": R(Text("signal : ")+Key("left,left"),rdescript="VHDL: Signal"), + "integer": R(Text("integer TOKEN to TOKEN"),rdescript="VHDL: integer"), + "type": R(Text("type :")+Key("left"),rdescript="VHDL: type"), + # Operators + "Not Equal": R(Text("/="),rdescript="VHDL: Not Equal"), + SymbolSpecs.NOT: R(Text("not"),rdescript="VHDL: NOT"), + SymbolSpecs.OR: R(Text("or"),rdescript="VHDL: OR"), + "not and": R(Text("nand"),rdescript="VHDL: NAND"), + "XOR": R(Text("xor"),rdescript="VHDL: XOR"), + "X NOR": R(Text("xnor"),rdescript="VHDL: XNOR"), + + + + + "Assignment": R(Text(" <= ")+Key("left"),rdescript="VHDL: Assignment"), + "Association": R(Text(' => ')+Key("left"),rdescript="VHDL: Association"), + "Concatenate": R(Text(" & "),rdescript="VHDL: Concatenate"), + + "Down To": R(Text("downto"),rdescript="VHDL: DownTo"), + "Up To": R(Text("upto"),rdescript="VHDL: UpTo"), + + + SymbolSpecs.COMMENT: R(Text( "-- " ), rdescript="VHDL: Add Comment"), + + "binary [] ": R(Function(binary_string),rdescript="Vhdl: binary string"), + + #VHDL specific + "length": R(Text("length'"),rdescript="VHDL: length"), + SymbolSpecs.TO_INTEGER: R(Text("to_integer()")+Key("left"),rdescript="VHDL: conversion to integer"), + "converts to signed": R(Text("signed()")+Key("left"),rdescript="VHDL: conversion to signed"), + "converts to unsigned": R(Text("unsigned()")+Key("left"),rdescript="VHDL: conversion to unsigned"), + "converts to unsigned specific": R(Text("conv_unsigned(,)")+Key("left:2"),rdescript="VHDL: conversion to unsigned"), + "converts to integer specific": R(Text("conv_integer(,)")+Key("left:2"),rdescript="VHDL: conversion to integer"), + + + + + } + + extras = [ + IntegerRefST("amount",1,128), + Choice("digit",{"(zero|zeros)":0,"(one|once)":1}), + IntegerRefST("digit",0,2) + ] + defaults = {} + + + + +control.nexus().merger.add_global_rule(VHDL()) diff --git a/caster/lib/ccr/vhdl/vhdl_strings.py b/caster/lib/ccr/vhdl/vhdl_strings.py new file mode 100644 index 000000000..f6290e934 --- /dev/null +++ b/caster/lib/ccr/vhdl/vhdl_strings.py @@ -0,0 +1,29 @@ +from dragonfly import Key,Text +case_string=Text("case TOKEN is")+Key("enter,tab")+Text("when 'TOKEN' => TOKEN")+\ +Key("enter,backspace")+Text("end case;") + +process_string=\ +Text("TOKEN: process()")+Key("enter")+Text("begin")+\ +Key("enter,tab")+Text("TOKEN")+Key("enter,backspace")+Text("end process;") + +component_string=\ +Text("TOKEN: TOKEN")+Key("enter")+Text("(")+\ +Key("right,semicolon,left:2,enter,tab")+Text("port map(")+Key("enter,tab")+Text("TOKEN <= TOKEN,")+\ +Key("right,enter,s-home,backspace") + +component_declaration_string=\ +Text("component TOKEN is")+Key("enter,tab")+Text("port (TOKEN: in std_logic;")+\ +Key("enter")+Text(");")+Key("enter,backspace")+Text("end component;") + +entity_string=Text("entity TOKEN is")+Key("enter,tab")+Text("port (TOKEN: in std_logic;")+\ +Key("enter")+Text(");")+Key("enter,backspace")+Text("end entity;") + +architecture_string=\ +Text("architecture TOKEN is")+Key("enter")+Text("begin")+\ +Key("enter,tab")+Text("TOKEN")+Key("enter,backspace")+Text("end architecture;") + +for_generate_string=Text("TOKEN:")+Key("enter,tab")+Text("for TOKEN in to generate")+Key("enter,tab")+Text("TOKEN : TOKEN port map")+Key("enter,tab")+\ +Text("();")+Key("enter,backspace:2")+Text("end generate TOKEN;")+Key("up:4,left:6") + +if_generate_string=Text("TOKEN:")+Key("enter,tab")+Text("if () generate")+Key("enter,tab")+Text("TOKEN : TOKEN port map")+Key("enter,tab")+\ +Text("();")+Key("enter,backspace:2")+Text("end generate TOKEN;")+Key("up:4,left:6") diff --git a/caster/lib/dfplus/merge/gfilter.py b/caster/lib/dfplus/merge/gfilter.py index 5b97a107f..0bb4c59cb 100644 --- a/caster/lib/dfplus/merge/gfilter.py +++ b/caster/lib/dfplus/merge/gfilter.py @@ -1,25 +1,26 @@ ################################# Global Filter Functions From File module ############################################ '''GlobalFilterDefs overrides ALL instances of some word(s) in all rules''' +import io import os +from caster.lib import settings +from caster.lib.dfplus.merge.mergepair import MergeInf, MergePair from dragonfly.grammar.elements import Choice -from caster.lib import settings -from caster.lib.dfplus.merge.mergepair import MergePair, MergeInf class PreservedSpec(object): def __init__(self): - self.original = None # original spec from Caster - self.extras = [] # bound extras' words - self.cleaned = None # original with bound extras replaced with '?'s - self.altered = None # 'cleaned' after replacement process - + self.original = None # original spec from Caster + self.extras = [] # bound extras' words + self.cleaned = None # original with bound extras replaced with '?'s + self.altered = None # 'cleaned' after replacement process + @staticmethod def preserve(spec): p = PreservedSpec() p.original = spec - + angles_mode = False preserved_word = "" cleaned_spec = "" @@ -40,71 +41,69 @@ def preserve(spec): cleaned_spec += c p.cleaned = cleaned_spec p.altered = cleaned_spec - + return p - + @staticmethod def restore(pspec): p = pspec - + q = p.altered.split("?") - if len(q) == 1: # no bound extras - return p.altered # so just return the gfilter result - + if len(q) == 1: # no bound extras + return p.altered # so just return the gfilter result + # intersperse the lists c = [b for a in map(None, q, p.extras) for b in a if b is not None] - + return "".join(c) + class GlobalFilterDefs(object): - - - + P = "" - + @staticmethod def preserve(spec, target): - _ = "<"+target+">" + _ = "<" + target + ">" if _ in spec: return spec.replace(_, GlobalFilterDefs.P) else: return spec - - @staticmethod + + @staticmethod def restore(spec, target): - return spec.replace(GlobalFilterDefs.P, "<"+target+">") - - + return spec.replace(GlobalFilterDefs.P, "<" + target + ">") + '''parsing modes''' MODES = { - "<<>>": 0, - "<<>>": 1, - "<<>>": 2, - "<<>>": 3, - "<<>>": 4 - } - + "<<>>": 0, + "<<>>": 1, + "<<>>": 2, + "<<>>": 3, + "<<>>": 4 + } + def __init__(self, lines): self.specs = {} self.extras = {} self.defaults = {} mode = 0 - + for line in lines: - - if line.startswith("#") or not line.strip(): # ignore comments and empty lines + + if line.startswith( + "#") or not line.strip(): # ignore comments and empty lines continue - + pair = line.split("->") original = pair[0].strip() - + if original in GlobalFilterDefs.MODES: mode = GlobalFilterDefs.MODES[original] continue - + new = pair[1].strip() new = "#".join(new.split("#")[:1]) - '''only handles mode 1 for now''' if mode == 0: self.specs[original] = new @@ -125,59 +124,62 @@ def __init__(self, lines): if os.path.isfile(settings.SETTINGS["paths"]["FILTER_DEFS_PATH"]): '''user must create caster/user/fdefs.txt for it to get picked up here''' - with open(settings.SETTINGS["paths"]["FILTER_DEFS_PATH"]) as f: + with io.open( + settings.SETTINGS["paths"]["FILTER_DEFS_PATH"], "rt", encoding="utf-8") as f: lines = f.readlines() try: DEFS = GlobalFilterDefs(lines) except Exception: print("Unable to parse words.txt") + def spec_override_from_config(mp): '''run at boot time only: changes are permanent''' - if mp.time != MergeInf.BOOT_NO_MERGE: # 3 == MergeInf.BOOT + if mp.time != MergeInf.BOOT_NO_MERGE: # 3 == MergeInf.BOOT return '''redundant safety check''' if DEFS is None: return - + for rule in [mp.rule1, mp.rule2]: if rule is not None: '''SPECS''' specs_changed = False for spec in rule.mapping_actual().keys(): action = rule.mapping_actual()[spec] - + pspec = PreservedSpec.preserve(spec) - + for original in DEFS.specs.keys(): if original in pspec.altered: new = DEFS.specs[original] pspec.altered = pspec.altered.replace(original, new) - + pspec.altered = PreservedSpec.restore(pspec) - + if spec == pspec.altered: - continue; - + continue + del rule.mapping_actual()[spec] rule.mapping_actual()[pspec.altered] = action specs_changed = True - - '''EXTRAS''' extras = rule.extras_copy().values() extras_changed = False if len(extras) > 0: replacements = {} for extra in extras: - if isinstance(extra, Choice): # IntegerRefSTs will be dealt with elsewhere + if isinstance(extra, + Choice): # IntegerRefSTs will be dealt with elsewhere choices = extra._choices replace = False - for s in choices.keys(): #ex: "dunce make" is key, some int or whatever is the value - for ns in DEFS.extras.keys(): #ex: "dunce" is key, "down" is the value - if ns in s: # ex: "dunce" is in "dunce make" + for s in choices.keys( + ): #ex: "dunce make" is key, some int or whatever is the value + for ns in DEFS.extras.keys( + ): #ex: "dunce" is key, "down" is the value + if ns in s: # ex: "dunce" is in "dunce make" replace = True - val = choices[s] + val = choices[s] del choices[s] s = s.replace(ns, DEFS.extras[ns]) choices[s] = val @@ -190,21 +192,21 @@ def spec_override_from_config(mp): extras.append(new_choice) if len(replacements) > 0: extras_changed = True - '''DEFAULTS''' defaults = rule.defaults_copy() defaults_changed = False if len(defaults) > 0: replacements = {} - for default_key in defaults.keys(): # + for default_key in defaults.keys(): # value = defaults[default_key] if isinstance(value, basestring): '''only replace strings; also, only replace values, not keys: default_key should not be changed - it will never be spoken''' - nvalue = value # new value + nvalue = value # new value replace = False - for old in DEFS.defaults.keys(): # 'old' is the target word(s) in the old 'value' + for old in DEFS.defaults.keys( + ): # 'old' is the target word(s) in the old 'value' new = DEFS.defaults[old] if old in nvalue: nvalue = nvalue.replace(old, new) @@ -212,17 +214,18 @@ def spec_override_from_config(mp): if replace: defaults[default_key] = nvalue defaults_changed = True - + if specs_changed or extras_changed or defaults_changed: - rule.__init__(rule._name, rule.mapping_actual(), extras, defaults, rule._exported, - rule.ID, rule.composite, rule.compatible, rule._mcontext, rule._mwith) - + rule.__init__(rule._name, rule.mapping_actual(), extras, defaults, + rule._exported, rule.ID, rule.composite, rule.compatible, + rule._mcontext, rule._mwith) + if DEFS is not None: print("Global rule filter from file 'words.txt' activated ...") - + + def run_on(rule): if DEFS is not None: mp = MergePair(MergeInf.BOOT_NO_MERGE, MergeInf.GLOBAL, None, rule, False) spec_override_from_config(mp) - diff --git a/caster/lib/navigation.py b/caster/lib/navigation.py index d082bc2ce..f88bd227b 100644 --- a/caster/lib/navigation.py +++ b/caster/lib/navigation.py @@ -1,136 +1,173 @@ +# -*- coding: utf-8 -*- ''' master_text_nav shouldn't take strings as arguments - it should take ints, so it can be language-agnostic ''' +import time from ctypes import windll from subprocess import Popen -import time -from dragonfly import (Key, Text, Choice, Mouse, monitors) import dragonfly -import win32clipboard - from caster.asynch.mouse.legion import LegionScanner -from caster.lib import utilities, settings - -DIRECTION_STANDARD={"sauce [E]": "up", "dunce [E]": "down", "lease [E]": "left", "Ross [E]": "right", "back": "left" } - -'''' +from caster.lib import settings, utilities +from dragonfly import Choice, Clipboard, Key, Mouse, Text, monitors + +DIRECTION_STANDARD = { + "sauce [E]": "up", + "dunce [E]": "down", + "lease [E]": "left", + "Ross [E]": "right", + "back": "left" +} +''' Note: distinct token types were removed because A) a general purpose fill token is easier to remember than 10 of them, and B) the user of a programming language will know what they're supposed to get filled with ''' -TARGET_CHOICE = Choice("target", - {"comma": ",", "(period | dot)": ".", "(pair | parentheses)": "(~)", - "[square] (bracket | brackets)": "[~]", "curly [brace]": "{~}", - "loop": "for~while", "L paren": "(", "are paren": ")", "openers": "(~[~{", - "closers": "}~]~)", "token": "TOKEN"} - ) - +TARGET_CHOICE = Choice( + "target", { + "comma": ",", + "(period | dot)": ".", + "(pair | parentheses)": "(~)", + "[square] (bracket | brackets)": "[~]", + "curly [brace]": "{~}", + "loop": "for~while", + "L paren": "(", + "are paren": ")", + "openers": "(~[~{", + "closers": "}~]~)", + "token": "TOKEN" + }) def get_direction_choice(name): global DIRECTION_STANDARD return Choice(name, DIRECTION_STANDARD) + def initialize_clipboard(nexus): if len(nexus.clip) == 0: - nexus.clip = utilities.load_json_file(settings.SETTINGS["paths"]["SAVED_CLIPBOARD_PATH"]) + nexus.clip = utilities.load_json_file( + settings.SETTINGS["paths"]["SAVED_CLIPBOARD_PATH"]) + def mouse_alternates(mode, nexus, monitor=1): if nexus.dep.PIL: if mode == "legion" and not utilities.window_exists(None, "legiongrid"): - r = monitors[int(monitor)-1].rectangle - bbox = [int(r.x), int(r.y), int(r.x) + int(r.dx) - 1, int(r.y) + int(r.dy) - 1] + r = monitors[int(monitor) - 1].rectangle + bbox = [ + int(r.x), + int(r.y), + int(r.x) + int(r.dx) - 1, + int(r.y) + int(r.dy) - 1 + ] ls = LegionScanner() ls.scan(bbox) tscan = ls.get_update() - Popen(["pythonw", settings.SETTINGS["paths"]["LEGION_PATH"], "-t", tscan[0], "-m", str(monitor)])#, "-d", "500_500_500_500" + Popen([ + "pythonw", settings.SETTINGS["paths"]["LEGION_PATH"], "-t", tscan[0], + "-m", + str(monitor) + ]) # , "-d", "500_500_500_500" elif mode == "rainbow" and not utilities.window_exists(None, "rainbowgrid"): - Popen(["pythonw", settings.SETTINGS["paths"]["RAINBOW_PATH"], "-g", "r", "-m", str(monitor)]) + Popen([ + "pythonw", settings.SETTINGS["paths"]["RAINBOW_PATH"], "-g", "r", "-m", + str(monitor) + ]) elif mode == "douglas" and not utilities.window_exists(None, "douglasgrid"): - Popen(["pythonw", settings.SETTINGS["paths"]["DOUGLAS_PATH"], "-g", "d", "-m", str(monitor)]) + Popen([ + "pythonw", settings.SETTINGS["paths"]["DOUGLAS_PATH"], "-g", "d", "-m", + str(monitor) + ]) else: - utilities.availability_message(mode.title(), "PIL") + utilities.availability_message(mode.title(), "PIL") def clipboard_to_file(nnavi500, nexus, do_copy=False): if do_copy: Key("c-c").execute() - + max_tries = 20 - + key = str(nnavi500) for i in range(0, max_tries): failure = False try: - time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"]/1000.) # time for keypress to execute - win32clipboard.OpenClipboard() - nexus.clip[key] = win32clipboard.GetClipboardData() - win32clipboard.CloseClipboard() - utilities.save_json_file(nexus.clip, settings.SETTINGS["paths"]["SAVED_CLIPBOARD_PATH"]) + # time for keypress to execute + time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"] / 1000.) + nexus.clip[key] = Clipboard.get_system_text() + utilities.save_json_file(nexus.clip, + settings.SETTINGS["paths"]["SAVED_CLIPBOARD_PATH"]) except Exception: failure = True utilities.simple_log() if not failure: break + def drop(nnavi500, nexus): key = str(nnavi500) while True: failure = False try: if key in nexus.clip: - win32clipboard.OpenClipboard() - win32clipboard.EmptyClipboard() - win32clipboard.SetClipboardText(nexus.clip[key]) - win32clipboard.CloseClipboard() + Clipboard.set_system_text(nexus.clip[key]) Key("c-v").execute() else: dragonfly.get_engine().speak("slot empty") - time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"]/1000.) + time.sleep(settings.SETTINGS["miscellaneous"]["keypress_wait"] / 1000.) except Exception: failure = True if not failure: break + def erase_multi_clipboard(nexus): nexus.clip = {} - utilities.save_json_file(nexus.clip, settings.SETTINGS["paths"]["SAVED_CLIPBOARD_PATH"]) + utilities.save_json_file(nexus.clip, + settings.SETTINGS["paths"]["SAVED_CLIPBOARD_PATH"]) + def volume_control(n, volume_mode): for i in range(0, int(n)): Key("volume" + str(volume_mode)).execute() + def kill_grids_and_wait(nexus): window_title = utilities.get_active_window_title() - if window_title == settings.RAINBOW_TITLE or window_title == settings.DOUGLAS_TITLE or window_title == settings.LEGION_TITLE: + if (window_title == settings.RAINBOW_TITLE or window_title == settings.DOUGLAS_TITLE + or window_title == settings.LEGION_TITLE): nexus.comm.get_com("grids").kill() time.sleep(0.1) + def kick(nexus): kill_grids_and_wait(nexus) windll.user32.mouse_event(0x00000002, 0, 0, 0, 0) windll.user32.mouse_event(0x00000004, 0, 0, 0, 0) + def kick_right(nexus): kill_grids_and_wait(nexus) windll.user32.mouse_event(0x00000008, 0, 0, 0, 0) windll.user32.mouse_event(0x00000010, 0, 0, 0, 0) + def kick_middle(nexus): kill_grids_and_wait(nexus) windll.user32.mouse_event(0x00000020, 0, 0, 0, 0) windll.user32.mouse_event(0x00000040, 0, 0, 0, 0) + def wheel_scroll(direction, nnavi500): amount = 120 if direction != "up": - amount = amount * -1; - for i in xrange(1, abs(nnavi500)+1): + amount = amount * -1 + for i in xrange(1, abs(nnavi500) + 1): windll.user32.mouse_event(0x00000800, 0, 0, amount, 0) time.sleep(0.1) - + + def curse(direction, direction2, nnavi500, dokick): x, y = 0, 0 d = str(direction) @@ -143,22 +180,20 @@ def curse(direction, direction2, nnavi500, dokick): x = -nnavi500 if d == "right" or d2 == "right": x = nnavi500 - + Mouse("<" + str(x) + ", " + str(y) + ">").execute() - if int(dokick)!=0: - if int(dokick)==1: + if int(dokick) != 0: + if int(dokick) == 1: kick() - elif int(dokick)==2: + elif int(dokick) == 2: kick_right() + def next_line(semi): - semi=str(semi) + semi = str(semi) Key("escape").execute() time.sleep(0.25) Key("end").execute() time.sleep(0.25) Text(semi).execute() Key("enter").execute() - - - diff --git a/caster/lib/settings.py b/caster/lib/settings.py index d755263df..e2dae2f69 100644 --- a/caster/lib/settings.py +++ b/caster/lib/settings.py @@ -1,14 +1,17 @@ +# -*- coding: utf-8 -*- + +import collections +import io import json import os import sys -import collections SETTINGS = {} -_SETTINGS_PATH = os.path.realpath(__file__).split("lib")[0]+"bin\\data\\settings.json" +_SETTINGS_PATH = os.path.realpath(__file__).split("lib")[0] + "bin\\data\\settings.json" BASE_PATH = os.path.realpath(__file__).split("\\lib")[0].replace("\\", "/") # title -SOFTWARE_VERSION_NUMBER = "0.5.9" +SOFTWARE_VERSION_NUMBER = "0.5.10" SOFTWARE_NAME = "Caster v " + SOFTWARE_VERSION_NUMBER HOMUNCULUS_VERSION = "HMC v " + SOFTWARE_VERSION_NUMBER HMC_TITLE_RECORDING = " :: Recording Manager" @@ -31,9 +34,11 @@ WSR = False + def _find_natspeak(): '''Tries to find the natspeak engine.''' possible_locations = [ + "C:/Program Files (x86)/Nuance/NaturallySpeaking15/Program/natspeak.exe", "C:/Program Files (x86)/Nuance/NaturallySpeaking14/Program/natspeak.exe", "C:/Program Files (x86)/Nuance/NaturallySpeaking13/Program/natspeak.exe", "C:/Program Files (x86)/Nuance/NaturallySpeaking12/Program/natspeak.exe", @@ -44,7 +49,8 @@ def _find_natspeak(): print "Cannot find default dragon engine path" return "" -# The defaults for every setting. Could be moved out into its own file. + +# The defaults for every setting. Could be moved out into its own file. _DEFAULT_SETTINGS = { "paths": { "BASE_PATH": BASE_PATH, @@ -99,6 +105,7 @@ def _find_natspeak(): "flashdevelop": True, "foxitreader": True, "gitbash": True, + "gitter": True, "kdiff3": True, "douglas": True, "legion": True, @@ -110,6 +117,7 @@ def _find_natspeak(): "sqldeveloper": True, "sublime": True, "visualstudio": True, + "visualstudiocode": True, "winword": True, "wsr": True, }, @@ -129,7 +137,7 @@ def _find_natspeak(): "miscellaneous": { "dev_commands": False, "sikuli_enabled": False, - "keypress_wait": 50, # milliseconds + "keypress_wait": 50, # milliseconds "max_ccr_repetitions": 16, "atom_palette_wait": "30", "rdp_mode": False, @@ -150,27 +158,25 @@ def _find_natspeak(): def _save(data, path): '''only to be used for settings file''' try: - formatted_data = json.dumps(data, sort_keys=True, indent=4, ensure_ascii=False) - if not os.path.exists(path): - f = open(path, "w") - f.close() - f = open(path, "w") - f.write(formatted_data) - f.close() + formatted_data = unicode( + json.dumps(data, sort_keys=True, indent=4, ensure_ascii=False)) + with io.open(path, "wt", encoding="utf-8") as f: + f.write(formatted_data) except Exception: print "Error saving json file: " + path + def _init(path): result = {} try: - f = open(path, "r") - result = json.loads(f.read()) - f.close() - except ValueError: - print("\n\nValueError while loading settings file: " + path + "\n\n") + with io.open(path, "rt", encoding="utf-8") as f: + result = json.loads(f.read()) + except ValueError as e: + print("\n\n" + repr(e) + " while loading settings file: " + path + "\n\n") print(sys.exc_info()) - except IOError: - print("\n\nIOError: Could not find settings file: " + path + "\nInitializing file...\n\n") + except IOError as e: + print("\n\n" + repr(e) + " while loading settings file: " + path + + "\nAttempting to recover...\n\n") result, num_default_added = _deep_merge_defaults(result, _DEFAULT_SETTINGS) if num_default_added > 0: print "Default settings values added: %d " % num_default_added @@ -187,8 +193,8 @@ def _deep_merge_defaults(data, defaults): changes = 0 for key, default_value in defaults.iteritems(): # If the key is in the data, use that, but call recursivly if it's a dict. - if(key in data): - if(isinstance(data[key], collections.Mapping)): + if (key in data): + if (isinstance(data[key], collections.Mapping)): child_data, child_changes = _deep_merge_defaults(data[key], default_value) data[key] = child_data changes += child_changes @@ -198,33 +204,33 @@ def _deep_merge_defaults(data, defaults): return data, changes - # Public interface: def save_config(): '''Save the current in-memory settings to disk''' _save(SETTINGS, _SETTINGS_PATH) + def get_settings(): global SETTINGS return SETTINGS + def get_default_browser_executable(): global SETTINGS return SETTINGS["paths"]["DEFAULT_BROWSER_PATH"].split("/")[-1] + def report_to_file(message, path=None): _path = SETTINGS["paths"]["LOG_PATH"] if path is not None: _path = path - f = open(_path, 'a') - f.write(str(message) + "\n") - f.close() + with io.open(_path, 'at', encoding="utf-8") as f: + f.write(unicode(message) + "\n") ## Kick everything off. SETTINGS = _init(_SETTINGS_PATH) for path in [ - SETTINGS["paths"]["REMOTE_DEBUGGER_PATH"], - SETTINGS["paths"]["WXPYTHON_PATH"] - ]: + SETTINGS["paths"]["REMOTE_DEBUGGER_PATH"], SETTINGS["paths"]["WXPYTHON_PATH"] +]: if not path in sys.path and os.path.isdir(path): sys.path.append(path) diff --git a/caster/lib/textformat.py b/caster/lib/textformat.py index 12d52d823..be1e2fcce 100644 --- a/caster/lib/textformat.py +++ b/caster/lib/textformat.py @@ -66,7 +66,11 @@ def get_text_format_description(capitalization, spacing): def master_format_text(capitalization, spacing, textnv): capitalization, spacing = normalize_text_format(capitalization, spacing) - Text(get_formatted_text(capitalization, spacing, str(textnv))).execute() + Text(get_formatted_text(capitalization, spacing, str(textnv))).execute() + +def partial_format_text(word_limit,textnv): + global _CAPITALIZATION, _SPACING + Text(get_formatted_text(_CAPITALIZATION, _SPACING, " ".join(str(textnv).split(" ")[0:word_limit]))).execute() def get_formatted_text(capitalization, spacing, t): tlen = len(t) diff --git a/caster/lib/utilities.py b/caster/lib/utilities.py index e466897b4..4f99eb07c 100644 --- a/caster/lib/utilities.py +++ b/caster/lib/utilities.py @@ -1,26 +1,32 @@ # -*- coding: utf-8 -*- -from __future__ import unicode_literals -import os, json, sys +from __future__ import print_function, unicode_literals + +import io +import json +import os import re -from subprocess import Popen +import sys import traceback - -from dragonfly.windows.window import Window -import win32gui, win32ui from __builtin__ import True +from subprocess import Popen +import win32gui +import win32ui +from dragonfly.windows.window import Window -try: # Style C -- may be imported into Caster, or externally +try: # Style C -- may be imported into Caster, or externally BASE_PATH = os.path.realpath(__file__).split("\\caster")[0].replace("\\", "/") if BASE_PATH not in sys.path: sys.path.append(BASE_PATH) finally: from caster.lib import settings -# filename_pattern was used to determine when to update the list in the element window, checked to see when a new file name had appeared +# filename_pattern was used to determine when to update the list in the element window, +# checked to see when a new file name had appeared FILENAME_PATTERN = re.compile(r"[/\\]([\w_ ]+\.[\w]+)") + def window_exists(classname, windowname): try: win32ui.FindWindow(classname, windowname) @@ -29,100 +35,99 @@ def window_exists(classname, windowname): else: return True + def get_active_window_title(pid=None): - _pid=win32gui.GetForegroundWindow() if pid is None else pid + _pid = win32gui.GetForegroundWindow() if pid is None else pid return unicode(win32gui.GetWindowText(_pid), errors='ignore') + def get_active_window_path(): return Window.get_foreground().executable + def get_window_by_title(title): # returns 0 if nothing found hwnd = win32gui.FindWindowEx(0, 0, 0, title) return hwnd + def get_window_title_info(): '''get name of active file and folders in path; - will be needed to look up collection of symbols - in scanner data''' + will be needed to look up collection of symbols + in scanner data''' global FILENAME_PATTERN title = get_active_window_title().replace("\\", "/") match_object = FILENAME_PATTERN.findall(title) filename = None - if len(match_object) > 0: + if len(match_object) > 0: filename = match_object[0] path_folders = title.split("/")[:-1] return [filename, path_folders, title] - - -# begin stuff that was moved def save_json_file(data, path): try: - formatted_data = json.dumps(data, sort_keys=True, indent=4, - ensure_ascii=False) - if not os.path.exists(path): - f = open(path, "w") - f.close() - with open(path, "w") as f: + formatted_data = unicode( + json.dumps(data, sort_keys=True, indent=4, ensure_ascii=False)) + with io.open(path, "wt", encoding="utf-8") as f: f.write(formatted_data) except Exception: simple_log(True) + def load_json_file(path): result = {} try: - if os.path.isfile(path): # If the file exists. - with open(path, "r") as f: - result = json.loads(f.read()) - f.close() - else: + with io.open(path, "rt", encoding="utf-8") as f: + result = json.loads(f.read()) + except IOError as e: + if e.errno == 2: # The file doesn't exist. save_json_file(result, path) + else: + raise except Exception: simple_log(True) return result def list_to_string(l): - return "\n".join([str(x) for x in l]) - + return u"\n".join([unicode(x) for x in l]) + + def simple_log(to_file=False): msg = list_to_string(sys.exc_info()) print(msg) for tb in traceback.format_tb(sys.exc_info()[2]): print(tb) if to_file: - f = open(settings.SETTINGS["paths"]["LOG_PATH"], 'a') - f.write(msg + "\n") - f.close() - + with io.open(settings.SETTINGS["paths"]["LOG_PATH"], 'at', encoding="utf-8") as f: + f.write(msg + "\n") def availability_message(feature, dependency): print(feature + " feature not available without " + dependency) -# end stuff that was moved + def remote_debug(who_called_it=None): - import pydevd; # @UnresolvedImport if who_called_it is None: who_called_it = "An unidentified process" try: + import pydevd # @UnresolvedImport pydevd.settrace() except Exception: - print("ERROR: " + who_called_it + " called utilities.remote_debug() but the debug server wasn't running.") - + print("ERROR: " + who_called_it + + " called utilities.remote_debug() but the debug server wasn't running.") + + def reboot(wsr=False): popen_parameters = [] if wsr: popen_parameters.append(settings.SETTINGS["paths"]["REBOOT_PATH_WSR"]) popen_parameters.append(settings.SETTINGS["paths"]["WSR_PATH"]) - #caster path inserted too if there's a way to wake up WSR + # caster path inserted too if there's a way to wake up WSR else: popen_parameters.append(settings.SETTINGS["paths"]["REBOOT_PATH"]) popen_parameters.append(settings.SETTINGS["paths"]["ENGINE_PATH"]) - + print(popen_parameters) Popen(popen_parameters) - -