def refresh(self, *args): '''args: spec, text''' aliases = utilities.load_toml_file( settings.SETTINGS["paths"]["ALIAS_PATH"]) if not Alias.toml_path in aliases: aliases[Alias.toml_path] = {} if len(args) > 0: aliases[Alias.toml_path][args[0]] = args[1] utilities.save_toml_file(aliases, settings.SETTINGS["paths"]["ALIAS_PATH"]) mapping = {} for spec in aliases[Alias.toml_path]: mapping[spec] = R( Function(context.paste_string_without_altering_clipboard, content=str(aliases[Alias.toml_path][spec]))) # R( # Text(str(aliases[Alias.toml_path][spec])), # rdescript="Alias: " + spec) mapping["alias <s>"] = R(Function(lambda s: self.alias(s)), rdescript="Create Alias") mapping["delete aliases"] = R( Function(lambda: delete_all(self, Alias.toml_path)), rdescript="Delete Aliases") self.reset(mapping)
def bring_restore(): ''' Restore bring me list to defaults ''' global CONFIG CONFIG = utilities.load_toml_file(settings.SETTINGS["paths"]["BRINGME_DEFAULTS_PATH"]) refresh()
def refresh(self, *args): '''args: spec, list of lists of strings''' # get mapping recorded_macros = utilities.load_toml_file( settings.SETTINGS["paths"]["RECORDED_MACROS_PATH"]) if len(args) > 0: recorded_macros[args[0]] = args[1] utilities.save_toml_file(recorded_macros, settings.SETTINGS["paths"]["RECORDED_MACROS_PATH"]) mapping = {} for spec in recorded_macros: # Create a copy of the string without Unicode characters. ascii_str = str(spec) sequences = recorded_macros[spec] delay = settings.SETTINGS["miscellaneous"]["history_playback_delay_secs"] # It appears that the associative string (ascii_str) must be ascii, but the sequences within Playback must be Unicode. mapping[ascii_str] = R( Playback([(sequence, delay) for sequence in sequences]), rdescript="Recorded Macro: " + ascii_str) mapping["record from history"] = R( Function(self.record_from_history), rdescript="Record From History") mapping["delete recorded macros"] = R( Function(self.delete_recorded_macros), rdescript="Delete Recorded Macros") # reload with new mapping self.reset(mapping)
def bring_restore(): ''' Restore bring me list to defaults ''' global CONFIG CONFIG = utilities.load_toml_file( settings.SETTINGS["paths"]["BRINGME_DEFAULTS_PATH"]) refresh()
def refresh(self, *args): aliases = utilities.load_toml_file(settings.SETTINGS["paths"]["ALIAS_PATH"]) if not ChainAlias.toml_path in aliases: aliases[ChainAlias.toml_path] = {} if len(args) > 0 and args[0] != "": aliases[ChainAlias.toml_path][args[0]] = args[1] utilities.save_toml_file(aliases, settings.SETTINGS["paths"]["ALIAS_PATH"]) mapping = {} for spec in aliases[ChainAlias.toml_path]: mapping[spec] = R( Text(str(aliases[ChainAlias.toml_path][spec])), rdescript="Chain Alias: " + spec) mapping["chain alias [<s>]"] = R( Function(lambda s: self.alias(s)), rdescript="Create Chainable Alias") mapping["delete chain aliases"] = R( Function(lambda: delete_all(self, ChainAlias.toml_path)), rdescript="Delete Aliases") self.reset(mapping)
def refresh(self, *args): aliases = utilities.load_toml_file( settings.SETTINGS["paths"]["ALIAS_PATH"]) if not ChainAlias.toml_path in aliases: aliases[ChainAlias.toml_path] = {} if len(args) > 0 and args[0] != "": aliases[ChainAlias.toml_path][args[0]] = args[1] utilities.save_toml_file(aliases, settings.SETTINGS["paths"]["ALIAS_PATH"]) mapping = {} for spec in aliases[ChainAlias.toml_path]: mapping[spec] = R(Text(str(aliases[ChainAlias.toml_path][spec])), rdescript="Chain Alias: " + spec) mapping["chain alias [<s>]"] = R(Function(lambda s: self.alias(s)), rdescript="Create Chainable Alias") mapping["delete chain aliases"] = R( Function(lambda: delete_all(self, ChainAlias.toml_path)), rdescript="Delete Aliases") self.reset(mapping)
def initialize_clipboard(nexus): if len(nexus.clip) == 0: nexus.clip = utilities.load_toml_file( settings.SETTINGS["paths"]["SAVED_CLIPBOARD_PATH"])
import os import threading import subprocess import time import shlex # import dragonfly from dragonfly import Choice, Function, Dictation from caster.lib import control, context, utilities, settings from caster.lib.actions import Text, Key from caster.lib.dfplus.merge.selfmodrule import SelfModifyingRule from caster.lib.dfplus.state.short import R CONFIG = utilities.load_toml_file(settings.SETTINGS["paths"]["BRINGME_PATH"]) if not CONFIG: CONFIG = utilities.load_toml_file(settings.SETTINGS["paths"]["BRINGME_DEFAULTS_PATH"]) if not CONFIG: # logger.warn("Could not load bringme defaults") print("Could not load bringme defaults") def refresh(): bring_rule.refresh() #module functions def bring_it(desired_item): ''' Currently simply invoke os.startfile. New thread keeps Dragon from crashing. ''' item, item_type = desired_item if item_type == "website": browser = utilities.default_browser_command()
def load_config(self): if self.use_real_config: self._config = utilities.load_toml_file( settings.SETTINGS["paths"]["CCR_CONFIG_PATH"]) else: self._config = {}
from dragonfly import Function, Choice from caster.lib import control, utilities from caster.lib.dfplus.actions import Key, Text from caster.lib.dfplus.merge.mergerule import MergeRule BINDINGS = utilities.load_toml_file( utilities.get_full_path("caster/ccr/html/html.toml")) # Alternate between executing as text and executing as keys def insert(element): if type(element) in [str, int]: Text(element).execute() elif type(element) in [list, tuple]: for i in range(len(element)): if i % 2 == 0: Text(element[i]).execute() else: Key(element[i]).execute() class HTML(MergeRule): mapping = { "insert <element>": Function(insert), } extras = [ Choice("element", BINDINGS["elements"]), ]
def delete_all(alias, path): aliases = utilities.load_toml_file(settings.SETTINGS["paths"]["ALIAS_PATH"]) aliases[path] = {} utilities.save_toml_file(aliases, settings.SETTINGS["paths"]["ALIAS_PATH"]) alias.refresh()
''' Created Jan 2019 @author: Alex Boche, Mike Roberts ''' from dragonfly import Function, Choice, Mouse, IntegerRef from caster.lib.actions import Key, Text from caster.lib import control, utilities from caster.lib.dfplus.additions import IntegerRefST from caster.lib.dfplus.merge.mergerule import MergeRule BINDINGS = utilities.load_toml_file( utilities.get_full_path("caster/ccr/mathematics/lyx.toml")) def greek(big, greek_letter): if big: greek_letter = greek_letter.title() Text("\\" + greek_letter + " ").execute() def matrix(rows, cols): Text("\\bmatrix ").execute() for _ in range(0, rows - 1): Key("a-m, w, i").execute() for _ in range(0, cols - 1): Key("a-m, c, i").execute() # Alternate between executing as text and executing as keys
def load_config(self): if self.use_real_config: self._config = utilities.load_toml_file( settings.SETTINGS["paths"]["CCR_CONFIG_PATH"]) else: self._config = {}
import os import threading import subprocess import time import shlex # import dragonfly from dragonfly import Choice, Function, Dictation from caster.lib import control, context, utilities, settings from caster.lib.actions import Text, Key from caster.lib.dfplus.merge.selfmodrule import SelfModifyingRule from caster.lib.dfplus.state.short import R CONFIG = utilities.load_toml_file(settings.SETTINGS["paths"]["BRINGME_PATH"]) if not CONFIG: CONFIG = utilities.load_toml_file( settings.SETTINGS["paths"]["BRINGME_DEFAULTS_PATH"]) if not CONFIG: # logger.warn("Could not load bringme defaults") print("Could not load bringme defaults") def refresh(): bring_rule.refresh() #module functions def bring_it(desired_item): ''' Currently simply invoke os.startfile. New thread keeps Dragon from crashing. '''
''' Created on Sep 4, 2018 @author: Mike Roberts ''' import re from dragonfly import Function, Choice from caster.lib.actions import Key, Text, Mouse from caster.ccr.standard import SymbolSpecs from caster.lib import control, utilities, context from caster.lib.dfplus.merge.mergerule import MergeRule from caster.lib.dfplus.state.short import R from caster.user.latex import word_counter BINDINGS = utilities.load_toml_file( utilities.get_full_path("caster/ccr/latex/latex.toml")) def quote(): e, text = context.read_selected_without_altering_clipboard(False) if text: Text("``" + text + "\'\'").execute() else: Text("``\'\'").execute() Key("left:2").execute() # Return \first{second}, if second is empty then end inside the brackets for user input def back_curl(first, second): if str(second) != "": return (Text("\\") + Text(str(first)) + Key("lbrace, rbrace, left") +
def delete_all(alias, path): aliases = utilities.load_toml_file( settings.SETTINGS["paths"]["ALIAS_PATH"]) aliases[path] = {} utilities.save_toml_file(aliases, settings.SETTINGS["paths"]["ALIAS_PATH"]) alias.refresh()
def initialize_clipboard(nexus): if len(nexus.clip) == 0: nexus.clip = utilities.load_toml_file( settings.SETTINGS["paths"]["SAVED_CLIPBOARD_PATH"])
def load_config(self): if self.use_real_config: self._config = utilities.load_toml_file(CCR_PATH) else: self._config = {}