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

Last change on this file since 2512 was 2505, checked in by bird, 26 years ago

Some helpfull utils.

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