source: trunk/VSlickMacros/kdev.e@ 252

Last change on this file since 252 was 214, checked in by bird, 21 years ago

use tagging to get args.

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