Ejemplo n.º 1
0
    def rule_changer(self, enable, name):
        ccr = utilities.load_toml_relative("config/ccr.toml")["global"]
        core = utilities.load_toml_relative("config/core.toml")

        del ccr["Core"]
        if (name == "LaTeX maths"
                and ccr["LaTeX"]) or (name == "LaTeX" and ccr["LaTeX maths"]):
            self.merger.global_rule_changer(name=name,
                                            enable=enable,
                                            save=True)
        else:
            for module in ccr:
                if ccr[module] and module != name:
                    self.merger.global_rule_changer(name=module,
                                                    enable=False,
                                                    save=True)
            self.merger.global_rule_changer(name=name,
                                            enable=enable,
                                            save=True)
        if name == core["pronunciation"]:
            self.merger.selfmod_rule_changer(name2="variable",
                                             enable=enable,
                                             save=True)
Ejemplo n.º 2
0
 def refresh(self, *args):
     '''args: spec, text'''
     aliases = utilities.load_toml_relative("config/aliases.toml")
     if not Var.key in aliases:
         aliases[Var.key] = {}
     if len(args) > 0:
         aliases[Var.key][args[0]] = args[1]
         utilities.save_toml_relative(aliases, "config/aliases.toml")
     mapping = {}
     for spec in aliases[Var.key]:
         mapping["var " + spec] = Text(str(aliases[Var.key][spec]))
         mapping["delete variable " + spec] = Function(self.delete,
                                                       spec=spec)
     mapping["variable <s> [brunt]"] = Function(lambda s: self.alias(s))
     mapping["delete variables"] = Function(self.delete_all)
     self.reset(mapping)
Ejemplo n.º 3
0
 def refresh(self, *args):
     '''args: spec, text'''
     aliases = utilities.load_toml_relative("config/aliases.toml")
     if not Alias.key in aliases:
         aliases[Alias.key] = {}
     if len(args) > 0:
         aliases[Alias.key][args[0]] = args[1]
         utilities.save_toml_relative(aliases, "config/aliases.toml")
     mapping = {}
     for spec in aliases[Alias.key]:
         mapping[spec] = Function(utilities.paste_string,
                                  content=str(aliases[Alias.key][spec]))
         mapping["delete alias " + spec] = Function(self.delete, spec=spec)
     mapping["alias <s>"] = Function(lambda s: self.alias(s))
     mapping["delete aliases"] = Function(self.delete_all)
     self.reset(mapping)
Ejemplo n.º 4
0
def math_mode(enable=True):
    BINDINGS = utilities.load_toml_relative("config/latex.toml")
    prefix = BINDINGS["symbol_prefix"].replace("[", "").replace("]", "")
    if enable:
        BINDINGS["symbol_prefix"] = "[" + prefix + "]"
    else:
        BINDINGS["symbol_prefix"] = prefix
    utilities.save_toml_relative(BINDINGS, "config/latex.toml")
    _NEXUS.merger.wipe()
    try:
        del _NEXUS.merger._global_rules[BINDINGS["pronunciation"]]
        want_reload_module = sys.modules["caster.ccr.latex"]
        reload(want_reload_module)
        print(BINDINGS["pronunciation"] + " rebuilt")
    except Exception as e:
        print(e)
    _NEXUS.merger.update_config()
    _NEXUS.merger.merge(3)
Ejemplo n.º 5
0

Key = KeyBase


class SlowText(TextBase):
    _pause_default = 0.01


class SlowKey(KeyBase):
    interval_default = 1.0


from caster.lib import utilities, control

SETTINGS = utilities.load_toml_relative("config/settings.toml")
# Override imported dragonfly actions with aenea's if the 'use_aenea' setting
# is set to true.
if SETTINGS["use_aenea"]:
    try:
        from aenea import Key, Text, Mouse
    except ImportError:
        print("Unable to import aenea actions. Dragonfly actions will be used "
              "instead.")
'''
Stores the currently highlighted text in a temporary variable,
to be Retrieved after some other action. If no text was
highlighted, an empty string will be stored.
Sample usage:
"find that": Store() + Key("c-f") + Retrieve() + Key("enter")
Ejemplo n.º 6
0
def initialize_clipboard(nexus):
    if len(nexus.clip) == 0:
        nexus.clip = utilities.load_toml_relative(SETTINGS["clipboard_path"])
Ejemplo n.º 7
0
 def delete(self, spec):
     aliases = utilities.load_toml_relative("config/aliases.toml")
     del aliases[Var.key][spec]
     utilities.save_toml_relative(aliases, "config/aliases.toml")
     self.refresh()
Ejemplo n.º 8
0
 def delete_all(self):
     aliases = utilities.load_toml_relative("config/aliases.toml")
     aliases[Var.key] = {}
     utilities.save_toml_relative(aliases, "config/aliases.toml")
     self.refresh()
Ejemplo n.º 9
0
 def reload_settings(self):
     self.settings = utilities.load_toml_relative("config/settings.toml")