Skip to content

Instantly share code, notes, and snippets.

# non_braces
[non_braces.greek]
# does not require curly braces in latex
alpha = "alpha"
beater = "beta"
gamma = "gamma"
delta = "delta"
epsilon = "epsilon"
zita = "zeta"
@alexboche
alexboche / natural numerical fraction command
Created February 14, 2019 08:11
natural numerical fraction command
# Here's a new command for writing numerical fractions more naturally. Not the most elegant but gets the job done.
"<number> <denominator>": R(Text("\\frac %(number)d") + Key("down")
+ Text("%(denominator)s") + Key("right")),
"[one] <denominator_single>": R(Text("\\frac 1") + Key("down")
+ Text("%(denominator_single)s") + Key("right")),
IntegerRefST("number", 2, 100),
Choice("denominator", {
"halves": "2",
from dragonfly import (Grammar, AppContext, Dictation, Key, Text, Repeat, Choice, Function, ActionBase, ActionError)
class MultiAppContext(AppContext):
# ----------------------------------------------------------------------
# Initialization methods.
def __init__(self, relevant_apps=None, title=None, exclude=False):
AppContext.__init__(self)
@alexboche
alexboche / lyx.py
Last active February 28, 2019 05:25
import toml
import io
from dragonfly import (Grammar, Context, AppContext, Dictation, Key, Text, Repeat,
Function, Choice, Mouse)
from castervoice.lib import context, navigation, alphanumeric, textformat, text_utils
from castervoice.lib import control
from castervoice.lib.dfplus.additions import IntegerRefST
from castervoice.lib.dfplus.merge.ccrmerger import CCRMerger
from castervoice.lib.dfplus.merge.mergerule import MergeRule
from castervoice.lib.dfplus.state.short import R
"""Unimacro grammar to Dictate latex markup, as defined in an inifile
"""
__version__ = "$Rev: 398 $ on $Date: 2011-03-07 14:50:15 +0100 (ma, 07 mrt 2011) $ by $Author: quintijn $"
# This file is part of a SourceForge project called "unimacro" see
# http://unimacro.SourceForge.net and http://qh.antenna.nl/unimacro
# (c) copyright 2003 see http://qh.antenna.nl/unimacro/aboutunimacro.html
# or the file COPYRIGHT.txt in the natlink\natlink directory
#
# _latex.py: Dictate latex markup
Function only works with keyword arguments. Something like arkalii's solution is a good way of dealing with the issue. You could also use a decorator on the add function to map argument names. This would keep the mappings clean:
arg_map = {
"num1": "x",
"n": "x",
"num2": "y",
"m": "y",
}
def replace_args(func):
def new_func(*_, **kwargs):
#
# This file is part of Dragonfly.
# (c) Copyright 2007, 2008 by Christo Butcher
# Licensed under the LGPL.
#
# Dragonfly is free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
from dragonfly import ActionBase
from dragonfly import Context
from dragonfly import Text
class PositionalTexter(object):
def __init__(self, func, extra=()):
self.func = func
# thanks to Casper and Caster for contributing commands to this.
from dragonfly import (Grammar, Context, AppContext, Dictation, Repeat, Function, Choice, Mouse, Pause)
from castervoice.lib import control
from castervoice.lib import settings
from castervoice.lib.actions import Key, Text
from castervoice.lib.context import AppContext
from castervoice.lib.dfplus.additions import IntegerRefS# thanks to Casper for contributing commands to this.
from inspect import getargspec
from .action_base import ActionBase, ActionError
class OtherFunction(ActionBase):
def __init__(self, function, defaults=None, remap_data=None):
ActionBase.__init__(self)
self._function = function