Exemple #1
0
 Function(start_tag),
 "tags <element>":
 Function(tags),
 "end tag":
 Text("</>") + Key("left"),
 "end tag <element>":
 Function(end_tag),
 "attribute <attribute>":
 Text(' %(attribute)s=""') + Key("left"),
 "attribute <attribute> [equals] <text>":
 Function(attribute_with_content),  # @IgnorePep8
 # Comments.
 "comment":
 Text("<!--  -->") + Key("left:4"),
 "comment <text>":
 SCText("<!-- %(text)s -->") + Key("left:4"),
 "(open|left) comment":
 Text("<!-- "),
 "(open|left) comment <text>":
 SCText("<!-- %(text)s"),
 "(close|right) comment":
 Text(" -->"),
 # Doctypes.
 "doctype 5":
 Text("<!DOCTYPE html>"),
 "doctype 4 [transitional]":
 Text(
     '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'
 ),  # @IgnorePep8
 "doctype 4 strict":
 Text(
Exemple #2
0
    Text(' = getElementById("#').execute()
    lib.format.camel_case_text(text)
    Text('");\n').execute()
    lib.format.camel_case_text(text)
    Text('.onclick = function() {\n\n}').execute()
    Key('up').execute()
    Text('  ').execute()

rules = MappingRule(
    mapping={
        # Keywords:
        "and": Text(" && "),
        "assign": Text(" = "),
        "break": Text("break"),
        "case": Text("case "),
        "case <text>": SCText("case %(text)s"),
        "catch": Text("catch () {") + Key("left:3"),
        "comment": Text("// "),
        "comment <text>": SCText("// %(text)s"),
        "continue": Text("continue"),
        "close comment": Text(" */"),
        "debugger": Text("debugger"),
        "default": Text("default"),
#         "delete": Text("delete "),  # Messes with ordinary delete command.
        "do": Text("do {"),
        "equals": Text(" == "),
        "equals (strict|strictly|exact|exactly)": Text(" === "),
        "else": Text("else"),
        "else if": Text("else if () {") + Key("left:3"),
        "extends ": Text("extends "),
        "for": Text("for () {") + Key("left:3"),
Exemple #3
0
    "skip": "--skip",
    "tags": "--tags",
    "staged": "--staged",
    "theirs": "--theirs",
    "track": "--track",
    "verbose": "--verbose",
    "version": "--version",
}

series_rule = SeriesMappingRule(
    mapping={
        # Git commands.
        "git add":
        Text("git add "),
        "git add <text>":
        SCText("git add %(text)s"),
        "git add patch":
        Text("git add --patch "),
        "git add patch <text>":
        SCText("git add --patch %(text)s"),
        "git add (all|period|dot)":
        Text("git add .") + Key("enter"),
        "git archive":
        Text("git archive --format=tar "),
        "git blame":
        Text("git blame "),
        "git branch":
        Text("git branch") + Key("enter"),
        "git branch track":
        Text("git branch -- track "),
        "git branch <text>":
 "class <text>": Function(define_class),
 "continue": Text("continue"),
 "del": Text("del "),
 "divided by": Text(" / "),
 "(dict|dictionary) key value": Text("\"\": \"\",") + Key("left:6"),
 "enumerate": Text("enumerate()") + Key("left"),
 "(def|define|definition) [function]": Text("def "),
 "(def|define|definition) [function] <text>": Function(define_function),
 "(def|define|definition) method <text>": Function(define_method),
 "(def|define|definition) init": Text("def __init__("),
 "doc string": Text('"""Doc string."""') + Key("left:14, s-right:11"),
 "else": Text("else:") + Key("enter"),
 "except": Text("except "),
 "exec": Text("exec "),
 "(el if|else if)": Text("elif "),
 "(el if|else if) <text>": SCText("elif %(text)s"),
 "equals": Text(" == "),
 "false": Text("False"),
 "finally": Text("finally:") + Key("enter"),
 "for": Text("for "),
 "for <text>": SCText("for %(text)s"),
 "from": Text("from "),
 "from <text>": SCText("from %(text)s"),
 "global ": Text("global "),
 "greater than": Text(" > "),
 "greater [than] equals": Text(" >= "),
 "if": Text("if "),
 "if <text>": SCText("if %(text)s"),
 "in": Text(" in "),
 "in <text>": SCText("in %(text)s"),
 "(int|I N T)": Text("int"),
Exemple #5
0
    "non-recursive": "--non-recursive",
    "password": "******",
    "quiet": "--quiet",
    "revision": "--revision",
    "username": "******",
    "verbose": "--verbose",
    "version": "--version",
}

svn = "(subversion|S V N) "

series_rule = SeriesMappingRule(
    mapping={
        # Subversion commands.
        svn + "add": Text("svn add "),
        svn + "add <text>": SCText("svn add %(text)s"),
        svn + "add (all|period|dot)": Text("svn add .") + Key("enter"),
        svn + "blame": Text("svn blame "),
        svn + "(check out|checkout)": Text("svn checkout "),
        svn + "(check out|checkout) <text>": SCText("svn checkout %(text)s"),
        svn + "commit": Text("svn commit -m ") + Key("dquote/3") + Key("dquote/3, left/3"),  # @IgnorePep8
        svn + "delete": Text("svn delete "),
        svn + "delete <text>": SCText("svn delete %(text)s"),\
        svn + "(diff|difference|differentiate)": Text("svn diff "),
        svn + "(diff|difference|differentiate) <text>": SCText("svn diff %(text)s"),  # @IgnorePep8
        svn + "help": Text("svn --help") + Key("enter"),
        svn + "help <svncmd>": Text("svn --help %(svncmd)s") + Key("enter"),
        svn + "log": Text("svn log "),
        svn + "log <text>": SCText("svn log %(text)s"),
        svn + "log limit <n>": Text("svn log -l %(n)d "),
        svn + "(list [files]|L S)": Text("svn ls "),
Exemple #6
0
INCOMPATIBLE_MODULES = []


def directory_up(n):
    repeat = ['..' for i in range(n)]  # @UnusedVariable
    txt = "cd %s\n" % ("/".join(repeat))
    Text(txt).execute()


rules = MappingRule(
    mapping={
        # Commands and keywords:
        "apt cache search":
        Text("apt-cache search "),
        "apt cache search <text>":
        SCText("apt-cache search %(text)s"),
        "apt cache show":
        Text("apt-cache show "),
        "apt cache show <text>":
        SCText("apt-get show %(text)s"),
        "apt get install":
        Text("apt-get install "),
        "apt get install <text>":
        SCText("apt-get install %(text)s"),
        "apt get update":
        Text("apt-get update") + Key("enter"),
        "sudo apt get install":
        Text("sudo apt-get install "),
        "sudo apt get install <text>":
        SCText("sudo apt-get install %(text)s"),
        "sudo apt get update":
def directory_up(n):
    repeat = ['..' for i in range(n)]  # @UnusedVariable
    txt = "cd %s\n" % ("/".join(repeat))
    Text(txt).execute()


rules = MappingRule(
    mapping={
        # Commands and keywords:
        "sudo apt get update": Text("sudo apt-get update"),
        "apt cache search": Text("apt-cache search "),
        "apt cache search <text>": Text("apt-cache search %(text)s"),
        "sudo apt get install": Text("sudo apt-get install "),
        "sudo apt get install <text>": Text("sudo apt-get install %(text)s"),
        "(cat|C A T)": Text("cat "),
        "(cat|C A T) <text>": SCText("cat %(text)s"),
        "(change (directory|dir)|C D)": Text("cd "),
        "(change (directory|dir)|C D) <text>": SCText("cd %(text)s"),
        "[press] control break": Key("ctrl:down, c/10, ctrl:up"),
        "(copy|C P)": Text("cp "),
        "(copy|C P) recursive": Text("cp -r "),
        "(change mode)|C H mod": Text("chmod "),
        "diff": Text("diff "),
        "directory up <n> [times]": Function(directory_up),
        "D P K G": Text("dpkg "),
        "D P K G list": Text("dpkg -l "),
        "exit": Text("exit"),
        "find": Text("find . -name "),
        "find <text>": SCText("find . -name %(text)s"),
        "[go to] end of line": Key("c-e"),
        "[go to] start of line": Key("c-a"),
Exemple #8
0
 "do":
 Text("do ||") + Key("left"),
 "else":
 Text("else") + Key("enter"),
 "end":
 Text("end"),
 "exec":
 Text("exec "),
 "exit":
 Text("exit") + Key("enter"),
 "(exponent|to the power of)":
 Text(" ** "),
 "(el if|else if)":
 Text("elsif "),
 "(el if|else if) <text>":
 SCText("elsif %(text)s"),
 "end [block]":
 Text("end") + Key("enter"),
 "ensure":
 Text("ensure") + Key("enter"),
 "equals":
 Text(" == "),
 "false":
 Text("false"),
 "for":
 Text("for "),
 "for <text>":
 SCText("for %(text)s"),
 "greater than":
 Text(" > "),
 "greater [than] equals":
Exemple #9
0
#---------------------------------------------------------------------------
# Set up this module's configuration.

config = Config("bash")
config.load()


#---------------------------------------------------------------------------
# Defined this module's main rule.

bash_rule = MappingRule(
    name="bash",
    mapping={
    
            # test bash
             "test bash": Text("this is from Text: :: ;; (( )) (((()))))") + SCText("this is from SCText: :: ;; (( )) (((()))))"),
             
            # terminal  
             "[keyboard] break": Key("c-c"),
             "new terminal": Key("ca-t"),
             "copy terminal": Key("cs-c/3"),
             "paste terminal": Key("cs-v/3"),
             
             # grep
             "grep [e]|[e] grep": Text("grep -Ei ''") + Key("left:1"),
             "grep directory": Text("grep -Eir '' ./") + Key("left:4"),
             "pipe grep": Text("grep -Ei ''") + Key("left"),
             "pipe grep": Text(" | grep -Ei ''") + Key("left"),
             "pipe (awkward|och)": Text(" | awk '{print $NF}'") + Key("left:2"),
             "pipe said": Text(" | sed 's///g'") + Key("left:4"),
             "[bash] pipe cut": Text(" | cut -d' ' -f1"),
    Key("left:3").execute()


rules = MappingRule(
    mapping={
        # Keywords:
        "and":
        Text(" && "),
        "assign":
        Text(" = "),
        "break":
        Text("break"),
        "case":
        Text("case "),
        "case <text>":
        SCText("case %(text)s"),
        "catch":
        Text("catch () {") + Key("left:3"),
        "comment":
        Text("// "),
        "comment <text>":
        SCText("// %(text)s"),
        "continue":
        Text("continue"),
        "close comment":
        Text(" */"),
        "debugger":
        Text("debugger"),
        "default":
        Text("default"),
        #         "delete": Text("delete "),  # Messes with ordinary delete command.
Exemple #11
0
    "seven": "7",
    "eight": "8",
    "nine": "9",
    "(A|alpha)": "a",
    "(B|bravo)": "b",
    "(C|charlie)": "c",
    "(D|delta)": "d",
    "(E|echo)": "e",
    "(F|foxtrot)": "f",
}

rules = MappingRule(
    mapping={
        # Commands and keywords.
        "class <text>":
        SCText(".%(text)s {"),
        "media":
        Text("@media ") + Key("left/3:3"),
        "media query":
        Text("@media () {") + Key("left/3:3"),
        "close comment":
        Text(" */"),
        "comment":
        Text("/*  */") + Key("left/3:3"),
        "hex <hex1><hex2><hex3>":
        Text("#%(hex1)s%(hex2)s%(hex3)s"),
        "hex <hex1><hex2><hex3><hex4><hex5><hex6>":
        Text("#%(hex1)s%(hex2)s%(hex3)s%(hex4)s%(hex5)s%(hex6)s"
             ),  # @IgnorePep8
        "import":
        Text("@import "),
    SCText(str(text)).execute()


rules = MappingRule(
    mapping={
        # Commands and keywords.
        "[start] tag": Text("<>") + Key("left"),
        "[start] tag <element>": Function(start_tag),
        "tags <element>": Function(tags),
        "end tag": Text("</>") + Key("left"),
        "end tag <element>": Function(end_tag),
        "attribute <attribute>": Text(' %(attribute)s=""') + Key("left"),
        "attribute <attribute> [equals] <text>": Function(attribute_with_content),  # @IgnorePep8
        # Comments.
        "comment": Text("<!--  -->") + Key("left:4"),
        "comment <text>": SCText("<!-- %(text)s -->") + Key("left:4"),
        "(open|left) comment": Text("<!-- "),
        "(open|left) comment <text>": SCText("<!-- %(text)s"),
        "(close|right) comment": Text(" -->"),
        # Doctypes.
        "doctype 5": Text("<!DOCTYPE html>"),
        "doctype 4 [transitional]": Text('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">'),  # @IgnorePep8
        "doctype 4 strict": Text('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">'),  # @IgnorePep8
        "doctype X [transitional]": Text('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'),  # @IgnorePep8
        "doctype X strict": Text('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'),  # @IgnorePep8
        # if conditions.
    },
    extras=[
        IntegerRef("n", 1, 100),
        Dictation("text"),
        Choice("element", htmlElements),
Exemple #13
0
    "seven": "7",
    "eight": "8",
    "nine": "9",
    "(A|alpha)": "a",
    "(B|bravo)": "b",
    "(C|charlie)": "c",
    "(D|delta)": "d",
    "(E|echo)": "e",
    "(F|foxtrot)": "f",
}


rules = MappingRule(
    mapping={
        # Commands and keywords.
        "class <text>": SCText(".%(text)s {"),
        "media": Text("@media ") + Key("left/3:3"),
        "media query": Text("@media () {") + Key("left/3:3"),
        "close comment": Text(" */"),
        "comment": Text("/*  */") + Key("left/3:3"),
        "hex <hex1><hex2><hex3>": Text("#%(hex1)s%(hex2)s%(hex3)s"),
        "hex <hex1><hex2><hex3><hex4><hex5><hex6>": Text("#%(hex1)s%(hex2)s%(hex3)s%(hex4)s%(hex5)s%(hex6)s"),  # @IgnorePep8
        "import": Text("@import "),
        "open comment": Text("/* "),
        "property <prop>": SCText("%(prop)s: "),
        "property <prop> <text>": Text("%(prop)s: ") + SCText("%(text)s"),
        "<numeric> E M": Text("%(numeric)sem"),
        "<numeric> P T": Text("%(numeric)spt"),
        "<numeric> P X": Text("%(numeric)spx"),
        "url": Text("url('')") + Key("left/3:2"),
    },
Exemple #14
0
 "class": Text("class "),
 "class <text>": Function(define_class),
 "divided by": Text(" / "),
 "(def|define|definition) [function|method]": Text("def "),
 "(def|define|definition) [function|method] <text>": Function(define_method),
 "(def|define|definition) class [function|method]": Text("def self."),
 "(def|define|definition) class [function|method] <text>": Function(define_class_method),
 "(def|define|definition) initialize": Text("def initialize()") + Key("left"),
 "do": Text("do ||") + Key("left"),
 "else": Text("else") + Key("enter"),
 "end": Text("end"),
 "exec": Text("exec "),
 "exit": Text("exit") + Key("enter"),
 "(exponent|to the power of)": Text(" ** "),
 "(el if|else if)": Text("elsif "),
 "(el if|else if) <text>": SCText("elsif %(text)s"),
 "end [block]": Text("end") + Key("enter"),
 "ensure": Text("ensure") + Key("enter"),
 "equals": Text(" == "),
 "false": Text("false"),
 "for": Text("for "),
 "for <text>": SCText("for %(text)s"),
 "greater than": Text(" > "),
 "greater [than] equals": Text(" >= "),
 "hash (arrow|operator|rocket)": Text(" => "),
 "hash key": Text(" => ") + Key("left:4"),
 "hash key string": Text("'' => ") + Key("left:5"),
 "hash key symbol": Text(": :") + Key("left:3"),
 "if": Text("if "),
 "if <text>": SCText("if %(text)s"),
 "index": Text("[]") + Key("left"),
Exemple #15
0
def attribute_with_content(attribute, text):
    Text(' %(attribute)s=""').execute()
    Key("left").execute()
    SCText(str(text)).execute()
    Text("function ").execute()
    lib.format.camel_case_text(text)
    Text("() {").execute()
    Key("left:3").execute()


rules = MappingRule(
    mapping={
        # Keywords:
        "abstract": Text("abstract "),
        "and": Text(" && "),
        "assign": Text(" = "),
        "(bool|boolean)": Text("boolean "),
        "break": Text("break"),
        "case": Text("case "),
        "case <text>": SCText("case %(text)s"),
        "catch": Text("catch () {") + Key("left:3"),
        "class": Text("class "),
        "comment": Text("// "),
        "comment <text>": SCText("// %(text)s"),
        "continue": Text("continue"),
        "close comment": Text(" */"),
        "do": Text("do {"),
        "equals": Text(" == "),
        "else": Text("else"),
        "else if": Text("else if () {") + Key("left:3"),
        "extends ": Text("extends "),
        "final": Text("final "),
        "for": Text("for () {") + Key("left:3"),
        "for <text>": SCText("for (%(text)s) {") + Key("left:3"),
        "false": Text("false"),
Exemple #17
0
    "remote": "--remote",
    "short": "--short",
    "skip": "--skip",
    "tags": "--tags",
    "staged": "--staged",
    "theirs": "--theirs",
    "track": "--track",
    "verbose": "--verbose",
    "version": "--version",
}

series_rule = SeriesMappingRule(
    mapping={
        # Git commands.
        "git add": Text("git add "),
        "git add <text>": SCText("git add %(text)s"),
        "git add patch": Text("git add --patch "),
        "git add patch <text>": SCText("git add --patch %(text)s"),
        "git add (all|period|dot)": Text("git add .") + Key("enter"),
        "git archive": Text("git archive --format=tar "),
        "git blame": Text("git blame "),
        "git branch": Text("git branch") + Key("enter"),
        "git branch track": Text("git branch -- track "),
        "git branch <text>": SCText("git branch %(text)s"),
        "git branch delete ": Text("git branch -d "),
        "git branch delete <text>": SCText("git branch -d %(text)s"),
        "git (check out|checkout)": Text("git checkout "),
        "git (check out|checkout) <text>": SCText("git checkout %(text)s"),
        "git (check out|checkout) branch": Text("git checkout -b "),
        "git (check out|checkout) branch <text>": SCText("git checkout -b %(text)s"),  # @IgnorePep8
        "git (check out|checkout) force": Text("git checkout -f "),
Exemple #18
0
DYN_MODULE_NAME = "bash"
INCOMPATIBLE_MODULES = []


def directory_up(n):
    repeat = ['..' for i in range(n)]  # @UnusedVariable
    txt = "cd %s\n" % ("/".join(repeat))
    Text(txt).execute()


rules = MappingRule(
    mapping={
        # Commands and keywords:
        "apt cache search": Text("apt-cache search "),
        "apt cache search <text>": SCText("apt-cache search %(text)s"),
        "apt cache show": Text("apt-cache show "),
        "apt cache show <text>": SCText("apt-get show %(text)s"),
        "apt get install": Text("apt-get install "),
        "apt get install <text>": SCText("apt-get install %(text)s"),
        "apt get update": Text("apt-get update") + Key("enter"),
        "sudo apt get install": Text("sudo apt-get install "),
        "sudo apt get install <text>": SCText("sudo apt-get install %(text)s"),
        "sudo apt get update": Text("sudo apt-get update") + Key("enter"),
        "background": Text("bg "),
        "(cat|C A T)": Text("cat "),
        "(cat|C A T) <text>": SCText("cat %(text)s"),
        "(change (directory|dir)|C D)": Text("cd "),
        "(change (directory|dir)|C D) <text>": SCText("cd %(text)s"),
        "[press] control break": Key("ctrl:down, c/10, ctrl:up"),
        "(copy|C P)": Text("cp "),