summaryrefslogtreecommitdiffstats
path: root/dia_profile.inc
blob: 61c2e243452c7a05092d4123637fd96d0bd1ad61 (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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
%
% Profile selection dialog.
%
% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


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

% fallback if we can't parse "profiles"
/profile.options	[ "" ] def
/profile.items		[ "Broken Profiles" ] def


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Parse "profiles" file.
%
% ( ) ==> ( )
%
/profile.parsedata {
  /pf.tmp.datalen profile.data length def
  /pf.tmp.str profile.data cvs def
 
  /profile.default 0 def

  pf.tmp.datalen 0 eq { return } if
  pf.tmp.str pf.tmp.datalen 1 sub get '\n' ne { return } if

  '\n' seteotchar

  /profile.items [

    /pf.tmp.len 0 def
    /pf.tmp.cnt 0 def
    {
      pf.tmp.str pf.tmp.len add strdup
      dup dup length 0 put
      /pf.tmp.len over length 1 add pf.tmp.len add def

      dup 0 get '*' eq { 1 add /profile.default pf.tmp.cnt def } if

      pf.tmp.len pf.tmp.datalen ge { exit } if

      /pf.tmp.cnt inc
    } loop

  ] def

  ' ' seteotchar

  /profile.options [

     profile.items {
       dup length add
       dup 0 0 put
       1 add
     } forall

  ] def

  0 seteotchar

} def


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

  profile.parsedata

  xmenu .xm_current profile.default put
  xmenu .xm_list profile.items put

  pmenu.init
} def


% - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
% Update profile.
%
% ( ) ==> ( )
%
/profile.update {
  /xmenu xmenu.profile def

  /window.action actRedrawPanel def

  pmenu.update
} def


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

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


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

  pmenu.width
} def


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

  pmenu.panel.update
} def