1 | /* $Id: kdev.e 290 2005-05-23 00:19:39Z bird $ -*- tab-width: 4 c-indent-level: 4 -*-
|
---|
2 | *
|
---|
3 | * Visual SlickEdit Documentation Macros.
|
---|
4 | *
|
---|
5 | * Copyright (c) 1999-2004 knut st. osmundsen <[email protected]>
|
---|
6 | *
|
---|
7 | *
|
---|
8 | * This program is free software; you can redistribute it and/or modify
|
---|
9 | * it under the terms of the GNU General Public License as published by
|
---|
10 | * the Free Software Foundation; either version 2 of the License, or
|
---|
11 | * (at your option) any later version.
|
---|
12 | *
|
---|
13 | * This program is distributed in the hope that it will be useful,
|
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
16 | * GNU General Public License for more details.
|
---|
17 | *
|
---|
18 | * You should have received a copy of the GNU General Public License
|
---|
19 | * along with This program; if not, write to the Free Software
|
---|
20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
21 | *
|
---|
22 | */
|
---|
23 |
|
---|
24 | /***
|
---|
25 | *
|
---|
26 | * This define the following keys:
|
---|
27 | *---------------------------------
|
---|
28 | * Ctrl+Shift+C: Class description box.
|
---|
29 | * Ctrl+Shift+F: Function/method description box.
|
---|
30 | * Ctrl+Shift+M: Module(file) description box
|
---|
31 | * Ctrl+Shift+O: One-liner (comment)
|
---|
32 | *
|
---|
33 | * Ctrl+Shift+G: Global box
|
---|
34 | * Ctrl+Shift+H: Header box
|
---|
35 | * Ctrl+Shift+E: Exported Symbols
|
---|
36 | * Ctrl+Shift+I: Internal function box
|
---|
37 | * Ctrl+Shift+K: Const/macro box
|
---|
38 | * Ctrl+Shift+S: Struct/Typedef box
|
---|
39 | *
|
---|
40 | * Ctrl+Shift+A: Signature+Date marker
|
---|
41 | * Ctrl+Shift+P: Mark line as change by me
|
---|
42 | *
|
---|
43 | * Ctrl+Shift+T: Update project tagfile.
|
---|
44 | *
|
---|
45 | * Ctrl+Shift+B: KLOGENTRYX(..)
|
---|
46 | * Ctrl+Shift+E: KLOGEXIT(..)
|
---|
47 | * Ctrl+Shift+N: Do kLog stuff for the current file. No questions.
|
---|
48 | * Ctrl+Shift+Q: Do kLog stuff for the current file. Ask a lot of questions.
|
---|
49 | *
|
---|
50 | * Remember to set the correct sOdin32UserName, sOdin32UserEmail and sOdin32UserInitials
|
---|
51 | * before compiling and loading the macros into Visual SlickEdit.
|
---|
52 | *
|
---|
53 | * These macros are compatible with both 3.0(c) and 4.0(b).
|
---|
54 | *
|
---|
55 | */
|
---|
56 | defeventtab default_keys
|
---|
57 | def 'C-S-A' = k_signature
|
---|
58 | def 'C-S-C' = k_javadoc_classbox
|
---|
59 | def 'C-S-E' = k_box_exported
|
---|
60 | def 'C-S-F' = k_javadoc_funcbox
|
---|
61 | def 'C-S-G' = k_box_globals
|
---|
62 | def 'C-S-H' = k_box_headers
|
---|
63 | def 'C-S-I' = k_box_intfuncs
|
---|
64 | def 'C-S-K' = k_box_consts
|
---|
65 | def 'C-S-M' = k_javadoc_moduleheader
|
---|
66 | def 'C-S-O' = k_oneliner
|
---|
67 | def 'C-S-P' = k_mark_modified_line
|
---|
68 | def 'C-S-S' = k_box_structs
|
---|
69 | def 'C-S-T' = odin32_maketagfile
|
---|
70 | def 'C-S-L' = k_style_load
|
---|
71 |
|
---|
72 | //optional stuff
|
---|
73 | //def 'C-S-Q' = odin32_klog_file_ask
|
---|
74 | //def 'C-S-N' = odin32_klog_file_no_ask
|
---|
75 | //def 'C-S-1' = odin32_klogentry
|
---|
76 | //def 'C-S-3' = odin32_klogexit
|
---|
77 |
|
---|
78 |
|
---|
79 | //MARKER. Editor searches for this line!
|
---|
80 | #pragma option(redeclvars, on)
|
---|
81 | #include 'slick.sh'
|
---|
82 | #ifndef VS_TAGDETAIL_context_args
|
---|
83 | /* newer vslick version. */
|
---|
84 | #include 'tagsdb.sh'
|
---|
85 | //#pragma option(strict,on)
|
---|
86 | /*#else: Version 4.0 (OS/2) */
|
---|
87 | #endif
|
---|
88 |
|
---|
89 | /* Remeber to change these! */
|
---|
90 | static _str skUserInitials = "kso";
|
---|
91 | static _str skUserName = "knut st. osmundsen";
|
---|
92 | static _str skUserEmail = "[email protected]";
|
---|
93 |
|
---|
94 |
|
---|
95 | /*******************************************************************************
|
---|
96 | * Global Variables *
|
---|
97 | *******************************************************************************/
|
---|
98 | static _str skCodeStyle = 'Opt2Ind4'; /* coding style scheme. */
|
---|
99 | static _str skDocStyle = 'javadoc';/* options: javadoc, */
|
---|
100 | static _str skLicense = 'GPL'; /* options: GPL, LGPL, Odin32, Confidential */
|
---|
101 | static _str skCompany = ''; /* empty or company name for copyright */
|
---|
102 | static _str skProgram = ''; /* Current program name - used by [L]GPL */
|
---|
103 | static _str skChange = ''; /* Current change identifier. */
|
---|
104 |
|
---|
105 | static int ikStyleWidth = 80; /* The page width of the style. */
|
---|
106 | static boolean fkStyleFullHeaders = false; /* false: omit some tags. */
|
---|
107 | static int ikStyleOneliner = 41; /* The oneline comment column. */
|
---|
108 | static int ikStyleModifyMarkColumn = 105;
|
---|
109 | static boolean fkStyleBoxTag = false; /* true: Include tag in k_box_start. */
|
---|
110 |
|
---|
111 | /*******************************************************************************
|
---|
112 | * Internal Functions *
|
---|
113 | *******************************************************************************/
|
---|
114 | /**
|
---|
115 | * Gets iso date.
|
---|
116 | * @returns ISO formatted date.
|
---|
117 | */
|
---|
118 | static _str k_date()
|
---|
119 | {
|
---|
120 | int i,j;
|
---|
121 | _str date;
|
---|
122 |
|
---|
123 | date = _date('U');
|
---|
124 | i = pos("/", date);
|
---|
125 | j = pos("/", date, i+1);
|
---|
126 | _str month = substr(date, 1, i-1);
|
---|
127 | if (length(month) == 1) month = '0'month;
|
---|
128 | _str day = substr(date, i+1, j-i-1);
|
---|
129 | if (length(day) == 1) day = '0'day;
|
---|
130 | _str year = substr(date, j+1);
|
---|
131 | return year"-"month"-"day;
|
---|
132 | }
|
---|
133 |
|
---|
134 |
|
---|
135 | /**
|
---|
136 | * Get the current year.
|
---|
137 | * @returns Current year string.
|
---|
138 | */
|
---|
139 | static _str k_year()
|
---|
140 | {
|
---|
141 | _str date = _date('U');
|
---|
142 | return substr(date, pos("/",date, pos("/",date)+1)+1, 4);
|
---|
143 | }
|
---|
144 |
|
---|
145 |
|
---|
146 | /**
|
---|
147 | * Aligns a value up to a given alignment.
|
---|
148 | */
|
---|
149 | static int k_alignup(int iValue, iAlign)
|
---|
150 | {
|
---|
151 | if (iAlign <= 0)
|
---|
152 | {
|
---|
153 | message('k_alignup: iValue='iValue ' iAlign='iAlign);
|
---|
154 | iAlign = 4;
|
---|
155 | }
|
---|
156 | return ((iValue intdiv iAlign) + 1) * iAlign;
|
---|
157 | }
|
---|
158 |
|
---|
159 |
|
---|
160 | /**
|
---|
161 | * Reads the comment setup for this lexer/extension .
|
---|
162 | *
|
---|
163 | * @returns Success indicator.
|
---|
164 | * @param sLeft Left comment. (output)
|
---|
165 | * @param sRight Right comment. (output)
|
---|
166 | * @param iColumn Comment mark column. (1-based) (output)
|
---|
167 | * @param sExt The extension to lookup defaults to the current one.
|
---|
168 | * @param sLexer The lexer to lookup defaults to the current one.
|
---|
169 | * @author knut st. osmundsen ([email protected])
|
---|
170 | * @remark This should be exported from box.e, but unfortunately it isn't.
|
---|
171 | */
|
---|
172 | static boolean k_commentconfig(_str &sLeft, _str &sRight, int &iColumn, _str sExt = p_extension, _str sLexer = p_lexer_name)
|
---|
173 | {
|
---|
174 | /* init returns */
|
---|
175 | sLeft = sRight = '';
|
---|
176 | iColumn = 0;
|
---|
177 |
|
---|
178 | /*
|
---|
179 | * Get comment setup from the lexer.
|
---|
180 | */
|
---|
181 | _str sLine = '';
|
---|
182 | if (sLexer)
|
---|
183 | {
|
---|
184 | /* multiline */
|
---|
185 | rc = _ini_get_value(slick_path_search("user.vlx"), sLexer, 'mlcomment', sLine);
|
---|
186 | if (rc)
|
---|
187 | rc = _ini_get_value(slick_path_search("vslick.vlx"), sLexer, 'mlcomment', sLine);
|
---|
188 | if (!rc)
|
---|
189 | {
|
---|
190 | sLeft = strip(word(sLine, 1));
|
---|
191 | sRight = strip(word(sLine, 2));
|
---|
192 | if (sLeft != '' && sRight != '')
|
---|
193 | return true;
|
---|
194 | }
|
---|
195 |
|
---|
196 | /* failed, try single line. */
|
---|
197 | rc = _ini_get_value(slick_path_search("user.vlx"), sLexer, 'linecomment', sLine);
|
---|
198 | if (rc)
|
---|
199 | rc = _ini_get_value(slick_path_search("vslick.vlx"), sLexer, 'linecomment', sLine);
|
---|
200 | if (!rc)
|
---|
201 | {
|
---|
202 | sLeft = strip(word(sLine, 1));
|
---|
203 | sRight = '';
|
---|
204 | iColumn = 0;
|
---|
205 | _str sTmp = word(sLine, 2);
|
---|
206 | if (isnumber(sTmp))
|
---|
207 | iColumn = (int)sTmp;
|
---|
208 | if (sLeft != '')
|
---|
209 | return true;
|
---|
210 | }
|
---|
211 | }
|
---|
212 |
|
---|
213 | /*
|
---|
214 | * Read the nonboxchars and determin user or default box.ini.
|
---|
215 | */
|
---|
216 | _str sFile = slick_path_search("ubox.ini");
|
---|
217 | boolean frc = _ini_get_value(sFile, sExt, 'nonboxchars', sLine);
|
---|
218 | if (frc)
|
---|
219 | {
|
---|
220 | sFile = slick_path_search("box.ini");
|
---|
221 | frc = _ini_get_value(sFile, sExt, 'nonboxchars', sLine);
|
---|
222 | }
|
---|
223 |
|
---|
224 | if (!frc)
|
---|
225 | { /*
|
---|
226 | * Found extension.
|
---|
227 | */
|
---|
228 | sLeft = strip(eq_name2value('left',sLine));
|
---|
229 | if (sLeft == '\e') sLeft = '';
|
---|
230 | sRight = strip(eq_name2value('right',sLine));
|
---|
231 | if (sRight == '\e') sRight = '';
|
---|
232 |
|
---|
233 | /* Read comment column too */
|
---|
234 | frc = _ini_get_value(sFile, sExt, 'comment_col', sLine);
|
---|
235 | if (frc)
|
---|
236 | {
|
---|
237 | iColumn = eq_name2value('comment_col', sLine);
|
---|
238 | if (iColumn == '\e') iColumn = 0;
|
---|
239 | }
|
---|
240 | else
|
---|
241 | iColumn = 0;
|
---|
242 | return true;
|
---|
243 | }
|
---|
244 |
|
---|
245 | /* failure */
|
---|
246 | sLeft = sRight = '';
|
---|
247 | iColumn = 0;
|
---|
248 |
|
---|
249 | return false;
|
---|
250 | }
|
---|
251 |
|
---|
252 |
|
---|
253 | /**
|
---|
254 | * Checks if current file only support line comments.
|
---|
255 | * @returns True / False.
|
---|
256 | * @remark Use builtin extension stuff!
|
---|
257 | */
|
---|
258 | static boolean k_line_comment()
|
---|
259 | {
|
---|
260 | _str sRight = '';
|
---|
261 | _str sLeft = '';
|
---|
262 | int iColumn;
|
---|
263 | boolean fLineComment = false;
|
---|
264 | if (k_commentconfig(sLeft, sRight, iColumn))
|
---|
265 | fLineComment = (sRight == '' || iColumn > 0);
|
---|
266 | return fLineComment;
|
---|
267 | }
|
---|
268 |
|
---|
269 |
|
---|
270 |
|
---|
271 | #define KIC_CURSOR_BEFORE 1
|
---|
272 | #define KIC_CURSOR_AFTER 2
|
---|
273 | #define KIC_CURSOR_AT_END 3
|
---|
274 |
|
---|
275 | /**
|
---|
276 | * Insert a comment at current or best fitting position in the text.
|
---|
277 | * @param sStr The comment to insert.
|
---|
278 | * @param iCursor Where to put the cursor.
|
---|
279 | * @param iPosition Where to start the comment.
|
---|
280 | * Doesn't apply to column based source.
|
---|
281 | * -1 means at cursor position. (default)
|
---|
282 | * >0 means at end of line, but not before this column (1-based).
|
---|
283 | * This also implies a min of one space to EOL.
|
---|
284 | */
|
---|
285 | void k_insert_comment(_str sStr, int iCursor, int iPosition = -1)
|
---|
286 | {
|
---|
287 | _str sLeft;
|
---|
288 | _str sRight;
|
---|
289 | int iColumn;
|
---|
290 | if (!k_commentconfig(sLeft, sRight, iColumn))
|
---|
291 | {
|
---|
292 | sLeft = '/*'; sRight = '*/'; iColumn = 0;
|
---|
293 | }
|
---|
294 |
|
---|
295 | int iCol = 0;
|
---|
296 | if (iColumn <= 0)
|
---|
297 | { /*
|
---|
298 | * not column based source
|
---|
299 | */
|
---|
300 |
|
---|
301 | /* position us first */
|
---|
302 | if (iPosition > 0)
|
---|
303 | {
|
---|
304 | end_line();
|
---|
305 | do {
|
---|
306 | _insert_text(" ");
|
---|
307 | } while (p_col < iPosition);
|
---|
308 | }
|
---|
309 |
|
---|
310 | /* insert comment saving the position for _BEFORE. */
|
---|
311 | iCol = p_col;
|
---|
312 | _insert_text(sLeft:+' ':+sStr);
|
---|
313 | if (iCursor == KIC_CURSOR_AT_END)
|
---|
314 | iCol = p_col;
|
---|
315 | /* right comment delimiter? */
|
---|
316 | if (sRight != '')
|
---|
317 | _insert_text(' ':+sRight);
|
---|
318 | }
|
---|
319 | else
|
---|
320 | {
|
---|
321 | if (p_col >= iColumn)
|
---|
322 | _insert_text("\n");
|
---|
323 | do { _insert_text(" "); } while (p_col < iColumn);
|
---|
324 | if (iCursor == KIC_CURSOR_BEFORE)
|
---|
325 | iCol = p_col;
|
---|
326 | _insert_text(sLeft:+' ':+sStr);
|
---|
327 | if (iCursor == KIC_CURSOR_AT_END)
|
---|
328 | iCol = p_col;
|
---|
329 | }
|
---|
330 |
|
---|
331 | /* set cursor. */
|
---|
332 | if (iCursor != KIC_CURSOR_AFTER)
|
---|
333 | p_col = iCol;
|
---|
334 | }
|
---|
335 |
|
---|
336 |
|
---|
337 | /**
|
---|
338 | * Gets the comment prefix or postfix.
|
---|
339 | * @returns Comment prefix or postfix.
|
---|
340 | * @param fRight If clear left comment string - default.
|
---|
341 | * If set right comment string.
|
---|
342 | * @author knut st. osmundsen ([email protected])
|
---|
343 | */
|
---|
344 | static _str k_comment(boolean fRight = false)
|
---|
345 | {
|
---|
346 | _str sLeft, sRight;
|
---|
347 | int iColumn;
|
---|
348 | _str sComment = '/*';
|
---|
349 | if (k_commentconfig(sLeft, sRight, iColumn))
|
---|
350 | sComment = (!fRight || iColumn > 0 ? sLeft : sRight);
|
---|
351 |
|
---|
352 | return strip(sComment);
|
---|
353 | }
|
---|
354 |
|
---|
355 |
|
---|
356 | /*******************************************************************************
|
---|
357 | * BOXES *
|
---|
358 | *******************************************************************************/
|
---|
359 |
|
---|
360 | /**
|
---|
361 | * Inserts the first line in a box.
|
---|
362 | * @param sTag Not used - box tag.
|
---|
363 | */
|
---|
364 | static void k_box_start(sTag)
|
---|
365 | {
|
---|
366 | _str sLeft, sRight;
|
---|
367 | int iColumn;
|
---|
368 | if (!k_commentconfig(sLeft, sRight, iColumn))
|
---|
369 | return;
|
---|
370 | _begin_line();
|
---|
371 | if (iColumn >= 0)
|
---|
372 | while (p_col < iColumn)
|
---|
373 | _insert_text(" ");
|
---|
374 |
|
---|
375 | _str sText = sLeft;
|
---|
376 | if (sTag != '' && fkStyleBoxTag)
|
---|
377 | {
|
---|
378 | if (substr(sText, length(sText)) != '*')
|
---|
379 | sText = sText:+'*';
|
---|
380 | sText = sText:+sTag;
|
---|
381 | }
|
---|
382 |
|
---|
383 | int i;
|
---|
384 | for (i = length(sText); i <= ikStyleWidth - p_col; i++)
|
---|
385 | sText = sText:+'*';
|
---|
386 | sText = sText:+"\n";
|
---|
387 |
|
---|
388 | _insert_text(sText);
|
---|
389 | }
|
---|
390 |
|
---|
391 |
|
---|
392 | /**
|
---|
393 | * Places a string, sStr, into a line started and ended by '*'.
|
---|
394 | * @param sStr Text to have between the '*'s.
|
---|
395 | */
|
---|
396 | static void k_box_line(_str sStr)
|
---|
397 | {
|
---|
398 | _str sLeft, sRight;
|
---|
399 | int iColumn;
|
---|
400 | if (!k_commentconfig(sLeft, sRight, iColumn))
|
---|
401 | return;
|
---|
402 | if (iColumn >= 0)
|
---|
403 | while (p_col < iColumn)
|
---|
404 | _insert_text(" ");
|
---|
405 |
|
---|
406 | _str sText = '';
|
---|
407 | if (k_line_comment())
|
---|
408 | sText = sLeft;
|
---|
409 | if (sText == '' || substr(sText, length(sText)) != '*')
|
---|
410 | sText = sText:+'*';
|
---|
411 |
|
---|
412 | sText = sText:+' ';
|
---|
413 | int i;
|
---|
414 | for (i = length(sText); i < p_SyntaxIndent; i++)
|
---|
415 | sText = sText:+' ';
|
---|
416 |
|
---|
417 | sText = sText:+sStr;
|
---|
418 |
|
---|
419 | for (i = length(sText) + 1; i <= ikStyleWidth - p_col; i++)
|
---|
420 | sText = sText:+' ';
|
---|
421 | sText = sText:+"*\n";
|
---|
422 |
|
---|
423 | _insert_text(sText);
|
---|
424 | }
|
---|
425 |
|
---|
426 |
|
---|
427 | /**
|
---|
428 | * Inserts the last line in a box.
|
---|
429 | */
|
---|
430 | static void k_box_end()
|
---|
431 | {
|
---|
432 | _str sLeft, sRight;
|
---|
433 | int iColumn, i;
|
---|
434 | if (!k_commentconfig(sLeft, sRight, iColumn))
|
---|
435 | return;
|
---|
436 | if (iColumn >= 0)
|
---|
437 | while (p_col < iColumn)
|
---|
438 | _insert_text(" ");
|
---|
439 |
|
---|
440 | _str sText = '';
|
---|
441 | if (k_line_comment())
|
---|
442 | sText = sLeft;
|
---|
443 | for (i = length(sText) + length(sRight); i <= ikStyleWidth - p_col; i++)
|
---|
444 | sText = sText:+'*';
|
---|
445 | sText = sText:+sRight:+"\n";
|
---|
446 |
|
---|
447 | _insert_text(sText);
|
---|
448 | }
|
---|
449 |
|
---|
450 |
|
---|
451 |
|
---|
452 | /*******************************************************************************
|
---|
453 | * FUNCTION AND CODE PARSERS *
|
---|
454 | *******************************************************************************/
|
---|
455 | /**
|
---|
456 | * Moves cursor to nearest function start.
|
---|
457 | * @returns 0 if ok.
|
---|
458 | * -1 on failure.
|
---|
459 | */
|
---|
460 | static int k_func_goto_nearest_function()
|
---|
461 | {
|
---|
462 | boolean fFix = false; /* cursor at function fix. (last function) */
|
---|
463 | int cur_line = p_line;
|
---|
464 | int prev_line = -1;
|
---|
465 | int next_line = -1;
|
---|
466 | typeless org_pos;
|
---|
467 | _save_pos2(org_pos);
|
---|
468 |
|
---|
469 | if (!next_proc(1))
|
---|
470 | {
|
---|
471 | next_line = p_line;
|
---|
472 | if (!prev_proc(1) && p_line == cur_line)
|
---|
473 | {
|
---|
474 | _restore_pos2(org_pos);
|
---|
475 | return 0;
|
---|
476 | }
|
---|
477 | _restore_pos2(org_pos);
|
---|
478 | _save_pos2(org_pos);
|
---|
479 | }
|
---|
480 | else
|
---|
481 | {
|
---|
482 | p_col++; /* fixes problem with single function files. */
|
---|
483 | fFix = true;
|
---|
484 | }
|
---|
485 |
|
---|
486 | if (!prev_proc(1))
|
---|
487 | {
|
---|
488 | prev_line = p_line;
|
---|
489 | if (!next_proc(1) && p_line == cur_line)
|
---|
490 | {
|
---|
491 | _restore_pos2(org_pos);
|
---|
492 | return 0;
|
---|
493 | }
|
---|
494 | _restore_pos2(org_pos);
|
---|
495 | _save_pos2(org_pos);
|
---|
496 | }
|
---|
497 |
|
---|
498 |
|
---|
499 | if (prev_line != -1 && (next_line == -1 || cur_line - prev_line <= next_line - cur_line))
|
---|
500 | {
|
---|
501 | if (fFix)
|
---|
502 | p_col++;
|
---|
503 | prev_proc(1);
|
---|
504 | return 0;
|
---|
505 | }
|
---|
506 |
|
---|
507 | if (next_line != -1 && (prev_line == -1 || cur_line - prev_line > next_line - cur_line))
|
---|
508 | {
|
---|
509 | next_proc();
|
---|
510 | return 0;
|
---|
511 | }
|
---|
512 |
|
---|
513 | _restore_pos2(org_pos);
|
---|
514 | return -1;
|
---|
515 | }
|
---|
516 |
|
---|
517 |
|
---|
518 | /**
|
---|
519 | * Check if nearest function is a prototype.
|
---|
520 | * @returns True if function prototype.
|
---|
521 | * False if not function prototype.
|
---|
522 | */
|
---|
523 | static boolean k_func_prototype()
|
---|
524 | {
|
---|
525 | /*
|
---|
526 | * Check if this is a real function implementation.
|
---|
527 | */
|
---|
528 | typeless procpos;
|
---|
529 | _save_pos2(procpos);
|
---|
530 | if (!k_func_goto_nearest_function())
|
---|
531 | {
|
---|
532 | int proc_line = p_line;
|
---|
533 |
|
---|
534 | if (!k_func_searchcode("{"))
|
---|
535 | {
|
---|
536 | prev_proc();
|
---|
537 | if (p_line != proc_line)
|
---|
538 | {
|
---|
539 | _restore_pos2(procpos);
|
---|
540 | return true;
|
---|
541 | }
|
---|
542 | }
|
---|
543 | }
|
---|
544 | _restore_pos2(procpos);
|
---|
545 |
|
---|
546 | return false;
|
---|
547 | }
|
---|
548 |
|
---|
549 |
|
---|
550 | /**
|
---|
551 | * Gets the name fo the current function.
|
---|
552 | * @returns The current function name.
|
---|
553 | */
|
---|
554 | static _str k_func_getfunction_name()
|
---|
555 | {
|
---|
556 | _str sFunctionName = current_proc();
|
---|
557 | if (!sFunctionName)
|
---|
558 | sFunctionName = "";
|
---|
559 | //say 'functionanme='sFunctionName;
|
---|
560 | return sFunctionName;
|
---|
561 | }
|
---|
562 |
|
---|
563 |
|
---|
564 | /**
|
---|
565 | * Goes to the neares function and gets its parameters.
|
---|
566 | * @remark Should be reimplemented to use tags (if someone can figure out how to query that stuff).
|
---|
567 | */
|
---|
568 | static _str k_func_getparams()
|
---|
569 | {
|
---|
570 | typeless org_pos;
|
---|
571 | _save_pos2(org_pos);
|
---|
572 |
|
---|
573 | /*
|
---|
574 | * Try use the tags first.
|
---|
575 | */
|
---|
576 | _UpdateContext(true);
|
---|
577 | int context_id = tag_current_context();
|
---|
578 | if (context_id <= 0)
|
---|
579 | {
|
---|
580 | k_func_goto_nearest_function();
|
---|
581 | context_id = tag_current_context();
|
---|
582 | }
|
---|
583 | if (context_id > 0)
|
---|
584 | {
|
---|
585 | _str args = '';
|
---|
586 | _str type = '';
|
---|
587 | tag_get_detail2(VS_TAGDETAIL_context_args, context_id, args);
|
---|
588 | tag_get_detail2(VS_TAGDETAIL_context_type, context_id, type);
|
---|
589 | if (tag_tree_type_is_func(type))
|
---|
590 | return args
|
---|
591 | //caption = tag_tree_make_caption_fast(VS_TAGMATCH_context,context_id,true,true,false);
|
---|
592 | }
|
---|
593 |
|
---|
594 | /*
|
---|
595 | * Go to nearest function.
|
---|
596 | */
|
---|
597 | if ( !k_func_goto_nearest_function()
|
---|
598 | && !k_func_searchcode("(") /* makes some assumptions. */
|
---|
599 | )
|
---|
600 | {
|
---|
601 | /*
|
---|
602 | * Get parameters.
|
---|
603 | */
|
---|
604 | typeless posStart;
|
---|
605 | _save_pos2(posStart);
|
---|
606 | long offStart = _QROffset();
|
---|
607 | if (!find_matching_paren())
|
---|
608 | {
|
---|
609 | long offEnd = _QROffset();
|
---|
610 | _restore_pos2(posStart);
|
---|
611 | p_col++;
|
---|
612 | _str sParamsRaw = strip(get_text((int)(offEnd - offStart - 1)));
|
---|
613 |
|
---|
614 |
|
---|
615 | /*
|
---|
616 | * Remove new lines and double spaces within params.
|
---|
617 | */
|
---|
618 | _str sParams = "";
|
---|
619 |
|
---|
620 | int i;
|
---|
621 | _str chPrev;
|
---|
622 | for (i = 1, chPrev = ' '; i <= length(sParamsRaw); i++)
|
---|
623 | {
|
---|
624 | _str ch = substr(sParamsRaw, i, 1);
|
---|
625 |
|
---|
626 | /*
|
---|
627 | * Do fixups.
|
---|
628 | */
|
---|
629 | if (ch == " " && chPrev == " ")
|
---|
630 | continue;
|
---|
631 |
|
---|
632 | if ((ch :== "\n") || (ch :== "\r") || (ch :== "\t"))
|
---|
633 | {
|
---|
634 | if (chPrev == ' ')
|
---|
635 | continue;
|
---|
636 | ch = ' ';
|
---|
637 | }
|
---|
638 |
|
---|
639 | if (ch == ',' && chPrev == ' ')
|
---|
640 | {
|
---|
641 | sParams = substr(sParams, 1, length(sParams) - 1);
|
---|
642 | }
|
---|
643 |
|
---|
644 | if (ch == '*')
|
---|
645 | {
|
---|
646 | if (chPrev != ' ')
|
---|
647 | sParams = sParams :+ ' * ';
|
---|
648 | else
|
---|
649 | sParams = sParams :+ '* ';
|
---|
650 | chPrev = ' ';
|
---|
651 | }
|
---|
652 | else
|
---|
653 | {
|
---|
654 | sParams = sParams :+ ch;
|
---|
655 | chPrev = ch;
|
---|
656 | }
|
---|
657 |
|
---|
658 | } /* for */
|
---|
659 |
|
---|
660 | sParams = strip(sParams);
|
---|
661 | if (sParams == 'void' || sParams == 'VOID')
|
---|
662 | sParams = "";
|
---|
663 | _restore_pos2(org_pos);
|
---|
664 | return sParams;
|
---|
665 | }
|
---|
666 | else
|
---|
667 | message("find_matchin_paren failed");
|
---|
668 | }
|
---|
669 |
|
---|
670 | _restore_pos2(org_pos);
|
---|
671 | return false;
|
---|
672 | }
|
---|
673 |
|
---|
674 |
|
---|
675 |
|
---|
676 | /**
|
---|
677 | * Enumerates the parameters to the function.
|
---|
678 | * @param sParams Parameter string from k_func_getparams.
|
---|
679 | * @param iParam The index (0-based) of the parameter to get.
|
---|
680 | * @param sType Type. (output)
|
---|
681 | * @param sName Name. (output)
|
---|
682 | * @param sDefault Default value. (output)
|
---|
683 | * @remark Doesn't perhaps handle function pointers very well (I think)?
|
---|
684 | * @remark Should be reimplemented to use tags (if someone can figure out how to query that stuff).
|
---|
685 | */
|
---|
686 | static int k_func_enumparams(_str sParams, int iParam, _str &sType, _str &sName, _str &sDefault)
|
---|
687 | {
|
---|
688 | int i;
|
---|
689 | int iParLevel;
|
---|
690 | int iCurParam;
|
---|
691 | int iStartParam;
|
---|
692 |
|
---|
693 | sType = sName = sDefault = "";
|
---|
694 |
|
---|
695 | /* no use working on empty string! */
|
---|
696 | if (length(sParams) == 0)
|
---|
697 | return -1;
|
---|
698 |
|
---|
699 | /* find the parameter in question */
|
---|
700 | for (iStartParam = i = 1, iParLevel = iCurParam = 0; i <= length(sParams); i++)
|
---|
701 | {
|
---|
702 | _str ch = substr(sParams, i, 1);
|
---|
703 | if (ch == ',' && iParLevel == 0)
|
---|
704 | {
|
---|
705 | /* is it this parameter ? */
|
---|
706 | if (iParam == iCurParam)
|
---|
707 | break;
|
---|
708 |
|
---|
709 | iCurParam++;
|
---|
710 | iStartParam = i + 1;
|
---|
711 | }
|
---|
712 | else if (ch == '(')
|
---|
713 | iParLevel++;
|
---|
714 | else if (ch == ')')
|
---|
715 | iParLevel--;
|
---|
716 | }
|
---|
717 |
|
---|
718 | /* did we find the parameter? */
|
---|
719 | if (iParam == iCurParam)
|
---|
720 | { /* (yeah, we did!) */
|
---|
721 | _str sArg = strip(substr(sParams, iStartParam, i - iStartParam));
|
---|
722 | /* remove M$ stuff */
|
---|
723 | sArg = stranslate(sArg, "", "IN", "E");
|
---|
724 | sArg = stranslate(sArg, "", "OUT", "E");
|
---|
725 | sArg = stranslate(sArg, "", "OPTIONAL", "E");
|
---|
726 | sArg = strip(sArg);
|
---|
727 |
|
---|
728 | /* lazy approach, which doens't support function types */
|
---|
729 |
|
---|
730 | if (pos('=', sParams) > 0) /* default */
|
---|
731 | {
|
---|
732 | sDefault = strip(substr(sParams, pos('=', sParams) + 1));
|
---|
733 | sArg = strip(substr(sArg, 1, pos('=', sParams) - 1));
|
---|
734 | }
|
---|
735 |
|
---|
736 | for (i = length(sArg); i > 1; i--)
|
---|
737 | {
|
---|
738 | _str ch = substr(sArg, i, 1);
|
---|
739 | if ( !(ch >= 'a' && ch <= 'z')
|
---|
740 | && !(ch >= 'A' && ch <= 'Z')
|
---|
741 | && !(ch >= '0' && ch <= '9')
|
---|
742 | && ch != '_' && ch != '$')
|
---|
743 | break;
|
---|
744 | }
|
---|
745 | if (sArg == "...")
|
---|
746 | i = 0;
|
---|
747 | sName = strip(substr(sArg, i + 1));
|
---|
748 | sType = strip(substr(sArg, 1, i));
|
---|
749 |
|
---|
750 | return 0;
|
---|
751 | }
|
---|
752 |
|
---|
753 | return -1;
|
---|
754 | }
|
---|
755 |
|
---|
756 |
|
---|
757 | /**
|
---|
758 | * Counts the parameters to the function.
|
---|
759 | * @param sParams Parameter string from k_func_getparams.
|
---|
760 | * @remark Should be reimplemented to use tags (if someone can figure out how to query that stuff).
|
---|
761 | */
|
---|
762 | static int k_func_countparams(_str sParams)
|
---|
763 | {
|
---|
764 | int i;
|
---|
765 | int iParLevel;
|
---|
766 | int iCurParam;
|
---|
767 | _str sType = "", sName = "", sDefault = "";
|
---|
768 |
|
---|
769 | /* check for 0 parameters */
|
---|
770 | if (length(sParams) == 0)
|
---|
771 | return 0;
|
---|
772 |
|
---|
773 | /* find the parameter in question */
|
---|
774 | for (i = 1, iParLevel = iCurParam = 0; i <= length(sParams); i++)
|
---|
775 | {
|
---|
776 | _str ch = substr(sParams, i, 1);
|
---|
777 | if (ch == ',' && iParLevel == 0)
|
---|
778 | {
|
---|
779 | iCurParam++;
|
---|
780 | }
|
---|
781 | else if (ch == '(')
|
---|
782 | iParLevel++;
|
---|
783 | else if (ch == ')')
|
---|
784 | iParLevel--;
|
---|
785 | }
|
---|
786 |
|
---|
787 | return iCurParam + 1;
|
---|
788 | }
|
---|
789 |
|
---|
790 |
|
---|
791 | /**
|
---|
792 | * Gets the return type.
|
---|
793 | */
|
---|
794 | static _str k_func_getreturntype(boolean fPureType = false)
|
---|
795 | {
|
---|
796 | typeless org_pos;
|
---|
797 | _save_pos2(org_pos);
|
---|
798 |
|
---|
799 | /*
|
---|
800 | * Go to nearest function.
|
---|
801 | */
|
---|
802 | if (!k_func_goto_nearest_function())
|
---|
803 | {
|
---|
804 | /*
|
---|
805 | * Return type is from function start to function name...
|
---|
806 | */
|
---|
807 | typeless posStart;
|
---|
808 | _save_pos2(posStart);
|
---|
809 | long offStart = _QROffset();
|
---|
810 |
|
---|
811 | if (!k_func_searchcode("(")) /* makes some assumptions. */
|
---|
812 | {
|
---|
813 | prev_word();
|
---|
814 | long offEnd = _QROffset();
|
---|
815 | _restore_pos2(posStart);
|
---|
816 | _str sTypeRaw = strip(get_text((int)(offEnd - offStart)));
|
---|
817 |
|
---|
818 | //say 'sTypeRaw='sTypeRaw;
|
---|
819 | /*
|
---|
820 | * Remove static, inline, _Optlink, stdcall, EXPENTRY etc.
|
---|
821 | */
|
---|
822 | if (fPureType)
|
---|
823 | {
|
---|
824 | sTypeRaw = stranslate(sTypeRaw, "", "__static__", "I");
|
---|
825 | sTypeRaw = stranslate(sTypeRaw, "", "__static", "I");
|
---|
826 | sTypeRaw = stranslate(sTypeRaw, "", "static__", "I");
|
---|
827 | sTypeRaw = stranslate(sTypeRaw, "", "static", "I");
|
---|
828 | sTypeRaw = stranslate(sTypeRaw, "", "__inline__", "I");
|
---|
829 | sTypeRaw = stranslate(sTypeRaw, "", "__inline", "I");
|
---|
830 | sTypeRaw = stranslate(sTypeRaw, "", "inline__", "I");
|
---|
831 | sTypeRaw = stranslate(sTypeRaw, "", "inline", "I");
|
---|
832 | sTypeRaw = stranslate(sTypeRaw, "", "EXPENTRY", "I");
|
---|
833 | sTypeRaw = stranslate(sTypeRaw, "", "_Optlink", "I");
|
---|
834 | sTypeRaw = stranslate(sTypeRaw, "", "__stdcall", "I");
|
---|
835 | sTypeRaw = stranslate(sTypeRaw, "", "__cdecl", "I");
|
---|
836 | sTypeRaw = stranslate(sTypeRaw, "", "_cdecl", "I");
|
---|
837 | sTypeRaw = stranslate(sTypeRaw, "", "cdecl", "I");
|
---|
838 | sTypeRaw = stranslate(sTypeRaw, "", "__PASCAL", "I");
|
---|
839 | sTypeRaw = stranslate(sTypeRaw, "", "_PASCAL", "I");
|
---|
840 | sTypeRaw = stranslate(sTypeRaw, "", "PASCAL", "I");
|
---|
841 | sTypeRaw = stranslate(sTypeRaw, "", "__Far32__", "I");
|
---|
842 | sTypeRaw = stranslate(sTypeRaw, "", "__Far32", "I");
|
---|
843 | sTypeRaw = stranslate(sTypeRaw, "", "Far32__", "I");
|
---|
844 | sTypeRaw = stranslate(sTypeRaw, "", "_Far32_", "I");
|
---|
845 | sTypeRaw = stranslate(sTypeRaw, "", "_Far32", "I");
|
---|
846 | sTypeRaw = stranslate(sTypeRaw, "", "Far32_", "I");
|
---|
847 | sTypeRaw = stranslate(sTypeRaw, "", "Far32", "I");
|
---|
848 | sTypeRaw = stranslate(sTypeRaw, "", "__far", "I");
|
---|
849 | sTypeRaw = stranslate(sTypeRaw, "", "_far", "I");
|
---|
850 | sTypeRaw = stranslate(sTypeRaw, "", "far", "I");
|
---|
851 | sTypeRaw = stranslate(sTypeRaw, "", "__near", "I");
|
---|
852 | sTypeRaw = stranslate(sTypeRaw, "", "_near", "I");
|
---|
853 | sTypeRaw = stranslate(sTypeRaw, "", "near", "I");
|
---|
854 | sTypeRaw = stranslate(sTypeRaw, "", "__loadds__", "I");
|
---|
855 | sTypeRaw = stranslate(sTypeRaw, "", "__loadds", "I");
|
---|
856 | sTypeRaw = stranslate(sTypeRaw, "", "loadds__", "I");
|
---|
857 | sTypeRaw = stranslate(sTypeRaw, "", "_loadds_", "I");
|
---|
858 | sTypeRaw = stranslate(sTypeRaw, "", "_loadds", "I");
|
---|
859 | sTypeRaw = stranslate(sTypeRaw, "", "loadds_", "I");
|
---|
860 | sTypeRaw = stranslate(sTypeRaw, "", "loadds", "I");
|
---|
861 | sTypeRaw = stranslate(sTypeRaw, "", "__loades__", "I");
|
---|
862 | sTypeRaw = stranslate(sTypeRaw, "", "__loades", "I");
|
---|
863 | sTypeRaw = stranslate(sTypeRaw, "", "loades__", "I");
|
---|
864 | sTypeRaw = stranslate(sTypeRaw, "", "_loades_", "I");
|
---|
865 | sTypeRaw = stranslate(sTypeRaw, "", "_loades", "I");
|
---|
866 | sTypeRaw = stranslate(sTypeRaw, "", "loades_", "I");
|
---|
867 | sTypeRaw = stranslate(sTypeRaw, "", "loades", "I");
|
---|
868 | sTypeRaw = stranslate(sTypeRaw, "", "WIN32API", "I");
|
---|
869 | sTypeRaw = stranslate(sTypeRaw, "", "WINAPI", "I");
|
---|
870 | sTypeRaw = stranslate(sTypeRaw, "", "LDRCALL", "I");
|
---|
871 | sTypeRaw = stranslate(sTypeRaw, "", "KRNLCALL", "I");
|
---|
872 | sTypeRaw = stranslate(sTypeRaw, "", "__operator__", "I"); /* operator fix */
|
---|
873 | sTypeRaw = stranslate(sTypeRaw, "", "__operator", "I"); /* operator fix */
|
---|
874 | sTypeRaw = stranslate(sTypeRaw, "", "operator__", "I"); /* operator fix */
|
---|
875 | sTypeRaw = stranslate(sTypeRaw, "", "operator", "I"); /* operator fix */
|
---|
876 | sTypeRaw = stranslate(sTypeRaw, "", "IN", "E");
|
---|
877 | sTypeRaw = stranslate(sTypeRaw, "", "OUT", "E");
|
---|
878 | sTypeRaw = stranslate(sTypeRaw, "", "OPTIONAL", "E");
|
---|
879 | }
|
---|
880 |
|
---|
881 | /*
|
---|
882 | * Remove new lines and double spaces within params.
|
---|
883 | */
|
---|
884 | _str sType = "";
|
---|
885 |
|
---|
886 | int i;
|
---|
887 | _str chPrev;
|
---|
888 | for (i = 1, chPrev = ' '; i <= length(sTypeRaw); i++)
|
---|
889 | {
|
---|
890 | _str ch = substr(sTypeRaw, i, 1);
|
---|
891 |
|
---|
892 | /*
|
---|
893 | * Do fixups.
|
---|
894 | */
|
---|
895 | if (ch == " " && chPrev == " ")
|
---|
896 | continue;
|
---|
897 |
|
---|
898 | if ((ch :== "\n") || (ch :== "\r") || (ch :== "\t"))
|
---|
899 | {
|
---|
900 | if (chPrev == ' ')
|
---|
901 | continue;
|
---|
902 | ch = ' ';
|
---|
903 | }
|
---|
904 |
|
---|
905 | if (ch == ',' && chPrev == ' ')
|
---|
906 | {
|
---|
907 | sType = substr(sType, 1, length(sType) - 1);
|
---|
908 | }
|
---|
909 |
|
---|
910 | if (ch == '*')
|
---|
911 | {
|
---|
912 | if (chPrev != ' ')
|
---|
913 | sType = sType :+ ' * ';
|
---|
914 | else
|
---|
915 | sType = sType :+ '* ';
|
---|
916 | chPrev = ' ';
|
---|
917 | }
|
---|
918 | else
|
---|
919 | {
|
---|
920 | sType = sType :+ ch;
|
---|
921 | chPrev = ch;
|
---|
922 | }
|
---|
923 |
|
---|
924 | } /* for */
|
---|
925 |
|
---|
926 | sType = strip(sType);
|
---|
927 |
|
---|
928 | _restore_pos2(org_pos);
|
---|
929 | return sType;
|
---|
930 | }
|
---|
931 | else
|
---|
932 | message('k_func_getreturntype: can''t find ''(''.');
|
---|
933 | }
|
---|
934 |
|
---|
935 | _restore_pos2(org_pos);
|
---|
936 | return false;
|
---|
937 | }
|
---|
938 |
|
---|
939 |
|
---|
940 | /**
|
---|
941 | * Search for some piece of code.
|
---|
942 | */
|
---|
943 | static int k_func_searchcode(_str sSearchString, _str sOptions = "E+")
|
---|
944 | {
|
---|
945 | int rc;
|
---|
946 | rc = search(sSearchString, sOptions);
|
---|
947 | while (!rc && !k_func_in_code())
|
---|
948 | {
|
---|
949 | p_col++;
|
---|
950 | rc = search(sSearchString, sOptions);
|
---|
951 | }
|
---|
952 | return rc;
|
---|
953 | }
|
---|
954 |
|
---|
955 |
|
---|
956 | /**
|
---|
957 | * Checks if cursor is in code or in comment.
|
---|
958 | * @return True if cursor in code.
|
---|
959 | */
|
---|
960 | static boolean k_func_in_code()
|
---|
961 | {
|
---|
962 | typeless searchsave;
|
---|
963 | _save_pos2(searchsave);
|
---|
964 | boolean fRc = !_in_comment();
|
---|
965 | _restore_pos2(searchsave);
|
---|
966 | return fRc;
|
---|
967 | }
|
---|
968 |
|
---|
969 |
|
---|
970 | /*
|
---|
971 | * Gets the next piece of code.
|
---|
972 | */
|
---|
973 | static _str k_func_get_next_code_text()
|
---|
974 | {
|
---|
975 | typeless searchsave;
|
---|
976 | _save_pos2(searchsave);
|
---|
977 | _str ch = k_func_get_next_code_text2();
|
---|
978 | _restore_pos2(searchsave);
|
---|
979 | return ch;
|
---|
980 | }
|
---|
981 |
|
---|
982 |
|
---|
983 | /**
|
---|
984 | * Checks if there is more code on the line.
|
---|
985 | */
|
---|
986 | static boolean k_func_more_code_on_line()
|
---|
987 | {
|
---|
988 | boolean fRc;
|
---|
989 | int curline = p_line;
|
---|
990 | typeless searchsave;
|
---|
991 | _save_pos2(searchsave);
|
---|
992 | k_func_get_next_code_text2();
|
---|
993 | fRc = curline == p_line;
|
---|
994 | _restore_pos2(searchsave);
|
---|
995 |
|
---|
996 | return fRc;
|
---|
997 | }
|
---|
998 |
|
---|
999 |
|
---|
1000 | /**
|
---|
1001 | * Gets the next piece of code.
|
---|
1002 | * Doesn't preserver cursor position.
|
---|
1003 | */
|
---|
1004 | static _str k_func_get_next_code_text2()
|
---|
1005 | {
|
---|
1006 | _str ch;
|
---|
1007 | do
|
---|
1008 | {
|
---|
1009 | int curcol = ++p_col;
|
---|
1010 | end_line();
|
---|
1011 | if (p_col <= curcol)
|
---|
1012 | {
|
---|
1013 | p_line++;
|
---|
1014 | p_col = 1;
|
---|
1015 | }
|
---|
1016 | else
|
---|
1017 | p_col = curcol;
|
---|
1018 |
|
---|
1019 | ch = get_text();
|
---|
1020 | //say ch ' ('_asc(ch)')';
|
---|
1021 | while (ch == "#") /* preprocessor stuff */
|
---|
1022 | {
|
---|
1023 | p_col = 1;
|
---|
1024 | p_line++;
|
---|
1025 | ch = get_text();
|
---|
1026 | //say ch ' ('_asc(ch)')';
|
---|
1027 | continue;
|
---|
1028 | }
|
---|
1029 | } while (ch :== ' ' || ch :== "\t" || ch :== "\n" || ch :== "\r" || !k_func_in_code());
|
---|
1030 |
|
---|
1031 | return ch;
|
---|
1032 | }
|
---|
1033 |
|
---|
1034 |
|
---|
1035 |
|
---|
1036 |
|
---|
1037 | /*******************************************************************************
|
---|
1038 | * JAVA DOC STYLED WORKERS *
|
---|
1039 | *******************************************************************************/
|
---|
1040 |
|
---|
1041 | /** starts a javadoc documentation box. */
|
---|
1042 | static void k_javadoc_box_start(_str sStr = '', boolean fDouble = true)
|
---|
1043 | {
|
---|
1044 | _str sLeft, sRight;
|
---|
1045 | int iColumn;
|
---|
1046 | if (!k_commentconfig(sLeft, sRight, iColumn))
|
---|
1047 | return;
|
---|
1048 | _begin_line();
|
---|
1049 | if (iColumn >= 0)
|
---|
1050 | while (p_col < iColumn)
|
---|
1051 | _insert_text(" ");
|
---|
1052 |
|
---|
1053 | _str sText = sLeft;
|
---|
1054 | if (fDouble)
|
---|
1055 | sText = sLeft:+substr(sLeft, length(sLeft), 1);
|
---|
1056 | if (sStr != '')
|
---|
1057 | sText = sText:+' ':+sStr;
|
---|
1058 | sText = sText:+"\n";
|
---|
1059 |
|
---|
1060 | _insert_text(sText);
|
---|
1061 | }
|
---|
1062 |
|
---|
1063 | /** inserts a new line in a javadoc documentation box. */
|
---|
1064 | static void k_javadoc_box_line(_str sStr = '', int iPadd = 0, _str sStr2 = '', int iPadd2 = 0, _str sStr3 = '')
|
---|
1065 | {
|
---|
1066 | _str sLeft, sRight;
|
---|
1067 | int iColumn;
|
---|
1068 | if (!k_commentconfig(sLeft, sRight, iColumn))
|
---|
1069 | return;
|
---|
1070 | if (iColumn >= 0)
|
---|
1071 | while (p_col < iColumn)
|
---|
1072 | _insert_text(" ");
|
---|
1073 |
|
---|
1074 | _str sText;
|
---|
1075 | if (k_line_comment())
|
---|
1076 | sText = sLeft;
|
---|
1077 | else
|
---|
1078 | {
|
---|
1079 | sText = sLeft;
|
---|
1080 | sText = ' ':+substr(sLeft, length(sLeft));
|
---|
1081 | }
|
---|
1082 |
|
---|
1083 | if (sStr != '')
|
---|
1084 | sText = sText:+' ':+sStr;
|
---|
1085 | if (iPadd > 0)
|
---|
1086 | {
|
---|
1087 | int i;
|
---|
1088 | for (i = length(sText); i < iPadd; i++)
|
---|
1089 | sText = sText:+' ';
|
---|
1090 |
|
---|
1091 | if (sStr2 != '')
|
---|
1092 | sText = sText:+sStr2;
|
---|
1093 |
|
---|
1094 | if (iPadd2 > 0)
|
---|
1095 | {
|
---|
1096 | for (i = length(sText); i < iPadd2; i++)
|
---|
1097 | sText = sText:+' ';
|
---|
1098 |
|
---|
1099 | if (sStr3 != '')
|
---|
1100 | sText = sText:+sStr3;
|
---|
1101 | }
|
---|
1102 | }
|
---|
1103 | sText = sText:+"\n";
|
---|
1104 |
|
---|
1105 | _insert_text(sText);
|
---|
1106 | }
|
---|
1107 |
|
---|
1108 | /** ends a javadoc documentation box. */
|
---|
1109 | static void k_javadoc_box_end()
|
---|
1110 | {
|
---|
1111 | _str sLeft, sRight;
|
---|
1112 | int iColumn;
|
---|
1113 | if (!k_commentconfig(sLeft, sRight, iColumn))
|
---|
1114 | return;
|
---|
1115 | if (iColumn >= 0)
|
---|
1116 | while (p_col < iColumn)
|
---|
1117 | _insert_text(" ");
|
---|
1118 |
|
---|
1119 | _str sText;
|
---|
1120 | if (k_line_comment())
|
---|
1121 | sText = sLeft;
|
---|
1122 | else
|
---|
1123 | {
|
---|
1124 | sText = sRight;
|
---|
1125 | /*if (substr(sText, 1, 1) != '*')
|
---|
1126 | sText = '*':+sText;*/
|
---|
1127 | sText = ' ':+sText;
|
---|
1128 | }
|
---|
1129 | sText = sText:+"\n";
|
---|
1130 |
|
---|
1131 | _insert_text(sText);
|
---|
1132 | }
|
---|
1133 |
|
---|
1134 |
|
---|
1135 | /**
|
---|
1136 | * Write a Javadoc styled classbox.
|
---|
1137 | */
|
---|
1138 | void k_javadoc_classbox()
|
---|
1139 | {
|
---|
1140 | int iCursorLine;
|
---|
1141 | int iPadd = k_alignup(12, p_SyntaxIndent);
|
---|
1142 |
|
---|
1143 | k_javadoc_box_start();
|
---|
1144 | iCursorLine = p_RLine;
|
---|
1145 | k_javadoc_box_line(' ');
|
---|
1146 |
|
---|
1147 | if (fkStyleFullHeaders)
|
---|
1148 | {
|
---|
1149 | k_javadoc_box_line('@shortdesc', iPadd);
|
---|
1150 | k_javadoc_box_line('@dstruct', iPadd);
|
---|
1151 | k_javadoc_box_line('@version', iPadd);
|
---|
1152 | k_javadoc_box_line('@verdesc', iPadd);
|
---|
1153 | }
|
---|
1154 | k_javadoc_box_line('@author', iPadd, skUserName ' <' skUserEmail '>');
|
---|
1155 | k_javadoc_box_line('@approval', iPadd);
|
---|
1156 | k_javadoc_box_end();
|
---|
1157 |
|
---|
1158 | up(p_RLine - iCursorLine);
|
---|
1159 | end_line();
|
---|
1160 | keyin(' ');
|
---|
1161 | }
|
---|
1162 |
|
---|
1163 |
|
---|
1164 | /**
|
---|
1165 | * Javadoc - functionbox(/header).
|
---|
1166 | */
|
---|
1167 | void k_javadoc_funcbox()
|
---|
1168 | {
|
---|
1169 | int cArgs = 1;
|
---|
1170 | _str sArgs = "";
|
---|
1171 | int iCursorLine;
|
---|
1172 | int iPadd = k_alignup(11, p_SyntaxIndent);
|
---|
1173 | /* look for parameters */
|
---|
1174 | boolean fFoundFn = !k_func_goto_nearest_function();
|
---|
1175 | if (fFoundFn)
|
---|
1176 | {
|
---|
1177 | sArgs = k_func_getparams();
|
---|
1178 | cArgs = k_func_countparams(sArgs);
|
---|
1179 | }
|
---|
1180 |
|
---|
1181 | k_javadoc_box_start();
|
---|
1182 | iCursorLine = p_RLine;
|
---|
1183 | k_javadoc_box_line(' ');
|
---|
1184 | if (file_eq(p_extension, 'asm'))
|
---|
1185 | k_javadoc_box_line('@cproto', iPadd);
|
---|
1186 | k_javadoc_box_line('@returns', iPadd);
|
---|
1187 | if (fFoundFn)
|
---|
1188 | {
|
---|
1189 | /*
|
---|
1190 | * Determin parameter description indent.
|
---|
1191 | */
|
---|
1192 | int iPadd2 = 0;
|
---|
1193 | int i;
|
---|
1194 | for (i = 0; i < cArgs; i++)
|
---|
1195 | {
|
---|
1196 | _str sName, sType, sDefault;
|
---|
1197 | if (!k_func_enumparams(sArgs, i, sType, sName, sDefault)
|
---|
1198 | && iPadd2 < length(sName))
|
---|
1199 | iPadd2 = length(sName);
|
---|
1200 | }
|
---|
1201 | iPadd2 = k_alignup((iPadd + iPadd2), p_SyntaxIndent);
|
---|
1202 |
|
---|
1203 | /*
|
---|
1204 | * Insert parameter.
|
---|
1205 | */
|
---|
1206 | for (i = 0; i < cArgs; i++)
|
---|
1207 | {
|
---|
1208 | _str sName, sType, sDefault;
|
---|
1209 | if (!k_func_enumparams(sArgs, i, sType, sName, sDefault))
|
---|
1210 | {
|
---|
1211 | _str sStr3 = '';
|
---|
1212 | if (sDefault != "")
|
---|
1213 | sStr3 = '(default='sDefault')';
|
---|
1214 | k_javadoc_box_line('@param', iPadd, sName, iPadd2, sStr3);
|
---|
1215 | }
|
---|
1216 | else
|
---|
1217 | k_javadoc_box_line('@param', iPadd);
|
---|
1218 | }
|
---|
1219 | }
|
---|
1220 | else
|
---|
1221 | k_javadoc_box_line('@param', iPadd);
|
---|
1222 |
|
---|
1223 | if (file_eq(p_extension, 'asm'))
|
---|
1224 | k_javadoc_box_line('@uses', iPadd);
|
---|
1225 | if (fkStyleFullHeaders)
|
---|
1226 | {
|
---|
1227 | k_javadoc_box_line('@equiv', iPadd);
|
---|
1228 | k_javadoc_box_line('@time', iPadd);
|
---|
1229 | k_javadoc_box_line('@sketch', iPadd);
|
---|
1230 | k_javadoc_box_line('@status', iPadd);
|
---|
1231 | k_javadoc_box_line('@author', iPadd, skUserName ' <' skUserEmail '>');
|
---|
1232 | k_javadoc_box_line('@remark', iPadd);
|
---|
1233 | }
|
---|
1234 | k_javadoc_box_end();
|
---|
1235 |
|
---|
1236 | up(p_RLine - iCursorLine);
|
---|
1237 | end_line();
|
---|
1238 | keyin(' ');
|
---|
1239 | }
|
---|
1240 |
|
---|
1241 |
|
---|
1242 | /**
|
---|
1243 | * Javadoc module header.
|
---|
1244 | */
|
---|
1245 | void k_javadoc_moduleheader()
|
---|
1246 | {
|
---|
1247 | int iCursorLine;
|
---|
1248 |
|
---|
1249 | _begin_line();
|
---|
1250 | k_insert_comment('$':+'I':+'d: $', KIC_CURSOR_AT_END, -1);
|
---|
1251 | _end_line();
|
---|
1252 | _insert_text("\n");
|
---|
1253 |
|
---|
1254 | k_javadoc_box_start('@file');
|
---|
1255 | k_javadoc_box_line();
|
---|
1256 | iCursorLine = p_RLine;
|
---|
1257 | k_javadoc_box_line();
|
---|
1258 | k_javadoc_box_line();
|
---|
1259 |
|
---|
1260 | if (skLicense == 'Confidential')
|
---|
1261 | {
|
---|
1262 | k_javadoc_box_line(skCompany ' confidential');
|
---|
1263 | k_javadoc_box_line();
|
---|
1264 | }
|
---|
1265 |
|
---|
1266 | if (skCompany != '')
|
---|
1267 | {
|
---|
1268 | k_javadoc_box_line('Copyright (c) ' k_year() ' ' skCompany);
|
---|
1269 | k_javadoc_box_line();
|
---|
1270 | k_javadoc_box_line('Author: ' skUserName' <' skUserEmail '>');
|
---|
1271 | }
|
---|
1272 | else
|
---|
1273 | k_javadoc_box_line('Copyright (c) ' k_year() ' 'skUserName' <' skUserEmail '>');
|
---|
1274 | k_javadoc_box_line();
|
---|
1275 | switch (skLicense)
|
---|
1276 | {
|
---|
1277 | case 'Odin32':
|
---|
1278 | k_javadoc_box_line('Project Odin Software License can be found in LICENSE.TXT.');
|
---|
1279 | break;
|
---|
1280 |
|
---|
1281 | case 'GPL':
|
---|
1282 | _str sProg = skProgram;
|
---|
1283 | k_javadoc_box_line();
|
---|
1284 | if (sProg == '')
|
---|
1285 | sProg = 'This program';
|
---|
1286 | else
|
---|
1287 | {
|
---|
1288 | k_javadoc_box_line('This file is part of ' sProg '.');
|
---|
1289 | k_javadoc_box_line();
|
---|
1290 | }
|
---|
1291 | k_javadoc_box_line(sProg ' is free software; you can redistribute it and/or modify');
|
---|
1292 | k_javadoc_box_line('it under the terms of the GNU General Public License as published by');
|
---|
1293 | k_javadoc_box_line('the Free Software Foundation; either version 2 of the License, or');
|
---|
1294 | k_javadoc_box_line('(at your option) any later version.');
|
---|
1295 | k_javadoc_box_line();
|
---|
1296 | k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful,');
|
---|
1297 | k_javadoc_box_line('but WITHOUT ANY WARRANTY; without even the implied warranty of');
|
---|
1298 | k_javadoc_box_line('MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the');
|
---|
1299 | k_javadoc_box_line('GNU General Public License for more details.');
|
---|
1300 | k_javadoc_box_line();
|
---|
1301 | k_javadoc_box_line('You should have received a copy of the GNU General Public License');
|
---|
1302 | k_javadoc_box_line('along with ' sProg '; if not, write to the Free Software');
|
---|
1303 | k_javadoc_box_line('Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA');
|
---|
1304 | break;
|
---|
1305 |
|
---|
1306 | case 'LGPL':
|
---|
1307 | sProg = skProgram;
|
---|
1308 | k_javadoc_box_line();
|
---|
1309 | if (sProg == '')
|
---|
1310 | sProg = 'This program';
|
---|
1311 | else
|
---|
1312 | {
|
---|
1313 | k_javadoc_box_line('This file is part of ' sProg '.');
|
---|
1314 | k_javadoc_box_line();
|
---|
1315 | }
|
---|
1316 | k_javadoc_box_line(sProg ' is free software; you can redistribute it and/or modify');
|
---|
1317 | k_javadoc_box_line('it under the terms of the GNU Lesser General Public License as published');
|
---|
1318 | k_javadoc_box_line('by the Free Software Foundation; either version 2 of the License, or');
|
---|
1319 | k_javadoc_box_line('(at your option) any later version.');
|
---|
1320 | k_javadoc_box_line();
|
---|
1321 | k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful,');
|
---|
1322 | k_javadoc_box_line('but WITHOUT ANY WARRANTY; without even the implied warranty of');
|
---|
1323 | k_javadoc_box_line('MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the');
|
---|
1324 | k_javadoc_box_line('GNU Lesser General Public License for more details.');
|
---|
1325 | k_javadoc_box_line();
|
---|
1326 | k_javadoc_box_line('You should have received a copy of the GNU Lesser General Public License');
|
---|
1327 | k_javadoc_box_line('along with ' sProg '; if not, write to the Free Software');
|
---|
1328 | k_javadoc_box_line('Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA');
|
---|
1329 | break;
|
---|
1330 |
|
---|
1331 | case 'Confidential':
|
---|
1332 | k_javadoc_box_line('All Rights Reserved');
|
---|
1333 | break;
|
---|
1334 |
|
---|
1335 | default:
|
---|
1336 |
|
---|
1337 | }
|
---|
1338 | k_javadoc_box_line();
|
---|
1339 | k_javadoc_box_end();
|
---|
1340 |
|
---|
1341 | up(p_RLine - iCursorLine);
|
---|
1342 | end_line();
|
---|
1343 | keyin(' ');
|
---|
1344 | }
|
---|
1345 |
|
---|
1346 |
|
---|
1347 |
|
---|
1348 |
|
---|
1349 |
|
---|
1350 |
|
---|
1351 |
|
---|
1352 | /*******************************************************************************
|
---|
1353 | * Keyboard Shortcuts *
|
---|
1354 | *******************************************************************************/
|
---|
1355 | /** Makes global box. */
|
---|
1356 | void k_box_globals()
|
---|
1357 | {
|
---|
1358 | k_box_start('Global');
|
---|
1359 | k_box_line('Global Variables');
|
---|
1360 | k_box_end();
|
---|
1361 | }
|
---|
1362 |
|
---|
1363 | /** Makes header box. */
|
---|
1364 | void k_box_headers()
|
---|
1365 | {
|
---|
1366 | k_box_start("Header");
|
---|
1367 | k_box_line("Header Files");
|
---|
1368 | k_box_end();
|
---|
1369 | }
|
---|
1370 |
|
---|
1371 | /** Makes internal function box. */
|
---|
1372 | void k_box_intfuncs()
|
---|
1373 | {
|
---|
1374 | k_box_start("IntFunc");
|
---|
1375 | k_box_line("Internal Functions");
|
---|
1376 | k_box_end();
|
---|
1377 | }
|
---|
1378 |
|
---|
1379 | /** Makes def/const box. */
|
---|
1380 | void k_box_consts()
|
---|
1381 | {
|
---|
1382 | k_box_start("Const");
|
---|
1383 | k_box_line("Defined Constants And Macros");
|
---|
1384 | k_box_end();
|
---|
1385 | }
|
---|
1386 |
|
---|
1387 | /** Structure box */
|
---|
1388 | void k_box_structs()
|
---|
1389 | {
|
---|
1390 | k_box_start("Struct");
|
---|
1391 | k_box_line("Structures and Typedefs");
|
---|
1392 | k_box_end();
|
---|
1393 | }
|
---|
1394 |
|
---|
1395 | /** Makes exported symbols box. */
|
---|
1396 | void k_box_exported()
|
---|
1397 | {
|
---|
1398 | k_box_start('Exported');
|
---|
1399 | k_box_line('Exported Symbols');
|
---|
1400 | k_box_end();
|
---|
1401 | }
|
---|
1402 |
|
---|
1403 |
|
---|
1404 |
|
---|
1405 | /** oneliner comment */
|
---|
1406 | void k_oneliner()
|
---|
1407 | {
|
---|
1408 | _str sLeft, sRight;
|
---|
1409 | int iColumn;
|
---|
1410 | if ( k_commentconfig(sLeft, sRight, iColumn)
|
---|
1411 | && iColumn > 0)
|
---|
1412 | { /* column based needs some tricky repositioning. */
|
---|
1413 | _end_line();
|
---|
1414 | if (p_col > iColumn)
|
---|
1415 | {
|
---|
1416 | _begin_line();
|
---|
1417 | _insert_text("\n\r");
|
---|
1418 | up();
|
---|
1419 | }
|
---|
1420 | }
|
---|
1421 | k_insert_comment("", KIC_CURSOR_AT_END, ikStyleOneliner);
|
---|
1422 | }
|
---|
1423 |
|
---|
1424 | /** mark line as modified. */
|
---|
1425 | void k_mark_modified_line()
|
---|
1426 | {
|
---|
1427 | /* not supported for column based sources */
|
---|
1428 | _str sLeft, sRight;
|
---|
1429 | int iColumn;
|
---|
1430 | if ( !k_commentconfig(sLeft, sRight, iColumn)
|
---|
1431 | || iColumn > 0)
|
---|
1432 | return;
|
---|
1433 | _str sStr;
|
---|
1434 | if (skChange != '')
|
---|
1435 | sStr = skChange ' (' skUserInitials ')';
|
---|
1436 | else
|
---|
1437 | sStr = skUserInitials;
|
---|
1438 | k_insert_comment(sStr, KIC_CURSOR_BEFORE, ikStyleModifyMarkColumn);
|
---|
1439 | down();
|
---|
1440 | }
|
---|
1441 |
|
---|
1442 |
|
---|
1443 | /**
|
---|
1444 | * Inserts a signature. Form: "//Initials ISO-date:"
|
---|
1445 | * @remark defeventtab
|
---|
1446 | */
|
---|
1447 | void k_signature()
|
---|
1448 | {
|
---|
1449 | /* kso I5-10000 2002-09-10: */
|
---|
1450 | _str sSig;
|
---|
1451 | if (skChange != '')
|
---|
1452 | sSig = skUserInitials ' ' skChange ' ' k_date() ': ';
|
---|
1453 | else
|
---|
1454 | sSig = skUserInitials ' ' k_date() ': ';
|
---|
1455 | k_insert_comment(sSig, KIC_CURSOR_AT_END);
|
---|
1456 | }
|
---|
1457 |
|
---|
1458 |
|
---|
1459 | /*******************************************************************************
|
---|
1460 | * kLIB Logging *
|
---|
1461 | *******************************************************************************/
|
---|
1462 | /**
|
---|
1463 | * Hot-Key: Inserts a KLOGENTRY statement at start of nearest function.
|
---|
1464 | */
|
---|
1465 | void klib_klogentry()
|
---|
1466 | {
|
---|
1467 | typeless org_pos;
|
---|
1468 | _save_pos2(org_pos);
|
---|
1469 |
|
---|
1470 | /*
|
---|
1471 | * Go to nearest function.
|
---|
1472 | */
|
---|
1473 | if (!k_func_goto_nearest_function())
|
---|
1474 | {
|
---|
1475 | /*
|
---|
1476 | * Get parameters.
|
---|
1477 | */
|
---|
1478 | _str sParams = k_func_getparams();
|
---|
1479 | if (sParams)
|
---|
1480 | {
|
---|
1481 | _str sRetType = k_func_getreturntype(true);
|
---|
1482 | if (!sRetType || sRetType == "")
|
---|
1483 | sRetType = "void"; /* paranoia! */
|
---|
1484 |
|
---|
1485 | /*
|
---|
1486 | * Insert text.
|
---|
1487 | */
|
---|
1488 | if (!k_func_searchcode("{"))
|
---|
1489 | {
|
---|
1490 | p_col++;
|
---|
1491 | int cArgs = k_func_countparams(sParams);
|
---|
1492 | if (cArgs > 0)
|
---|
1493 | {
|
---|
1494 | _str sArgs = "";
|
---|
1495 | int i;
|
---|
1496 | for (i = 0; i < cArgs; i++)
|
---|
1497 | {
|
---|
1498 | _str sType, sName, sDefault;
|
---|
1499 | if (!k_func_enumparams(sParams, i, sType, sName, sDefault))
|
---|
1500 | sArgs = sArgs', 'sName;
|
---|
1501 | }
|
---|
1502 |
|
---|
1503 | _insert_text("\n KLOGENTRY"cArgs"(\""sRetType"\",\""sParams"\""sArgs");"); /* todo tab size.. or smart indent */
|
---|
1504 | }
|
---|
1505 | else
|
---|
1506 | _insert_text("\n KLOGENTRY0(\""sRetType"\");"); /* todo tab size.. or smart indent */
|
---|
1507 |
|
---|
1508 | /*
|
---|
1509 | * Check if the next word is KLOGENTRY.
|
---|
1510 | */
|
---|
1511 | next_word();
|
---|
1512 | if (def_next_word_style == 'E')
|
---|
1513 | prev_word();
|
---|
1514 | int iIgnorePos = 0;
|
---|
1515 | if (substr(cur_word(iIgnorePos), 1, 9) == "KLOGENTRY")
|
---|
1516 | delete_line();
|
---|
1517 |
|
---|
1518 | }
|
---|
1519 | else
|
---|
1520 | message("didn't find {");
|
---|
1521 | }
|
---|
1522 | else
|
---|
1523 | message("k_func_getparams failed, sParams=" sParams);
|
---|
1524 | return;
|
---|
1525 | }
|
---|
1526 |
|
---|
1527 | _restore_pos2(org_pos);
|
---|
1528 | }
|
---|
1529 |
|
---|
1530 |
|
---|
1531 | /**
|
---|
1532 | * Hot-Key: Inserts a KLOGEXIT statement at cursor location.
|
---|
1533 | */
|
---|
1534 | void klib_klogexit()
|
---|
1535 | {
|
---|
1536 | typeless org_pos;
|
---|
1537 | _save_pos2(org_pos);
|
---|
1538 |
|
---|
1539 | /*
|
---|
1540 | * Go to nearest function.
|
---|
1541 | */
|
---|
1542 | if (!prev_proc())
|
---|
1543 | {
|
---|
1544 | /*
|
---|
1545 | * Get parameters.
|
---|
1546 | */
|
---|
1547 | _str sType = k_func_getreturntype(true);
|
---|
1548 | _restore_pos2(org_pos);
|
---|
1549 | if (sType)
|
---|
1550 | {
|
---|
1551 | boolean fReturn = true; /* true if an return statment is following the KLOGEXIT statement. */
|
---|
1552 |
|
---|
1553 | /*
|
---|
1554 | * Insert text.
|
---|
1555 | */
|
---|
1556 | int cur_col = p_col;
|
---|
1557 | if (sType == 'void' || sType == 'VOID')
|
---|
1558 | { /* procedure */
|
---|
1559 | int iIgnorePos;
|
---|
1560 | fReturn = cur_word(iIgnorePos) == 'return';
|
---|
1561 | if (!fReturn)
|
---|
1562 | {
|
---|
1563 | while (p_col <= p_SyntaxIndent)
|
---|
1564 | keyin(" ");
|
---|
1565 | }
|
---|
1566 |
|
---|
1567 | _insert_text("KLOGEXITVOID();\n");
|
---|
1568 |
|
---|
1569 | if (fReturn)
|
---|
1570 | {
|
---|
1571 | int i;
|
---|
1572 | for (i = 1; i < cur_col; i++)
|
---|
1573 | _insert_text(" ");
|
---|
1574 | }
|
---|
1575 | search(")","E-");
|
---|
1576 | }
|
---|
1577 | else
|
---|
1578 | { /* function */
|
---|
1579 | _insert_text("KLOGEXIT();\n");
|
---|
1580 | int i;
|
---|
1581 | for (i = 1; i < cur_col; i++)
|
---|
1582 | _insert_text(" ");
|
---|
1583 | search(")","E-");
|
---|
1584 |
|
---|
1585 | /*
|
---|
1586 | * Insert value if possible.
|
---|
1587 | */
|
---|
1588 | typeless valuepos;
|
---|
1589 | _save_pos2(valuepos);
|
---|
1590 | next_word();
|
---|
1591 | if (def_next_word_style == 'E')
|
---|
1592 | prev_word();
|
---|
1593 | int iIgnorePos;
|
---|
1594 | if (cur_word(iIgnorePos) == 'return')
|
---|
1595 | {
|
---|
1596 | p_col += length('return');
|
---|
1597 | typeless posStart;
|
---|
1598 | _save_pos2(posStart);
|
---|
1599 | long offStart = _QROffset();
|
---|
1600 | if (!k_func_searchcode(";", "E+"))
|
---|
1601 | {
|
---|
1602 | long offEnd = _QROffset();
|
---|
1603 | _restore_pos2(posStart);
|
---|
1604 | _str sValue = strip(get_text((int)(offEnd - offStart)));
|
---|
1605 | //say 'sValue = 'sValue;
|
---|
1606 | _restore_pos2(valuepos);
|
---|
1607 | _save_pos2(valuepos);
|
---|
1608 | _insert_text(sValue);
|
---|
1609 | }
|
---|
1610 | }
|
---|
1611 | _restore_pos2(valuepos);
|
---|
1612 | }
|
---|
1613 |
|
---|
1614 | /*
|
---|
1615 | * Remove old KLOGEXIT statement on previous line if any.
|
---|
1616 | */
|
---|
1617 | typeless valuepos;
|
---|
1618 | _save_pos2(valuepos);
|
---|
1619 | int newexitline = p_line;
|
---|
1620 | p_line--; p_col = 1;
|
---|
1621 | next_word();
|
---|
1622 | if (def_next_word_style == 'E')
|
---|
1623 | prev_word();
|
---|
1624 | int iIgnorePos;
|
---|
1625 | if (p_line == newexitline - 1 && substr(cur_word(iIgnorePos), 1, 8) == 'KLOGEXIT')
|
---|
1626 | delete_line();
|
---|
1627 | _restore_pos2(valuepos);
|
---|
1628 |
|
---|
1629 | /*
|
---|
1630 | * Check for missing '{...}'.
|
---|
1631 | */
|
---|
1632 | if (fReturn)
|
---|
1633 | {
|
---|
1634 | boolean fFound = false;
|
---|
1635 | _save_pos2(valuepos);
|
---|
1636 | p_col--; find_matching_paren(); p_col += 2;
|
---|
1637 | k_func_searchcode(';', 'E+'); /* places us at the ';' of the return. (hopefully) */
|
---|
1638 |
|
---|
1639 | _str ch = k_func_get_next_code_text();
|
---|
1640 | if (ch != '}')
|
---|
1641 | {
|
---|
1642 | _restore_pos2(valuepos);
|
---|
1643 | _save_pos2(valuepos);
|
---|
1644 | p_col--; find_matching_paren(); p_col += 2;
|
---|
1645 | k_func_searchcode(';', 'E+'); /* places us at the ';' of the return. (hopefully) */
|
---|
1646 | p_col++;
|
---|
1647 | if (k_func_more_code_on_line())
|
---|
1648 | _insert_text(' }');
|
---|
1649 | else
|
---|
1650 | {
|
---|
1651 | typeless returnget;
|
---|
1652 | _save_pos2(returnget);
|
---|
1653 | k_func_searchcode("return", "E-");
|
---|
1654 | int return_col = p_col;
|
---|
1655 | _restore_pos2(returnget);
|
---|
1656 |
|
---|
1657 | end_line();
|
---|
1658 | _insert_text("\n");
|
---|
1659 | while (p_col < return_col - p_SyntaxIndent)
|
---|
1660 | _insert_text(' ');
|
---|
1661 | _insert_text('}');
|
---|
1662 | }
|
---|
1663 |
|
---|
1664 | _restore_pos2(valuepos);
|
---|
1665 | _save_pos2(valuepos);
|
---|
1666 | prev_word();
|
---|
1667 | p_col -= p_SyntaxIndent;
|
---|
1668 | int codecol = p_col;
|
---|
1669 | _insert_text("{\n");
|
---|
1670 | while (p_col < codecol)
|
---|
1671 | _insert_text(' ');
|
---|
1672 | }
|
---|
1673 |
|
---|
1674 | _restore_pos2(valuepos);
|
---|
1675 | }
|
---|
1676 | }
|
---|
1677 | else
|
---|
1678 | message("k_func_getreturntype failed, sType=" sType);
|
---|
1679 | return;
|
---|
1680 | }
|
---|
1681 |
|
---|
1682 | _restore_pos2(org_pos);
|
---|
1683 | }
|
---|
1684 |
|
---|
1685 |
|
---|
1686 | /**
|
---|
1687 | * Processes a file - ask user all the time.
|
---|
1688 | */
|
---|
1689 | void klib_klog_file_ask()
|
---|
1690 | {
|
---|
1691 | klib_klog_file_int(true);
|
---|
1692 | }
|
---|
1693 |
|
---|
1694 |
|
---|
1695 | /**
|
---|
1696 | * Processes a file - no questions.
|
---|
1697 | */
|
---|
1698 | void klib_klog_file_no_ask()
|
---|
1699 | {
|
---|
1700 | klib_klog_file_int(false);
|
---|
1701 | }
|
---|
1702 |
|
---|
1703 |
|
---|
1704 |
|
---|
1705 | /**
|
---|
1706 | * Processes a file.
|
---|
1707 | */
|
---|
1708 | static void klib_klog_file_int(boolean fAsk)
|
---|
1709 | {
|
---|
1710 | show_all();
|
---|
1711 | bottom();
|
---|
1712 | _refresh_scroll();
|
---|
1713 |
|
---|
1714 | /* ask question so we can get to the right position somehow.. */
|
---|
1715 | if (fAsk && _message_box("kLog process this file?", "Visual SlickEdit", MB_YESNO | MB_ICONQUESTION) != IDYES)
|
---|
1716 | return;
|
---|
1717 |
|
---|
1718 | /*
|
---|
1719 | * Entries.
|
---|
1720 | */
|
---|
1721 | while (!prev_proc())
|
---|
1722 | {
|
---|
1723 | //say 'entry main loop: ' k_func_getfunction_name();
|
---|
1724 |
|
---|
1725 | /*
|
---|
1726 | * Skip prototypes.
|
---|
1727 | */
|
---|
1728 | if (k_func_prototype())
|
---|
1729 | continue;
|
---|
1730 |
|
---|
1731 | /*
|
---|
1732 | * Ask user.
|
---|
1733 | */
|
---|
1734 | center_line();
|
---|
1735 | _refresh_scroll();
|
---|
1736 | _str sFunction = k_func_getfunction_name();
|
---|
1737 | rc = fAsk ? _message_box("Process this function ("sFunction")?", "Visual SlickEdit", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
|
---|
1738 | if (rc == IDYES)
|
---|
1739 | {
|
---|
1740 | typeless procpos;
|
---|
1741 | _save_pos2(procpos);
|
---|
1742 | klib_klogentry();
|
---|
1743 | _restore_pos2(procpos);
|
---|
1744 | }
|
---|
1745 | else if (rc == IDNO)
|
---|
1746 | continue;
|
---|
1747 | else
|
---|
1748 | break;
|
---|
1749 | }
|
---|
1750 |
|
---|
1751 | /*
|
---|
1752 | * Exits.
|
---|
1753 | */
|
---|
1754 | bottom(); _refresh_scroll();
|
---|
1755 | boolean fUserCancel = false;
|
---|
1756 | while (!prev_proc() && !fUserCancel)
|
---|
1757 | {
|
---|
1758 | typeless procpos;
|
---|
1759 | _save_pos2(procpos);
|
---|
1760 | _str sCurFunction = k_func_getfunction_name();
|
---|
1761 | //say 'exit main loop: ' sCurFunction
|
---|
1762 |
|
---|
1763 | /*
|
---|
1764 | * Skip prototypes.
|
---|
1765 | */
|
---|
1766 | if (k_func_prototype())
|
---|
1767 | continue;
|
---|
1768 |
|
---|
1769 | /*
|
---|
1770 | * Select procedure.
|
---|
1771 | */
|
---|
1772 | while ( !k_func_searchcode("return", "WE<+")
|
---|
1773 | && k_func_getfunction_name() == sCurFunction)
|
---|
1774 | {
|
---|
1775 | //say 'exit sub loop: ' p_line
|
---|
1776 | /*
|
---|
1777 | * Ask User.
|
---|
1778 | */
|
---|
1779 | center_line();
|
---|
1780 | _refresh_scroll();
|
---|
1781 | _str sFunction = k_func_getfunction_name();
|
---|
1782 | rc = fAsk ? _message_box("Process this exit from "sFunction"?", "Visual SlickEdit", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
|
---|
1783 | deselect();
|
---|
1784 | if (rc == IDYES)
|
---|
1785 | {
|
---|
1786 | typeless returnpos;
|
---|
1787 | _save_pos2(returnpos);
|
---|
1788 | klib_klogexit();
|
---|
1789 | _restore_pos2(returnpos);
|
---|
1790 | p_line++;
|
---|
1791 | }
|
---|
1792 | else if (rc != IDNO)
|
---|
1793 | {
|
---|
1794 | fUserCancel = true;
|
---|
1795 | break;
|
---|
1796 | }
|
---|
1797 | p_line++; /* just so we won't hit it again. */
|
---|
1798 | }
|
---|
1799 |
|
---|
1800 | /*
|
---|
1801 | * If void function we'll have to check if there is and return; prior to the ending '}'.
|
---|
1802 | */
|
---|
1803 | _restore_pos2(procpos);
|
---|
1804 | _save_pos2(procpos);
|
---|
1805 | _str sType = k_func_getreturntype(true);
|
---|
1806 | if (!fUserCancel && sType && (sType == 'void' || sType == 'VOID'))
|
---|
1807 | {
|
---|
1808 | if ( !k_func_searchcode("{", "E+")
|
---|
1809 | && !find_matching_paren())
|
---|
1810 | {
|
---|
1811 | typeless funcend;
|
---|
1812 | _save_pos2(funcend);
|
---|
1813 | prev_word();
|
---|
1814 | int iIgnorePos;
|
---|
1815 | if (cur_word(iIgnorePos) != "return")
|
---|
1816 | {
|
---|
1817 | /*
|
---|
1818 | * Ask User.
|
---|
1819 | */
|
---|
1820 | _restore_pos2(funcend);
|
---|
1821 | center_line();
|
---|
1822 | _refresh_scroll();
|
---|
1823 | _str sFunction = k_func_getfunction_name();
|
---|
1824 | rc = fAsk ? _message_box("Process this exit from "sFunction"?", "Visual SlickEdit", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
|
---|
1825 | deselect();
|
---|
1826 | if (rc == IDYES)
|
---|
1827 | {
|
---|
1828 | typeless returnpos;
|
---|
1829 | _save_pos2(returnpos);
|
---|
1830 | klib_klogexit();
|
---|
1831 | _restore_pos2(returnpos);
|
---|
1832 | }
|
---|
1833 | }
|
---|
1834 | }
|
---|
1835 | }
|
---|
1836 |
|
---|
1837 | /*
|
---|
1838 | * Next proc.
|
---|
1839 | */
|
---|
1840 | _restore_pos2(procpos);
|
---|
1841 | }
|
---|
1842 | }
|
---|
1843 |
|
---|
1844 |
|
---|
1845 | /*******************************************************************************
|
---|
1846 | * Odin32 backward compatibility *
|
---|
1847 | *******************************************************************************/
|
---|
1848 | _command void odin32_maketagfile()
|
---|
1849 | {
|
---|
1850 | /* We'll */
|
---|
1851 | if (file_match('-p 'maybe_quote_filename(strip_filename(_project_name,'e'):+TAG_FILE_EXT),1) != "")
|
---|
1852 | {
|
---|
1853 | _project_update_files_retag(false,false,false,false);
|
---|
1854 | /*
|
---|
1855 | RetagFilesInTagFile2(project_tag_file, orig_view_id, temp_view_id, rebuild_all, false,
|
---|
1856 | doRemove,false,true,true);*/
|
---|
1857 | }
|
---|
1858 | else
|
---|
1859 | _project_update_files_retag(true,false,false,true);
|
---|
1860 | }
|
---|
1861 |
|
---|
1862 | _command void odin32_setcurrentdir()
|
---|
1863 | {
|
---|
1864 | //_ini_get_value(_project_name,"COMPILER","WORKINGDIR", workingdir);
|
---|
1865 | //cd(workingdir);
|
---|
1866 | /* Go the the directory containing the project filename */
|
---|
1867 | cd(strip_filename(_project_name, 'NE'));
|
---|
1868 | }
|
---|
1869 |
|
---|
1870 |
|
---|
1871 |
|
---|
1872 |
|
---|
1873 | /*******************************************************************************
|
---|
1874 | * Styles *
|
---|
1875 | *******************************************************************************/
|
---|
1876 | static _str StyleLanguages[] =
|
---|
1877 | {
|
---|
1878 | "c",
|
---|
1879 | "e",
|
---|
1880 | "java"
|
---|
1881 | };
|
---|
1882 |
|
---|
1883 | struct StyleScheme
|
---|
1884 | {
|
---|
1885 | _str name;
|
---|
1886 | _str settings[];
|
---|
1887 | };
|
---|
1888 |
|
---|
1889 | static StyleScheme StyleSchemes[] =
|
---|
1890 | {
|
---|
1891 | {
|
---|
1892 | "Opt2Ind4",
|
---|
1893 | {
|
---|
1894 | "orig_tabsize=4",
|
---|
1895 | "syntax_indent=4",
|
---|
1896 | "tabsize=4",
|
---|
1897 | "align_on_equal=1",
|
---|
1898 | "pad_condition_state=1",
|
---|
1899 | "indent_with_tabs=0",
|
---|
1900 | "nospace_before_paren=0",
|
---|
1901 | "indent_comments=1",
|
---|
1902 | "indent_case=1",
|
---|
1903 | "statement_comment_col=0",
|
---|
1904 | "disable_bestyle=0",
|
---|
1905 | "decl_comment_col=0",
|
---|
1906 | "bestyle_on_functions=0",
|
---|
1907 | "use_relative_indent=1",
|
---|
1908 | "nospace_before_brace=0",
|
---|
1909 | "indent_fl=1",
|
---|
1910 | "statement_comment_state=2",
|
---|
1911 | "indent_pp=1",
|
---|
1912 | "be_style=1",
|
---|
1913 | "parens_on_return=0",
|
---|
1914 | "eat_blank_lines=0",
|
---|
1915 | "brace_indent=0",
|
---|
1916 | "eat_pp_space=1",
|
---|
1917 | "align_on_parens=1",
|
---|
1918 | "continuation_indent=0",
|
---|
1919 | "cuddle_else=0",
|
---|
1920 | "nopad_condition=1",
|
---|
1921 | "pad_condition=0",
|
---|
1922 | "indent_col1_comments=0"
|
---|
1923 | }
|
---|
1924 | }
|
---|
1925 | ,
|
---|
1926 | {
|
---|
1927 | "Opt2Ind3",
|
---|
1928 | {
|
---|
1929 | "orig_tabsize=3",
|
---|
1930 | "syntax_indent=3",
|
---|
1931 | "tabsize=3",
|
---|
1932 | "align_on_equal=1",
|
---|
1933 | "pad_condition_state=1",
|
---|
1934 | "indent_with_tabs=0",
|
---|
1935 | "nospace_before_paren=0",
|
---|
1936 | "indent_comments=1",
|
---|
1937 | "indent_case=1",
|
---|
1938 | "statement_comment_col=0",
|
---|
1939 | "disable_bestyle=0",
|
---|
1940 | "decl_comment_col=0",
|
---|
1941 | "bestyle_on_functions=0",
|
---|
1942 | "use_relative_indent=1",
|
---|
1943 | "nospace_before_brace=0",
|
---|
1944 | "indent_fl=1",
|
---|
1945 | "statement_comment_state=2",
|
---|
1946 | "indent_pp=1",
|
---|
1947 | "be_style=1",
|
---|
1948 | "parens_on_return=0",
|
---|
1949 | "eat_blank_lines=0",
|
---|
1950 | "brace_indent=0",
|
---|
1951 | "eat_pp_space=1",
|
---|
1952 | "align_on_parens=1",
|
---|
1953 | "continuation_indent=0",
|
---|
1954 | "cuddle_else=0",
|
---|
1955 | "nopad_condition=1",
|
---|
1956 | "pad_condition=0",
|
---|
1957 | "indent_col1_comments=0"
|
---|
1958 | }
|
---|
1959 | }
|
---|
1960 | ,
|
---|
1961 | {
|
---|
1962 | "Opt2Ind8",
|
---|
1963 | {
|
---|
1964 | "orig_tabsize=8",
|
---|
1965 | "syntax_indent=8",
|
---|
1966 | "tabsize=8",
|
---|
1967 | "align_on_equal=1",
|
---|
1968 | "pad_condition_state=1",
|
---|
1969 | "indent_with_tabs=0",
|
---|
1970 | "nospace_before_paren=0",
|
---|
1971 | "indent_comments=1",
|
---|
1972 | "indent_case=1",
|
---|
1973 | "statement_comment_col=0",
|
---|
1974 | "disable_bestyle=0",
|
---|
1975 | "decl_comment_col=0",
|
---|
1976 | "bestyle_on_functions=0",
|
---|
1977 | "use_relative_indent=1",
|
---|
1978 | "nospace_before_brace=0",
|
---|
1979 | "indent_fl=1",
|
---|
1980 | "statement_comment_state=2",
|
---|
1981 | "indent_pp=1",
|
---|
1982 | "be_style=1",
|
---|
1983 | "parens_on_return=0",
|
---|
1984 | "eat_blank_lines=0",
|
---|
1985 | "brace_indent=0",
|
---|
1986 | "eat_pp_space=1",
|
---|
1987 | "align_on_parens=1",
|
---|
1988 | "continuation_indent=0",
|
---|
1989 | "cuddle_else=0",
|
---|
1990 | "nopad_condition=1",
|
---|
1991 | "pad_condition=0",
|
---|
1992 | "indent_col1_comments=0"
|
---|
1993 | }
|
---|
1994 | }
|
---|
1995 | ,
|
---|
1996 | {
|
---|
1997 | "Opt3Ind4",
|
---|
1998 | {
|
---|
1999 | "orig_tabsize=4",
|
---|
2000 | "syntax_indent=4",
|
---|
2001 | "tabsize=4",
|
---|
2002 | "align_on_equal=1",
|
---|
2003 | "pad_condition_state=1",
|
---|
2004 | "indent_with_tabs=0",
|
---|
2005 | "nospace_before_paren=0",
|
---|
2006 | "indent_comments=1",
|
---|
2007 | "indent_case=1",
|
---|
2008 | "statement_comment_col=0",
|
---|
2009 | "disable_bestyle=0",
|
---|
2010 | "decl_comment_col=0",
|
---|
2011 | "bestyle_on_functions=0",
|
---|
2012 | "use_relative_indent=1",
|
---|
2013 | "nospace_before_brace=0",
|
---|
2014 | "indent_fl=1",
|
---|
2015 | "statement_comment_state=2",
|
---|
2016 | "indent_pp=1",
|
---|
2017 | "be_style=2",
|
---|
2018 | "parens_on_return=0",
|
---|
2019 | "eat_blank_lines=0",
|
---|
2020 | "brace_indent=0",
|
---|
2021 | "eat_pp_space=1",
|
---|
2022 | "align_on_parens=1",
|
---|
2023 | "continuation_indent=0",
|
---|
2024 | "cuddle_else=0",
|
---|
2025 | "nopad_condition=1",
|
---|
2026 | "pad_condition=0",
|
---|
2027 | "indent_col1_comments=0"
|
---|
2028 | }
|
---|
2029 | }
|
---|
2030 | ,
|
---|
2031 | {
|
---|
2032 | "Opt3Ind3",
|
---|
2033 | {
|
---|
2034 | "orig_tabsize=3",
|
---|
2035 | "syntax_indent=3",
|
---|
2036 | "tabsize=3",
|
---|
2037 | "align_on_equal=1",
|
---|
2038 | "pad_condition_state=1",
|
---|
2039 | "indent_with_tabs=0",
|
---|
2040 | "nospace_before_paren=0",
|
---|
2041 | "indent_comments=1",
|
---|
2042 | "indent_case=1",
|
---|
2043 | "statement_comment_col=0",
|
---|
2044 | "disable_bestyle=0",
|
---|
2045 | "decl_comment_col=0",
|
---|
2046 | "bestyle_on_functions=0",
|
---|
2047 | "use_relative_indent=1",
|
---|
2048 | "nospace_before_brace=0",
|
---|
2049 | "indent_fl=1",
|
---|
2050 | "statement_comment_state=2",
|
---|
2051 | "indent_pp=1",
|
---|
2052 | "be_style=2",
|
---|
2053 | "parens_on_return=0",
|
---|
2054 | "eat_blank_lines=0",
|
---|
2055 | "brace_indent=0",
|
---|
2056 | "eat_pp_space=1",
|
---|
2057 | "align_on_parens=1",
|
---|
2058 | "continuation_indent=0",
|
---|
2059 | "cuddle_else=0",
|
---|
2060 | "nopad_condition=1",
|
---|
2061 | "pad_condition=0",
|
---|
2062 | "indent_col1_comments=0"
|
---|
2063 | }
|
---|
2064 | }
|
---|
2065 | };
|
---|
2066 |
|
---|
2067 |
|
---|
2068 | static void k_styles_create()
|
---|
2069 | {
|
---|
2070 | /*
|
---|
2071 | * Find user format ini file.
|
---|
2072 | */
|
---|
2073 | _str userini = maybe_quote_filename(_config_path():+'uformat.ini');
|
---|
2074 | if (file_match('-p 'userini, 1) == '')
|
---|
2075 | {
|
---|
2076 | _str ini = maybe_quote_filename(slick_path_search('uformat.ini'));
|
---|
2077 | if (ini != '') userini = ini;
|
---|
2078 | }
|
---|
2079 |
|
---|
2080 |
|
---|
2081 | /*
|
---|
2082 | * Remove any old schemes.
|
---|
2083 | */
|
---|
2084 | int i,j,tv;
|
---|
2085 | for (i = 0; i < StyleSchemes._length(); i++)
|
---|
2086 | for (j = 0; j < StyleLanguages._length(); j++)
|
---|
2087 | {
|
---|
2088 | _str sectionname = StyleLanguages[j]:+'-scheme-':+StyleSchemes[i].name;
|
---|
2089 | if (!_ini_get_section(userini, sectionname, tv))
|
---|
2090 | {
|
---|
2091 | _ini_delete_section(userini, sectionname);
|
---|
2092 | _delete_temp_view(tv);
|
---|
2093 | //message("delete old scheme");
|
---|
2094 | }
|
---|
2095 | }
|
---|
2096 |
|
---|
2097 | /*
|
---|
2098 | * Create the new schemes.
|
---|
2099 | */
|
---|
2100 | for (i = 0; i < StyleSchemes._length(); i++)
|
---|
2101 | {
|
---|
2102 | for (j = 0; j < StyleLanguages._length(); j++)
|
---|
2103 | {
|
---|
2104 | _str sectionname = StyleLanguages[j]:+'-scheme-':+StyleSchemes[i].name;
|
---|
2105 | int temp_view_id, k;
|
---|
2106 | _str orig_view_id = _create_temp_view(temp_view_id);
|
---|
2107 | activate_view(temp_view_id);
|
---|
2108 | for (k = 0; k < StyleSchemes[i].settings._length(); k++)
|
---|
2109 | insert_line(StyleSchemes[i].settings[k]);
|
---|
2110 |
|
---|
2111 | /* Insert the scheme section. */
|
---|
2112 | _ini_replace_section(userini, sectionname, temp_view_id);
|
---|
2113 | //message(userini)
|
---|
2114 | //bogus id - activate_view(orig_view_id);
|
---|
2115 | }
|
---|
2116 | }
|
---|
2117 |
|
---|
2118 | //last_scheme = last scheme name!!!
|
---|
2119 | }
|
---|
2120 |
|
---|
2121 |
|
---|
2122 | /*
|
---|
2123 | * Sets the last used beutify scheme.
|
---|
2124 | */
|
---|
2125 | static k_styles_set(_str scheme)
|
---|
2126 | {
|
---|
2127 |
|
---|
2128 | /*
|
---|
2129 | * Find user format ini file.
|
---|
2130 | */
|
---|
2131 | _str userini = maybe_quote_filename(_config_path():+'uformat.ini');
|
---|
2132 | if (file_match('-p 'userini, 1) == '')
|
---|
2133 | {
|
---|
2134 | _str ini = maybe_quote_filename(slick_path_search('uformat.ini'));
|
---|
2135 | if (ini != '') userini = ini;
|
---|
2136 | }
|
---|
2137 |
|
---|
2138 | /*
|
---|
2139 | * Set the scheme for each language.
|
---|
2140 | */
|
---|
2141 | int j;
|
---|
2142 | for (j = 0; j < StyleLanguages._length(); j++)
|
---|
2143 | {
|
---|
2144 | _ini_set_value(userini,
|
---|
2145 | StyleLanguages[j]:+'-scheme-Default',
|
---|
2146 | 'last_scheme',
|
---|
2147 | scheme);
|
---|
2148 | }
|
---|
2149 | }
|
---|
2150 |
|
---|
2151 |
|
---|
2152 | static _str defoptions[] =
|
---|
2153 | {
|
---|
2154 | "def-options-sas",
|
---|
2155 | "def-options-js",
|
---|
2156 | "def-options-bat",
|
---|
2157 | "def-options-c",
|
---|
2158 | "def-options-pas",
|
---|
2159 | "def-options-e",
|
---|
2160 | "def-options-java",
|
---|
2161 | "def-options-bourneshell",
|
---|
2162 | "def-options-csh",
|
---|
2163 | "def-options-vlx",
|
---|
2164 | "def-options-plsql",
|
---|
2165 | "def-options-sqlserver",
|
---|
2166 | "def-options-cmd"
|
---|
2167 | };
|
---|
2168 |
|
---|
2169 | static _str defsetups[] =
|
---|
2170 | {
|
---|
2171 | "def-setup-sas",
|
---|
2172 | "def-setup-js",
|
---|
2173 | "def-setup-bat",
|
---|
2174 | "def-setup-fundamental",
|
---|
2175 | "def-setup-process",
|
---|
2176 | "def-setup-c",
|
---|
2177 | "def-setup-pas",
|
---|
2178 | "def-setup-e",
|
---|
2179 | "def-setup-asm",
|
---|
2180 | "def-setup-java",
|
---|
2181 | "def-setup-html",
|
---|
2182 | "def-setup-bourneshell",
|
---|
2183 | "def-setup-csh",
|
---|
2184 | "def-setup-vlx",
|
---|
2185 | "def-setup-fileman",
|
---|
2186 | "def-setup-plsql",
|
---|
2187 | "def-setup-sqlserver",
|
---|
2188 | "def-setup-s",
|
---|
2189 | "def-setup-cmd"
|
---|
2190 | };
|
---|
2191 |
|
---|
2192 | static _str defsetupstab8[] =
|
---|
2193 | {
|
---|
2194 | "def-setup-c"
|
---|
2195 | };
|
---|
2196 |
|
---|
2197 |
|
---|
2198 | static void k_styles_setindent(int indent, int iBraceStyle, boolean iWithTabs = false)
|
---|
2199 | {
|
---|
2200 | if (iBraceStyle < 1 || iBraceStyle > 3)
|
---|
2201 | {
|
---|
2202 | message('k_styles_setindent: iBraceStyle is bad (=' :+ iBraceStyle :+ ')');
|
---|
2203 | iBraceStyle = 2;
|
---|
2204 | }
|
---|
2205 |
|
---|
2206 | /*
|
---|
2207 | * def-options for extentions known to have that info.
|
---|
2208 | */
|
---|
2209 | int i;
|
---|
2210 | for (i = 0; i < defoptions._length(); i++)
|
---|
2211 | {
|
---|
2212 | int idx = find_index(defoptions[i], MISC_TYPE);
|
---|
2213 | if (!idx)
|
---|
2214 | continue;
|
---|
2215 |
|
---|
2216 | parse name_info(idx) with syntax_indent o2 o3 o4 flags indent_fl o7 indent_case rest;
|
---|
2217 |
|
---|
2218 | /* Begin/end style */
|
---|
2219 | flags = flags & ~(1|2);
|
---|
2220 | flags = flags | (iBraceStyle - 1); /* Set style (0-based) */
|
---|
2221 | flags = flags & ~(16); /* no scape before parent.*/
|
---|
2222 | indent_fl = 1; /* Indent first level */
|
---|
2223 | indent_case = 1; /* Indent case from switch */
|
---|
2224 |
|
---|
2225 | sNewOptions = indent' 'o2' 'o3' 'o4' 'flags' 'indent_fl' 'o7' 'indent_case' 'rest;
|
---|
2226 | set_name_info(idx, sNewOptions);
|
---|
2227 | _config_modify |= CFGMODIFY_DEFDATA;
|
---|
2228 | }
|
---|
2229 |
|
---|
2230 | /*
|
---|
2231 | * def-setup for known extentions.
|
---|
2232 | */
|
---|
2233 | for (i = 0; i < defsetups._length(); i++)
|
---|
2234 | {
|
---|
2235 | idx = find_index(defsetups[i], MISC_TYPE);
|
---|
2236 | if (!idx)
|
---|
2237 | continue;
|
---|
2238 | sExt = substr(defsetups[i], length('def-setup-') + 1);
|
---|
2239 | sSetup = name_info(idx);
|
---|
2240 |
|
---|
2241 | /*
|
---|
2242 | parse sSetup with 'MN=' mode_name ','\
|
---|
2243 | 'TABS=' tabs ',' 'MA=' margins ',' 'KEYTAB=' keytab_name ','\
|
---|
2244 | 'WW='word_wrap_style ',' 'IWT='indent_with_tabs ','\
|
---|
2245 | 'ST='show_tabs ',' 'IN='indent_style ','\
|
---|
2246 | 'WC='word_chars',' 'LN='lexer_name',' 'CF='color_flags','\
|
---|
2247 | 'LNL='line_numbers_len','rest;
|
---|
2248 |
|
---|
2249 | indent_with_tabs = 0; /* Indent with tabs */
|
---|
2250 |
|
---|
2251 | /* Make sure all the values are legal */
|
---|
2252 | _ext_init_values(ext, lexer_name, color_flags);
|
---|
2253 | if (!isinteger(line_numbers_len)) line_numbers_len = 0;
|
---|
2254 | if (word_chars == '') word_chars = 'A-Za-z0-9_$';
|
---|
2255 | if (word_wrap_style == '') word_wrap_style = 3;
|
---|
2256 | if (show_tabs == '') show_tabs = 0;
|
---|
2257 | if (indent_style == '') indent_style = INDENT_SMART;
|
---|
2258 |
|
---|
2259 | /* Set new indent */
|
---|
2260 | tabs = '+'indent;
|
---|
2261 | */
|
---|
2262 |
|
---|
2263 | sNewSetup = sSetup;
|
---|
2264 |
|
---|
2265 | /* Set new indent */
|
---|
2266 | if (pos('TABS=', sNewSetup) > 0)
|
---|
2267 | {
|
---|
2268 | /*
|
---|
2269 | * If either in defoptions or defsetupstab8 use default tab of 8
|
---|
2270 | * For those supporting separate syntax indent using the normal tabsize
|
---|
2271 | * helps us a lot when reading it...
|
---|
2272 | */
|
---|
2273 | fTab8 = false;
|
---|
2274 | for (j = 0; !fTab8 && j < defsetupstab8._length(); j++)
|
---|
2275 | if (substr(defsetupstab8[j], lastpos('-', defsetupstab8[j]) + 1) == sExt)
|
---|
2276 | fTab8 = true;
|
---|
2277 | for (j = 0; !fTab8 && j < defoptions._length(); j++)
|
---|
2278 | if (substr(defoptions[j], lastpos('-', defoptions[j]) + 1) == sExt)
|
---|
2279 | fTab8 = true;
|
---|
2280 |
|
---|
2281 | parse sNewSetup with sPre 'TABS=' sValue ',' sPost;
|
---|
2282 | if (fTab8)
|
---|
2283 | sNewSetup = sPre 'TABS=+8,' sPost
|
---|
2284 | else
|
---|
2285 | sNewSetup = sPre 'TABS=+' indent ',' sPost
|
---|
2286 | }
|
---|
2287 |
|
---|
2288 | /* Set indent with tabs flag. */
|
---|
2289 | if (pos('IWT=', sNewSetup) > 0)
|
---|
2290 | {
|
---|
2291 | parse sNewSetup with sPre 'IWT=' sValue ',' sPost;
|
---|
2292 | if (iWithTabs)
|
---|
2293 | sNewSetup = sPre 'IWT=1,' sPost
|
---|
2294 | else
|
---|
2295 | sNewSetup = sPre 'IWT=0,' sPost
|
---|
2296 | }
|
---|
2297 |
|
---|
2298 | /* Do the real changes */
|
---|
2299 | set_name_info(idx, sNewSetup);
|
---|
2300 | _config_modify |= CFGMODIFY_DEFDATA;
|
---|
2301 | _update_buffers(sExt);
|
---|
2302 | }
|
---|
2303 | }
|
---|
2304 |
|
---|
2305 |
|
---|
2306 | /**
|
---|
2307 | * Takes necessary steps to convert a string to integer.
|
---|
2308 | */
|
---|
2309 | static int k_style_emacs_var_integer(_str sVal)
|
---|
2310 | {
|
---|
2311 | int i = (int)sVal;
|
---|
2312 | //say 'k_style_emacs_var_integer('sVal') -> 'i;
|
---|
2313 | return (int)sVal;
|
---|
2314 | }
|
---|
2315 |
|
---|
2316 |
|
---|
2317 | /**
|
---|
2318 | * Sets a Emacs style variable.
|
---|
2319 | */
|
---|
2320 | static int k_style_emacs_var(_str sVar, _str sVal)
|
---|
2321 | {
|
---|
2322 | /* check input. */
|
---|
2323 | if (sVar == '' || sVal == '')
|
---|
2324 | return -1;
|
---|
2325 | say 'k_style_emacs_var: 'sVar'='sVal;
|
---|
2326 |
|
---|
2327 | /*
|
---|
2328 | * Unpack the mode style parameters.
|
---|
2329 | */
|
---|
2330 | _str sStyle = name_info(_edit_window().p_index);
|
---|
2331 | _str sStyleName = p_mode_name;
|
---|
2332 | typeless iIndentAmount, fExpansion, iMinAbbrivation, fIndentAfterOpenParen, iBeginEndStyle, fIndent1stLevel, iMainStyle, iSwitchStyle,
|
---|
2333 | sRest, sRes0, sRes1;
|
---|
2334 | if (sStyleName == 'Slick-C')
|
---|
2335 | {
|
---|
2336 | parse sStyle with iMinAbbrivation sRes0 iBeginEndStyle fIndent1stLevel sRes1 iSwitchStyle sRest;
|
---|
2337 | iIndentAmount = p_SyntaxIndent;
|
---|
2338 | }
|
---|
2339 | else /* C */
|
---|
2340 | parse sStyle with iIndentAmount fExpansion iMinAbbrivation fIndentAfterOpenParen iBeginEndStyle fIndent1stLevel iMainStyle iSwitchStyle sRest;
|
---|
2341 |
|
---|
2342 |
|
---|
2343 | /*
|
---|
2344 | * Process the variable.
|
---|
2345 | */
|
---|
2346 | switch (sVar)
|
---|
2347 | {
|
---|
2348 | case 'mode':
|
---|
2349 | case 'Mode':
|
---|
2350 | {
|
---|
2351 | switch (sVal)
|
---|
2352 | {
|
---|
2353 | case 'c':
|
---|
2354 | case 'C':
|
---|
2355 | case 'c++':
|
---|
2356 | case 'C++':
|
---|
2357 | case 'cpp':
|
---|
2358 | case 'CPP':
|
---|
2359 | case 'cxx':
|
---|
2360 | case 'CXX':
|
---|
2361 | p_extension = 'c';
|
---|
2362 | p_mode_name = 'C';
|
---|
2363 | break;
|
---|
2364 |
|
---|
2365 | case 'e':
|
---|
2366 | case 'slick-c':
|
---|
2367 | case 'Slick-c':
|
---|
2368 | case 'Slick-C':
|
---|
2369 | p_extension = 'e';
|
---|
2370 | p_mode_name = 'Slick-C';
|
---|
2371 | break;
|
---|
2372 |
|
---|
2373 | default:
|
---|
2374 | message('emacs mode "'sVal'" is not known to us');
|
---|
2375 | return -3;
|
---|
2376 | }
|
---|
2377 | break;
|
---|
2378 | }
|
---|
2379 |
|
---|
2380 | case 'c-file-style':
|
---|
2381 | case 'c-indentation-style':
|
---|
2382 | switch (sVal)
|
---|
2383 | {
|
---|
2384 | case 'BSD':
|
---|
2385 | case 'bsd':
|
---|
2386 | iBeginEndStyle = 1 | (iBeginEndStyle & ~3);
|
---|
2387 | p_indent_with_tabs = true;
|
---|
2388 | iIndentAmount = 8;
|
---|
2389 | p_SyntaxIndent = 8;
|
---|
2390 | p_tabs = "+8";
|
---|
2391 | //say 'bsd';
|
---|
2392 | break;
|
---|
2393 |
|
---|
2394 | case 'k&r':
|
---|
2395 | case 'K&R':
|
---|
2396 | iBeginEndStyle = 0 | (iBeginEndStyle & ~3);
|
---|
2397 | p_indent_with_tabs = false;
|
---|
2398 | iIndentAmount = 4;
|
---|
2399 | p_SyntaxIndent = 4;
|
---|
2400 | p_tabs = "+4";
|
---|
2401 | //say 'k&r';
|
---|
2402 | break;
|
---|
2403 |
|
---|
2404 | case 'linux-c':
|
---|
2405 | iBeginEndStyle = 0 | (iBeginEndStyle & ~3);
|
---|
2406 | p_indent_with_tabs = true;
|
---|
2407 | iIndentAmount = 4;
|
---|
2408 | p_SyntaxIndent = 4;
|
---|
2409 | p_tabs = "+4";
|
---|
2410 | //say 'linux-c';
|
---|
2411 | break;
|
---|
2412 |
|
---|
2413 | case 'yet-to-be-found':
|
---|
2414 | iBeginEndStyle = 2 | (iBeginEndStyle & ~3);
|
---|
2415 | p_indent_with_tabs = false;
|
---|
2416 | iIndentAmount = 4;
|
---|
2417 | p_SyntaxIndent = 4;
|
---|
2418 | p_tabs = "+4";
|
---|
2419 | //say 'todo';
|
---|
2420 | break;
|
---|
2421 |
|
---|
2422 | default:
|
---|
2423 | message('emacs "'sVar'" value "'sVal'" is not known to us.');
|
---|
2424 | return -3;
|
---|
2425 | }
|
---|
2426 | break;
|
---|
2427 |
|
---|
2428 | case 'c-label-offset':
|
---|
2429 | {
|
---|
2430 | int i = k_style_emacs_var_integer(sVal);
|
---|
2431 | if (i >= -16 && i <= 16)
|
---|
2432 | {
|
---|
2433 | if (i == -p_SyntaxIndent)
|
---|
2434 | iSwitchStyle = 0;
|
---|
2435 | else
|
---|
2436 | iSwitchStyle = 1;
|
---|
2437 | }
|
---|
2438 | break;
|
---|
2439 | }
|
---|
2440 |
|
---|
2441 |
|
---|
2442 | case 'indent-tabs-mode':
|
---|
2443 | p_indent_with_tabs = sVal == 't';
|
---|
2444 | break;
|
---|
2445 |
|
---|
2446 | case 'c-indent-level':
|
---|
2447 | case 'c-basic-offset':
|
---|
2448 | {
|
---|
2449 | int i = k_style_emacs_var_integer(sVal);
|
---|
2450 | if (i > 0 && i <= 16)
|
---|
2451 | {
|
---|
2452 | iIndentAmount = i;
|
---|
2453 | p_SyntaxIndent = i;
|
---|
2454 | }
|
---|
2455 | else
|
---|
2456 | {
|
---|
2457 | message('emacs "'sVar'" value "'sVal'" is out of range.');
|
---|
2458 | return -4;
|
---|
2459 | }
|
---|
2460 | break;
|
---|
2461 | }
|
---|
2462 |
|
---|
2463 | case 'tab-width':
|
---|
2464 | {
|
---|
2465 | int i = k_style_emacs_var_integer(sVal);
|
---|
2466 | if (i > 0 && i <= 16)
|
---|
2467 | p_tabs = '+'i;
|
---|
2468 | else
|
---|
2469 | {
|
---|
2470 | message('emacs "'sVar'" value "'sVal'" is out of range.');
|
---|
2471 | return -4;
|
---|
2472 | }
|
---|
2473 | break;
|
---|
2474 | }
|
---|
2475 |
|
---|
2476 | default:
|
---|
2477 | message('emacs variable "'sVar'" (value "'sVal'") is unknown to us.');
|
---|
2478 | return -5;
|
---|
2479 | }
|
---|
2480 |
|
---|
2481 | /*
|
---|
2482 | * Update the style?
|
---|
2483 | */
|
---|
2484 | _str sNewStyle = "";
|
---|
2485 | if (sStyleName == 'Slick-C')
|
---|
2486 | sNewStyle = iMinAbbrivation' 'sRes0' 'iBeginEndStyle' 'fIndent1stLevel' 'sRes1' 'iSwitchStyle' 'sRest;
|
---|
2487 | else
|
---|
2488 | sNewStyle = iIndentAmount' 'fExpansion' 'iMinAbbrivation' 'fIndentAfterOpenParen' 'iBeginEndStyle' 'fIndent1stLevel' 'iMainStyle' 'iSwitchStyle' 'sRest;
|
---|
2489 | if ( sNewStyle != ""
|
---|
2490 | && sNewStyle != sStyle
|
---|
2491 | && sStyleName == p_mode_name)
|
---|
2492 | {
|
---|
2493 | //say ' sStyle='sStyle' p_mode_name='p_mode_name;
|
---|
2494 | //say 'sNewStyle='sNewStyle;
|
---|
2495 | set_name_info(_edit_window().p_index, sNewStyle);
|
---|
2496 | }
|
---|
2497 |
|
---|
2498 | return 0;
|
---|
2499 | }
|
---|
2500 |
|
---|
2501 |
|
---|
2502 | /**
|
---|
2503 | * Parses a string with emacs variables.
|
---|
2504 | *
|
---|
2505 | * The variables are separated by new line. Junk at
|
---|
2506 | * the start and end of the line is ignored.
|
---|
2507 | */
|
---|
2508 | static int k_style_emac_vars(_str sVars)
|
---|
2509 | {
|
---|
2510 | /* process them line by line */
|
---|
2511 | int iLine = 0;
|
---|
2512 | while (sVars != '' && iLine++ < 20)
|
---|
2513 | {
|
---|
2514 | int iNext, iEnd;
|
---|
2515 | iEnd = iNext = pos("\n", sVars);
|
---|
2516 | if (iEnd <= 0)
|
---|
2517 | iEnd = iNext = length(sVars);
|
---|
2518 | else
|
---|
2519 | iEnd--;
|
---|
2520 | iNext++;
|
---|
2521 |
|
---|
2522 | sLine = strip(substr(sVars, 1, iEnd), 'B', " \t\n\r");
|
---|
2523 | sVars = strip(substr(sVars, iNext), 'L', " \t\n\r");
|
---|
2524 | //say 'iLine='iLine' sVars='sVars'<eol>';
|
---|
2525 | //say 'iLine='iLine' sLine='sLine'<eol>';
|
---|
2526 | if (sLine != '')
|
---|
2527 | {
|
---|
2528 | rc = pos('[^a-zA-Z0-9-_]*([a-zA-Z0-9-_]+)[ \t]*:[ \t]*([^ \t]*)', sLine, 1, 'U');
|
---|
2529 | //say '0={'pos('S0')','pos('0')',"'substr(sLine,pos('S0'),pos('0'))'"'
|
---|
2530 | //say '1={'pos('S1')','pos('1')',"'substr(sLine,pos('S1'),pos('1'))'"'
|
---|
2531 | //say '2={'pos('S2')','pos('2')',"'substr(sLine,pos('S2'),pos('2'))'"'
|
---|
2532 | //say '3={'pos('S3')','pos('3')',"'substr(sLine,pos('S3'),pos('3'))'"'
|
---|
2533 | //say '4={'pos('S4')','pos('4')',"'substr(sLine,pos('S4'),pos('4'))'"'
|
---|
2534 | if (rc > 0)
|
---|
2535 | k_style_emacs_var(substr(sLine,pos('S1'),pos('1')),
|
---|
2536 | substr(sLine,pos('S2'),pos('2')));
|
---|
2537 | }
|
---|
2538 | }
|
---|
2539 | return 0;
|
---|
2540 | }
|
---|
2541 |
|
---|
2542 | /**
|
---|
2543 | * Searches for Emacs style specification for the current document.
|
---|
2544 | */
|
---|
2545 | void k_style_load()
|
---|
2546 | {
|
---|
2547 | /* save the position before we start looking around the file. */
|
---|
2548 | typeless saved_pos;
|
---|
2549 | _save_pos2(saved_pos);
|
---|
2550 |
|
---|
2551 | int rc;
|
---|
2552 |
|
---|
2553 | /* Check first line. */
|
---|
2554 | top_of_buffer();
|
---|
2555 | _str sLine;
|
---|
2556 | get_line(sLine);
|
---|
2557 | strip(sLine);
|
---|
2558 | if (pos('-*-[ \t]+(.*:.*)[ \t]+-*-', sLine, 1, 'U'))
|
---|
2559 | {
|
---|
2560 | _str sVars;
|
---|
2561 | sVars = substr(sLine, pos('S1'), pos('1'));
|
---|
2562 | sVars = translate(sVars, "\n", ";");
|
---|
2563 | k_style_emac_vars(sVars);
|
---|
2564 | }
|
---|
2565 |
|
---|
2566 | /* Look for the "Local Variables:" stuff from the end of the file. */
|
---|
2567 | bottom_of_buffer();
|
---|
2568 | rc = search('Local Variables:[ \t]*\n\om(.*)\ol\n.*End:.*\n', '-EU');
|
---|
2569 | if (!rc)
|
---|
2570 | {
|
---|
2571 | /* copy the variables out to a buffer. */
|
---|
2572 | _str sVars;
|
---|
2573 | sVars = get_text(match_length("1"), match_length("S1"));
|
---|
2574 | k_style_emac_vars(sVars);
|
---|
2575 | }
|
---|
2576 |
|
---|
2577 | _restore_pos2(saved_pos);
|
---|
2578 | }
|
---|
2579 |
|
---|
2580 |
|
---|
2581 |
|
---|
2582 | /*******************************************************************************
|
---|
2583 | * Menu and Menu commands *
|
---|
2584 | *******************************************************************************/
|
---|
2585 | static int iTimer = 0;
|
---|
2586 | static int mhkDev = 0;
|
---|
2587 | static int mhCode = 0;
|
---|
2588 | static int mhDoc = 0;
|
---|
2589 | static int mhLic = 0;
|
---|
2590 | static int mhPre = 0;
|
---|
2591 |
|
---|
2592 | /*
|
---|
2593 | * Creates the kDev menu.
|
---|
2594 | */
|
---|
2595 | static k_menu_create()
|
---|
2596 | {
|
---|
2597 | if (arg(1) == 'timer')
|
---|
2598 | _kill_timer(iTimer);
|
---|
2599 | menu_handle = _mdi.p_menu_handle;
|
---|
2600 | menu_index = find_index(_cur_mdi_menu,oi2type(OI_MENU));
|
---|
2601 |
|
---|
2602 | /*
|
---|
2603 | * Remove any old menu.
|
---|
2604 | */
|
---|
2605 | mhDelete = iPos = 0;
|
---|
2606 | index = _menu_find(menu_handle, "kDev", mhDelete, iPos, 'C');
|
---|
2607 | //message("index="index " mhDelete="mhDelete " iPos="iPos);
|
---|
2608 | if (index == 0)
|
---|
2609 | _menu_delete(mhDelete, iPos);
|
---|
2610 |
|
---|
2611 |
|
---|
2612 | /*
|
---|
2613 | * Insert the "kDev" menu.
|
---|
2614 | */
|
---|
2615 | mhkDev = _menu_insert(menu_handle, 9, MF_SUBMENU, "&kDev", "", "kDev");
|
---|
2616 | mhCode=_menu_insert(mhkDev, -1, MF_ENABLED | MF_SUBMENU, "Coding &Style", "", "coding");
|
---|
2617 | rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 2, Syntax Indent 4 (knut)", "k_menu_style Opt2Ind4", "Opt2Ind4");
|
---|
2618 | rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 2, Syntax Indent 3", "k_menu_style Opt2Ind3", "Opt2Ind3");
|
---|
2619 | rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 2, Syntax Indent 8", "k_menu_style Opt2Ind8", "Opt2Ind8");
|
---|
2620 | rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 3, Syntax Indent 4 (giws)", "k_menu_style Opt3Ind4", "Opt3Ind4");
|
---|
2621 | rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 3, Syntax Indent 3 (giws)", "k_menu_style Opt3Ind3", "Opt3Ind3");
|
---|
2622 |
|
---|
2623 | mhDoc= _menu_insert(mhkDev, -1, MF_ENABLED | MF_SUBMENU, "&Documentation", "", "doc");
|
---|
2624 | mhDSJ= _menu_insert(mhDoc, -1, MF_ENABLED | MF_UNCHECKED, "&Javadoc Style", "k_menu_doc_style javadoc", "javadoc");
|
---|
2625 | mhDSL= _menu_insert(mhDoc, -1, MF_GRAYED | MF_UNCHECKED, "&Linux Kernel Style", "k_menu_doc_style linux", "linux");
|
---|
2626 |
|
---|
2627 | mhLic= _menu_insert(mhkDev, -1, MF_ENABLED | MF_SUBMENU, "&License", "", "License");
|
---|
2628 | rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&Odin32", "k_menu_license Odin32", "Odin32");
|
---|
2629 | rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&GPL", "k_menu_license GPL", "GPL");
|
---|
2630 | rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&LGPL", "k_menu_license LGPL", "LGPL");
|
---|
2631 | rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&Confidential", "k_menu_license Confidential", "Confidential");
|
---|
2632 |
|
---|
2633 | rc = _menu_insert(mhkDev, -1, MF_ENABLED, "-", "", "dash vars");
|
---|
2634 | rc = _menu_insert(mhkDev, -1, MF_ENABLED, skChange == '' ? '&Change...' : '&Change (' skChange ')...', "k_menu_change", "");
|
---|
2635 | rc = _menu_insert(mhkDev, -1, MF_ENABLED, skProgram == '' ? '&Program...' : '&Program (' skProgram ')...', "k_menu_program", "");
|
---|
2636 | rc = _menu_insert(mhkDev, -1, MF_ENABLED, skCompany == '' ? 'Co&mpany...' : 'Co&mpany (' skCompany ')...', "k_menu_company", "");
|
---|
2637 | rc = _menu_insert(mhkDev, -1, MF_ENABLED, '&User Name (' skUserName ')...', "k_menu_user_name", "username");
|
---|
2638 | rc = _menu_insert(mhkDev, -1, MF_ENABLED, 'User &e-mail (' skUserEmail ')...', "k_menu_user_email", "useremail");
|
---|
2639 | rc = _menu_insert(mhkDev, -1, MF_ENABLED, 'User &Initials (' skUserInitials ')...', "k_menu_user_initials", "userinitials");
|
---|
2640 | rc = _menu_insert(mhkDev, -1, MF_ENABLED, "-", "", "dash preset");
|
---|
2641 | mhPre= _menu_insert(mhkDev, -1, MF_SUBMENU, "P&resets", "", "");
|
---|
2642 | rc = _menu_insert(mhPre, -1, MF_ENABLED, "Odin32", "k_menu_preset javadoc, Odin32, Opt2Ind4,,Odin32", "odin32");
|
---|
2643 | rc = _menu_insert(mhPre, -1, MF_ENABLED, "Linux Kernel","k_menu_preset linux, GPL, Opt1Ind4,,Linux", "linux");
|
---|
2644 | rc = _menu_insert(mhPre, -1, MF_ENABLED, "The Bird", "k_menu_preset javadoc, GPL, Opt2Ind4", "bird");
|
---|
2645 | rc = _menu_insert(mhPre, -1, MF_ENABLED, "Win32k", "k_menu_preset javadoc, GPL, Opt2Ind4,, Win32k", "Win32k");
|
---|
2646 | rc = _menu_insert(mhPre, -1, MF_ENABLED, "kKrnlLib", "k_menu_preset javadoc, GPL, Opt2Ind4,, kKrnlLib", "kKrnlLib");
|
---|
2647 | rc = _menu_insert(mhPre, -1, MF_ENABLED, "kLib", "k_menu_preset javadoc, GPL, Opt2Ind4,, kLib", "kLib");
|
---|
2648 | rc = _menu_insert(mhPre, -1, MF_ENABLED, "kBuild", "k_menu_preset javadoc, GPL, Opt2Ind4,, kBuild", "kBuild");
|
---|
2649 | rc = _menu_insert(mhPre, -1, MF_ENABLED, "Innotek", "k_menu_preset javadoc, Confidential, Opt2Ind4, InnoTek Systemberatung GmbH", "Innotek");
|
---|
2650 | rc = _menu_insert(mhPre, -1, MF_ENABLED, "VPC/2", "k_menu_preset javadoc, Confidential, Opt2Ind4, InnoTek Systemberatung GmbH, VPC/2", "VPC2");
|
---|
2651 |
|
---|
2652 | k_menu_doc_style();
|
---|
2653 | k_menu_license();
|
---|
2654 | k_menu_style();
|
---|
2655 | }
|
---|
2656 |
|
---|
2657 |
|
---|
2658 | /**
|
---|
2659 | * Change change Id.
|
---|
2660 | */
|
---|
2661 | _command k_menu_change()
|
---|
2662 | {
|
---|
2663 | sRc = show("-modal k_form_simple_input", "Change ID", skChange);
|
---|
2664 | if (sRc != "\r")
|
---|
2665 | {
|
---|
2666 | skChange = sRc;
|
---|
2667 | k_menu_create();
|
---|
2668 | }
|
---|
2669 | }
|
---|
2670 |
|
---|
2671 |
|
---|
2672 | /**
|
---|
2673 | * Change program name.
|
---|
2674 | */
|
---|
2675 | _command k_menu_program()
|
---|
2676 | {
|
---|
2677 | sRc = show("-modal k_form_simple_input", "Program", skProgram);
|
---|
2678 | if (sRc != "\r")
|
---|
2679 | {
|
---|
2680 | skProgram = sRc;
|
---|
2681 | k_menu_create();
|
---|
2682 | }
|
---|
2683 | }
|
---|
2684 |
|
---|
2685 |
|
---|
2686 | /**
|
---|
2687 | * Change company.
|
---|
2688 | */
|
---|
2689 | _command k_menu_company()
|
---|
2690 | {
|
---|
2691 | if (skCompany == '')
|
---|
2692 | sRc = show("-modal k_form_simple_input", "Company", 'InnoTek Systemberatung GmbH');
|
---|
2693 | else
|
---|
2694 | sRc = show("-modal k_form_simple_input", "Company", skCompany);
|
---|
2695 | if (sRc != "\r")
|
---|
2696 | {
|
---|
2697 | skCompany = sRc;
|
---|
2698 | k_menu_create();
|
---|
2699 | }
|
---|
2700 | }
|
---|
2701 |
|
---|
2702 |
|
---|
2703 | /**
|
---|
2704 | * Change user name.
|
---|
2705 | */
|
---|
2706 | _command k_menu_user_name()
|
---|
2707 | {
|
---|
2708 | sRc = show("-modal k_form_simple_input", "User Name", skUserName);
|
---|
2709 | if (sRc != "\r" && sRc != '')
|
---|
2710 | {
|
---|
2711 | skUserName = sRc;
|
---|
2712 | k_menu_create();
|
---|
2713 | }
|
---|
2714 | }
|
---|
2715 |
|
---|
2716 |
|
---|
2717 | /**
|
---|
2718 | * Change user email.
|
---|
2719 | */
|
---|
2720 | _command k_menu_user_email()
|
---|
2721 | {
|
---|
2722 | sRc = show("-modal k_form_simple_input", "User e-mail", skUserEmail);
|
---|
2723 | if (sRc != "\r" && sRc != '')
|
---|
2724 | {
|
---|
2725 | skUserEmail = sRc;
|
---|
2726 | k_menu_create();
|
---|
2727 | }
|
---|
2728 | }
|
---|
2729 |
|
---|
2730 |
|
---|
2731 | /**
|
---|
2732 | * Change user initials.
|
---|
2733 | */
|
---|
2734 | _command k_menu_user_initials()
|
---|
2735 | {
|
---|
2736 | sRc = show("-modal k_form_simple_input", "User e-mail", skUserInitials);
|
---|
2737 | if (sRc != "\r" && sRc != '')
|
---|
2738 | {
|
---|
2739 | skUserInitials = sRc;
|
---|
2740 | k_menu_create();
|
---|
2741 | }
|
---|
2742 | }
|
---|
2743 |
|
---|
2744 |
|
---|
2745 |
|
---|
2746 | /**
|
---|
2747 | * Checks the correct menu item.
|
---|
2748 | */
|
---|
2749 | _command void k_menu_doc_style(_str sNewDocStyle = '')
|
---|
2750 | {
|
---|
2751 | //say 'sNewDocStyle='sNewDocStyle;
|
---|
2752 | if (sNewDocStyle != '')
|
---|
2753 | skDocStyle = sNewDocStyle
|
---|
2754 | _menu_set_state(mhDoc, "javadoc", MF_UNCHECKED);
|
---|
2755 | _menu_set_state(mhDoc, "linux", MF_UNCHECKED | MF_GRAYED);
|
---|
2756 | _menu_set_state(mhDoc, skDocStyle, MF_CHECKED);
|
---|
2757 | }
|
---|
2758 |
|
---|
2759 |
|
---|
2760 | /**
|
---|
2761 | * Checks the correct menu item.
|
---|
2762 | */
|
---|
2763 | _command void k_menu_license(_str sNewLicense = '')
|
---|
2764 | {
|
---|
2765 | //say 'sNewLicense='sNewLicense;
|
---|
2766 | if (sNewLicense != '')
|
---|
2767 | skLicense = sNewLicense
|
---|
2768 | _menu_set_state(mhLic, "Odin32", MF_UNCHECKED);
|
---|
2769 | _menu_set_state(mhLic, "GPL", MF_UNCHECKED);
|
---|
2770 | _menu_set_state(mhLic, "LGPL", MF_UNCHECKED);
|
---|
2771 | _menu_set_state(mhLic, "Confidential", MF_UNCHECKED);
|
---|
2772 | _menu_set_state(mhLic, skLicense, MF_CHECKED);
|
---|
2773 | }
|
---|
2774 |
|
---|
2775 |
|
---|
2776 | /**
|
---|
2777 | * Check the correct style menu item.
|
---|
2778 | */
|
---|
2779 | _command void k_menu_style(_str sNewStyle = '')
|
---|
2780 | {
|
---|
2781 | //say 'sNewStyle='sNewStyle;
|
---|
2782 | _menu_set_state(mhCode, "Opt1Ind4", MF_UNCHECKED);
|
---|
2783 | _menu_set_state(mhCode, "Opt1Ind3", MF_UNCHECKED);
|
---|
2784 | _menu_set_state(mhCode, "Opt1Ind8", MF_UNCHECKED);
|
---|
2785 | _menu_set_state(mhCode, "Opt2Ind4", MF_UNCHECKED);
|
---|
2786 | _menu_set_state(mhCode, "Opt2Ind3", MF_UNCHECKED);
|
---|
2787 | _menu_set_state(mhCode, "Opt2Ind8", MF_UNCHECKED);
|
---|
2788 | _menu_set_state(mhCode, "Opt3Ind4", MF_UNCHECKED);
|
---|
2789 | _menu_set_state(mhCode, "Opt3Ind3", MF_UNCHECKED);
|
---|
2790 | _menu_set_state(mhCode, "Opt3Ind8", MF_UNCHECKED);
|
---|
2791 |
|
---|
2792 | if (sNewStyle != '')
|
---|
2793 | {
|
---|
2794 | int iIndent = (int)substr(sNewStyle, 8, 1);
|
---|
2795 | int iBraceStyle = (int)substr(sNewStyle, 4, 1);
|
---|
2796 | skCodeStyle = sNewStyle;
|
---|
2797 | k_styles_setindent(iIndent, iBraceStyle);
|
---|
2798 | k_styles_set(sNewStyle);
|
---|
2799 | }
|
---|
2800 |
|
---|
2801 | _menu_set_state(mhCode, skCodeStyle, MF_CHECKED);
|
---|
2802 | }
|
---|
2803 |
|
---|
2804 |
|
---|
2805 | /**
|
---|
2806 | * Load a 'preset'.
|
---|
2807 | */
|
---|
2808 | _command void k_menu_preset(_str sArgs = '')
|
---|
2809 | {
|
---|
2810 | parse sArgs with sNewDocStyle ',' sNewLicense ',' sNewStyle ',' sNewCompany ',' sNewProgram ',' sNewChange
|
---|
2811 | sNewDocStyle= strip(sNewDocStyle);
|
---|
2812 | sNewLicense = strip(sNewLicense);
|
---|
2813 | sNewStyle = strip(sNewStyle);
|
---|
2814 | sNewCompany = strip(sNewCompany);
|
---|
2815 | sNewProgram = strip(sNewProgram);
|
---|
2816 | sNewChange = strip(sNewChange);
|
---|
2817 |
|
---|
2818 | //say 'k_menu_preset('sNewDocStyle',' sNewLicense',' sNewStyle',' sNewCompany',' sNewProgram')';
|
---|
2819 | k_menu_doc_style(sNewDocStyle);
|
---|
2820 | k_menu_license(sNewLicense);
|
---|
2821 | k_menu_style(sNewStyle);
|
---|
2822 | skCompany = sNewCompany;
|
---|
2823 | skProgram = sNewProgram;
|
---|
2824 | skChange = sNewChange;
|
---|
2825 | k_menu_create();
|
---|
2826 | }
|
---|
2827 |
|
---|
2828 |
|
---|
2829 |
|
---|
2830 | /* future ones..
|
---|
2831 | _command k_menu_setcolor()
|
---|
2832 | {
|
---|
2833 | createMyColorSchemeAndUseIt();
|
---|
2834 | }
|
---|
2835 |
|
---|
2836 |
|
---|
2837 | _command k_menu_setkeys()
|
---|
2838 | {
|
---|
2839 | rc = load("d:/knut/VSlickMacros/BoxerDef.e");
|
---|
2840 | }
|
---|
2841 |
|
---|
2842 | _command k_menu_settings()
|
---|
2843 | {
|
---|
2844 | mySettings();
|
---|
2845 | }
|
---|
2846 | */
|
---|
2847 |
|
---|
2848 |
|
---|
2849 | /*******************************************************************************
|
---|
2850 | * Dialogs *
|
---|
2851 | *******************************************************************************/
|
---|
2852 | _form k_form_simple_input {
|
---|
2853 | p_backcolor=0x80000005
|
---|
2854 | p_border_style=BDS_DIALOG_BOX
|
---|
2855 | p_caption='Simple Input'
|
---|
2856 | p_clip_controls=FALSE
|
---|
2857 | p_forecolor=0x80000008
|
---|
2858 | p_height=1120
|
---|
2859 | p_width=5020
|
---|
2860 | p_x=6660
|
---|
2861 | p_y=6680
|
---|
2862 | _text_box entText {
|
---|
2863 | p_auto_size=TRUE
|
---|
2864 | p_backcolor=0x80000005
|
---|
2865 | p_border_style=BDS_FIXED_SINGLE
|
---|
2866 | p_completion=NONE_ARG
|
---|
2867 | p_font_bold=FALSE
|
---|
2868 | p_font_italic=FALSE
|
---|
2869 | p_font_name='MS Sans Serif'
|
---|
2870 | p_font_size=8
|
---|
2871 | p_font_underline=FALSE
|
---|
2872 | p_forecolor=0x80000008
|
---|
2873 | p_height=270
|
---|
2874 | p_tab_index=1
|
---|
2875 | p_tab_stop=TRUE
|
---|
2876 | p_text='text'
|
---|
2877 | p_width=3180
|
---|
2878 | p_x=1680
|
---|
2879 | p_y=240
|
---|
2880 | p_eventtab2=_ul2_textbox
|
---|
2881 | }
|
---|
2882 | _label lblLabel {
|
---|
2883 | p_alignment=AL_VCENTERRIGHT
|
---|
2884 | p_auto_size=FALSE
|
---|
2885 | p_backcolor=0x80000005
|
---|
2886 | p_border_style=BDS_NONE
|
---|
2887 | p_caption='Label'
|
---|
2888 | p_font_bold=FALSE
|
---|
2889 | p_font_italic=FALSE
|
---|
2890 | p_font_name='MS Sans Serif'
|
---|
2891 | p_font_size=8
|
---|
2892 | p_font_underline=FALSE
|
---|
2893 | p_forecolor=0x80000008
|
---|
2894 | p_height=240
|
---|
2895 | p_tab_index=2
|
---|
2896 | p_width=1380
|
---|
2897 | p_word_wrap=FALSE
|
---|
2898 | p_x=180
|
---|
2899 | p_y=240
|
---|
2900 | }
|
---|
2901 | _command_button btnOK {
|
---|
2902 | p_cancel=FALSE
|
---|
2903 | p_caption='&OK'
|
---|
2904 | p_default=TRUE
|
---|
2905 | p_font_bold=FALSE
|
---|
2906 | p_font_italic=FALSE
|
---|
2907 | p_font_name='MS Sans Serif'
|
---|
2908 | p_font_size=8
|
---|
2909 | p_font_underline=FALSE
|
---|
2910 | p_height=360
|
---|
2911 | p_tab_index=3
|
---|
2912 | p_tab_stop=TRUE
|
---|
2913 | p_width=1020
|
---|
2914 | p_x=180
|
---|
2915 | p_y=660
|
---|
2916 | }
|
---|
2917 | _command_button btnCancel {
|
---|
2918 | p_cancel=TRUE
|
---|
2919 | p_caption='Cancel'
|
---|
2920 | p_default=FALSE
|
---|
2921 | p_font_bold=FALSE
|
---|
2922 | p_font_italic=FALSE
|
---|
2923 | p_font_name='MS Sans Serif'
|
---|
2924 | p_font_size=8
|
---|
2925 | p_font_underline=FALSE
|
---|
2926 | p_height=360
|
---|
2927 | p_tab_index=4
|
---|
2928 | p_tab_stop=TRUE
|
---|
2929 | p_width=840
|
---|
2930 | p_x=1380
|
---|
2931 | p_y=660
|
---|
2932 | }
|
---|
2933 | }
|
---|
2934 |
|
---|
2935 | defeventtab k_form_simple_input
|
---|
2936 | btnOK.on_create(_str sLabel = '', _str sText = '')
|
---|
2937 | {
|
---|
2938 | p_active_form.p_caption = sLabel;
|
---|
2939 | lblLabel.p_caption = sLabel;
|
---|
2940 | entText.p_text = sText;
|
---|
2941 | }
|
---|
2942 |
|
---|
2943 | btnOK.lbutton_up()
|
---|
2944 | {
|
---|
2945 | sText = entText.p_text;
|
---|
2946 | p_active_form._delete_window(sText);
|
---|
2947 | }
|
---|
2948 | btnCancel.lbutton_up()
|
---|
2949 | {
|
---|
2950 | sText = entText.p_text;
|
---|
2951 | p_active_form._delete_window("\r");
|
---|
2952 | }
|
---|
2953 |
|
---|
2954 |
|
---|
2955 |
|
---|
2956 | /**
|
---|
2957 | * Module initiation.
|
---|
2958 | */
|
---|
2959 | definit()
|
---|
2960 | {
|
---|
2961 | k_styles_create();
|
---|
2962 | k_menu_create();
|
---|
2963 | iTimer = _set_timer(1000, k_menu_create, "timer");
|
---|
2964 | /* createMyColorSchemeAndUseIt();*/
|
---|
2965 | }
|
---|
2966 |
|
---|
2967 |
|
---|