-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwlmail.py
95 lines (79 loc) · 3.82 KB
/
wlmail.py
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
#
# 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.
#
# Dragonfly is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with Dragonfly. If not, see
# <http://www.gnu.org/licenses/>.
#
"""
This module is a simple shortcuts of Dragonfly use.
It shows how to use Dragonfly's Grammar, AppContext, and MappingRule
classes. This module can be activated in the same way as other
Natlink macros by placing it in the "My Documents\Natlink folder" or
"Program Files\NetLink/MacroSystem".
"""
from dragonfly import (Grammar, AppContext, MappingRule, Dictation,
Key, Text)
#---------------------------------------------------------------------------
# Create this module's grammar and the context under which it'll be active.
grammar_context = AppContext(executable="wlmail")
grammar = Grammar("wlmail_shortcuts", context=grammar_context)
#---------------------------------------------------------------------------
# Create a mapping rule which maps things you can say to actions.
#
# Note the relationship between the *mapping* and *extras* keyword
# arguments. The extras is a list of Dragonfly elements which are
# available to be used in the specs of the mapping. In this shortcuts
# the Dictation("text")* extra makes it possible to use "<text>"
# within a mapping spec and "%(text)s" within the associated action.
shortcuts_rule = MappingRule(
name="shortcuts", # The name of the rule.
mapping={ # The mapping dict: spec -> action.
# Windows live mail shortcuts
"move to folder": Key("cs-v"),
"sort with date": Key("a-v, b/10, down:1, enter"),
"sort with flag": Key("a-v, b/11, down:6, enter"),
'flag': Key("a-a, a"),
'send to junk': Key("ca-j"),
#"sort with flag": Key("a-v/200, b/200"), #, right, down/300, enter"), # + 6*"down/20, "), # + "enter"),
#"sort with from": Key("a-v/200, b/200"), #, right, down/300, enter"), # + 6*"down/20, "), # + "enter"),
# todo: fix
# 'live emails': ('{esc}{tab}',0x100),
# # Google wlmail commands
# 'next': Key("c-tab"),
# 'previous': Key("cs-tab"),
# 'private': Key("a-e, i/20"),
# 'close': Key('c-w'),
# 'bookmark': Key('c-d/20'),
# 'tools': Key('a-e'),
# "save [file]": Key("c-s"),
# "save [file] as": Key("a-f, a"),
# "save [file] as <text>": Key("a-f, a/20") + Text("%(text)s"),
# "find <text>": Key("c-f/20") + Text("%(text)s\n"),
},
extras=[ # Special elements in the specs of the mapping.
Dictation("text"),
],
)
# Add the action rule to the grammarecurjinstance.
grammar.add_rule(shortcuts_rule)
#---------------------------------------------------------------------------
# Load the grammar instance and define how to unload it.
grammar.load()
# Unload function which will be called by natlink at unload time.
def unload():
global grammar
if grammar: grammar.unload()
grammar = None