1 // vim:syntax=javascript
3 // Helper function to toggle frame
4 function toggle_frame(map)
6 if (map.getFrameType() == "NoFrame" ) {
7 map.setFrameType ("RoundedRectangle");
9 map.setFrameType ("NoFrame");
11 function colorSubtreeWithQuickColor(n)
13 map = vym.currentMap();
14 vym.selectQuickColor(n);
15 c = vym.currentColor();
19 // Macro F1: Color subtree red
22 colorSubtreeWithQuickColor(0);
25 // Macro F2: Color subtree orange
28 colorSubtreeWithQuickColor(1);
30 // Or if you prefer to edit the heading of a branch using "F2"-key,
31 // you can use below instead of above:
35 // Macro F3: Color subtree green
38 colorSubtreeWithQuickColor(2);
42 // Macro F4: Color subtree purple
45 colorSubtreeWithQuickColor(3);
48 // Macro F5: Color subtree blue
51 colorSubtreeWithQuickColor(4);
54 // Macro F6: Color subtree blue
57 colorSubtreeWithQuickColor(5);
60 // Macro F7: Color subtree black
63 colorSubtreeWithQuickColor(6);
66 // Macro F8: Color subtree dark gray
69 colorSubtreeWithQuickColor(7);
72 // Macro F9: Color subtree light gray
75 colorSubtreeWithQuickColor(8);
78 // Macro F10: Color subtree light white
81 colorSubtreeWithQuickColor(9);
84 // Macro F11: Repeat last command
87 map = vym.currentMap();
88 map.repeatLastCommand();
91 // Macro F12: toggle high prio task
94 // Assuming 3 states, which are cycled:
96 // 1 - high prio task with arrows
97 // 2 - done task without arrows, but green hook
98 map = vym.currentMap();
102 map.unsetFlagByName("2arrow-up");
103 map.unsetFlagByName("stopsign");
104 map.setFlagByName("hook-green");
105 map.colorBranch("#0000ff");
107 if (map.hasActiveFlag("hook-green")) {
109 map.unsetFlagByName("hook-green");
112 map.setFlagByName("2arrow-up");
119 // Macro Shift + F1: Frame background light red
120 function macro_shift_f1()
122 map = vym.currentMap();
123 status = "Background off";
124 if (map.getFrameType() == "NoFrame") {
125 status = "Background light red";
127 toggle_frame ( map );
128 map.setFrameBrushColor("#ffb3b4");
129 statusMessage(status);
132 // Macro Shift + F2: Frame background light green
133 function macro_shift_f2()
135 map = vym.currentMap();
136 status = "Background off";
137 if (map.getFrameType() == "NoFrame") {
138 status = "Background light green";
140 toggle_frame ( map );
141 map.setFrameBrushColor("#bdffd6");
142 statusMessage(status);
145 // Macro Shift + F3: Frame background light yellow
146 function macro_shift_f3()
148 map = vym.currentMap();
149 status = "Background off";
150 if (map.getFrameType() == "NoFrame") {
151 status = "Background light yellow";
153 toggle_frame ( map );
154 map.setFrameBrushColor("#efefb3");
155 statusMessage(status);
158 // Macro Shift + F4: Frame background light blue
159 function macro_shift_f4()
161 map = vym.currentMap();
162 status = "Background off";
163 if (map.getFrameType() == "NoFrame") {
164 status = "Background light blue";
166 toggle_frame ( map );
167 map.setFrameBrushColor("#e2e6ff");
168 statusMessage(status);
171 // Macro Shift + F5: Frame background light grey
172 function macro_shift_f5()
174 map = vym.currentMap();
175 status = "Background off";
176 if (map.getFrameType() == "NoFrame") {
177 status = "Background light grey";
179 toggle_frame ( map );
180 map.setFrameBrushColor("#d6d6d6");
181 statusMessage(status);
184 // Macro Shift + F6: Frame background purple
185 function macro_shift_f6()
187 map = vym.currentMap();
188 status = "Background off";
189 if (map.getFrameType() == "NoFrame") {
190 status = "Background purple";
192 toggle_frame ( map );
193 map.setFrameBrushColor("#ffaaff");
194 statusMessage(status);
197 // Macro Shift + F7: Frame background white
198 function macro_shift_f7()
200 map = vym.currentMap();
201 status = "Background off";
202 if (map.getFrameType() == "NoFrame") {
203 status = "Background white";
205 toggle_frame ( map );
206 map.setFrameBrushColor("#ffffff");
207 statusMessage(status);
210 // Macro Shift + F8: Frame background black
211 function macro_shift_f8()
213 map = vym.currentMap();
214 status = "Background off";
215 if (map.getFrameType() == "NoFrame") {
216 status = "Background black";
218 toggle_frame ( map );
219 map.setFrameBrushColor("#000000");
220 statusMessage(status);
223 // Macro Shift + F9: Toggle frame to include children
224 function macro_shift_f9()
226 map = vym.currentMap();
227 map.toggleFrameIncludeChildren();
230 // Macro Shift + F10:
231 // Useful for timestamps created on last entry
232 function macro_shift_f10()
236 // Macro Shift + F11: Replace "@..." by mutt aliases
237 function macro_shift_f11()
239 map = vym.currentMap();
240 lines = vym.loadFile("/home/uwe/.mutt/eb-aliases").split('\n');
243 if (map.getHeadingPlainText() == "parts") {
244 map.setHeadingPlainText("Participants");
247 map.initIterator("foobar");
249 while (map.nextIterator("foobar") ) {
250 heading = map.getHeadingPlainText();
252 // Search for "@alias" at beginning of heading
253 if (heading.search(/^@\w/) == 0) {
254 alias_map = heading.replace(/@/,"");
256 for(var i = 0;i < lines.length;i++){
257 if (lines[i].search(/^alias/) == 0) {
258 if (lines[i].search(alias_map) == 6) {
259 name = lines[i].replace(/^.+?\"/, "");
260 name = name.replace(/\".+/, "");
262 email = lines[i].replace(/^.+?</, "");
263 email = email.replace(/>.*/, "");
265 map.setHeadingPlainText(name);
270 print ("No alias found");
275 // Macro Shift + F12: Strip URLs from confluence and generate readable heading
276 function macro_shift_f12()
279 m1 = vym.currentMap();
281 if (vym.isConfluenceAgentAvailable() ) {
282 m1.setHeadingConfluencePageName();
283 statusMessage("Contacting Confluence...");
289 if (org.length == 0) {
291 org = m1.getHeadingPlainText();
292 print ("No URL yet");
293 print ("org: " + org);
302 if (s[s.length-1] == '/') {
303 s = s.slice(0, s.length - 1);
306 // Remove confluence parts
307 if (s.indexOf("infohub") != -1) {
308 print("Found infohub page");
309 if (s.indexOf("spaceKey") != -1) {
310 s = s.replace(/^.*spaceKey=/g, "");
311 s = s.replace(/(&title=)/g, ": ");
314 s = s.replace(/^.*display\//g, "");
315 s = s.replace(/\//g, ": ");
317 } else // no infohub page
320 s = s.replace(/^.*\//g, "");
325 // Replace "+" and "-"
326 s = s.replace(/\+/g, " ");
327 s = s.replace(/%3A/g, "");
328 print ("After replacing:");
332 m1.setHeadingPlainText(s);
335 statusMessage ("Heading not changed.");
337 statusMessage("Changed heading: " + org + " -> " + s);