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

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

confidential bugfix ;)

File size: 73.2 KB
Line 
1/* $Id: kdev.e,v 1.6 2003-05-31 20:11:21 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
677 /* lazy approach, which doens't support function types */
678
679 if (pos('=', sParams) > 0) /* default */
680 {
681 sDefault = strip(substr(sParams, pos('=', sParams) + 1));
682 sArg = strip(substr(sArg, 1, pos('=', sParams) - 1));
683 }
684
685 for (i = length(sArg); i > 1; i--)
686 {
687 _str ch = substr(sArg, i, 1);
688 if ( !(ch >= 'a' && ch <= 'z')
689 && !(ch >= 'A' && ch <= 'Z')
690 && !(ch >= '0' && ch <= '9')
691 && ch != '_' && ch != '$')
692 break;
693 }
694 if (sArg == "...")
695 i = 0;
696 sName = strip(substr(sArg, i + 1));
697 sType = strip(substr(sArg, 1, i));
698
699 return 0;
700 }
701
702 return -1;
703}
704
705
706/**
707 * Counts the parameters to the function.
708 * @param sParams Parameter string from k_func_getparams.
709 * @remark Should be reimplemented to use tags (if someone can figure out how to query that stuff).
710 */
711static int k_func_countparams(_str sParams)
712{
713 int i;
714 int iParLevel;
715 int iCurParam;
716
717 sType = sName = sDefault = "";
718
719 /* check for 0 parameters */
720 if (length(sParams) == 0)
721 return 0;
722
723 /* find the parameter in question */
724 for (i = 1, iParLevel = iCurParam = 0; i <= length(sParams); i++)
725 {
726 _str ch = substr(sParams, i, 1);
727 if (ch == ',' && iParLevel == 0)
728 {
729 iCurParam++;
730 }
731 else if (ch == '(')
732 iParLevel++;
733 else if (ch == ')')
734 iParLevel--;
735 }
736
737 return iCurParam + 1;
738}
739
740
741/**
742 * Gets the return type.
743 */
744static _str k_func_getreturntype(boolean fPureType = false)
745{
746 _save_pos2(org_pos);
747
748 /*
749 * Go to nearest function.
750 */
751 if (!k_func_goto_nearest_function())
752 {
753 /*
754 * Return type is from function start to function name...
755 */
756 _save_pos2(posStart);
757 offStart = _QROffset();
758
759 if (!k_func_searchcode("(")) /* makes some assumptions. */
760 {
761 prev_word();
762 offEnd = _QROffset();
763 _restore_pos2(posStart);
764 _str sTypeRaw = strip(get_text(offEnd - offStart));
765
766 //say 'sTypeRaw='sTypeRaw;
767 /*
768 * Remove static, inline, _Optlink, stdcall, EXPENTRY etc.
769 */
770 if (fPureType)
771 {
772 sTypeRaw = stranslate(sTypeRaw, "", "__static__", "I");
773 sTypeRaw = stranslate(sTypeRaw, "", "__static", "I");
774 sTypeRaw = stranslate(sTypeRaw, "", "static__", "I");
775 sTypeRaw = stranslate(sTypeRaw, "", "static", "I");
776 sTypeRaw = stranslate(sTypeRaw, "", "__inline__", "I");
777 sTypeRaw = stranslate(sTypeRaw, "", "__inline", "I");
778 sTypeRaw = stranslate(sTypeRaw, "", "inline__", "I");
779 sTypeRaw = stranslate(sTypeRaw, "", "inline", "I");
780 sTypeRaw = stranslate(sTypeRaw, "", "EXPENTRY", "I");
781 sTypeRaw = stranslate(sTypeRaw, "", "_Optlink", "I");
782 sTypeRaw = stranslate(sTypeRaw, "", "__stdcall", "I");
783 sTypeRaw = stranslate(sTypeRaw, "", "__cdecl", "I");
784 sTypeRaw = stranslate(sTypeRaw, "", "_cdecl", "I");
785 sTypeRaw = stranslate(sTypeRaw, "", "cdecl", "I");
786 sTypeRaw = stranslate(sTypeRaw, "", "__PASCAL", "I");
787 sTypeRaw = stranslate(sTypeRaw, "", "_PASCAL", "I");
788 sTypeRaw = stranslate(sTypeRaw, "", "PASCAL", "I");
789 sTypeRaw = stranslate(sTypeRaw, "", "__Far32__", "I");
790 sTypeRaw = stranslate(sTypeRaw, "", "__Far32", "I");
791 sTypeRaw = stranslate(sTypeRaw, "", "Far32__", "I");
792 sTypeRaw = stranslate(sTypeRaw, "", "_Far32_", "I");
793 sTypeRaw = stranslate(sTypeRaw, "", "_Far32", "I");
794 sTypeRaw = stranslate(sTypeRaw, "", "Far32_", "I");
795 sTypeRaw = stranslate(sTypeRaw, "", "Far32", "I");
796 sTypeRaw = stranslate(sTypeRaw, "", "__far", "I");
797 sTypeRaw = stranslate(sTypeRaw, "", "_far", "I");
798 sTypeRaw = stranslate(sTypeRaw, "", "far", "I");
799 sTypeRaw = stranslate(sTypeRaw, "", "__near", "I");
800 sTypeRaw = stranslate(sTypeRaw, "", "_near", "I");
801 sTypeRaw = stranslate(sTypeRaw, "", "near", "I");
802 sTypeRaw = stranslate(sTypeRaw, "", "__loadds__", "I");
803 sTypeRaw = stranslate(sTypeRaw, "", "__loadds", "I");
804 sTypeRaw = stranslate(sTypeRaw, "", "loadds__", "I");
805 sTypeRaw = stranslate(sTypeRaw, "", "_loadds_", "I");
806 sTypeRaw = stranslate(sTypeRaw, "", "_loadds", "I");
807 sTypeRaw = stranslate(sTypeRaw, "", "loadds_", "I");
808 sTypeRaw = stranslate(sTypeRaw, "", "loadds", "I");
809 sTypeRaw = stranslate(sTypeRaw, "", "__loades__", "I");
810 sTypeRaw = stranslate(sTypeRaw, "", "__loades", "I");
811 sTypeRaw = stranslate(sTypeRaw, "", "loades__", "I");
812 sTypeRaw = stranslate(sTypeRaw, "", "_loades_", "I");
813 sTypeRaw = stranslate(sTypeRaw, "", "_loades", "I");
814 sTypeRaw = stranslate(sTypeRaw, "", "loades_", "I");
815 sTypeRaw = stranslate(sTypeRaw, "", "loades", "I");
816 sTypeRaw = stranslate(sTypeRaw, "", "WIN32API", "I");
817 sTypeRaw = stranslate(sTypeRaw, "", "WINAPI", "I");
818 sTypeRaw = stranslate(sTypeRaw, "", "LDRCALL", "I");
819 sTypeRaw = stranslate(sTypeRaw, "", "KRNLCALL", "I");
820 sTypeRaw = stranslate(sTypeRaw, "", "__operator__", "I"); /* operator fix */
821 sTypeRaw = stranslate(sTypeRaw, "", "__operator", "I"); /* operator fix */
822 sTypeRaw = stranslate(sTypeRaw, "", "operator__", "I"); /* operator fix */
823 sTypeRaw = stranslate(sTypeRaw, "", "operator", "I"); /* operator fix */
824 }
825
826 /*
827 * Remove new lines and double spaces within params.
828 */
829 _str sType = "";
830
831 int i;
832 for (i = 1, chPrev = ' '; i <= length(sTypeRaw); i++)
833 {
834 ch = substr(sTypeRaw, i, 1);
835
836 /*
837 * Do fixups.
838 */
839 if (ch == " " && chPrev == " ")
840 continue;
841
842 if ((ch :== "\n") || (ch :== "\r") || (ch :== "\t"))
843 {
844 if (chPrev == ' ')
845 continue;
846 ch = ' ';
847 }
848
849 if (ch == ',' && chPrev == ' ')
850 {
851 sType = substr(sType, 1, length(sType) - 1);
852 }
853
854 if (ch == '*')
855 {
856 if (chPrev != ' ')
857 sType = sType :+ ' * ';
858 else
859 sType = sType :+ '* ';
860 chPrev = ' ';
861 }
862 else
863 {
864 sType = sType :+ ch;
865 chPrev = ch;
866 }
867
868 } /* for */
869
870 sType = strip(sType);
871
872 _restore_pos2(org_pos);
873 return sType;
874 }
875 else
876 message('k_func_getreturntype: can''t find ''(''.');
877 }
878
879 _restore_pos2(org_pos);
880 return false;
881}
882
883
884/**
885 * Search for some piece of code.
886 */
887static int k_func_searchcode(_str sSearchString, _str sOptions = "E+")
888{
889 int rc;
890 rc = search(sSearchString, sOptions);
891 while (!rc && !k_func_in_code())
892 {
893 p_col++;
894 rc = search(sSearchString, sOptions);
895 }
896 return rc;
897}
898
899
900/**
901 * Checks if cursor is in code or in comment.
902 * @return True if cursor in code.
903 */
904static boolean k_func_in_code()
905{
906 _save_pos2(searchsave);
907 boolean fRc = !_in_comment();
908 _restore_pos2(searchsave);
909 return fRc;
910}
911
912
913/*
914 * Gets the next piece of code.
915 */
916static _str k_func_get_next_code_text()
917{
918 _str ch;
919 _save_pos2(searchsave);
920 ch = k_func_get_next_code_text2();
921 _restore_pos2(searchsave);
922 return ch;
923}
924
925
926/**
927 * Checks if there is more code on the line.
928 */
929static boolean k_func_more_code_on_line()
930{
931 boolean fRc;
932 int curline = p_line;
933
934 _save_pos2(searchsave);
935 k_func_get_next_code_text2();
936 fRc = curline == p_line;
937 _restore_pos2(searchsave);
938
939 return fRc;
940}
941
942
943/**
944 * Gets the next piece of code.
945 * Doesn't preserver cursor position.
946 */
947static _str k_func_get_next_code_text2()
948{
949 _str ch;
950 do
951 {
952 curcol = ++p_col;
953 end_line()
954 if (p_col <= curcol)
955 {
956 p_line++;
957 p_col = 1;
958 }
959 else
960 p_col = curcol;
961
962 ch = get_text();
963 //say ch ' ('_asc(ch)')';
964 while (ch == "#") /* preprocessor stuff */
965 {
966 p_col = 1;
967 p_line++;
968 ch = get_text();
969 //say ch ' ('_asc(ch)')';
970 continue;
971 }
972 } while (ch :== ' ' || ch :== "\t" || ch :== "\n" || ch :== "\r" || !k_func_in_code());
973
974 return ch;
975}
976
977
978
979
980/*******************************************************************************
981* JAVA DOC STYLED WORKERS *
982*******************************************************************************/
983
984/** starts a javadoc documentation box. */
985static void k_javadoc_box_start(_str sStr = '', boolean fDouble = true)
986{
987 if (!k_commentconfig(sLeft, sRight, iColumn))
988 return;
989 _begin_line();
990 if (iColumn >= 0)
991 while (p_col < iColumn)
992 _insert_text(" ");
993
994 sText = sLeft;
995 if (fDouble)
996 sText = sLeft:+substr(sLeft, length(sLeft), 1);
997 if (sStr != '')
998 sText = sText:+' ':+sStr;
999 sText = sText:+"\n";
1000
1001 _insert_text(sText);
1002}
1003
1004/** inserts a new line in a javadoc documentation box. */
1005static void k_javadoc_box_line(_str sStr = '', int iPadd = 0, _str sStr2 = '', int iPadd2 = 0, _str sStr3 = '')
1006{
1007 if (!k_commentconfig(sLeft, sRight, iColumn))
1008 return;
1009 if (iColumn >= 0)
1010 while (p_col < iColumn)
1011 _insert_text(" ");
1012
1013 if (k_line_comment())
1014 sText = sLeft;
1015 else
1016 {
1017 sText = sLeft;
1018 sText = ' ':+substr(sLeft, length(sLeft));
1019 }
1020
1021 if (sStr != '')
1022 sText = sText:+' ':+sStr;
1023 if (iPadd > 0)
1024 {
1025 for (i = length(sText); i < iPadd; i++)
1026 sText = sText:+' ';
1027
1028 if (sStr2 != '')
1029 sText = sText:+sStr2;
1030
1031 if (iPadd2 > 0)
1032 {
1033 for (i = length(sText); i < iPadd2; i++)
1034 sText = sText:+' ';
1035
1036 if (sStr3 != '')
1037 sText = sText:+sStr3;
1038 }
1039 }
1040 sText = sText:+"\n";
1041
1042 _insert_text(sText);
1043}
1044
1045/** ends a javadoc documentation box. */
1046static void k_javadoc_box_end()
1047{
1048 if (!k_commentconfig(sLeft, sRight, iColumn))
1049 return;
1050 if (iColumn >= 0)
1051 while (p_col < iColumn)
1052 _insert_text(" ");
1053
1054 if (k_line_comment())
1055 sText = sLeft;
1056 else
1057 {
1058 sText = sRight;
1059 if (substr(sText, 1, 1) != '*')
1060 sText = '*':+sText;
1061 sText = ' ':+sText;
1062 }
1063 sText = sText:+"\n";
1064
1065 _insert_text(sText);
1066}
1067
1068
1069/**
1070 * Write a Javadoc styled classbox.
1071 */
1072void k_javadoc_classbox()
1073{
1074 int iCursorLine;
1075 int iPadd = k_alignup(12, p_SyntaxIndent);
1076
1077 k_javadoc_box_start();
1078 iCursorLine = p_RLine;
1079 k_javadoc_box_line(' ');
1080
1081 if (fkStyleFullHeaders)
1082 {
1083 k_javadoc_box_line('@shortdesc', iPadd);
1084 k_javadoc_box_line('@dstruct', iPadd);
1085 k_javadoc_box_line('@version', iPadd);
1086 k_javadoc_box_line('@verdesc', iPadd);
1087 }
1088 k_javadoc_box_line('@author', iPadd, skUserName " <" skUserEmail ">");
1089 k_javadoc_box_line('@approval', iPadd);
1090 k_javadoc_box_end();
1091
1092 up(p_RLine - iCursorLine);
1093 end_line();
1094 keyin(' ');
1095}
1096
1097
1098/**
1099 * Javadoc - functionbox(/header).
1100 */
1101void k_javadoc_funcbox()
1102{
1103 int cArgs = 1;
1104 _str sArgs = "";
1105 int iCursorLine;
1106 int iPadd = k_alignup(11, p_SyntaxIndent);
1107 /* look for parameters */
1108 boolean fFoundFn = !k_func_goto_nearest_function();
1109 if (fFoundFn)
1110 {
1111 sArgs = k_func_getparams();
1112 cArgs = k_func_countparams(sArgs);
1113 }
1114
1115 k_javadoc_box_start();
1116 iCursorLine = p_RLine;
1117 k_javadoc_box_line(' ');
1118 if (file_eq(p_extension, 'asm'))
1119 k_javadoc_box_line('@cproto', iPadd);
1120 k_javadoc_box_line('@returns', iPadd);
1121 if (fFoundFn)
1122 {
1123 /*
1124 * Determin parameter description indent.
1125 */
1126 int iPadd2 = 0;
1127 for (i = 0; i < cArgs; i++)
1128 {
1129 _str sName, sType, sDefault;
1130 if (!k_func_enumparams(sArgs, i, sType, sName, sDefault)
1131 && iPadd2 < length(sName))
1132 iPadd2 = length(sName);
1133 }
1134 iPadd2 = k_alignup((iPadd + iPadd2), p_SyntaxIndent);
1135
1136 /*
1137 * Insert parameter.
1138 */
1139 for (i = 0; i < cArgs; i++)
1140 {
1141 _str sName, sType, sDefault;
1142 if (!k_func_enumparams(sArgs, i, sType, sName, sDefault))
1143 {
1144 sStr3 = '';
1145 if (sDefault != "")
1146 sStr3 = '(default='sDefault')';
1147 k_javadoc_box_line('@param', iPadd, sName, iPadd2, sStr3);
1148 }
1149 else
1150 k_javadoc_box_line('@param', iPadd);
1151 }
1152 }
1153 else
1154 k_javadoc_box_line('@param', iPadd);
1155
1156 if (file_eq(p_extension, 'asm'))
1157 k_javadoc_box_line('@uses', iPadd);
1158 if (fkStyleFullHeaders)
1159 {
1160 k_javadoc_box_line('@equiv', iPadd);
1161 k_javadoc_box_line('@time', iPadd);
1162 }
1163 k_javadoc_box_line('@sketch', iPadd);
1164 k_javadoc_box_line('@status', iPadd);
1165 k_javadoc_box_line('@author', iPadd, skUserName '<' skUserEmail '>');
1166 k_javadoc_box_line('@remark', iPadd);
1167 k_javadoc_box_end();
1168
1169 up(p_RLine - iCursorLine);
1170 end_line();
1171 keyin(' ');
1172}
1173
1174
1175/**
1176 * Javadoc module header.
1177 */
1178void k_javadoc_moduleheader()
1179{
1180 int iCursorLine;
1181
1182 _begin_line();
1183 k_javadoc_box_start('$':+'I':+'d: $', false);
1184 k_javadoc_box_line();
1185 iCursorLine = p_RLine;
1186 k_javadoc_box_line();
1187 k_javadoc_box_line();
1188
1189 if (skLicense == 'Confidential')
1190 {
1191 k_javadoc_box_line(skCompany ' confidential');
1192 k_javadoc_box_line();
1193 }
1194
1195 if (skCompany != '')
1196 {
1197 k_javadoc_box_line('Copyright (c) ' k_year() ' ' skCompany);
1198 k_javadoc_box_line('Author: ' skUserName' <' skUserEmail '>');
1199 }
1200 else
1201 k_javadoc_box_line('Copyright (c) ' k_year() ' 'skUserName' <' skUserEmail '>');
1202 k_javadoc_box_line();
1203 switch (skLicense)
1204 {
1205 case 'Odin32':
1206 k_javadoc_box_line('Project Odin Software License can be found in LICENSE.TXT.');
1207 break;
1208
1209 case 'GPL':
1210 sProg = skProgram;
1211 k_javadoc_box_line()
1212 if (sProg == '')
1213 sProg = 'This program';
1214 else
1215 {
1216 k_javadoc_box_line('This file is part of ' sProg '.');
1217 k_javadoc_box_line();
1218 }
1219 k_javadoc_box_line(sProg ' is free software; you can redistribute it and/or modify');
1220 k_javadoc_box_line('it under the terms of the GNU General Public License as published by');
1221 k_javadoc_box_line('the Free Software Foundation; either version 2 of the License, or');
1222 k_javadoc_box_line('(at your option) any later version.');
1223 k_javadoc_box_line()
1224 k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful,');
1225 k_javadoc_box_line('but WITHOUT ANY WARRANTY; without even the implied warranty of');
1226 k_javadoc_box_line('MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the');
1227 k_javadoc_box_line('GNU General Public License for more details.');
1228 k_javadoc_box_line()
1229 k_javadoc_box_line('You should have received a copy of the GNU General Public License');
1230 k_javadoc_box_line('along with ' sProg '; if not, write to the Free Software');
1231 k_javadoc_box_line('Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA');
1232 break;
1233
1234 case 'LGPL':
1235 sProg = skProgram;
1236 k_javadoc_box_line()
1237 if (sProg == '')
1238 sProg = 'This program';
1239 else
1240 {
1241 k_javadoc_box_line('This file is part of ' sProg '.');
1242 k_javadoc_box_line();
1243 }
1244 k_javadoc_box_line(sProg ' is free software; you can redistribute it and/or modify');
1245 k_javadoc_box_line('it under the terms of the GNU Lesser General Public License as published');
1246 k_javadoc_box_line('by the Free Software Foundation; either version 2 of the License, or');
1247 k_javadoc_box_line('(at your option) any later version.');
1248 k_javadoc_box_line()
1249 k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful,');
1250 k_javadoc_box_line('but WITHOUT ANY WARRANTY; without even the implied warranty of');
1251 k_javadoc_box_line('MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the');
1252 k_javadoc_box_line('GNU Lesser General Public License for more details.');
1253 k_javadoc_box_line()
1254 k_javadoc_box_line('You should have received a copy of the GNU Lesser General Public License');
1255 k_javadoc_box_line('along with ' sProg '; if not, write to the Free Software');
1256 k_javadoc_box_line('Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA');
1257 break;
1258
1259 case 'Confidential':
1260 k_javadoc_box_line('All Rights Reserved');
1261 break;
1262
1263 default:
1264
1265 }
1266 k_javadoc_box_line();
1267 k_javadoc_box_end();
1268
1269 up(p_RLine - iCursorLine);
1270 end_line();
1271 keyin(' ');
1272}
1273
1274
1275
1276
1277
1278
1279
1280/*******************************************************************************
1281* Keyboard Shortcuts *
1282*******************************************************************************/
1283/** Makes global box. */
1284void k_box_globals()
1285{
1286 k_box_start('Global');
1287 k_box_line('Global Variables');
1288 k_box_end();
1289}
1290
1291/** Makes header box. */
1292void k_box_headers()
1293{
1294 k_box_start("Header");
1295 k_box_line("Header Files");
1296 k_box_end();
1297}
1298
1299/** Makes internal function box. */
1300void k_box_intfuncs()
1301{
1302 k_box_start("IntFunc");
1303 k_box_line("Internal Functions");
1304 k_box_end();
1305}
1306
1307/** Makes def/const box. */
1308void k_box_consts()
1309{
1310 k_box_start("Const");
1311 k_box_line("Defined Constants And Macros");
1312 k_box_end();
1313}
1314
1315/** Structure box */
1316void k_box_structs()
1317{
1318 k_box_start("Struct");
1319 k_box_line("Structures and Typedefs");
1320 k_box_end();
1321}
1322
1323/** Makes exported symbols box. */
1324void k_box_exported()
1325{
1326 k_box_start('Exported');
1327 k_box_line('Exported Symbols');
1328 k_box_end();
1329}
1330
1331
1332
1333/** oneliner comment */
1334void k_oneliner()
1335{
1336 if ( k_commentconfig(sLeft, sRight, iColumn)
1337 && iColumn > 0)
1338 { /* column based needs some tricy repositioning. */
1339 _end_line();
1340 if (p_col > iColumn)
1341 {
1342 _begin_line();
1343 _insert_text("\n\r");
1344 up();
1345 }
1346 }
1347 k_insert_comment("", KIC_CURSOR_AT_END, ikStyleOneliner);
1348}
1349
1350/** mark line as modified. */
1351void k_mark_modified_line()
1352{
1353 /* not supported for column based sources */
1354 if ( !k_commentconfig(sLeft, sRight, iColumn)
1355 || iColumn > 0)
1356 return;
1357
1358 if (skChange != '')
1359 sStr = skChange ' (' skUserInitials ')';
1360 else
1361 sStr = skUserInitials;
1362 k_insert_comment(sStr, KIC_CURSOR_BEFORE, ikStyleModifyMarkColumn);
1363 down();
1364}
1365
1366
1367/**
1368 * Inserts a signature. Form: "//Initials ISO-date:"
1369 * @remark defeventtab
1370 */
1371void k_signature()
1372{
1373 /* kso I5-10000 2002-09-10: */
1374 if (skChange != '')
1375 sSig = skUserInitials ' ' skChange ' ' k_date() ': ';
1376 else
1377 sSig = skUserInitials ' ' k_date() ': ';
1378 k_insert_comment(sSig, KIC_CURSOR_AT_END);
1379}
1380
1381
1382/*******************************************************************************
1383* kLIB Logging *
1384*******************************************************************************/
1385/**
1386 * Hot-Key: Inserts a KLOGENTRY statement at start of nearest function.
1387 */
1388void klib_klogentry()
1389{
1390 _save_pos2(org_pos);
1391
1392 /*
1393 * Go to nearest function.
1394 */
1395 if (!k_func_goto_nearest_function())
1396 {
1397 /*
1398 * Get parameters.
1399 */
1400 _str sParams = k_func_getparams();
1401 if (sParams)
1402 {
1403 _str sRetType = k_func_getreturntype(true);
1404 if (!sRetType || sRetType == "")
1405 sRetType = "void"; /* paranoia! */
1406
1407 /*
1408 * Insert text.
1409 */
1410 if (!k_func_searchcode("{"))
1411 {
1412 p_col++;
1413 cArgs = k_func_countparams(sParams);
1414 if (cArgs > 0)
1415 {
1416 sArgs = "";
1417 for (i = 0; i < cArgs; i++)
1418 {
1419 _str sType, sName, sDefault
1420 if (!k_func_enumparams(sParams, i, sType, sName, sDefault))
1421 sArgs = sArgs', 'sName;
1422 }
1423
1424 _insert_text("\n KLOGENTRY"cArgs"(\""sRetType"\",\""sParams"\""sArgs");"); /* todo tab size.. or smart indent */
1425 }
1426 else
1427 _insert_text("\n KLOGENTRY0(\""sRetType"\");"); /* todo tab size.. or smart indent */
1428
1429 /*
1430 * Check if the next word is KLOGENTRY.
1431 */
1432 next_word();
1433 if (def_next_word_style == 'E')
1434 prev_word();
1435 if (substr(cur_word(iIgnorePos), 1, 9) == "KLOGENTRY")
1436 delete_line();
1437
1438 }
1439 else
1440 message("didn't find {");
1441 }
1442 else
1443 message("k_func_getparams failed, sParams=" sParams);
1444 return;
1445 }
1446
1447 _restore_pos2(org_pos);
1448}
1449
1450
1451/**
1452 * Hot-Key: Inserts a KLOGEXIT statement at cursor location.
1453 */
1454void klib_klogexit()
1455{
1456 _save_pos2(org_pos);
1457
1458 /*
1459 * Go to nearest function.
1460 */
1461 if (!prev_proc())
1462 {
1463 /*
1464 * Get parameters.
1465 */
1466 _str sType = k_func_getreturntype(true);
1467 _restore_pos2(org_pos);
1468 if (sType)
1469 {
1470 boolean fReturn = true; /* true if an return statment is following the KLOGEXIT statement. */
1471
1472 /*
1473 * Insert text.
1474 */
1475 cur_col = p_col;
1476 if (sType == 'void' || sType == 'VOID')
1477 { /* procedure */
1478 fReturn = cur_word(iIgnorePos) == 'return';
1479 if (!fReturn)
1480 {
1481 while (p_col <= p_SyntaxIndent)
1482 keyin(" ");
1483 }
1484
1485 _insert_text("KLOGEXITVOID();\n");
1486
1487 if (fReturn)
1488 {
1489 for (i = 1; i < cur_col; i++)
1490 _insert_text(" ");
1491 }
1492 search(")","E-");
1493 }
1494 else
1495 { /* function */
1496 _insert_text("KLOGEXIT();\n");
1497 for (i = 1; i < cur_col; i++)
1498 _insert_text(" ");
1499 search(")","E-");
1500
1501 /*
1502 * Insert value if possible.
1503 */
1504 _save_pos2(valuepos);
1505 next_word();
1506 if (def_next_word_style == 'E')
1507 prev_word();
1508 if (cur_word(iIgnorePos) == 'return')
1509 {
1510 p_col += length('return');
1511 _save_pos2(posStart);
1512 offStart = _QROffset();
1513 if (!k_func_searchcode(";", "E+"))
1514 {
1515 offEnd = _QROffset();
1516 _restore_pos2(posStart);
1517 _str sValue = strip(get_text(offEnd - offStart));
1518 //say 'sValue = 'sValue;
1519 _restore_pos2(valuepos);
1520 _save_pos2(valuepos);
1521 _insert_text(sValue);
1522 }
1523 }
1524 _restore_pos2(valuepos);
1525 }
1526
1527 /*
1528 * Remove old KLOGEXIT statement on previous line if any.
1529 */
1530 _save_pos2(valuepos);
1531 newexitline = p_line;
1532 p_line--; p_col = 1;
1533 next_word();
1534 if (def_next_word_style == 'E')
1535 prev_word();
1536 if (p_line == newexitline - 1 && substr(cur_word(iIgnorePos), 1, 8) == 'KLOGEXIT')
1537 delete_line();
1538 _restore_pos2(valuepos);
1539
1540 /*
1541 * Check for missing '{...}'.
1542 */
1543 if (fReturn)
1544 {
1545 boolean fFound = false;
1546 _save_pos2(valuepos);
1547 p_col--; find_matching_paren(); p_col += 2;
1548 k_func_searchcode(';', 'E+'); /* places us at the ';' of the return. (hopefully) */
1549
1550 _str ch = k_func_get_next_code_text();
1551 if (ch != '}')
1552 {
1553 _restore_pos2(valuepos);
1554 _save_pos2(valuepos);
1555 p_col--; find_matching_paren(); p_col += 2;
1556 k_func_searchcode(';', 'E+'); /* places us at the ';' of the return. (hopefully) */
1557 p_col++;
1558 if (k_func_more_code_on_line())
1559 _insert_text(' }');
1560 else
1561 {
1562 _save_pos2(returnget);
1563 k_func_searchcode("return", "E-");
1564 return_col = p_col;
1565 _restore_pos2(returnget);
1566
1567 end_line();
1568 _insert_text("\n");
1569 while (p_col < return_col - p_SyntaxIndent)
1570 _insert_text(' ');
1571 _insert_text('}');
1572 }
1573
1574 _restore_pos2(valuepos);
1575 _save_pos2(valuepos);
1576 prev_word();
1577 p_col -= p_SyntaxIndent;
1578 codecol = p_col;
1579 _insert_text("{\n");
1580 while (p_col < codecol)
1581 _insert_text(' ');
1582 }
1583
1584 _restore_pos2(valuepos);
1585 }
1586 }
1587 else
1588 message("k_func_getreturntype failed, sType=" sType);
1589 return;
1590 }
1591
1592 _restore_pos2(org_pos);
1593}
1594
1595
1596/**
1597 * Processes a file - ask user all the time.
1598 */
1599void klib_klog_file_ask()
1600{
1601 klib_klog_file_int(true)
1602}
1603
1604
1605/**
1606 * Processes a file - no questions.
1607 */
1608void klib_klog_file_no_ask()
1609{
1610 klib_klog_file_int(false)
1611}
1612
1613
1614
1615/**
1616 * Processes a file.
1617 */
1618static void klib_klog_file_int(boolean fAsk)
1619{
1620 show_all();
1621 bottom();
1622 _refresh_scroll();
1623
1624 /* ask question so we can get to the right position somehow.. */
1625 if (fAsk && _message_box("kLog process this file?", "Visual SlickEdit", MB_YESNO | MB_ICONQUESTION) != IDYES)
1626 return;
1627
1628 /*
1629 * Entries.
1630 */
1631 while (!prev_proc())
1632 {
1633 //say 'entry main loop: ' k_func_getfunction_name();
1634
1635 /*
1636 * Skip prototypes.
1637 */
1638 if (k_func_prototype())
1639 continue;
1640
1641 /*
1642 * Ask user.
1643 */
1644 center_line();
1645 _refresh_scroll();
1646 sFunction = k_func_getfunction_name();
1647 rc = fAsk ? _message_box("Process this function ("sFunction")?", "Visual SlickEdit", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
1648 if (rc == IDYES)
1649 {
1650 _save_pos2(procpos);
1651 klib_klogentry();
1652 _restore_pos2(procpos);
1653 }
1654 else if (rc == IDNO)
1655 continue;
1656 else
1657 break;
1658 }
1659
1660 /*
1661 * Exits.
1662 */
1663 bottom(); _refresh_scroll();
1664 boolean fUserCancel = false;
1665 while (!prev_proc() && !fUserCancel)
1666 {
1667 _save_pos2(procpos);
1668 sCurFunction = k_func_getfunction_name();
1669 //say 'exit main loop: ' sCurFunction
1670
1671 /*
1672 * Skip prototypes.
1673 */
1674 if (k_func_prototype())
1675 continue;
1676
1677 /*
1678 * Select procedure.
1679 */
1680 while ( !k_func_searchcode("return", "WE<+")
1681 && k_func_getfunction_name() == sCurFunction)
1682 {
1683 //say 'exit sub loop: ' p_line
1684 /*
1685 * Ask User.
1686 */
1687 center_line();
1688 _refresh_scroll();
1689 sFunction = k_func_getfunction_name();
1690 rc = fAsk ? _message_box("Process this exit from "sFunction"?", "Visual SlickEdit", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
1691 deselect();
1692 if (rc == IDYES)
1693 {
1694 _save_pos2(returnpos);
1695 klib_klogexit();
1696 _restore_pos2(returnpos);
1697 p_line++;
1698 }
1699 else if (rc != IDNO)
1700 {
1701 fUserCancel = true;
1702 break;
1703 }
1704 p_line++; /* just so we won't hit it again. */
1705 }
1706
1707 /*
1708 * If void function we'll have to check if there is and return; prior to the ending '}'.
1709 */
1710 _restore_pos2(procpos);
1711 _save_pos2(procpos);
1712 sType = k_func_getreturntype(true);
1713 if (!fUserCancel && sType && (sType == 'void' || sType == 'VOID'))
1714 {
1715 if ( !k_func_searchcode("{", "E+")
1716 && !find_matching_paren())
1717 {
1718 _save_pos2(funcend);
1719 prev_word();
1720 if (cur_word(iIgnorePos) != "return")
1721 {
1722 /*
1723 * Ask User.
1724 */
1725 _restore_pos2(funcend);
1726 center_line();
1727 _refresh_scroll();
1728 sFunction = k_func_getfunction_name();
1729 rc = fAsk ? _message_box("Process this exit from "sFunction"?", "Visual SlickEdit", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
1730 deselect();
1731 if (rc == IDYES)
1732 {
1733 _save_pos2(returnpos);
1734 klib_klogexit();
1735 _restore_pos2(returnpos);
1736 }
1737 }
1738 }
1739 }
1740
1741 /*
1742 * Next proc.
1743 */
1744 _restore_pos2(procpos);
1745 }
1746}
1747
1748
1749/*******************************************************************************
1750* Odin32 backward compatibility *
1751*******************************************************************************/
1752_command void odin32_maketagfile()
1753{
1754 /* We'll */
1755 if (file_match('-p 'maybe_quote_filename(strip_filename(_project_name,'e'):+TAG_FILE_EXT),1) != "")
1756 {
1757 _project_update_files_retag(false,false,false,false);
1758 /*
1759 RetagFilesInTagFile2(project_tag_file, orig_view_id, temp_view_id, rebuild_all, false,
1760 doRemove,false,true,true);*/7
1761 }
1762 else
1763 _project_update_files_retag(true,false,false,true);
1764}
1765
1766_command void odin32_setcurrentdir()
1767{
1768 //_ini_get_value(_project_name,"COMPILER","WORKINGDIR", workingdir);
1769 //cd(workingdir);
1770 /* Go the the directory containing the project filename */
1771 cd(strip_filename(_project_name, 'NE'));
1772}
1773
1774
1775
1776
1777/*******************************************************************************
1778* Styles *
1779*******************************************************************************/
1780static _str StyleLanguages[] =
1781{
1782 "c",
1783 "e",
1784 "java"
1785};
1786
1787struct StyleScheme
1788{
1789 _str name;
1790 _str settings[];
1791};
1792
1793static StyleScheme StyleSchemes[] =
1794{
1795 {
1796 "Opt2Ind4",
1797 {
1798 "orig_tabsize=4",
1799 "syntax_indent=4",
1800 "tabsize=4",
1801 "align_on_equal=1",
1802 "pad_condition_state=1",
1803 "indent_with_tabs=0",
1804 "nospace_before_paren=0",
1805 "indent_comments=1",
1806 "indent_case=1",
1807 "statement_comment_col=0",
1808 "disable_bestyle=0",
1809 "decl_comment_col=0",
1810 "bestyle_on_functions=0",
1811 "use_relative_indent=1",
1812 "nospace_before_brace=0",
1813 "indent_fl=1",
1814 "statement_comment_state=2",
1815 "indent_pp=1",
1816 "be_style=1",
1817 "parens_on_return=0",
1818 "eat_blank_lines=0",
1819 "brace_indent=0",
1820 "eat_pp_space=1",
1821 "align_on_parens=1",
1822 "continuation_indent=0",
1823 "cuddle_else=0",
1824 "nopad_condition=1",
1825 "pad_condition=0",
1826 "indent_col1_comments=0"
1827 }
1828 }
1829 ,
1830 {
1831 "Opt2Ind3",
1832 {
1833 "orig_tabsize=3",
1834 "syntax_indent=3",
1835 "tabsize=3",
1836 "align_on_equal=1",
1837 "pad_condition_state=1",
1838 "indent_with_tabs=0",
1839 "nospace_before_paren=0",
1840 "indent_comments=1",
1841 "indent_case=1",
1842 "statement_comment_col=0",
1843 "disable_bestyle=0",
1844 "decl_comment_col=0",
1845 "bestyle_on_functions=0",
1846 "use_relative_indent=1",
1847 "nospace_before_brace=0",
1848 "indent_fl=1",
1849 "statement_comment_state=2",
1850 "indent_pp=1",
1851 "be_style=1",
1852 "parens_on_return=0",
1853 "eat_blank_lines=0",
1854 "brace_indent=0",
1855 "eat_pp_space=1",
1856 "align_on_parens=1",
1857 "continuation_indent=0",
1858 "cuddle_else=0",
1859 "nopad_condition=1",
1860 "pad_condition=0",
1861 "indent_col1_comments=0"
1862 }
1863 }
1864 ,
1865 {
1866 "Opt2Ind8",
1867 {
1868 "orig_tabsize=8",
1869 "syntax_indent=8",
1870 "tabsize=8",
1871 "align_on_equal=1",
1872 "pad_condition_state=1",
1873 "indent_with_tabs=0",
1874 "nospace_before_paren=0",
1875 "indent_comments=1",
1876 "indent_case=1",
1877 "statement_comment_col=0",
1878 "disable_bestyle=0",
1879 "decl_comment_col=0",
1880 "bestyle_on_functions=0",
1881 "use_relative_indent=1",
1882 "nospace_before_brace=0",
1883 "indent_fl=1",
1884 "statement_comment_state=2",
1885 "indent_pp=1",
1886 "be_style=1",
1887 "parens_on_return=0",
1888 "eat_blank_lines=0",
1889 "brace_indent=0",
1890 "eat_pp_space=1",
1891 "align_on_parens=1",
1892 "continuation_indent=0",
1893 "cuddle_else=0",
1894 "nopad_condition=1",
1895 "pad_condition=0",
1896 "indent_col1_comments=0"
1897 }
1898 }
1899 ,
1900 {
1901 "Opt3Ind4",
1902 {
1903 "orig_tabsize=4",
1904 "syntax_indent=4",
1905 "tabsize=4",
1906 "align_on_equal=1",
1907 "pad_condition_state=1",
1908 "indent_with_tabs=0",
1909 "nospace_before_paren=0",
1910 "indent_comments=1",
1911 "indent_case=1",
1912 "statement_comment_col=0",
1913 "disable_bestyle=0",
1914 "decl_comment_col=0",
1915 "bestyle_on_functions=0",
1916 "use_relative_indent=1",
1917 "nospace_before_brace=0",
1918 "indent_fl=1",
1919 "statement_comment_state=2",
1920 "indent_pp=1",
1921 "be_style=2",
1922 "parens_on_return=0",
1923 "eat_blank_lines=0",
1924 "brace_indent=0",
1925 "eat_pp_space=1",
1926 "align_on_parens=1",
1927 "continuation_indent=0",
1928 "cuddle_else=0",
1929 "nopad_condition=1",
1930 "pad_condition=0",
1931 "indent_col1_comments=0"
1932 }
1933 }
1934 ,
1935 {
1936 "Opt3Ind3",
1937 {
1938 "orig_tabsize=3",
1939 "syntax_indent=3",
1940 "tabsize=3",
1941 "align_on_equal=1",
1942 "pad_condition_state=1",
1943 "indent_with_tabs=0",
1944 "nospace_before_paren=0",
1945 "indent_comments=1",
1946 "indent_case=1",
1947 "statement_comment_col=0",
1948 "disable_bestyle=0",
1949 "decl_comment_col=0",
1950 "bestyle_on_functions=0",
1951 "use_relative_indent=1",
1952 "nospace_before_brace=0",
1953 "indent_fl=1",
1954 "statement_comment_state=2",
1955 "indent_pp=1",
1956 "be_style=2",
1957 "parens_on_return=0",
1958 "eat_blank_lines=0",
1959 "brace_indent=0",
1960 "eat_pp_space=1",
1961 "align_on_parens=1",
1962 "continuation_indent=0",
1963 "cuddle_else=0",
1964 "nopad_condition=1",
1965 "pad_condition=0",
1966 "indent_col1_comments=0"
1967 }
1968 }
1969};
1970
1971
1972static void k_styles_create()
1973{
1974 /*
1975 * Find user format ini file.
1976 */
1977 userini = maybe_quote_filename(_config_path():+'uformat.ini');
1978 if (file_match('-p 'userini, 1) == '')
1979 {
1980 ini = maybe_quote_filename(slick_path_search('uformat.ini'));
1981 if (ini != '') userini = ini;
1982 }
1983
1984
1985 /*
1986 * Remove any old schemes.
1987 */
1988 for (i = 0; i < StyleSchemes._length(); i++)
1989 for (j = 0; j < StyleLanguages._length(); j++)
1990 {
1991 sectionname = StyleLanguages[j]:+'-scheme-':+StyleSchemes[i].name;
1992 if (!_ini_get_section(userini, sectionname, tv))
1993 {
1994 _ini_delete_section(userini, sectionname);
1995 _delete_temp_view(tv);
1996 //message("delete old scheme");
1997 }
1998 }
1999
2000 /*
2001 * Create the new schemes.
2002 */
2003 for (i = 0; i < StyleSchemes._length(); i++)
2004 {
2005 for (j = 0; j < StyleLanguages._length(); j++)
2006 {
2007 sectionname = StyleLanguages[j]:+'-scheme-':+StyleSchemes[i].name;
2008 orig_view_id = _create_temp_view(temp_view_id);
2009 activate_view(temp_view_id);
2010 for (k = 0; k < StyleSchemes[i].settings._length(); k++)
2011 insert_line(StyleSchemes[i].settings[k]);
2012
2013 /* Insert the scheme section. */
2014 _ini_replace_section(userini, sectionname, temp_view_id);
2015 //message(userini)
2016 activate_view(orig_view_id);
2017 }
2018 }
2019
2020 //last_scheme = last scheme name!!!
2021}
2022
2023
2024/*
2025 * Sets the last used beutify scheme.
2026 */
2027static k_styles_set(_str scheme)
2028{
2029
2030 /*
2031 * Find user format ini file.
2032 */
2033 userini = maybe_quote_filename(_config_path():+'uformat.ini');
2034 if (file_match('-p 'userini, 1) == '')
2035 {
2036 ini = maybe_quote_filename(slick_path_search('uformat.ini'));
2037 if (ini != '') userini = ini;
2038 }
2039
2040 /*
2041 * Set the scheme for each language.
2042 */
2043 for (j = 0; j < StyleLanguages._length(); j++)
2044 {
2045 _ini_set_value(userini,
2046 StyleLanguages[j]:+'-scheme-Default',
2047 'last_scheme',
2048 scheme);
2049 }
2050}
2051
2052
2053static _str defoptions[] =
2054{
2055 "def-options-sas",
2056 "def-options-js",
2057 "def-options-bat",
2058 "def-options-c",
2059 "def-options-pas",
2060 "def-options-e",
2061 "def-options-java",
2062 "def-options-bourneshell",
2063 "def-options-csh",
2064 "def-options-vlx",
2065 "def-options-plsql",
2066 "def-options-sqlserver",
2067 "def-options-cmd"
2068};
2069
2070static _str defsetups[] =
2071{
2072 "def-setup-sas",
2073 "def-setup-js",
2074 "def-setup-bat",
2075 "def-setup-fundamental",
2076 "def-setup-process",
2077 "def-setup-c",
2078 "def-setup-pas",
2079 "def-setup-e",
2080 "def-setup-asm",
2081 "def-setup-java",
2082 "def-setup-html",
2083 "def-setup-bourneshell",
2084 "def-setup-csh",
2085 "def-setup-vlx",
2086 "def-setup-fileman",
2087 "def-setup-plsql",
2088 "def-setup-sqlserver",
2089 "def-setup-s",
2090 "def-setup-cmd"
2091};
2092
2093static _str defsetupstab8[] =
2094{
2095 "def-setup-c"
2096};
2097
2098
2099static void k_styles_setindent(int indent, int iBraceStyle, boolean iWithTabs = false)
2100{
2101 if (iBraceStyle < 1 || iBraceStyle > 3)
2102 {
2103 say 'k_styles_setindent: iBraceStyle is bad (='iBraceStyle')';
2104 iBraceStyle = 2;
2105 }
2106 /*
2107 * def-options for extentions known to have that info.
2108 */
2109 for (i = 0; i < defoptions._length(); i++)
2110 {
2111 idx = find_index(defoptions[i], MISC_TYPE);
2112 if (!idx)
2113 continue;
2114
2115 parse name_info(idx) with syntax_indent o2 o3 o4 flags indent_fl o7 indent_case rest;
2116
2117 /* Begin/end style */
2118 flags = flags & ~(1|2);
2119 flags = flags | (iBraceStyle - 1); /* Set style (0-based) */
2120 flags = flags & ~(16); /* no scape before parent.*/
2121 indent_fl = 1; /* Indent first level */
2122 indent_case = 1; /* Indent case from switch */
2123
2124 sNewOptions = indent' 'o2' 'o3' 'o4' 'flags' 'indent_fl' 'o7' 'indent_case' 'rest;
2125 set_name_info(idx, sNewOptions);
2126 _config_modify |= CFGMODIFY_DEFDATA;
2127 }
2128
2129 /*
2130 * def-setup for known extentions.
2131 */
2132 for (i = 0; i < defsetups._length(); i++)
2133 {
2134 idx = find_index(defsetups[i], MISC_TYPE);
2135 if (!idx)
2136 continue;
2137 sExt = substr(defsetups[i], length('def-setup-') + 1);
2138 sSetup = name_info(idx);
2139
2140 /*
2141 parse sSetup with 'MN=' mode_name ','\
2142 'TABS=' tabs ',' 'MA=' margins ',' 'KEYTAB=' keytab_name ','\
2143 'WW='word_wrap_style ',' 'IWT='indent_with_tabs ','\
2144 'ST='show_tabs ',' 'IN='indent_style ','\
2145 'WC='word_chars',' 'LN='lexer_name',' 'CF='color_flags','\
2146 'LNL='line_numbers_len','rest;
2147
2148 indent_with_tabs = 0; /* Indent with tabs */
2149
2150 /* Make sure all the values are legal */
2151 _ext_init_values(ext, lexer_name, color_flags);
2152 if (!isinteger(line_numbers_len)) line_numbers_len = 0;
2153 if (word_chars == '') word_chars = 'A-Za-z0-9_$';
2154 if (word_wrap_style == '') word_wrap_style = 3;
2155 if (show_tabs == '') show_tabs = 0;
2156 if (indent_style == '') indent_style = INDENT_SMART;
2157
2158 /* Set new indent */
2159 tabs = '+'indent;
2160 */
2161
2162 sNewSetup = sSetup;
2163
2164 /* Set new indent */
2165 if (pos('TABS=', sNewSetup) > 0)
2166 {
2167 /*
2168 * If either in defoptions or defsetupstab8 use default tab of 8
2169 * For those supporting separate syntax indent using the normal tabsize
2170 * helps us a lot when reading it...
2171 */
2172 fTab8 = false;
2173 for (j = 0; !fTab8 && j < defsetupstab8._length(); j++)
2174 if (substr(defsetupstab8[j], lastpos('-', defsetupstab8[j]) + 1) == sExt)
2175 fTab8 = true;
2176 for (j = 0; !fTab8 && j < defoptions._length(); j++)
2177 if (substr(defoptions[j], lastpos('-', defoptions[j]) + 1) == sExt)
2178 fTab8 = true;
2179
2180 parse sNewSetup with sPre 'TABS=' sValue ',' sPost;
2181 if (fTab8)
2182 sNewSetup = sPre 'TABS=+8,' sPost
2183 else
2184 sNewSetup = sPre 'TABS=+' indent ',' sPost
2185 }
2186
2187 /* Set indent with tabs flag. */
2188 if (pos('IWT=', sNewSetup) > 0)
2189 {
2190 parse sNewSetup with sPre 'IWT=' sValue ',' sPost;
2191 if (iWithTabs)
2192 sNewSetup = sPre 'IWT=1,' sPost
2193 else
2194 sNewSetup = sPre 'IWT=0,' sPost
2195 }
2196
2197 /* Do the real changes */
2198 set_name_info(idx, sNewSetup);
2199 _config_modify |= CFGMODIFY_DEFDATA;
2200 _update_buffers(sExt);
2201 }
2202}
2203
2204
2205/*******************************************************************************
2206* Menu and Menu commands *
2207*******************************************************************************/
2208static int iTimer = 0;
2209static int mhExtra = 0;
2210static int mhCode = 0;
2211static int mhDoc = 0;
2212static int mhLic = 0;
2213static int mhPre = 0;
2214
2215/*
2216 * Creates the Extra menu.
2217 */
2218static k_menu_create()
2219{
2220 if (arg(1) == 'timer')
2221 _kill_timer(iTimer);
2222 menu_handle = _mdi.p_menu_handle;
2223 menu_index = find_index(_cur_mdi_menu,oi2type(OI_MENU));
2224
2225 /*
2226 * Remove any old menu.
2227 */
2228 mhDelete = iPos = 0;
2229 index = _menu_find(menu_handle, "Extra", mhDelete, iPos, 'C');
2230 //message("index="index " mhDelete="mhDelete " iPos="iPos);
2231 if (index == 0)
2232 _menu_delete(mhDelete, iPos);
2233
2234
2235 /*
2236 * Insert the "Extra" menu.
2237 */
2238 mhExtra = _menu_insert(menu_handle, 9, MF_SUBMENU, "E&xtra", "", "Extra");
2239 mhCode=_menu_insert(mhExtra, -1, MF_ENABLED | MF_SUBMENU, "Coding &Style", "", "coding");
2240 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 2, Syntax Indent 4 (knut)", "k_menu_style Opt2Ind4", "Opt2Ind4");
2241 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 2, Syntax Indent 3", "k_menu_style Opt2Ind3", "Opt2Ind3");
2242 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 2, Syntax Indent 8", "k_menu_style Opt2Ind8", "Opt2Ind8");
2243 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 3, Syntax Indent 4 (giws)", "k_menu_style Opt3Ind4", "Opt3Ind4");
2244 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 3, Syntax Indent 3 (giws)", "k_menu_style Opt3Ind3", "Opt3Ind3");
2245
2246 mhDoc= _menu_insert(mhExtra, -1, MF_ENABLED | MF_SUBMENU, "&Documentation", "", "doc");
2247 mhDSJ= _menu_insert(mhDoc, -1, MF_ENABLED | MF_UNCHECKED, "&Javadoc Style", "k_menu_doc_style javadoc", "javadoc");
2248 mhDSL= _menu_insert(mhDoc, -1, MF_GRAYED | MF_UNCHECKED, "&Linux Kernel Style", "k_menu_doc_style linux", "linux");
2249
2250 mhLic= _menu_insert(mhExtra, -1, MF_ENABLED | MF_SUBMENU, "&License", "", "License");
2251 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&Odin32", "k_menu_license Odin32", "Odin32");
2252 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&GPL", "k_menu_license GPL", "GPL");
2253 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&LGPL", "k_menu_license LGPL", "LGPL");
2254 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&Confidential", "k_menu_license Confidential", "Confidential");
2255
2256 rc = _menu_insert(mhExtra, -1, MF_ENABLED, "-", "", "dash vars");
2257 rc = _menu_insert(mhExtra, -1, MF_ENABLED, skChange == '' ? '&Change...' : '&Change (' skChange ')...', "k_menu_change", "");
2258 rc = _menu_insert(mhExtra, -1, MF_ENABLED, skProgram == '' ? '&Program...' : '&Program (' skProgram ')...', "k_menu_program", "");
2259 rc = _menu_insert(mhExtra, -1, MF_ENABLED, skCompany == '' ? 'Co&mpany...' : 'Co&mpany (' skCompany ')...', "k_menu_company", "");
2260 rc = _menu_insert(mhExtra, -1, MF_ENABLED, '&User Name (' skUserName ')...', "k_menu_user_name", "username");
2261 rc = _menu_insert(mhExtra, -1, MF_ENABLED, 'User &e-mail (' skUserEmail ')...', "k_menu_user_email", "useremail");
2262 rc = _menu_insert(mhExtra, -1, MF_ENABLED, 'User &Initials (' skUserInitials ')...', "k_menu_user_initials", "userinitials");
2263 rc = _menu_insert(mhExtra, -1, MF_ENABLED, "-", "", "dash preset");
2264 mhPre= _menu_insert(mhExtra, -1, MF_SUBMENU, "P&resets", "", "");
2265 rc = _menu_insert(mhPre, -1, MF_ENABLED, "Odin32", "k_menu_preset javadoc, Odin32, Opt2Ind4,,Odin32", "odin32");
2266 rc = _menu_insert(mhPre, -1, MF_ENABLED, "Linux Kernel","k_menu_preset linux, GPL, Opt1Ind4,,Linux", "linux");
2267 rc = _menu_insert(mhPre, -1, MF_ENABLED, "The Bird", "k_menu_preset javadoc, GPL, Opt2Ind4", "bird");
2268 rc = _menu_insert(mhPre, -1, MF_ENABLED, "Win32k", "k_menu_preset javadoc, GPL, Opt2Ind4,, Win32k", "Win32k");
2269 rc = _menu_insert(mhPre, -1, MF_ENABLED, "kKrnlLib", "k_menu_preset javadoc, GPL, Opt2Ind4,, kKrnlLib", "kKrnlLib");
2270 rc = _menu_insert(mhPre, -1, MF_ENABLED, "kLib", "k_menu_preset javadoc, GPL, Opt2Ind4,, kLib", "kLib");
2271 rc = _menu_insert(mhPre, -1, MF_ENABLED, "kBuild", "k_menu_preset javadoc, GPL, Opt2Ind4,, kBuild", "kBuild");
2272 rc = _menu_insert(mhPre, -1, MF_ENABLED, "Innotek", "k_menu_preset javadoc, Confidential, Opt2Ind4, InnoTek Systemberatung GmbH", "Innotek");
2273 rc = _menu_insert(mhPre, -1, MF_ENABLED, "VPC/2", "k_menu_preset javadoc, Confidential, Opt2Ind4, InnoTek Systemberatung GmbH, VPC/2", "VPC2");
2274
2275 k_menu_doc_style();
2276 k_menu_license();
2277 k_menu_style();
2278}
2279
2280
2281/**
2282 * Change change Id.
2283 */
2284_command k_menu_change()
2285{
2286 sRc = show("-modal k_form_simple_input", "Change ID", skChange);
2287 if (sRc != "\r")
2288 {
2289 skChange = sRc;
2290 k_menu_create();
2291 }
2292}
2293
2294
2295/**
2296 * Change program name.
2297 */
2298_command k_menu_program()
2299{
2300 sRc = show("-modal k_form_simple_input", "Program", skProgram);
2301 if (sRc != "\r")
2302 {
2303 skProgram = sRc;
2304 k_menu_create();
2305 }
2306}
2307
2308
2309/**
2310 * Change company.
2311 */
2312_command k_menu_company()
2313{
2314 if (skCompany == '')
2315 sRc = show("-modal k_form_simple_input", "Company", 'InnoTek Systemberatung GmbH');
2316 else
2317 sRc = show("-modal k_form_simple_input", "Company", skCompany);
2318 if (sRc != "\r")
2319 {
2320 skCompany = sRc;
2321 k_menu_create();
2322 }
2323}
2324
2325
2326/**
2327 * Change user name.
2328 */
2329_command k_menu_user_name()
2330{
2331 sRc = show("-modal k_form_simple_input", "User Name", skUserName);
2332 if (sRc != "\r" && sRc != '')
2333 {
2334 skUserName = sRc;
2335 k_menu_create();
2336 }
2337}
2338
2339
2340/**
2341 * Change user email.
2342 */
2343_command k_menu_user_email()
2344{
2345 sRc = show("-modal k_form_simple_input", "User e-mail", skUserEmail);
2346 if (sRc != "\r" && sRc != '')
2347 {
2348 skUserEmail = sRc;
2349 k_menu_create();
2350 }
2351}
2352
2353
2354/**
2355 * Change user initials.
2356 */
2357_command k_menu_user_initials()
2358{
2359 sRc = show("-modal k_form_simple_input", "User e-mail", skUserInitials);
2360 if (sRc != "\r" && sRc != '')
2361 {
2362 skUserInitials = sRc;
2363 k_menu_create();
2364 }
2365}
2366
2367
2368
2369/**
2370 * Checks the correct menu item.
2371 */
2372_command void k_menu_doc_style(_str sNewDocStyle = '')
2373{
2374 //say 'sNewDocStyle='sNewDocStyle;
2375 if (sNewDocStyle != '')
2376 skDocStyle = sNewDocStyle
2377 _menu_set_state(mhDoc, "javadoc", MF_UNCHECKED);
2378 _menu_set_state(mhDoc, "linux", MF_UNCHECKED | MF_GRAYED);
2379 _menu_set_state(mhDoc, skDocStyle, MF_CHECKED);
2380}
2381
2382
2383/**
2384 * Checks the correct menu item.
2385 */
2386_command void k_menu_license(_str sNewLicense = '')
2387{
2388 //say 'sNewLicense='sNewLicense;
2389 if (sNewLicense != '')
2390 skLicense = sNewLicense
2391 _menu_set_state(mhLic, "Odin32", MF_UNCHECKED);
2392 _menu_set_state(mhLic, "GPL", MF_UNCHECKED);
2393 _menu_set_state(mhLic, "LGPL", MF_UNCHECKED);
2394 _menu_set_state(mhLic, "Confidential", MF_UNCHECKED);
2395 _menu_set_state(mhLic, skLicense, MF_CHECKED);
2396}
2397
2398
2399/**
2400 * Check the correct style menu item.
2401 */
2402_command void k_menu_style(_str sNewStyle = '')
2403{
2404 //say 'sNewStyle='sNewStyle;
2405 _menu_set_state(mhCode, "Opt1Ind4", MF_UNCHECKED);
2406 _menu_set_state(mhCode, "Opt1Ind3", MF_UNCHECKED);
2407 _menu_set_state(mhCode, "Opt1Ind8", MF_UNCHECKED);
2408 _menu_set_state(mhCode, "Opt2Ind4", MF_UNCHECKED);
2409 _menu_set_state(mhCode, "Opt2Ind3", MF_UNCHECKED);
2410 _menu_set_state(mhCode, "Opt2Ind8", MF_UNCHECKED);
2411 _menu_set_state(mhCode, "Opt3Ind4", MF_UNCHECKED);
2412 _menu_set_state(mhCode, "Opt3Ind3", MF_UNCHECKED);
2413 _menu_set_state(mhCode, "Opt3Ind8", MF_UNCHECKED);
2414
2415 if (sNewStyle != '')
2416 {
2417 int iIndent = (int)substr(sNewStyle, 8, 1);
2418 int iBraceStyle = (int)substr(sNewStyle, 4, 1);
2419 skCodeStyle = sNewStyle;
2420 k_styles_setindent(iIndent, iBraceStyle);
2421 k_styles_set(sNewStyle);
2422 }
2423
2424 _menu_set_state(mhCode, skCodeStyle, MF_CHECKED);
2425}
2426
2427
2428/**
2429 * Load a 'preset'.
2430 */
2431_command void k_menu_preset(_str sArgs = '')
2432{
2433 parse sArgs with sNewDocStyle ',' sNewLicense ',' sNewStyle ',' sNewCompany ',' sNewProgram ',' sNewChange
2434 sNewDocStyle= strip(sNewDocStyle);
2435 sNewLicense = strip(sNewLicense);
2436 sNewStyle = strip(sNewStyle);
2437 sNewCompany = strip(sNewCompany);
2438 sNewProgram = strip(sNewProgram);
2439 sNewChange = strip(sNewChange);
2440
2441 //say 'k_menu_preset('sNewDocStyle',' sNewLicense',' sNewStyle',' sNewCompany',' sNewProgram')';
2442 k_menu_doc_style(sNewDocStyle);
2443 k_menu_license(sNewLicense);
2444 k_menu_style(sNewStyle);
2445 skCompany = sNewCompany;
2446 skProgram = sNewProgram;
2447 skChange = sNewChange;
2448 k_menu_create();
2449}
2450
2451
2452
2453/* future ones..
2454_command k_menu_setcolor()
2455{
2456 createMyColorSchemeAndUseIt();
2457}
2458
2459
2460_command k_menu_setkeys()
2461{
2462 rc = load("d:/knut/VSlickMacros/BoxerDef.e");
2463}
2464
2465_command k_menu_settings()
2466{
2467 mySettings();
2468}
2469*/
2470
2471
2472/*******************************************************************************
2473* Dialogs *
2474*******************************************************************************/
2475_form k_form_simple_input {
2476 p_backcolor=0x80000005
2477 p_border_style=BDS_DIALOG_BOX
2478 p_caption='Simple Input'
2479 p_clip_controls=FALSE
2480 p_forecolor=0x80000008
2481 p_height=1120
2482 p_width=5020
2483 p_x=6660
2484 p_y=6680
2485 _text_box entText {
2486 p_auto_size=TRUE
2487 p_backcolor=0x80000005
2488 p_border_style=BDS_FIXED_SINGLE
2489 p_completion=NONE_ARG
2490 p_font_bold=FALSE
2491 p_font_italic=FALSE
2492 p_font_name='MS Sans Serif'
2493 p_font_size=8
2494 p_font_underline=FALSE
2495 p_forecolor=0x80000008
2496 p_height=270
2497 p_tab_index=1
2498 p_tab_stop=TRUE
2499 p_text='text'
2500 p_width=3180
2501 p_x=1680
2502 p_y=240
2503 p_eventtab2=_ul2_textbox
2504 }
2505 _label lblLabel {
2506 p_alignment=AL_VCENTERRIGHT
2507 p_auto_size=FALSE
2508 p_backcolor=0x80000005
2509 p_border_style=BDS_NONE
2510 p_caption='Label'
2511 p_font_bold=FALSE
2512 p_font_italic=FALSE
2513 p_font_name='MS Sans Serif'
2514 p_font_size=8
2515 p_font_underline=FALSE
2516 p_forecolor=0x80000008
2517 p_height=240
2518 p_tab_index=2
2519 p_width=1380
2520 p_word_wrap=FALSE
2521 p_x=180
2522 p_y=240
2523 }
2524 _command_button btnOK {
2525 p_cancel=FALSE
2526 p_caption='&OK'
2527 p_default=TRUE
2528 p_font_bold=FALSE
2529 p_font_italic=FALSE
2530 p_font_name='MS Sans Serif'
2531 p_font_size=8
2532 p_font_underline=FALSE
2533 p_height=360
2534 p_tab_index=3
2535 p_tab_stop=TRUE
2536 p_width=1020
2537 p_x=180
2538 p_y=660
2539 }
2540 _command_button btnCancel {
2541 p_cancel=TRUE
2542 p_caption='Cancel'
2543 p_default=FALSE
2544 p_font_bold=FALSE
2545 p_font_italic=FALSE
2546 p_font_name='MS Sans Serif'
2547 p_font_size=8
2548 p_font_underline=FALSE
2549 p_height=360
2550 p_tab_index=4
2551 p_tab_stop=TRUE
2552 p_width=840
2553 p_x=1380
2554 p_y=660
2555 }
2556}
2557
2558defeventtab k_form_simple_input
2559btnOK.on_create(_str sLabel = '', _str sText = '')
2560{
2561 p_active_form.p_caption = sLabel;
2562 lblLabel.p_caption = sLabel;
2563 entText.p_text = sText;
2564}
2565
2566btnOK.lbutton_up()
2567{
2568 sText = entText.p_text;
2569 p_active_form._delete_window(sText);
2570}
2571btnCancel.lbutton_up()
2572{
2573 sText = entText.p_text;
2574 p_active_form._delete_window("\r");
2575}
2576
2577
2578
2579/**
2580 * Module initiation.
2581 */
2582definit()
2583{
2584 k_styles_create();
2585 k_menu_create();
2586 iTimer = _set_timer(1000, k_menu_create, "timer");
2587 /* createMyColorSchemeAndUseIt();*/
2588}
2589
2590
Note: See TracBrowser for help on using the repository browser.