Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
synkarius committed Oct 15, 2018
2 parents 87430da + 31918e2 commit eb4f2bf
Show file tree
Hide file tree
Showing 125 changed files with 7,216 additions and 3,774 deletions.
Binary file removed CasterQuickReference0.5.3.pdf
Binary file not shown.
Binary file added CasterQuickReference0.5.7.pdf
Binary file not shown.
122 changes: 69 additions & 53 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 All @@ -46,15 +49,14 @@ def _wait_for_wsr_activation():
from caster.lib.dfplus.merge.mergepair import MergeInf
from caster.lib.ccr import *
from caster.lib.ccr.recording.again import Again
from caster.lib.ccr.recording.alias import VanillaAlias
from caster.lib.ccr.recording.alias import Alias
from caster.lib.ccr.recording import history
from caster.lib.dev import dev
from caster.lib.dfplus.hint.nodes import css
from caster.user.filters.examples import scen4, modkeysup
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 @@ -136,7 +153,7 @@ def generate_sm_ccr_choices(nexus):
grammar.add_rule(again_rule)

if settings.SETTINGS["feature_rules"]["alias"]:
alias_rule = VanillaAlias(name="vanilla alias")
alias_rule = Alias(name="alias")
gfilter.run_on(alias_rule)
grammar.add_rule(alias_rule)

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
23 changes: 21 additions & 2 deletions caster/apps/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
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')]


def is_valid(module):
''' This function attempts to import the applications in order to detect
errors in their implementation . After they are imported, they are garbage collected
when the function returns.'''
try:
_ = __import__(module, globals(), locals())
return True
except Exception as e:
print(
"Ignoring application '{}'. Failed to load with: ".format(module))
print(e)
return False


modules = glob.glob(os.path.dirname(__file__) + "/*.py")
# only valid applications will be added to the list
__all__ = [
os.path.basename(f)[:-3] for f in modules if (not f.endswith('__init__.py') and is_valid(os.path.basename(f)[:-3]))
]
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
Loading

0 comments on commit eb4f2bf

Please sign in to comment.