1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                PROGUTIL.CC                                */
4 /*                                                                           */
5 /* (C) 1993-96  Ullrich von Bassewitz                                        */
6 /*              Zwehrenbuehlstrasse 33                                       */
7 /*              D-72070 Tuebingen                                            */
8 /* EMail:       uz@ibb.schwaben.com                                          */
9 /*                                                                           */
10 /*****************************************************************************/
11 
12 
13 
14 // $Id$
15 //
16 // $Log$
17 //
18 //
19 
20 
21 
22 // This module contains utility functions for message handling. Most of the
23 // functions do nothing but call some other functions. This functions are
24 // easier to use and you need only one include file.
25 
26 
27 
28 #include "kbd.h"
29 #include "program.h"
30 #include "progutil.h"
31 
32 
33 
34 /*****************************************************************************/
35 /*                                   Code                                    */
36 /*****************************************************************************/
37 
38 
39 
GetArgVec()40 char** GetArgVec ()
41 // Get the program arguments
42 {
43     return App->ArgVec;
44 }
45 
46 
47 
GetArgCount()48 int GetArgCount ()
49 // Get the program argument count
50 {
51     return App->ArgCount;
52 }
53 
54 
55 
RemoveArg(int Index)56 void RemoveArg (int Index)
57 // Remove the argument with the given index
58 {
59     App->RemoveArg (Index);
60 }
61 
62 
63 
Idle()64 void Idle ()
65 // Call the applications Idle() method
66 {
67     // No harm done if App does not exist...
68     if (App) {
69         App->Idle ();
70     }
71 }
72 
73 
74 
GetProgName()75 const String& GetProgName ()
76 // Return the program base name
77 {
78     return App->GetProgName ();
79 }
80 
81 
82 
HelpAvail()83 int HelpAvail ()
84 // Calls App->HasHelp, see there
85 {
86     return App->HasHelp ();
87 }
88 
89 
90 
CallHelp(const String & HelpKey)91 void CallHelp (const String& HelpKey)
92 // Calls App->CallHelp, see there
93 {
94     App->CallHelp (HelpKey);
95 }
96 
97 
98 
LoadMsg(u16 MsgNum)99 const Msg& LoadMsg (u16 MsgNum)
100 // Calls App->LoadMsg, see there
101 {
102     return App->LoadMsg (MsgNum);
103 }
104 
105 
106 
LoadAppMsg(u16 MsgNum)107 const Msg& LoadAppMsg (u16 MsgNum)
108 // Calls App->LoadAppMsg, see there
109 {
110     return App->LoadAppMsg (MsgNum);
111 }
112 
113 
114 
FreeMsgBase()115 void FreeMsgBase ()
116 // Calls App->FreeMsgBase, see there
117 {
118     App->FreeMsgBase ();
119 }
120 
121 
122 
FreeAppMsgBase()123 void FreeAppMsgBase ()
124 // Calls App->FreeAppMsgbase, see there
125 {
126     App->FreeAppMsgBase ();
127 }
128 
129 
130 
LoadResource(const String & ResName,int MustHave)131 Streamable* LoadResource (const String& ResName, int MustHave)
132 // Calls App->LoadResource, see there
133 {
134     return App->LoadResource (ResName, MustHave);
135 }
136 
137 
138 
PushStatusLine(const String & NewLine)139 void PushStatusLine (const String& NewLine)
140 // Push the new status line
141 {
142     App->StatusLine->Push (NewLine);
143 }
144 
145 
146 
PushStatusLine(u32 StatusFlags)147 void PushStatusLine (u32 StatusFlags)
148 // Push a standard status line described by StatusFlags
149 {
150     App->StatusLine->Push (StatusFlags);
151 }
152 
153 
154 
PopStatusLine()155 void PopStatusLine ()
156 // Pops the next saved status line from the stack
157 {
158     App->StatusLine->Pop ();
159 }
160 
161 
162 
ReplaceStatusLine(const String & NewLine)163 void ReplaceStatusLine (const String& NewLine)
164 // Replace the current statusline contents by the given string
165 {
166     App->StatusLine->Replace (NewLine);
167 }
168 
169 
170 
ReplaceStatusLine(u32 NewFlags)171 void ReplaceStatusLine (u32 NewFlags)
172 // Replace the current statusline contents by the given string
173 {
174     App->StatusLine->Replace (NewFlags);
175 }
176 
177 
178 
CreateStatusLine(u32 StatusFlags)179 String CreateStatusLine (u32 StatusFlags)
180 // Create a standard status line string
181 {
182     return StatusLine::CreateLine (StatusFlags);
183 }
184 
185 
186 
GetKeyName(Key K)187 String GetKeyName (Key K)
188 // Return the name of the given key.
189 {
190     return Kbd->GetKeyName (K);
191 }
192 
193 
194 
GetKeyName2(Key K)195 String GetKeyName2 (Key K)
196 // Return the name of the given key with a '~' before and after it.
197 {
198     return '~' + Kbd->GetKeyName (K) + '~';
199 }
200 
201 
202 
GetKeyName3(Key K)203 String GetKeyName3 (Key K)
204 // Return the name of the given key with " ~" before, and "~ " after the key
205 // name, ready for a use in the status line.
206 {
207     return " ~" + Kbd->GetKeyName (K) + "~ ";
208 }
209 
210 
211 
KbdGet()212 Key KbdGet ()
213 // Get a key from the keyboard. Calls CurThread()->KbdGet
214 {
215     return CurThread () -> KbdGet ();
216 }
217 
218 
219 
KbdPut(Key K)220 void KbdPut (Key K)
221 // Put a key back into the keyboard queue. Calls CurThread()->KbdPut (K)
222 {
223     CurThread () -> KbdPut (K);
224 }
225 
226 
227 
RegisterKey(Key K)228 void RegisterKey (Key K)
229 // Calls CurThread()->RegisterKey()
230 {
231     CurThread () -> RegisterKey (K);
232 }
233 
234 
235 
UnregisterKey(Key K)236 void UnregisterKey (Key K)
237 // Calls CurThread()->UnregisterKey()
238 {
239     CurThread () -> UnregisterKey (K);
240 }
241 
242 
243 
KeyIsRegistered(Key K)244 int KeyIsRegistered (Key K)
245 // Calls CurThread()->KeyIsRegistered()
246 {
247     return CurThread () -> KeyIsRegistered (K);
248 }
249 
250 
251 
PostEvent(Event * E)252 void PostEvent (Event* E)
253 // Post an event to the programs event queue and deliver it
254 {
255     App->PostEvent (E);
256 }
257 
258 
259 
PostEvent(unsigned What)260 void PostEvent (unsigned What)
261 // Post an event to the programs event queue and deliver it
262 {
263     App->PostEvent (new Event (What));
264 }
265 
266 
267 
PostEvent(unsigned What,unsigned long Info)268 void PostEvent (unsigned What, unsigned long Info)
269 // Post an event to the programs event queue and deliver it
270 {
271     App->PostEvent (new Event (What, Info));
272 }
273 
274 
275 
PostEvent(unsigned What,void * Info)276 void PostEvent (unsigned What, void* Info)
277 // Post an event to the programs event queue and deliver it
278 {
279     App->PostEvent (new Event (What, Info));
280 }
281 
282 
283 
PostEvent(unsigned What,Object * Info)284 void PostEvent (unsigned What, Object* Info)
285 // Post an event to the programs event queue and deliver it
286 {
287     App->PostEvent (new Event (What, Info));
288 }
289 
290 
291 
292 
293