source: trunk/tools/vslick/odin32.e@ 5280

Last change on this file since 5280 was 4361, checked in by bird, 25 years ago

Generates relative projects.
Changes directory to the same directory as the project file during project
loading.

File size: 7.8 KB
Line 
1/* $Id: odin32.e,v 1.6 2000-10-02 04:08:49 bird Exp $
2 *
3 * Visual SlickEdit Documentation Macros.
4 *
5 * Copyright (c) 1999-2000 knut st. osmundsen (knut.stange.osmundsen@pmsc.no)
6 *
7 * Project Odin Software License can be found in LICENSE.TXT
8 *
9 ****
10 *
11 * This define the following keys:
12 *---------------------------------
13 * Ctrl+Shift+C: Class description box.
14 * Ctrl+Shift+F: Function/method description box.
15 * Ctrl+Shift+M: Module(file) description box
16 * Ctrl+Shift+O: One-liner (comment)
17 *
18 * Ctrl+Shift+G: Global box
19 * Ctrl+Shift+H: Header box
20 * Ctrl+Shift+I: Internal function box
21 * Ctrl+Shift+K: Const/macro box
22 * Ctrl+Shift+S: Struct/Typedef box
23 *
24 * Ctrl+Shift+T: Makes tag file
25 *
26 * Remember to set the correct sOdin32UserName, sOdin32UserEmail and sOdin32UserInitials
27 * before compiling and loading the macros into Visual SlickEdit.
28 *
29 * These macros are compatible with both 3.0(c) and 4.0(b).
30 *
31 */
32defeventtab default_keys
33def 'C-S-A' = odin32_signature
34def 'C-S-C' = odin32_classbox
35def 'C-S-F' = odin32_funcbox
36def 'C-S-G' = odin32_globalbox
37def 'C-S-H' = odin32_headerbox
38def 'C-S-I' = odin32_intfuncbox
39def 'C-S-K' = odin32_constbox
40def 'C-S-M' = odin32_modulebox
41def 'C-S-O' = odin32_oneliner
42def 'C-S-S' = odin32_structbox
43def 'C-S-T' = odin32_maketagfile
44
45
46//MARKER. Editor searches for this line!
47#pragma option(redeclvars, on)
48#include 'slick.sh'
49
50/* Remeber to change these! */
51static _str sOdin32UserInitials = "kso";
52static _str sOdin32UserName = "knut st. osmundsen";
53static _str sOdin32UserEmail = "knut.stange.osmundsen@mynd.no";
54
55
56
57/**
58 * Insers a date string. The date is in ISO format.
59 */
60void odin32_date()
61{
62 int i,j;
63 _str date;
64
65 date = _date('U');
66 i = pos("/", date);
67 j = pos("/", date, i+1);
68 month = substr(date, 1, i-1);
69 if (length(month) == 1) month = '0'month;
70 day = substr(date, i+1, j-i-1);
71 if (length(day) == 1) day = '0'day;
72 year = substr(date, j+1);
73 _insert_text(nls("%s-%s-%s", year, month, day));
74}
75
76
77/**
78 * Get the current year.
79 * @returns Current year string.
80 */
81_str odin32_year()
82{
83 date = _date('U');
84 return substr(date, pos("/",date, pos("/",date)+1)+1, 4);
85}
86
87
88/**
89 * Inserts the first line in a box.
90 * @param sTag Not used - box tag.
91 */
92static void odin32_firstline(sTag)
93{
94 begin_line();
95 if (file_eq(p_extension, 'asm'))
96 _insert_text(";\n");
97 else
98 {
99 _insert_text("/");
100 for (i = 0; i < 80-1; i++)
101 _insert_text("*");
102 _insert_text("\n");
103 }
104}
105
106/**
107 * Inserts a line with a '*' in both ends and some text (a) inside.
108 * @param a text.
109 */
110void odin32_starlinestr(a)
111{
112 if (file_eq(p_extension, 'asm'))
113 {
114 _insert_text("; ");
115 _insert_text(a);
116 _insert_text("\n");
117 }
118 else
119 {
120 _insert_text("* ");
121 _insert_text(a);
122 for (i = 0; i < 80-3-length(a); i++)
123 _insert_text(" ");
124 _insert_text("*\n");
125 }
126}
127
128
129/**
130 * Empty line with a '*' in both ends.
131 */
132void odin32_starline()
133{
134 odin32_starlinestr("");
135}
136
137
138/**
139 * Inserts the last line in a box.
140 */
141void odin32_lastline()
142{
143 if (file_eq(p_extension, 'asm'))
144 _insert_text(";\n");
145 else
146 {
147 for (i = 0; i < 80-1; i++)
148 _insert_text("*");
149 _insert_text("/\n");
150 }
151}
152
153
154
155/**
156 * Inserts a signature. Form: "//Initials ISO-date:"
157 * @remark defeventtab
158 */
159void odin32_signature()
160{
161 if (file_eq(p_extension, 'asm'))
162 _insert_text(";"sOdin32UserInitials" ");
163 else
164 _insert_text("//"sOdin32UserInitials" ");
165
166 odin32_date()
167 _insert_text(":");
168}
169
170
171/**
172 * SDS - Classbox(/header).
173 * @remark defeventtab
174 */
175void odin32_classbox()
176{
177 _begin_line();
178 _insert_text("/**\n");
179 _insert_text(" * \n");
180 _insert_text(" * @shortdesc \n");
181 _insert_text(" * @dstruct \n");
182 _insert_text(" * @version \n");
183 _insert_text(" * @verdesc \n");
184 _insert_text(" * @author " sOdin32UserName " (" sOdin32UserEmail ")\n");
185 _insert_text(" * @approval \n");
186 _insert_text(" */\n");
187
188 up(8);
189 p_col += 3;
190}
191
192
193/**
194 * SDS - functionbox(/header).
195 * @remark defeventtab
196 */
197void odin32_funcbox()
198{
199 _begin_line();
200 if (file_eq(p_extension, 'asm'))
201 {
202 _insert_text(";;\n");
203 _insert_text("; \n");
204 _insert_text("; @cproto \n");
205 _insert_text("; @returns \n");
206 _insert_text("; @param \n");
207 _insert_text("; @uses \n");
208 _insert_text("; @equiv \n");
209 _insert_text("; @time \n");
210 _insert_text("; @sketch \n");
211 _insert_text("; @status \n");
212 _insert_text("; @author "sOdin32UserName" (" sOdin32UserEmail ")\n");
213 _insert_text("; @remark \n");
214 up(11);
215 p_col = 3;
216 }
217 else
218 {
219 _insert_text("/**\n");
220 _insert_text(" * \n");
221 _insert_text(" * @returns \n");
222 _insert_text(" * @param \n");
223 _insert_text(" * @equiv \n");
224 _insert_text(" * @time \n");
225 _insert_text(" * @sketch \n");
226 _insert_text(" * @status \n");
227 _insert_text(" * @author "sOdin32UserName" (" sOdin32UserEmail ")\n");
228 _insert_text(" * @remark \n");
229 _insert_text(" */\n");
230 up(10);
231 p_col = 4;
232 }
233}
234
235
236/**
237 *
238 * @remark defeventtab
239 */
240void odin32_globalbox()
241{
242 odin32_firstline("Global");
243 odin32_starlinestr(" Global Variables");
244 odin32_lastline();
245}
246
247
248void odin32_headerbox()
249{
250 odin32_firstline("Header");
251 odin32_starlinestr(" Header Files");
252 odin32_lastline();
253}
254
255
256void odin32_intfuncbox()
257{
258 odin32_firstline("IntFunc");
259 odin32_starlinestr(" Internal Functions");
260 odin32_lastline();
261}
262
263
264void odin32_constbox()
265{
266 odin32_firstline("Const");
267 odin32_starlinestr(" Defined Constants And Macros");
268 odin32_lastline();
269}
270
271
272void odin32_oneliner()
273{
274 end_line();
275 do
276 {
277 _insert_text(" ");
278 } while (p_col < 41);
279
280 if (file_eq(p_extension, 'asm'))
281 {
282 _insert_text("; ");
283 }
284 else
285 {
286 _insert_text("/* */");
287 p_col = p_col - 3;
288 }
289}
290
291
292void odin32_structbox()
293{
294 odin32_firstline("Struct");
295 odin32_starlinestr(" Structures and Typedefs");
296 odin32_lastline();
297}
298
299
300void odin32_modulebox()
301{
302 _begin_line();
303 if (file_eq(p_extension, 'asm'))
304 {
305 _insert_text("; $Id: odin32.e,v 1.6 2000-10-02 04:08:49 bird Exp $\n");
306 _insert_text("; \n");
307 _insert_text("; \n");
308 _insert_text("; \n");
309 _insert_text("; Copyright (c) " odin32_year() " "sOdin32UserName" (" sOdin32UserEmail ")\n");
310 _insert_text("; \n");
311 _insert_text("; Project Odin Software License can be found in LICENSE.TXT\n");
312 _insert_text("; \n");
313 up(6);
314 p_col = 3;
315 }
316 else
317 {
318 _insert_text("/* $Id: odin32.e,v 1.6 2000-10-02 04:08:49 bird Exp $\n");
319 _insert_text(" * \n");
320 _insert_text(" * \n");
321 _insert_text(" * \n");
322 _insert_text(" * Copyright (c) " odin32_year() " "sOdin32UserName" (" sOdin32UserEmail ")\n");
323 _insert_text(" *\n");
324 _insert_text(" * Project Odin Software License can be found in LICENSE.TXT\n");
325 _insert_text(" *\n");
326 _insert_text(" */\n");
327 up(7);
328 p_col = 4;
329 }
330}
331
332
333_command void odin32_maketagfile()
334{
335 /* We'll */
336 if (file_match('-p 'maybe_quote_filename(strip_filename(_project_name,'e'):+TAG_FILE_EXT),1)=="")
337 _project_update_files_retag(true,false,false,true);
338 else
339 _project_update_files_retag(false,false,false,false);
340}
341
342_command void odin32_setcurrentdir()
343{
344 //_ini_get_value(_project_name,"COMPILER","WORKINGDIR", workingdir);
345 //cd(workingdir);
346 /* Go the the directory containing the project filename */
347 cd(strip_filename(_project_name, 'NE'));
348}
349
Note: See TracBrowser for help on using the repository browser.