]> www.wagner.pp.ru Git - oss/fubar.git/blob - hotkeys.tcl
Reimport after CVS crash
[oss/fubar.git] / hotkeys.tcl
1 proc read_hotkey_file {} {
2         global CONFIGDIR
3         if {![file exists $CONFIGDIR/hotkeys]} return
4         set f [open $CONFIGDIR/hotkeys]
5         set count 0
6         while {[gets $f line]>=0} {
7            regsub {#.*$} $line {} command
8            if {[regexp {^\s*$} $command]} continue
9            if {[regexp {((Key|Mouse)\s+(\(\S+\))?\s*(\w+)\s+([ARWSDT\[\]-_F<^>vI0-9F]+)\s+([NCSMLA]+))\s+(\S.*$)} $command match keydescr k w key c m cmd]} {
10                         puts stderr "$keydescr SendToModule *fubar* $cmd"
11                         ::fvwm::send "$keydescr SendToModule *fubar* $cmd"
12                         incr count
13                 } else {
14                         append errors "\nUnrecognized syntax: $line"
15                 }       
16         }       
17         close $f
18         if {$count} {
19                 ::fvwm::bind String interpet_hotkeys
20                 ::fvwm::setMask {String}
21         }       
22         if {[info exists errors]} {
23                 after idle [list error $errors]
24         }       
25
26 }
27
28 proc interpret_hotkeys {event_type id len message} {
29         set cmd hotkey_[string trim message]
30         puts stderr "Hotkey $event_type $id $len $message"
31         if [llength [info proc [lindex $cmd 0]]] {
32                 uplevel #0 $cmd
33         } else {
34                 set widget .[lindex $message 0]
35                 if {![winfo exists $widget]} {
36                         return
37                 }
38                 switch {[winfo class $widget]} {
39                         Button -
40                         Menubutton {uplevel #0 $widget invoke}
41                         default {
42                                 event generate $widget <Button-1>
43                         }
44                 }       
45         }       
46 }
47
48 proc hotkey_menu {{menu_path {}}} {
49         if {![string length $menu_path]} {
50                 .start invoke
51         }       
52 }
53
54 proc hotkey_find {{menu_path {}}} {
55         if {![string length $menu_path]} {
56                 .find invoke
57         } else {
58           $find.m invoke $menu_path
59         }  
60 }
61