source: trunk/tools/vslick/kdev.e@ 9352

Last change on this file since 9352 was 9352, checked in by bird, 23 years ago

Fixed missing spaces. Fixed some '\e' problem. ++

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