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

Last change on this file since 10367 was 10342, checked in by bird, 22 years ago

Some fixes..

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