]> git.sven.stormbind.net Git - sven/vym.git/blob - macros/macros.vys
Replace Pierre as the maintainer
[sven/vym.git] / macros / macros.vys
1 // vim:syntax=javascript
2
3 //! Helper function to toggle frame
4 function toggle_frame(map)
5 {
6     if (map.getFrameType() == "NoFrame" ) {
7         map.setFrameType ("RoundedRectangle");
8     } else
9         map.setFrameType ("NoFrame");
10 }
11 function colorSubtreeWithQuickColor(n)
12 {
13     map = vym.currentMap();
14     vym.selectQuickColor(n);
15     c = vym.currentColor();
16     map.colorSubtree (c);
17 }
18
19 //! Macro F1: Color subtree red
20 function macro_f1()
21 {
22     colorSubtreeWithQuickColor(0);
23 }
24
25 //! Macro F2: Color subtree orange
26 function macro_f2()
27 {
28     colorSubtreeWithQuickColor(1);
29
30     // Or if you prefer to edit the heading of a branch using "F2"-key,
31     // you can use below instead of above:
32     // vym.editHeading();
33 }
34
35 //! Macro F3: Color subtree green
36 function macro_f3()
37 {
38     colorSubtreeWithQuickColor(2);
39 }
40
41
42 //! Macro F4: Color subtree purple
43 function macro_f4()
44 {
45     colorSubtreeWithQuickColor(3);
46 }
47
48 //! Macro F5: Color subtree blue
49 function macro_f5()
50 {
51     colorSubtreeWithQuickColor(4);
52 }
53
54 //! Macro F6: Color subtree blue
55 function macro_f6()
56 {
57     colorSubtreeWithQuickColor(5);
58 }
59
60 //! Macro F7: Color subtree black
61 function macro_f7()
62 {
63     colorSubtreeWithQuickColor(6);
64 }
65
66 //! Macro F8: Color subtree dark gray
67 function macro_f8()
68 {
69     colorSubtreeWithQuickColor(7);
70 }
71
72 //! Macro F9: Color subtree light gray
73 function macro_f9()
74 {
75     colorSubtreeWithQuickColor(8);
76 }
77
78 //! Macro F10: Color subtree light white
79 function macro_f10()
80 {
81     colorSubtreeWithQuickColor(9);
82 }
83
84 //! Macro F11: Repeat last command
85 function macro_f11()
86 {
87     map = vym.currentMap();
88     map.repeatLastCommand();
89 }
90
91 //! Macro F12: toggle high prio task
92 function macro_f12()
93 {
94         // Assuming 3 states, which are cycled:
95         // 0 - nothing set
96         // 1 - high prio task with arrows
97         // 2 - done task without arrows, but green hook
98     map = vym.currentMap();
99     if (map.hasTask() ) {
100         // Switch to state 2 
101         map.toggleTask();
102         map.unsetFlagByName("2arrow-up");
103         map.unsetFlagByName("stopsign");
104         map.setFlagByName("hook-green");
105         map.colorBranch("#0000ff");
106     } else {
107         if (map.hasActiveFlag("hook-green")) {
108             // Switch to state 0
109             map.unsetFlagByName("hook-green");
110         } else {
111             // Switch to state 1
112             map.setFlagByName("2arrow-up");
113             map.toggleTask();
114         }
115     }
116 }
117
118
119 //! Macro Shift + F1: Frame background light red
120 function macro_shift_f1()
121 {
122     map = vym.currentMap();
123     status = "Background off";
124     if (map.getFrameType() == "NoFrame") {
125         status = "Background light red";
126     }
127     toggle_frame ( map );
128     map.setFrameBrushColor("#ffb3b4");
129     statusMessage(status);
130 }
131
132 //! Macro Shift + F2: Frame background light green
133 function macro_shift_f2()
134 {
135     map = vym.currentMap();
136     status = "Background off";
137     if (map.getFrameType() == "NoFrame") {
138         status = "Background light green";
139     }
140     toggle_frame ( map );
141     map.setFrameBrushColor("#bdffd6");
142     statusMessage(status);
143 }
144
145 //! Macro Shift + F3: Frame background light yellow
146 function macro_shift_f3()
147 {
148     map = vym.currentMap();
149     status = "Background off";
150     if (map.getFrameType() == "NoFrame") {
151         status = "Background light yellow";
152     }
153     toggle_frame ( map );
154     map.setFrameBrushColor("#efefb3");
155     statusMessage(status);
156 }
157
158 //! Macro Shift + F4: Frame background light blue
159 function macro_shift_f4()
160 {
161     map = vym.currentMap();
162     status = "Background off";
163     if (map.getFrameType() == "NoFrame") {
164         status = "Background light blue";
165     }
166     toggle_frame ( map );
167     map.setFrameBrushColor("#e2e6ff");
168     statusMessage(status);
169 }
170
171 //! Macro Shift + F5: Frame background light grey
172 function macro_shift_f5()
173 {
174     map = vym.currentMap();
175     status = "Background off";
176     if (map.getFrameType() == "NoFrame") {
177         status = "Background light grey";
178     }
179     toggle_frame ( map );
180     map.setFrameBrushColor("#d6d6d6");
181     statusMessage(status);
182 }
183
184 //! Macro Shift + F6: Frame background purple
185 function macro_shift_f6()
186 {
187     map = vym.currentMap();
188     status = "Background off";
189     if (map.getFrameType() == "NoFrame") {
190         status = "Background purple";
191     }
192     toggle_frame ( map );
193     map.setFrameBrushColor("#ffaaff");
194     statusMessage(status);
195 }
196
197 //! Macro Shift + F7: Frame background white
198 function macro_shift_f7()
199 {
200     map = vym.currentMap();
201     status = "Background off";
202     if (map.getFrameType() == "NoFrame") {
203         status = "Background white";
204     }
205     toggle_frame ( map );
206     map.setFrameBrushColor("#ffffff");
207     statusMessage(status);
208 }
209
210 //! Macro Shift + F8: Frame background black
211 function macro_shift_f8()
212 {
213     map = vym.currentMap();
214     status = "Background off";
215     if (map.getFrameType() == "NoFrame") {
216         status = "Background black";
217     }
218     toggle_frame ( map );
219     map.setFrameBrushColor("#000000");
220     statusMessage(status);
221 }
222
223 //! Macro Shift + F9: Toggle frame to include children
224 function macro_shift_f9()
225 {
226     map = vym.currentMap();
227     map.toggleFrameIncludeChildren();
228 }
229
230 //! Macro Shift + F10: 
231 // Useful for timestamps created on last entry
232 function macro_shift_f10()
233 {   
234 }
235
236 //! Macro Shift + F11: Replace "@..." by mutt aliases
237 function macro_shift_f11()
238 {
239         map     = vym.currentMap();
240         lines   = vym.loadFile("/home/uwe/.mutt/eb-aliases").split('\n');
241
242
243         if (map.getHeadingPlainText() == "parts") {
244                 map.setHeadingPlainText("Participants");
245         }
246
247         map.initIterator("foobar");
248
249         while (map.nextIterator("foobar") ) {
250                 heading = map.getHeadingPlainText();
251
252                 // Search for "@alias" at beginning of heading
253                 if (heading.search(/^@\w/) == 0) {
254                         alias_map = heading.replace(/@/,"");
255
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(/\".+/, "");
261
262                                                 email = lines[i].replace(/^.+?</, "");
263                                                 email = email.replace(/>.*/, "");
264
265                                                 map.setHeadingPlainText(name);
266                                         }
267                                 }
268                         }
269                 } else {
270                         print ("No alias found");
271         }
272         }
273 }
274
275 //! Macro Shift + F12:
276 function macro_shift_f12()
277 {
278     statusMessage("Macro F12 + Shift triggered");
279 }
280
281
282 // New /////////////////////////////////////
283 //! Macro Ctrl + F1:
284 function macro_ctrl_f1()
285 {
286     statusMessage("Macro F1 + Ctrl triggered");
287 }
288
289 //! Macro Ctrl + F2:
290 function macro_ctrl_f2()
291 {
292     statusMessage("Macro F2 + Ctrl triggered");
293 }
294
295 //! Macro Ctrl + F3:
296 function macro_ctrl_f3()
297 {
298     statusMessage("Macro F3 + Ctrl triggered");
299 }
300
301 //! Macro Ctrl + F4:
302 function macro_ctrl_f4()
303 {
304     statusMessage("Macro F4 + Ctrl triggered");
305 }
306
307 //! Macro Ctrl + F5:
308 function macro_ctrl_f5()
309 {
310     statusMessage("Macro F5 + Ctrl triggered");
311 }
312
313 //! Macro Ctrl + F6:
314 function macro_ctrl_f6()
315 {
316     statusMessage("Macro F6 + Ctrl triggered");
317 }
318
319 //! Macro Ctrl + F7:
320 function macro_ctrl_f7()
321 {
322     statusMessage("Macro F7 + Ctrl triggered");
323 }
324
325 //! Macro Ctrl + F8:
326 function macro_ctrl_f8()
327 {
328     statusMessage("Macro F8 + Ctrl triggered");
329 }
330
331 //! Macro Ctrl + F9:
332 function macro_ctrl_f9()
333 {
334     statusMessage("Macro F9 + Ctrl triggered");
335 }
336
337 //! Macro Ctrl + F10: 
338 function macro_ctrl_f10()
339 {
340     statusMessage("Macro F10 + Ctrl triggered");
341 }
342
343 //! Macro Ctrl + F11:
344 function macro_ctrl_f11()
345 {
346     statusMessage("Macro F11 + Ctrl triggered");
347 }
348
349 //! Macro Ctrl + F12:
350 function macro_ctrl_f12()
351 {
352     statusMessage("Macro F12 + Ctrl triggered");
353 }
354
355 //! Macro Ctrl + Shift + F1:
356 function macro_ctrl_shift_f1()
357 {
358     statusMessage("Macro F1 + Ctrl + Shift triggered");
359 }
360
361 //! Macro Ctrl + Shift + F2:
362 function macro_ctrl_shift_f2()
363 {
364     statusMessage("Macro F2 + Ctrl + Shift triggered");
365 }
366
367 //! Macro Ctrl + Shift + F3:
368 function macro_ctrl_shift_f3()
369 {
370     statusMessage("Macro F3 + Ctrl + Shift triggered");
371 }
372
373 //! Macro Ctrl + Shift + F4:
374 function macro_ctrl_shift_f4()
375 {
376     statusMessage("Macro F4 + Ctrl + Shift triggered");
377 }
378
379 //! Macro Ctrl + Shift + F5:
380 function macro_ctrl_shift_f5()
381 {
382     statusMessage("Macro F5 + Ctrl + Shift triggered");
383 }
384
385 //! Macro Ctrl + Shift + F6:
386 function macro_ctrl_shift_f6()
387 {
388     statusMessage("Macro F6 + Ctrl + Shift triggered");
389 }
390
391 //! Macro Ctrl + Shift + F7:
392 function macro_ctrl_shift_f7()
393 {
394     statusMessage("Macro F7 + Ctrl + Shift triggered");
395 }
396
397 //! Macro Ctrl + Shift + F8:
398 function macro_ctrl_shift_f8()
399 {
400     statusMessage("Macro F8 + Ctrl + Shift triggered");
401 }
402
403 //! Macro Ctrl + Shift + F9:
404 function macro_ctrl_shift_f9()
405 {
406     statusMessage("Macro F9 + Ctrl + Shift triggered");
407 }
408
409 //! Macro Ctrl + Shift + F10: 
410 function macro_ctrl_shift_f10()
411 {
412     statusMessage("Macro F10 + Ctrl + Shift triggered");
413 }
414
415 //! Macro Ctrl + Shift + F11:
416 function macro_ctrl_shift_f11()
417 {
418     statusMessage("Macro F11 + Ctrl + Shift triggered");
419 }
420
421 //! Macro Ctrl + Shift + F12:
422 function macro_ctrl_shift_f12()
423 {
424     statusMessage("Macro F12 + Ctrl + Shift triggered");
425 }