-
Notifications
You must be signed in to change notification settings - Fork 0
/
_multiedit.txt
138 lines (114 loc) · 5.92 KB
/
_multiedit.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#
# This is a config file for Dragonfly's _multiedit.py command-module.
# To use this config, you must rename this file to _multiedit.txt and
# place it in the same directory as the _multiedit.py file.
#
# Pull in all of Dragonfly's action objects so that we can use them here.
from dragonfly import *
#---------------------------------------------------------------------------
# Here we define the release action which releases all
# modifier-keys used within this grammar. It is defined here
# because this functionality is used in many different places.
# Note that it is harmless to release ("...:up") a key multiple
# times or when that key is not held down at all.
release = Key("shift:up, ctrl:up")
#---------------------------------------------------------------------------
# Here we define the single-action commands. These can be spoken
# in series so as to execute multiple actions within a single utterance.
cmd.map = {
# Spoken-form -> -> -> Action object
"up [<n>]": Key("up:%(n)d"),
"down [<n>]": Key("down:%(n)d"),
"left [<n>]": Key("left:%(n)d"),
"right [<n>]": Key("right:%(n)d"),
"page up [<n>]": Key("pgup:%(n)d"),
"page down [<n>]": Key("pgdown:%(n)d"),
"up <n> (page | pages)": Key("pgup:%(n)d"),
"down <n> (page | pages)": Key("pgdown:%(n)d"),
"left <n> (word | words)": Key("c-left:%(n)d"),
"right <n> (word | words)": Key("c-right:%(n)d"),
"home": Key("home"),
"end": Key("end"),
"doc home": Key("c-home"),
"doc end": Key("c-end"),
"space [<n>]": release + Key("space:%(n)d"),
"enter [<n>]": release + Key("enter:%(n)d"),
"tab [<n>]": Key("tab:%(n)d"),
"delete [<n>]": release + Key("del:%(n)d"),
"delete [<n> | this] (line|lines)": release + Key("home, s-down:%(n)d, del"),
"backspace [<n>]": release + Key("backspace:%(n)d"),
"pop up": release + Key("apps"),
"paste": release + Key("c-v"),
"duplicate <n>": release + Key("c-c, c-v:%(n)d"),
"copy": release + Key("c-c"),
"cut": release + Key("c-x"),
"select all": release + Key("c-a"),
"[hold] shift": Key("shift:down"),
"release shift": Key("shift:up"),
"[hold] control": Key("ctrl:down"),
"release control": Key("ctrl:up"),
"release [all]": release,
"say <text>": release + Text("%(text)s"),
"mimic <text>": release + Mimic(extra="text"),
}
#---------------------------------------------------------------------------
# Here we define various functions for formatting text.
# Each of these functions must have a docstring which defines its
# spoken-form. This docstring must include the "<dictation>" extra.
# See below for various examples.
# Format: some-words
def format_hyphen(dictation): # Function name must start with "format_".
""" hyphenate <dictation> """ # Docstring defining spoken-form.
text = str(dictation) # Get written-form of dictated text.
return "-".join(text.split(" ")) # Put hyphens between words.
# Format: some-words [ensures all words are lower case]
def format_hyphen_lower(dictation):
""" lowercase hyphenate <dictation> """
text = str(dictation)
words = [word.lower() for word in text.split(" ")]
return "-".join(words)
# Format: some_words
def format_score(dictation): # Function name must start with "format_".
""" score <dictation> """ # Docstring defining spoken-form.
text = str(dictation) # Get written-form of dictated text.
return "_".join(text.split(" ")) # Put underscores between words.
# Format: some_words [ensures all words are lower case]
def format_score_lower(dictation):
""" lowercase score <dictation> """
text = str(dictation)
words = [word.lower() for word in text.split(" ")]
return "_".join(words)
# Format: SOME_WORDS
def format_score_upper(dictation):
""" uppercase score <dictation> """
text = str(dictation)
words = [word.upper() for word in text.split(" ")]
return "_".join(words)
# Format: somewords
def format_one_word(dictation):
""" [all] one word <dictation> """
text = str(dictation)
return "".join(text.split(" "))
# Format: SOMEWORDS
def format_one_word_upper(dictation):
""" uppercase one word <dictation> """
text = str(dictation)
words = [word.upper() for word in text.split(" ")]
return "".join(words)
# Format: SomeWords
def format_camel_case(dictation):
""" camel case <dictation> """
text = str(dictation)
words = [word.capitalize() for word in text.split(" ")]
return "".join(words)
# Format: someWords
def format_little_camel_case(dictation):
""" (little | small | tiny | lower [case]) camel case <dictation> """
text = str(dictation)
words = text.split(" ")
return words[0] + "".join(w.capitalize() for w in words[1:])
# Format: some_words()
def format_score_function(dictation):
""" score function <dictation> """
text = str(dictation)
return "_".join(text.split(" ")) + "()"