コード例 #1
0
class Alphabet(MergeRule):
    pronunciation = CCRMerger.CORE[0]
    
    mapping = {
        "[<big>] <letter>": R(Function(alphanumeric.letters2, extra ={"big", "letter"}), rdescript="Spell"),
        }
    extras = [
        alphanumeric.get_alphabet_choice("letter"),
        Choice("big",
              {"big": "big",
               }),
    ]
    defaults = {
    "big": "", 
    }
コード例 #2
0
ファイル: rust.py プロジェクト: tyoung87/caster
class Rust(MergeRule):
    auto = [".rs"]
    non = RustNon

    mapping = {
        SymbolSpecs.IF:
        R(Text("if  {}") + Key("left/5:3"), rdescript="Rust: If"),
        SymbolSpecs.ELSE:
        R(Text("else {}") + Key("left/5:3"), rdescript="Rust: Else"),
        #
        SymbolSpecs.SWITCH:
        R(Text("match"), rdescript="Rust: Switch (match)"),
        SymbolSpecs.CASE:
        R(Text(" => ") + Key("left"), rdescript="Rust: Case"),
        SymbolSpecs.BREAK:
        R(Text("break;"), rdescript="Rust: Break"),
        SymbolSpecs.DEFAULT:
        R(Text("_"), rdescript="Rust: Default"),
        #
        SymbolSpecs.DO_LOOP:
        R(Text("while {TOKEN;TOKEN}{}"), rdescript="Rust: Do Loop"),
        SymbolSpecs.WHILE_LOOP:
        R(Text("while TOKEN {}") + Key("left"), rdescript="Rust: While"),
        "for loop [of <a> [in <n>]]":
        R(Text("for %(a)s in 0..%(n)d {}") + Key("left"),
          rdescript="Rust: For i Loop"),
        SymbolSpecs.FOR_EACH_LOOP:
        R(Text("for TOKEN in TOKEN {}") + Key("left"),
          rdescript="Rust: For Each Loop"),
        #
        SymbolSpecs.TO_INTEGER:
        R(Text("parse::<i32>().unwrap()"),
          rdescript="Rust: Convert To Integer"),
        SymbolSpecs.TO_FLOAT:
        R(Text("parse::<f64>().unwrap()"),
          rdescript="Rust: Convert To Floating-Point"),
        SymbolSpecs.TO_STRING:
        R(Text("to_string()"), rdescript="Rust: Convert To String"),
        #
        SymbolSpecs.AND:
        R(Text(" && "), rdescript="Rust: And"),
        SymbolSpecs.OR:
        R(Text(" || "), rdescript="Rust: Or"),
        SymbolSpecs.NOT:
        R(Text("!"), rdescript="Rust: Not"),
        #
        SymbolSpecs.SYSOUT:
        R(Text("println!()") + Key("left"), rdescript="Rust: Print"),
        #
        SymbolSpecs.IMPORT:
        R(Text("use "), rdescript="Rust: Import (use)"),
        #
        # function moved to ncmap
        SymbolSpecs.CLASS:
        R(Text("struct "), rdescript="Rust: Class (struct)"),
        #
        SymbolSpecs.COMMENT:
        R(Text("//"), rdescript="Rust: Add Comment"),
        SymbolSpecs.LONG_COMMENT:
        R(Text("///"), rdescript="Rust: Doc Comment"),
        #
        SymbolSpecs.NULL:
        R(Text("None"), rdescript="Rust: None"),
        #
        SymbolSpecs.RETURN:
        R(Text("return "), rdescript="Rust: Early Return"),
        #
        SymbolSpecs.TRUE:
        R(Text("true"), rdescript="Rust: True"),
        SymbolSpecs.FALSE:
        R(Text("false"), rdescript="Rust: False"),

        # Rust specific
        "value some":
        R(Text("Some()") + Key("left"), rdescript="Rust: Some"),
        "enumerate for loop [of <a> [in <n>]]":
        R(Text("for (%(a)s, TOKEN) in (0..%(n)d).enumerate() {}") +
          Key("left"),
          rdescript="Rust: Enumerated For i Loop"),
        "enumerate for each [<a> <b>]":
        R(Text("for (%(a)s, %(b)s) in TOKEN.enumerate() {}") + Key("left"),
          rdescript="Rust: Enumerated For Each Loop"),
        "bind [<mutability>]":
        R(Text("let %(mutability)s"), rdescript="Rust: Bind Variable"),
        "of type":
        R(Text(": "), rdescript="Rust: Set Type"),
        "[<signed>] integer [<ibits>]":
        R(Text("%(signed)s%(bits)s "), rdescript="Rust: Integer"),
        "float [<fbits>]":
        R(Text("f%(fbits)s "), rdescript="Rust: Float"),
        "boolean":
        R(Text("bool "), rdescript="Rust: Boolean"),
        "string":
        R(Text("String "), rdescript="Rust: String"),
        "array [of] size <n>":
        R(Text("[TOKEN; %(n)d]"), rdescript="Rust: Array"),
        "macro vector":
        R(Text("vec![]") + Key("left"), rdescript="Rust: Vector"),
        "refer to [<mutability>]":
        R(Text("&%(mutability)s"), rdescript="Rust: Borrow"),
        "lifetime":
        R(Text("'"), rdescript="Rust: Lifetime"),
        "static":
        R(Text("static "), rdescript="Rust: Static"),
        "brace pan":
        R(Key("escape, escape, end, left, enter, enter, up, tab"),
          rdescript="Rust: Expand Curly Braces"),
        "namespace":
        R(Key("colon, colon"), rdescript="Rust: Namespace"),
    }

    extras = [
        Choice("ibits", {
            "eight": "8",
            "sixteen": "16",
            "thirty two": "32",
            "sixty four": "64"
        }),
        Choice("fbits", {
            "thirty two": "32",
            "sixty four": "64"
        }),
        Choice("signed", {"unsigned": "u"}),
        Choice("mutability", {"mute ah | mute": "mut "}),
        IntegerRefST("n", 0, 1000),
        alphanumeric.get_alphabet_choice("a"),
        alphanumeric.get_alphabet_choice("b"),
    ]
    defaults = {
        "bits": "32",
        "signed": "i",
        "mutability": "",
        "a": "i",
        "b": "j",
        "n": 1
    }
コード例 #3
0
class EclipseRule(MergeRule):
    pronunciation = "eclipse"

    mapping = {

            "prior tab [<n>]":                          R(Key("cs-f6"), rdescript="Eclipse: Previous Tab") * Repeat(extra="n"),  # these two must be set up in the eclipse preferences
            "next tab [<n>]":                           R(Key("c-f6"), rdescript="Eclipse: Next Tab") * Repeat(extra="n"),
            "open resource":                            R(Key("cs-r"), rdescript="Eclipse: Open Resource"),
            "open type":                                R(Key("cs-t"), rdescript="Eclipse: Open Type"),

            "jump to source":                           R(Key("f3"), rdescript="Eclipse: Jump To Source"),
            "editor select":                            R(Key("c-e"), rdescript="Eclipse: Editor Select"),

            "step over [<n>]":                          R(Key("f6/50") * Repeat(extra="n"), rdescript="Eclipse: Step Over"),
            "step into":                                R(Key("f5"), rdescript="Eclipse: Step Into"),
            "step out [of]":                            R(Key("f7"), rdescript="Eclipse: Step Out"),
            "resume":                                   R(Key("f8"), rdescript="Eclipse: Resume"),
            "(debug | run) last":                       R(Key("f11"), rdescript="Eclipse: Run Last"),
            "mark occurrences":                         R(Key("as-o"), rdescript="Eclipse: Mark Occurrences"),

            # "terminate" changes to the settings for this hotkey: (when: in dialogs and windows)
            "terminate":                                R(Key("c-f2"), rdescript="Eclipse: Terminate Running Program"),

            "refractor symbol":                         R(Key("sa-r"), rdescript="Eclipse: Re-Factor Symbol"),

            "symbol next [<n>]":                        R(Key("c-k"), rdescript="Eclipse: Symbol Next") * Repeat(extra="n"),
            "symbol prior [<n>]":                       R(Key("cs-k"), rdescript="Eclipse: Symbol Prior") * Repeat(extra="n"),

            "format code":                              R(Key("cs-f"), rdescript="Eclipse: Format Code"),
            "do imports":                               R(Key("cs-o"), rdescript="Eclipse: Do Imports"),
            "comment line":                             R(Key("c-slash"), rdescript="Eclipse: Comment Line"),

            "build it":                                 R(Key("c-b"), rdescript="Eclipse: Build"),

            "split view horizontal":                    R(Key("cs-underscore"), rdescript="Eclipse: Split View (H)"),
            "split view vertical":                      R(Key("cs-lbrace"), rdescript="Eclipse: Split View (V)"),

            #Line Ops
            "find everywhere":                          R(Key("ca-g"), rdescript="Eclipse: Search Project"),
            "find word <text> [<back>] [<go>]":         R(Key("c-f")+Function(ec_con.regex_off)+Function(ec_con.find),\
                                                          rdescript="Eclipse: Find Word"),
            "find regex <text> [<back>] [<go>]":        R(Key("c-f")+Function(ec_con.regex_on)+Function(ec_con.find),\
                                                          rdescript="Eclipse: Find Regex"),
            "find <a> [<b> [<c>]] [<back>] [<go>]":     R(Key("c-f")+Function(ec_con.find),\
                                                          rdescript="Eclipse: Find Alpha"),
            "find <punctuation> [<back>] [<go>]":       R(Key("c-f")+Function(ec_con.find),\
                                                          rdescript="Eclipse: Find Character(s)"),


        }
    extras = [
        Dictation("text"),
        Dictation("mim"),
        IntegerRefST("n", 1, 3000),
        alphanumeric.get_alphabet_choice("a"),
        alphanumeric.get_alphabet_choice("b"),
        alphanumeric.get_alphabet_choice("c"),
        Choice("punctuation", {"hash tag": "#"}),
        Boolean("back"),
        Boolean("go"),
    ]
    defaults = {
        "n": 1,
        "mim": "",
        "a": None,
        "b": None,
        "c": None,
        "punctuation": None,
        "back": False,
        "go": False
    }