Skip to content

Commit

Permalink
Minor version bump - Major feature upgrades!
Browse files Browse the repository at this point in the history
The next release is likely to be 0.6.0.
Added Prolog and VHDL CCR grammars.
JavaScript CCR updates.
VS Code support.
Mostly internal overhaul of Atom support.
Improved Unicode support.
  • Loading branch information
Versatilus authored Mar 29, 2018
2 parents 2eb453a + 790f046 commit b7b9ba8
Show file tree
Hide file tree
Showing 19 changed files with 1,233 additions and 484 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ complexity_report*
*.*\#
*.*~

# Ignore Rope
.ropeproject/

# Ignoring Visual Studio (Code)
.vs/
.vscode/

# Ignore Natlink
/core/
Expand Down
6 changes: 6 additions & 0 deletions .style.yapf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[style]
based_on_style=pep8
column_limit=90
indent_dictionary_value=True
split_complex_comprehension=True
no_spaces_around_selected_binary_operators=*,/
887 changes: 599 additions & 288 deletions caster/apps/atom.py

Large diffs are not rendered by default.

59 changes: 59 additions & 0 deletions caster/apps/gitter.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"""
__author__ = 'LexiconCode'
Command-module for Gitter
Official Site "https://gitter.im/"
"""
#---------------------------------------------------------------------------

from dragonfly import AppContext, Dictation, Grammar, Key, MappingRule, Text

from caster.lib import control, settings
from caster.lib.dfplus.merge import gfilter
from caster.lib.dfplus.merge.mergerule import MergeRule
from caster.lib.dfplus.state.short import R


class GitterRule(MergeRule):
pronunciation = "Gitter"

mapping = {
"bold":
R(Text("****") + Key("left:2"), rdescript="Gitter: Bold"),
"emphasize":
R(Text("**") + Key("left"), rdescript="Gitter: Italicize"),
# "header": R(Text( "" ), rdescript="Gitter: Header"), # H1 ## H2 ### H3
"insert item":
R(Text("* "), rdescript="Gitter: Insert Item"),
"block quote":
R(Text("> "), rdescript="Gitter: Block Quote"),
"mention":
R(Text("@"), rdescript="Gitter: Mention"),
"insert link":
R(Text("[]()") + Key("left:3"), rdescript="Gitter: Insert Link"),
"insert image":
R(Text("![]()") + Key("left:3"), rdescript="Gitter: Insert Image"),
"insert code":
R(Text("``") + Key("left"), rdescript="Gitter: Insert Code"),
"formatted code":
R(Text("```") + Key("s-enter"), rdescript="Gitter: Formatted Code"),
}
extras = [
Dictation("text"),
]
Defaults = {}


#---------------------------------------------------------------------------

context = AppContext(executable="gitter")
grammar = Grammar("gitter", context=context)

if settings.SETTINGS["apps"]["gitter"]:
if settings.SETTINGS["miscellaneous"]["rdp_mode"]:
control.nexus().merger.add_global_rule(GitterRule())
print("added Gitter")
else:
rule = GitterRule(name="gitter")
gfilter.run_on(rule)
grammar.add_rule(rule)
grammar.load()
97 changes: 97 additions & 0 deletions caster/apps/vscode.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
from dragonfly import (Grammar, AppContext, Dictation, Key, Text, Repeat, Function)

from caster.lib import control
from caster.lib import settings
from caster.lib.dfplus.additions import IntegerRefST
from caster.lib.dfplus.merge import gfilter
from caster.lib.dfplus.merge.mergerule import MergeRule
from caster.lib.dfplus.state.short import R

def findNthToken(text, n, direction):
Key("c-f").execute()
Text("%(text)s").execute({"text": text})
if direction == "reverse":
print("yeah? %(n)d")
Key("s-enter:%(n)d").execute()
else:
Key("enter:%(n)d").execute()
print("no? %(n)d")
Key('escape').execute()

class VisualStudioCodeRule(MergeRule):
pronunciation = "visual studio code"

mapping = {
### ported from my dragonfly scripts
# File management
"[open] command palette": R(Key("cs-p"), rdescript="Visual Studio Code: Command Palette"),
"(Open [file] | Go to [tab]) [<text>]": R(Key("c-p") + Text("%(text)s"), rdescript="Visual Studio Code: Go To File"),
"Close tab": R(Key("c-w"), rdescript="Visual Studio Code: Close Tab"),
"Save file": R(Key("c-s"), rdescript="Visual Studio Code: Save File"),
"Save and close": R(Key("c-s/10, c-w"), rdescript="Visual Studio Code: Save And Close File"),

# Search
"(search | find in) [all] (files | codebase)": R(Key("cs-f"), rdescript="Visual Studio Code: Find in Codebase"),
"(search | find) [file]": R(Key("c-f"), rdescript="Visual Studio Code: Find in File"),
"(Find | Jump [to]) next <text>": R(Function(findNthToken, n=1, direction="forward"), rdescript="Visual Studio Code: Find Next"),
"(Find | Jump [to]) previous <text>": R(Function(findNthToken, n=1, direction="reverse"), rdescript="Visual Studio Code: Find Previous"),

# Tab management
"nexta [<n>]": R(Key("c-pgdown"), rdescript="Visual Studio Code: Next Tab") * Repeat(extra="n"), # These would be next and previous tab but i have a conflict with chrome
"prexta [<n>]": R(Key("c-pgup"), rdescript="Visual Studio Code: Previous Tab") * Repeat(extra="n"),
"Close tab": R(Key("c-f4"), rdescript="Visual Studio Code: Close Tab"),
"Exit preview": R(Key("space, c-z"), rdescript="Visual Studio Code: Exit Preview"),

# moving around a file
"(go to | jump | jump to) line <n>": R(Key("c-g") + Text("%(n)d") + Key("enter"), rdescript="Visual Studio Code: Go to Line"),
"Go to definition": R(Key("f12"), rdescript="Visual Studio Code: Go to Definition"),
"Go to required definition": R(Key("c-f12:2, c-right:5, left/50, f12"), rdescript="Visual Studio Code: Go to Required Definition"),
"Go to (top | first line)": R(Key("c-home"), rdescript="Visual Studio Code: Go to Top"),
"Go to ( bottom | last line)": R(Key("c-end"), rdescript="Visual Studio Code: Go to Bottom"),
"ee-ol": R(Key("end"), rdescript="Visual Studio Code: End Of Line"),
"beol": R(Key("home"), rdescript="Visual Studio Code: Beginning of Line"),
"Go back [<n>]": R(Key("a-left"), rdescript="Visual Studio Code: Go Back") * Repeat(extra="n"),
"Go forward [<n>]": R(Key("a-right"), rdescript="Visual Studio Code: Go Forward") * Repeat(extra="n"),

# Formatting
"indent [<n>]": R(Key("tab"), rdescript="Visual Studio Code: Indent") * Repeat(extra="n"),
"Unindent [<n>]": R(Key("s-tab"), rdescript="Visual Studio Code: Unindent") * Repeat(extra="n"),
"Comment": R(Key("c-slash"), rdescript="Visual Studio Code: Line Comment"),
"Block comment": R(Key("sa-a"), rdescript="Visual Studio Code: Block Comment"),

# Window Management
"[toggle] full screen": R(Key("f11"), rdescript="Visual Studio Code:Fullscreen"),
"[toggle] Zen mode": R(Key("c-k/3, z")),


# Debugging
"[toggle] breakpoint": R(Key("f9"), rdescript="Visual Studio Code:Breakpoint"),
"step over [<n>]": R(Key("f10/50") * Repeat(extra="n"), rdescript="Visual Studio Code:Step Over"),
"step into": R(Key("f11"), rdescript="Visual Studio Code:Step Into"),
"step out [of]": R(Key("s-f11"), rdescript="Visual Studio Code:Step Out"),
"resume": R(Key("f5"), rdescript="Visual Studio Code:Resume"),
}
extras = [
Dictation("text"),
Dictation("mim"),
IntegerRefST("n", 1, 1000),

]
defaults = {
"n": 1,
"mim":"",
"text": ""
}

#---------------------------------------------------------------------------

context = AppContext(executable="code")
grammar = Grammar("Visual Studio Code", context=context)
if settings.SETTINGS["apps"]["visualstudiocode"]:
if settings.SETTINGS["miscellaneous"]["rdp_mode"]:
control.nexus().merger.add_global_rule(VisualStudioCodeRule())
else:
rule = VisualStudioCodeRule(name="visualstudiocode")
gfilter.run_on(rule)
grammar.add_rule(rule)
grammar.load()
4 changes: 3 additions & 1 deletion caster/lib/ccr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@
from javascript.javascript import Javascript
from python.python import Python
from rust.rust import Rust
from sql.sql import SQL
from sql.sql import SQL
from vhdl.vhdl import VHDL
from prolog.prolog import Prolog
3 changes: 2 additions & 1 deletion caster/lib/ccr/core/nav.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ class Navigation(MergeRule):
"peek format": R(Function(textformat.peek_text_format), rdescript="Peek Format"),
"(<capitalization> <spacing> | <capitalization> | <spacing>) (bow|bowel) <textnv> [brunt]": R(Function(textformat.master_format_text), rdescript="Text Format"),
"format <textnv>": R(Function(textformat.prior_text_format), rdescript="Last Text Format"),

"<word_limit> format <textnv>": R(Function(textformat.partial_format_text), rdescript="Partial Text Format"),
"dredge": R(Key("a-tab"), rdescript="Alt-Tab"),

}
Expand All @@ -167,6 +167,7 @@ class Navigation(MergeRule):
Choice("semi",
{"dock": ";", "doc": ";", "sink": ""
}),
Choice("word_limit",{"single": 1,"double": 2,"triple":3,"Quadra":4}),



Expand Down
4 changes: 2 additions & 2 deletions caster/lib/ccr/core/punctuation.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class Punctuation(MergeRule):
"comma": R(Text(","), rdescript="Comma"),
"carrot": R(Text("^"), rdescript="Carat"),
"(period | dot)": R(Text("."), rdescript="Dot"),
"at sign": R(Text("@"), rdescript="At Sign"),
"atty": R(Text("@"), rdescript="At Sign"),
"hash tag": R(Text("#"), rdescript="Hash Tag"),
"apostrophe": R(Text("'"), rdescript="Apostrophe"),
"underscore": R(Text("_"), rdescript="Underscore"),
Expand All @@ -59,4 +59,4 @@ class Punctuation(MergeRule):
"npunc": 1,
}

control.nexus().merger.add_global_rule(Punctuation())
control.nexus().merger.add_global_rule(Punctuation())
16 changes: 6 additions & 10 deletions caster/lib/ccr/javascript/javascript.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@
@author: synkarius
'''
from dragonfly import Key, Text

from caster.lib import control
from caster.lib.ccr.standard import SymbolSpecs
from caster.lib.dfplus.additions import SelectiveAction
from caster.lib.dfplus.merge.mergerule import MergeRule
from caster.lib.dfplus.state.short import R
from dragonfly import Key, Text


class Javascript(MergeRule):
Expand Down Expand Up @@ -59,12 +58,9 @@ class Javascript(MergeRule):


# JavaScript specific
"anon funk": R(Text("function () {}") + Key("left:1, enter")
+ SelectiveAction(Key("enter, up"), ["AptanaStudio3.exe"]),
rdescript="Javascript: Anonymous Function"),
"anon funk": R(Text("() => {}") + Key("left:1, enter"), rdescript="Javascript: Anonymous Function"),
"timer": R(Text("setInterval()") + Key("left"), rdescript="Javascript: Timer"),
"timeout": R(Text("setTimeout()") + Key("left"), rdescript="Javascript: Timeout"),
"sue iffae": R(Text("if()") + Key("left"), rdescript="Javascript: Short If"),
"document": R(Text("document"), rdescript="Javascript: Document"),
"index of": R(Text("indexOf()") + Key("left"), rdescript="Javascript: Index Of"),
"has own property": R(Text("hasOwnProperty()") + Key("left"), rdescript="Javascript: Has Own Property"),
Expand All @@ -82,10 +78,10 @@ class Javascript(MergeRule):
"throw": R(Text("throw "), rdescript="Javascript: Throw"),
"instance of": R(Text("instanceof "), rdescript="Javascript: Instance Of"),

"(far | variable)": R(Text("var "), rdescript="Javascript: Variable"),
"sue iffae": R(Text("if ()") + Key("left"), rdescript="Javascript: Short If"),
"sue shells": R(Text("else") + Key("enter"), rdescript="Javascript: Short Else"),
"var": R(Text("var "), rdescript="Javascript: Var"),
"const": R(Text("const "), rdescript=" JavaScript: Const"),
"Let": R(Text("let "), rdescript=" JavaScript: Let"),

"shell iffae": R(Text("else if ()") + Key("left"), rdescript="Javascript: Else If"),

}
Expand Down
Empty file.
42 changes: 42 additions & 0 deletions caster/lib/ccr/prolog/prolog.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
'''
Created on Sep 2, 2015
@author: Gerrish
'''
from dragonfly import Key, Text, Dictation, MappingRule
from dragonfly.actions.action_text import Text

from caster.lib import control
from caster.lib.dfplus.merge.mergerule import MergeRule
from caster.lib.dfplus.state.short import R
from caster.lib.ccr.standard import SymbolSpecs

class PrologNon(MappingRule):
mapping = {
"Rule": R(Text("() :-.")+Key("left/6"),rdescript="Prolog: rule"),
SymbolSpecs.IF: R(Text("( ")+Key("enter")+Text(";")+Key("enter")+Text(")"),rdescript="Prolog: IF"),
}



class Prolog(MergeRule):
pronunciation = "prolog"

non = PrologNon

mapping = {
"implies": R(Text(":-"), rdescript="Prolog: Select"),
"comment": R(Text("%"), rdescript="Prolog: Line Comment"),
"Open Block comment": R(Text("/* "),rdescript="Prolog: Line Comment"),
"Close Block comment": R(Text("*\ "),rdescript="Prolog: Line Comment"),
"Anonymous": R(Text("_"), rdescript="Prolog: Anonymous"),
"Not": R(Text("\+"), rdescript="Prolog: Not"),
"cut": R(Text("!"), rdescript="Prolog: cut "),
"Or": R(Text(";"), rdescript="Prolog: Or"),
"Fail": R(Text("Fail"), rdescript="Prolog: Fail")
}

extras = []
defaults = {}

control.nexus().merger.add_global_rule(Prolog())
Empty file added caster/lib/ccr/vhdl/__init__.py
Empty file.
Loading

0 comments on commit b7b9ba8

Please sign in to comment.