Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legion Enhancement, Cheat sheet update, and more #220

Merged
merged 7 commits into from
Mar 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed CasterQuickReference0.5.3.pdf
Binary file not shown.
Binary file added CasterQuickReference0.5.4.pdf
Binary file not shown.
118 changes: 67 additions & 51 deletions _caster.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,25 @@
from dragonfly import (Key, Function, Grammar, Playback, Dictation, Choice, Pause)
from caster.lib.ccr.standard import SymbolSpecs


def _wait_for_wsr_activation():
count = 1
while True:
try:
try:
from caster.apps import firefox
break
except:
print("(%d) Attempting to load Caster -- WSR not loaded and listening yet..." % count)
except:
print("(%d) Attempting to load Caster -- WSR not loaded and listening yet..."
% count)
count += 1
time.sleep(1)


_NEXUS = None

from caster.lib import settings# requires nothing
from caster.lib import settings # requires nothing
settings.WSR = __name__ == "__main__"
from caster.lib import utilities# requires settings
from caster.lib import utilities # requires settings
if settings.WSR:
_wait_for_wsr_activation()
SymbolSpecs.set_cancel_word("escape")
Expand Down Expand Up @@ -54,7 +57,6 @@ def _wait_for_wsr_activation():
from caster import user
from caster.lib.dfplus.merge.mergerule import MergeRule
from caster.lib.dfplus.merge import gfilter



def change_monitor():
Expand All @@ -63,66 +65,81 @@ def change_monitor():
else:
print("This command requires SikuliX to be enabled in the settings file")


class MainRule(MergeRule):

@staticmethod
def generate_ccr_choices(nexus):
choices = {}
for ccr_choice in nexus.merger.global_rule_names():
choices[ccr_choice] = ccr_choice
return Choice("name", choices)

@staticmethod
def generate_sm_ccr_choices(nexus):
choices = {}
for ccr_choice in nexus.merger.selfmod_rule_names():
choices[ccr_choice] = ccr_choice
return Choice("name2", choices)

mapping = {
# Dragon NaturallySpeaking commands moved to dragon.py

# hardware management
"volume <volume_mode> [<n>]": R(Function(navigation.volume_control, extra={'n', 'volume_mode'}), rdescript="Volume Control"),
"change monitor": R(Key("w-p") + Pause("100") + Function(change_monitor), rdescript="Change Monitor"),

# window management
'minimize': Playback([(["minimize", "window"], 0.0)]),
'maximize': Playback([(["maximize", "window"], 0.0)]),
"remax": R(Key("a-space/10,r/10,a-space/10,x"), rdescript="Force Maximize"),

# passwords


# mouse alternatives
"legion [<monitor>]": R(Function(navigation.mouse_alternates, mode="legion", nexus=_NEXUS), rdescript="Activate Legion"),
"rainbow [<monitor>]": R(Function(navigation.mouse_alternates, mode="rainbow", nexus=_NEXUS), rdescript="Activate Rainbow Grid"),
"douglas [<monitor>]": R(Function(navigation.mouse_alternates, mode="douglas", nexus=_NEXUS), rdescript="Activate Douglas Grid"),

# ccr de/activation
"<enable> <name>": R(Function(_NEXUS.merger.global_rule_changer(), save=True), rdescript="Toggle CCR Module"),
"<enable> <name2>": R(Function(_NEXUS.merger.selfmod_rule_changer(), save=True), rdescript="Toggle sm-CCR Module"),


# Dragon NaturallySpeaking commands moved to dragon.py

# hardware management
"volume <volume_mode> [<n>]":
R(Function(navigation.volume_control, extra={'n', 'volume_mode'}),
rdescript="Volume Control"),
"change monitor":
R(Key("w-p") + Pause("100") + Function(change_monitor),
rdescript="Change Monitor"),

# window management
'minimize':
Playback([(["minimize", "window"], 0.0)]),
'maximize':
Playback([(["maximize", "window"], 0.0)]),
"remax":
R(Key("a-space/10,r/10,a-space/10,x"), rdescript="Force Maximize"),

# passwords

# mouse alternatives
"legion [<monitor>]":
R(Function(navigation.mouse_alternates, mode="legion", nexus=_NEXUS),
rdescript="Activate Legion"),
"rainbow [<monitor>]":
R(Function(navigation.mouse_alternates, mode="rainbow", nexus=_NEXUS),
rdescript="Activate Rainbow Grid"),
"douglas [<monitor>]":
R(Function(navigation.mouse_alternates, mode="douglas", nexus=_NEXUS),
rdescript="Activate Douglas Grid"),

# ccr de/activation
"<enable> <name>":
R(Function(_NEXUS.merger.global_rule_changer(), save=True),
rdescript="Toggle CCR Module"),
"<enable> <name2>":
R(Function(_NEXUS.merger.selfmod_rule_changer(), save=True),
rdescript="Toggle sm-CCR Module"),
}
extras = [
IntegerRefST("n", 1, 50),
Dictation("text"),
Dictation("text2"),
Dictation("text3"),
Choice("enable",
{"enable": True, "disable": False
}),
Choice("volume_mode",
{"mute": "mute", "up":"up", "down":"down"
}),
generate_ccr_choices.__func__(_NEXUS),
generate_sm_ccr_choices.__func__(_NEXUS),
IntegerRefST("monitor", 1, 10)
]
defaults = {"n": 1, "nnv": 1,
"text": "", "volume_mode": "setsysvolume",
"enable":-1
}
IntegerRefST("n", 1, 50),
Dictation("text"),
Dictation("text2"),
Dictation("text3"),
Choice("enable", {
"enable": True,
"disable": False
}),
Choice("volume_mode", {
"mute": "mute",
"up": "up",
"down": "down"
}),
generate_ccr_choices.__func__(_NEXUS),
generate_sm_ccr_choices.__func__(_NEXUS),
IntegerRefST("monitor", 1, 10)
]
defaults = {"n": 1, "nnv": 1, "text": "", "volume_mode": "setsysvolume", "enable": -1}


grammar = Grammar('general')
Expand All @@ -147,7 +164,6 @@ def generate_sm_ccr_choices(nexus):

print("*- Starting " + settings.SOFTWARE_NAME + " -*")


if settings.WSR:
import pythoncom
print("Windows Speech Recognition is garbage; it is " \
Expand Down
4 changes: 2 additions & 2 deletions caster/apps/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import glob
import inspect
import os
modules = glob.glob(os.path.dirname(__file__)+"/*.py" )
__all__ = [ os.path.basename(f)[:-3] for f in modules if not f.endswith('__init__.py')]
modules = glob.glob(os.path.dirname(__file__) + "/*.py")
__all__ = [os.path.basename(f)[:-3] for f in modules if not f.endswith('__init__.py')]
62 changes: 30 additions & 32 deletions caster/apps/atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
Command-module for Atom
Official Site "https://atom.io/"
"""
from dragonfly import (AppContext, Dictation, Grammar, IntegerRef, Key,
MappingRule, Pause, Repeat, Text)
from dragonfly import (AppContext, Dictation, Grammar, IntegerRef, Key, MappingRule,
Pause, Repeat, Text)
from dragonfly.actions.action_mimic import Mimic

from caster.lib import control, settings
Expand Down Expand Up @@ -36,18 +36,18 @@ class AtomRule(MergeRule):

#Basic Cursor Navigation
"up [<n>]":
R(Key("up"), rdescript="Atom: Move Cursor Up #") * Repeat(extra="n"),
R(Key("up"), rdescript="Atom: Move Cursor Up #")*Repeat(extra="n"),
"down [<n>]":
R(Key("down"), rdescript="Atom: Move Cursor Down #") * Repeat(extra="n"),
R(Key("down"), rdescript="Atom: Move Cursor Down #")*Repeat(extra="n"),
"right [<n>]":
R(Key("right"), rdescript="Atom: Move Cursor Right #") * Repeat(extra="n"),
R(Key("right"), rdescript="Atom: Move Cursor Right #")*Repeat(extra="n"),
"left [<n>]":
R(Key("left"), rdescript="Atom: Move Cursor Left #") * Repeat(extra="n"),
R(Key("left"), rdescript="Atom: Move Cursor Left #")*Repeat(extra="n"),
#Basic White Text Manipulation
"tab|indent [<n>]":
R(Key("tab"), rdescript="Atom: Press Tab Key #") * Repeat(extra="n"),
R(Key("tab"), rdescript="Atom: Press Tab Key #")*Repeat(extra="n"),
"space [<n>]":
R(Key("space"), rdescript="Atom: Press Tab Key #") * Repeat(extra="n"),
R(Key("space"), rdescript="Atom: Press Tab Key #")*Repeat(extra="n"),
# Menu UI-------------------------------------------------------------------------------------------
#File Menu
"[open] new window":
Expand Down Expand Up @@ -92,7 +92,7 @@ class AtomRule(MergeRule):
"copy ":
R(Key("c-insert"), rdescript="Atom: Copy"),
"paste [<n>]":
R(Key("s-insert"), rdescript="Atom: Paste") * Repeat(extra="n"),
R(Key("s-insert"), rdescript="Atom: Paste")*Repeat(extra="n"),
"copy path":
R(Key("cs-c"), rdescript="Atom: Copy Path"),
"select all":
Expand All @@ -115,15 +115,15 @@ class AtomRule(MergeRule):
"auto indent windows":
R(palettized("Window Auto Indent"), rdescript="Atom: Auto Indent"),
"[move] line up [<n>]":
R(Key("c-up"), rdescript="Atom: Move Line Up #") * Repeat(extra="n"),
R(Key("c-up"), rdescript="Atom: Move Line Up #")*Repeat(extra="n"),
"[move] line down [<n>]":
R(Key("c-down"), rdescript="Atom: Move Line Down #") * Repeat(extra="n"),
R(Key("c-down"), rdescript="Atom: Move Line Down #")*Repeat(extra="n"),
"duplicate line [<n>]":
R(Key("cs-d"), rdescript="Atom: Duplicate Line") * Repeat(
R(Key("cs-d"), rdescript="Atom: Duplicate Line")*Repeat(
extra="n"
), #Unless remapped the command triggers Dragon NaturallySpeaking dictation box
"delete line [<n>]":
R(Key("cs-k"), rdescript="Atom: Delete Line or # Lines Below") *
R(Key("cs-k"), rdescript="Atom: Delete Line or # Lines Below")*
Repeat(extra="n"),
"join line":
R(Key("c-j"), rdescript="Atom: Join Line"),
Expand All @@ -135,17 +135,16 @@ class AtomRule(MergeRule):
"lowercase":
R(palettized("Editor Lower Case"), rdescript="Atom: Convert lowercase"),
"delete [to] end [of word] [<n>]":
R(Key("c-delete"), rdescript="Atom: Delete to End oF Word") *
Repeat(extra="n"),
R(Key("c-delete"), rdescript="Atom: Delete to End oF Word")*Repeat(extra="n"),
"delete sub [word] [<n>]":
R(Key("a-backspace"), rdescript="Atom: Delete to End of Subword") *
R(Key("a-backspace"), rdescript="Atom: Delete to End of Subword")*
Repeat(extra="n"),
"delete [to] previous [word] [<n>]":
R(palettized("Delete to Previous Word boundary"),
rdescript="Atom: Delete to previous word boundary") * Repeat(extra="n"),
rdescript="Atom: Delete to previous word boundary")*Repeat(extra="n"),
"delete [to] next [word] [<n>]":
R(palettized("Delete to Next Word Boundary"),
rdescript="Atom: Delete to next word boundary") * Repeat(extra="n"),
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"),
Expand Down Expand Up @@ -177,9 +176,9 @@ class AtomRule(MergeRule):
"toggle menubar":
R(palettized("Toggle Menu Bar"), rdescript="Atom: Toggle Menubar"),
"increase font [size] [<n>]":
R(Key("cs-equals"), rdescript="Atom: Increase Font Size") * Repeat(extra="n"),
R(Key("cs-equals"), rdescript="Atom: Increase Font Size")*Repeat(extra="n"),
"decrease font [size] [<n>]":
R(Key("cs-minus"), rdescript="Atom: Decrease Font size") * Repeat(extra="n"),
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":
Expand Down Expand Up @@ -231,10 +230,9 @@ class AtomRule(MergeRule):
R(Key("ac-i"), rdescript="Atom: Toggle Developer Tools"),
#Selection Menu
"[add] select above [<n>]":
R(Key("ac-up"), rdescript="Atom: Add Selection Above #") * Repeat(extra="n"),
R(Key("ac-up"), rdescript="Atom: Add Selection Above #")*Repeat(extra="n"),
"[add] select below [<n>]":
R(Key("ac-down"), rdescript="Atom: Add Selection Below #") *
Repeat(extra="n"),
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":
Expand All @@ -246,10 +244,10 @@ class AtomRule(MergeRule):
#"select line": R(Key("c-l"), rdescript="Atom: Select Line"),
#"select word [<n>]": R(palettized("Editor: Word"), rdescript="Atom: Select Word") * Repeat(extra="n"),
"[select] [to] begin [of] word [<n>]":
R(Key("cs-left"), rdescript="Atom: Select to Beginning of Word #") *
R(Key("cs-left"), rdescript="Atom: Select to Beginning of Word #")*
Repeat(extra="n"),
"[select] [to] end word [<n>]":
R(Key("cs-right"), rdescript="Atom: Select to End of 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"),
Expand Down Expand Up @@ -624,29 +622,29 @@ class AtomRule(MergeRule):
#Atom Shortcut Snippets
"dev keys [input] [<n>]":
R(Text('#"": R(Key("-"), rdescript="Atom: "),') + Key("enter"),
rdescript="Macro: Dev Keys #") * Repeat(extra="n"),
rdescript="Macro: Dev Keys #")*Repeat(extra="n"),
"dev [command] palette [<n>]":
R(Text('#"": R(palettized(""), rdescript="Atom: "),') + Key("enter"),
rdescript="Macro: Dev Command Palette #") * Repeat(extra="n"),
rdescript="Macro: Dev Command Palette #")*Repeat(extra="n"),
#Repeatable Snippets
"dev numb keys [input] [<n>]":
R(Text('#" [<n>]": R(Key("-"), rdescript="Atom: ") * Repeat(extra="n"),') +
Key("enter"),
rdescript="Macro: Numb Dev Keys #") * Repeat(extra="n"),
rdescript="Macro: Numb Dev Keys #")*Repeat(extra="n"),
"dev numb [command] palette [<n>]":
R(Text('#" [<n>]": R(palettized(""), rdescript="Atom: ") * Repeat(extra="n"),'
) + Key("enter"),
rdescript="Macro: Dev Numb Command Palette #") * Repeat(extra="n"),
rdescript="Macro: Dev Numb Command Palette #")*Repeat(extra="n"),
#Basic Dragonfly Snippets
"dev key [<n>]":
R(Text('"": Key(""),'), rdescript="Dragonfly: Print Dev Key #") *
R(Text('"": Key(""),'), rdescript="Dragonfly: Print Dev Key #")*
Repeat(extra="n"),
"dev text [<n>]":
R(Text('"": Text(""),'), rdescript="Dragonfly: Print Dev Text #") *
R(Text('"": Text(""),'), rdescript="Dragonfly: Print Dev Text #")*
Repeat(extra="n"),
"send command [<n>]":
R(Text('"": R(Function(SendJsonCommands, a_command=""), rdescript=""),'),
rdescript="Macro: Print SendJsonCommands Template #") * Repeat(extra="n"),
rdescript="Macro: Print SendJsonCommands Template #")*Repeat(extra="n"),
}

extras = [
Expand Down
18 changes: 9 additions & 9 deletions caster/apps/chrome.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ChromeRule(MergeRule):
"new tab [<n>]": R(Key("c-t"), rdescript="Browser: New Tab") * Repeat(extra="n"),
"reopen tab [<n>]": R(Key("cs-t"), rdescript="Browser: Reopen Tab") * Repeat(extra="n"),
"close all tabs": R(Key("cs-w"), rdescript="Browser: Close All Tabs"),

"go back [<n>]": R(Key("a-left/20"), rdescript="Browser: Navigate History Backward") * Repeat(extra="n"),
"go forward [<n>]": R(Key("a-right/20"), rdescript="Browser: Navigate History Forward") * Repeat(extra="n"),
"zoom in [<n>]": R(Key("c-plus/20"), rdescript="Browser: Zoom In") * Repeat(extra="n"),
Expand All @@ -53,26 +53,26 @@ class ChromeRule(MergeRule):
"focus notification": R(Key("a-n"), rdescript="Browser: Focus Notification"),
"allow notification": R(Key("as-a"), rdescript="Browser: Allow Notification"),
"deny notification": R(Key("as-a"), rdescript="Browser: Deny Notification"),

"developer tools": R(Key("f12"), rdescript="Browser: Developer Tools"),
"view [page] source": R(Key("c-u"), rdescript="Browser: View Page Source"),
"resume": R(Key("f8"), rdescript="Browser: Resume"),
"step over": R(Key("f10"), rdescript="Browser: Step Over"),
"step into": R(Key("f11"), rdescript="Browser: Step Into"),
"step into": R(Key("f11"), rdescript="Browser: Step Into"),
"step out": R(Key("s-f11"), rdescript="Browser: Step Out"),

"IRC identify": R(Text("/msg NickServ identify PASSWORD"), rdescript="IRC Chat Channel Identify"),
}
extras = [
Dictation("dict"),
IntegerRefST("n",1, 10),
]
defaults ={"n": 1, "dict":"nothing"}
Dictation("dict"),
IntegerRefST("n", 1, 10),
]
defaults = {"n": 1, "dict": "nothing"}


#---------------------------------------------------------------------------

context = AppContext(executable="chrome")
context = AppContext(executable="chrome")
grammar = Grammar("chrome", context=context)

if settings.SETTINGS["apps"]["chrome"]:
Expand Down
Loading