summaryrefslogtreecommitdiffstats
path: root/src/dia_keymap.inc
blob: 2f3a9395cf39a9a10b9d5266a3bf284142ebc867 (plain)
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
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%
% keyboard map selection dialog.
%
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Some global vars.
%

/keymap.setdefault {
  xmenu.keymap .xm_current

    0
    keymaps {
      .km.id get config.keymap.id eq { exit } if
      1 add
    } forall

    dup keymaps length ge { pop 0 } if

  put

} def

% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Build menu list.
%
% ( ) ==> ( )
%
/keymap.init {
  /xmenu.keymap .xm_size array def

  /xmenu xmenu.keymap def

  xmenu .xm_list [
    keymaps { .km.name get } forall
  ] put

  xmenu .xm_title "Keyboard" put

  keymap.setdefault

  % just once (see lang.init)
  /keymap.init { } def
} def


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Update keybaord selection menu.
%
% ( ) ==> ( )
%
/keymap.update {
  /xmenu xmenu.keymap def

  keymaps xmenu .xm_current get get .km.id get setkeymap

  /window.action actRedrawPanel def
} def


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Show keymap selection menu.
%
% ( ) => ( )
%
/panel.keymap {
  "keymap" help.setcontext

  keymap.setdefault

  window.xmenu
  dup .xmenu xmenu.keymap put
  dup .xmenu.update /keymap.update put
  dup window.init
      window.show
} def


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Return width of panel entry.
%
% ( ) => ( width )
%
/panel.keymap.width {
  /xmenu xmenu.keymap def

  pmenu.width
} def


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Redraw panel entry.
%
% ( panel ) => ( )
%
/panel.keymap.update {
  /xmenu xmenu.keymap def

  pmenu.panel.update
} def