qt3/4.kmk: clean up the .dep files.
[kbuild-mirror.git] / VSlickMacros / kdev.e
blobb6721878e8f70157cb6d343fe85017534d0f05dc
1 /* $Id$ -*- tab-width: 4 c-indent-level: 4 -*- */
2 /** @file
3 * Visual SlickEdit Documentation Macros.
4 */
6 /*
7 * Copyright (c) 1999-2008 knut st. osmundsen <bird-src-spam@anduin.net>
9 * This file is part of kBuild.
11 * kBuild is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
16 * kBuild is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with kBuild. If not, see <http://www.gnu.org/licenses/>
26 /***
28 * This define the following keys:
29 *---------------------------------
30 * Ctrl+Shift+C: Class description box.
31 * Ctrl+Shift+F: Function/method description box.
32 * Ctrl+Shift+M: Module(file) description box
33 * Ctrl+Shift+O: One-liner (comment)
35 * Ctrl+Shift+G: Global box
36 * Ctrl+Shift+H: Header box
37 * Ctrl+Shift+E: Exported Symbols
38 * Ctrl+Shift+I: Internal function box
39 * Ctrl+Shift+K: Const/macro box
40 * Ctrl+Shift+S: Struct/Typedef box
42 * Ctrl+Shift+A: Signature+Date marker
43 * Ctrl+Shift+P: Mark line as change by me
45 * Ctrl+Shift+T: Update project tagfile.
46 * Ctrl+Shift+L: Load document variables.
48 * Ctrl+Shift+B: KLOGENTRYX(..)
49 * Ctrl+Shift+E: KLOGEXIT(..)
50 * Ctrl+Shift+N: Do kLog stuff for the current file. No questions.
51 * Ctrl+Shift+Q: Do kLog stuff for the current file. Ask a lot of questions.
53 * Remember to set the correct sOdin32UserName, sOdin32UserEmail and sOdin32UserInitials
54 * before compiling and loading the macros into Visual SlickEdit.
56 * These macros are compatible with both 3.0(c) and 4.0(b).
59 defeventtab default_keys
60 def 'C-S-A' = k_signature
61 def 'C-S-C' = k_javadoc_classbox
62 def 'C-S-E' = k_box_exported
63 def 'C-S-F' = k_javadoc_funcbox
64 def 'C-S-G' = k_box_globals
65 def 'C-S-H' = k_box_headers
66 def 'C-S-I' = k_box_intfuncs
67 def 'C-S-K' = k_box_consts
68 def 'C-S-M' = k_javadoc_moduleheader
69 def 'C-S-O' = k_oneliner
70 def 'C-S-P' = k_mark_modified_line
71 def 'C-S-S' = k_box_structs
72 def 'C-S-T' = odin32_maketagfile
73 def 'C-S-L' = k_style_load
75 //optional stuff
76 //def 'C-S-Q' = klib_klog_file_ask
77 //def 'C-S-N' = klib_klog_file_no_ask
78 //def 'C-S-1' = klib_klogentry
79 //def 'C-S-3' = klib_klogexit
82 //MARKER. Editor searches for this line!
83 #pragma option(redeclvars, on)
84 #include 'slick.sh'
85 #ifndef VS_TAGDETAIL_context_args
86 /* newer vslick version. */
87 #include 'tagsdb.sh'
88 //#pragma option(strict,on)
89 /*#else: Version 4.0 (OS/2) */
90 #endif
92 /* Remeber to change these! */
93 static _str skUserInitials = "bird";
94 static _str skUserName = "knut st. osmundsen";
95 static _str skUserEmail = "bird-src-spam@anduin.net";
98 /*******************************************************************************
99 * Global Variables *
100 *******************************************************************************/
101 static _str skCodeStyle = 'Opt2Ind4'; /* coding style scheme. */
102 static _str skDocStyle = 'javadoc';/* options: javadoc, */
103 static _str skLicense = 'GPLv3'; /* options: GPL, LGPL, Odin32, Confidential, ++ */
104 static _str skCompany = ''; /* empty or company name for copyright */
105 static _str skProgram = ''; /* Current program name - used by [L]GPL */
106 static _str skChange = ''; /* Current change identifier. */
108 static int ikStyleWidth = 80; /* The page width of the style. */
109 static boolean fkStyleFullHeaders = false; /* false: omit some tags. */
110 static int ikStyleOneliner = 41; /* The oneline comment column. */
111 static int ikStyleModifyMarkColumn = 105;
112 static boolean fkStyleBoxTag = false; /* true: Include tag in k_box_start. */
114 /*******************************************************************************
115 * Internal Functions *
116 *******************************************************************************/
118 * Gets iso date.
119 * @returns ISO formatted date.
121 static _str k_date()
123 int i,j;
124 _str date;
126 date = _date('U');
127 i = pos("/", date);
128 j = pos("/", date, i+1);
129 _str month = substr(date, 1, i-1);
130 if (length(month) == 1) month = '0'month;
131 _str day = substr(date, i+1, j-i-1);
132 if (length(day) == 1) day = '0'day;
133 _str year = substr(date, j+1);
134 return year"-"month"-"day;
139 * Get the current year.
140 * @returns Current year string.
142 static _str k_year()
144 _str date = _date('U');
145 return substr(date, pos("/",date, pos("/",date)+1)+1, 4);
150 * Aligns a value up to a given alignment.
152 static int k_alignup(int iValue, iAlign)
154 if (iAlign <= 0)
156 message('k_alignup: iValue='iValue ' iAlign='iAlign);
157 iAlign = 4;
159 return ((iValue intdiv iAlign) + 1) * iAlign;
164 * Reads the comment setup for this lexer/extension .
166 * @returns Success indicator.
167 * @param sLeft Left comment. (output)
168 * @param sRight Right comment. (output)
169 * @param iColumn Comment mark column. (1-based) (output)
170 * @param sExt The extension to lookup defaults to the current one.
171 * @param sLexer The lexer to lookup defaults to the current one.
172 * @remark This should be exported from box.e, but unfortunately it isn't.
174 static boolean k_commentconfig(_str &sLeft, _str &sRight, int &iColumn, _str sExt = p_extension, _str sLexer = p_lexer_name)
176 /* init returns */
177 sLeft = sRight = '';
178 iColumn = 0;
181 * Get comment setup from the lexer.
183 _str sLine = '';
184 if (sLexer)
186 /* multiline */
187 rc = _ini_get_value(slick_path_search("user.vlx"), sLexer, 'mlcomment', sLine);
188 if (rc)
189 rc = _ini_get_value(slick_path_search("vslick.vlx"), sLexer, 'mlcomment', sLine);
190 if (!rc)
192 sLeft = strip(word(sLine, 1));
193 sRight = strip(word(sLine, 2));
194 if (sLeft != '' && sRight != '')
195 return true;
198 /* failed, try single line. */
199 rc = _ini_get_value(slick_path_search("user.vlx"), sLexer, 'linecomment', sLine);
200 if (rc)
201 rc = _ini_get_value(slick_path_search("vslick.vlx"), sLexer, 'linecomment', sLine);
202 if (!rc)
204 sLeft = strip(word(sLine, 1));
205 sRight = '';
206 iColumn = 0;
207 _str sTmp = word(sLine, 2);
208 if (isnumber(sTmp))
209 iColumn = (int)sTmp;
210 if (sLeft != '')
211 return true;
216 * Read the nonboxchars and determin user or default box.ini.
218 _str sFile = slick_path_search("ubox.ini");
219 boolean frc = _ini_get_value(sFile, sExt, 'nonboxchars', sLine);
220 if (frc)
222 sFile = slick_path_search("box.ini");
223 frc = _ini_get_value(sFile, sExt, 'nonboxchars', sLine);
226 if (!frc)
227 { /*
228 * Found extension.
230 sLeft = strip(eq_name2value('left',sLine));
231 if (sLeft == '\e') sLeft = '';
232 sRight = strip(eq_name2value('right',sLine));
233 if (sRight == '\e') sRight = '';
235 /* Read comment column too */
236 frc = _ini_get_value(sFile, sExt, 'comment_col', sLine);
237 if (frc)
239 iColumn = eq_name2value('comment_col', sLine);
240 if (iColumn == '\e') iColumn = 0;
242 else
243 iColumn = 0;
244 return true;
247 /* failure */
248 sLeft = sRight = '';
249 iColumn = 0;
251 return false;
256 * Checks if current file only support line comments.
257 * @returns True / False.
258 * @remark Use builtin extension stuff!
260 static boolean k_line_comment()
262 _str sRight = '';
263 _str sLeft = '';
264 int iColumn;
265 boolean fLineComment = false;
266 if (k_commentconfig(sLeft, sRight, iColumn))
267 fLineComment = (sRight == '' || iColumn > 0);
268 return fLineComment;
273 #define KIC_CURSOR_BEFORE 1
274 #define KIC_CURSOR_AFTER 2
275 #define KIC_CURSOR_AT_END 3
278 * Insert a comment at current or best fitting position in the text.
279 * @param sStr The comment to insert.
280 * @param iCursor Where to put the cursor.
281 * @param iPosition Where to start the comment.
282 * Doesn't apply to column based source.
283 * -1 means at cursor position. (default)
284 * >0 means at end of line, but not before this column (1-based).
285 * This also implies a min of one space to EOL.
287 void k_insert_comment(_str sStr, int iCursor, int iPosition = -1)
289 _str sLeft;
290 _str sRight;
291 int iColumn;
292 if (!k_commentconfig(sLeft, sRight, iColumn))
294 sLeft = '/*'; sRight = '*/'; iColumn = 0;
297 int iCol = 0;
298 if (iColumn <= 0)
299 { /*
300 * not column based source
303 /* position us first */
304 if (iPosition > 0)
306 end_line();
307 do {
308 _insert_text(" ");
309 } while (p_col < iPosition);
312 /* insert comment saving the position for _BEFORE. */
313 iCol = p_col;
314 _insert_text(sLeft:+' ':+sStr);
315 if (iCursor == KIC_CURSOR_AT_END)
316 iCol = p_col;
317 /* right comment delimiter? */
318 if (sRight != '')
319 _insert_text(' ':+sRight);
321 else
323 if (p_col >= iColumn)
324 _insert_text("\n");
325 do { _insert_text(" "); } while (p_col < iColumn);
326 if (iCursor == KIC_CURSOR_BEFORE)
327 iCol = p_col;
328 _insert_text(sLeft:+' ':+sStr);
329 if (iCursor == KIC_CURSOR_AT_END)
330 iCol = p_col;
333 /* set cursor. */
334 if (iCursor != KIC_CURSOR_AFTER)
335 p_col = iCol;
340 * Gets the comment prefix or postfix.
341 * @returns Comment prefix or postfix.
342 * @param fRight If clear left comment string - default.
343 * If set right comment string.
345 static _str k_comment(boolean fRight = false)
347 _str sLeft, sRight;
348 int iColumn;
349 _str sComment = '/*';
350 if (k_commentconfig(sLeft, sRight, iColumn))
351 sComment = (!fRight || iColumn > 0 ? sLeft : sRight);
353 return strip(sComment);
357 /*******************************************************************************
358 * BOXES *
359 *******************************************************************************/
362 * Inserts the first line in a box.
363 * @param sTag Not used - box tag.
365 static void k_box_start(sTag)
367 _str sLeft, sRight;
368 int iColumn;
369 if (!k_commentconfig(sLeft, sRight, iColumn))
370 return;
371 _begin_line();
372 if (iColumn >= 0)
373 while (p_col < iColumn)
374 _insert_text(" ");
376 _str sText = sLeft;
377 if (sTag != '' && fkStyleBoxTag)
379 if (substr(sText, length(sText)) != '*')
380 sText = sText:+'*';
381 sText = sText:+sTag;
384 int i;
385 for (i = length(sText); i <= ikStyleWidth - p_col; i++)
386 sText = sText:+'*';
387 sText = sText:+"\n";
389 _insert_text(sText);
394 * Places a string, sStr, into a line started and ended by '*'.
395 * @param sStr Text to have between the '*'s.
397 static void k_box_line(_str sStr)
399 _str sLeft, sRight;
400 int iColumn;
401 if (!k_commentconfig(sLeft, sRight, iColumn))
402 return;
403 if (iColumn >= 0)
404 while (p_col < iColumn)
405 _insert_text(" ");
407 _str sText = '';
408 if (k_line_comment())
409 sText = sLeft;
410 if (sText == '' || substr(sText, length(sText)) != '*')
411 sText = sText:+'*';
413 sText = sText:+' ';
414 int i;
415 for (i = length(sText); i < p_SyntaxIndent; i++)
416 sText = sText:+' ';
418 sText = sText:+sStr;
420 for (i = length(sText) + 1; i <= ikStyleWidth - p_col; i++)
421 sText = sText:+' ';
422 sText = sText:+"*\n";
424 _insert_text(sText);
429 * Inserts the last line in a box.
431 static void k_box_end()
433 _str sLeft, sRight;
434 int iColumn, i;
435 if (!k_commentconfig(sLeft, sRight, iColumn))
436 return;
437 if (iColumn >= 0)
438 while (p_col < iColumn)
439 _insert_text(" ");
441 _str sText = '';
442 if (k_line_comment())
443 sText = sLeft;
444 for (i = length(sText) + length(sRight); i <= ikStyleWidth - p_col; i++)
445 sText = sText:+'*';
446 sText = sText:+sRight:+"\n";
448 _insert_text(sText);
453 /*******************************************************************************
454 * FUNCTION AND CODE PARSERS *
455 *******************************************************************************/
457 * Moves cursor to nearest function start.
458 * @returns 0 if ok.
459 * -1 on failure.
461 static int k_func_goto_nearest_function()
463 boolean fFix = false; /* cursor at function fix. (last function) */
464 int cur_line = p_line;
465 int prev_line = -1;
466 int next_line = -1;
467 typeless org_pos;
468 _save_pos2(org_pos);
470 if (!next_proc(1))
472 next_line = p_line;
473 if (!prev_proc(1) && p_line == cur_line)
475 _restore_pos2(org_pos);
476 return 0;
478 _restore_pos2(org_pos);
479 _save_pos2(org_pos);
481 else
483 p_col++; /* fixes problem with single function files. */
484 fFix = true;
487 if (!prev_proc(1))
489 prev_line = p_line;
490 if (!next_proc(1) && p_line == cur_line)
492 _restore_pos2(org_pos);
493 return 0;
495 _restore_pos2(org_pos);
496 _save_pos2(org_pos);
500 if (prev_line != -1 && (next_line == -1 || cur_line - prev_line <= next_line - cur_line))
502 if (fFix)
503 p_col++;
504 prev_proc(1);
505 return 0;
508 if (next_line != -1 && (prev_line == -1 || cur_line - prev_line > next_line - cur_line))
510 next_proc();
511 return 0;
514 _restore_pos2(org_pos);
515 return -1;
520 * Check if nearest function is a prototype.
521 * @returns True if function prototype.
522 * False if not function prototype.
524 static boolean k_func_prototype()
527 * Check if this is a real function implementation.
529 typeless procpos;
530 _save_pos2(procpos);
531 if (!k_func_goto_nearest_function())
533 int proc_line = p_line;
535 if (!k_func_searchcode("{"))
537 prev_proc();
538 if (p_line != proc_line)
540 _restore_pos2(procpos);
541 return true;
545 _restore_pos2(procpos);
547 return false;
552 * Gets the name fo the current function.
553 * @returns The current function name.
555 static _str k_func_getfunction_name()
557 _str sFunctionName = current_proc();
558 if (!sFunctionName)
559 sFunctionName = "";
560 //say 'functionanme='sFunctionName;
561 return sFunctionName;
566 * Goes to the neares function and gets its parameters.
567 * @remark Should be reimplemented to use tags (if someone can figure out how to query that stuff).
569 static _str k_func_getparams()
571 typeless org_pos;
572 _save_pos2(org_pos);
575 * Try use the tags first.
577 _UpdateContext(true);
578 int context_id = tag_current_context();
579 if (context_id <= 0)
581 k_func_goto_nearest_function();
582 context_id = tag_current_context();
584 if (context_id > 0)
586 _str args = '';
587 _str type = '';
588 tag_get_detail2(VS_TAGDETAIL_context_args, context_id, args);
589 tag_get_detail2(VS_TAGDETAIL_context_type, context_id, type);
590 if (tag_tree_type_is_func(type))
591 return args
592 //caption = tag_tree_make_caption_fast(VS_TAGMATCH_context,context_id,true,true,false);
596 * Go to nearest function.
598 if ( !k_func_goto_nearest_function()
599 && !k_func_searchcode("(") /* makes some assumptions. */
603 * Get parameters.
605 typeless posStart;
606 _save_pos2(posStart);
607 long offStart = _QROffset();
608 if (!find_matching_paren())
610 long offEnd = _QROffset();
611 _restore_pos2(posStart);
612 p_col++;
613 _str sParamsRaw = strip(get_text((int)(offEnd - offStart - 1)));
617 * Remove new lines and double spaces within params.
619 _str sParams = "";
621 int i;
622 _str chPrev;
623 for (i = 1, chPrev = ' '; i <= length(sParamsRaw); i++)
625 _str ch = substr(sParamsRaw, i, 1);
628 * Do fixups.
630 if (ch == " " && chPrev == " ")
631 continue;
633 if ((ch :== "\n") || (ch :== "\r") || (ch :== "\t"))
635 if (chPrev == ' ')
636 continue;
637 ch = ' ';
640 if (ch == ',' && chPrev == ' ')
642 sParams = substr(sParams, 1, length(sParams) - 1);
645 if (ch == '*')
647 if (chPrev != ' ')
648 sParams = sParams :+ ' * ';
649 else
650 sParams = sParams :+ '* ';
651 chPrev = ' ';
653 else
655 sParams = sParams :+ ch;
656 chPrev = ch;
659 } /* for */
661 sParams = strip(sParams);
662 if (sParams == 'void' || sParams == 'VOID')
663 sParams = "";
664 _restore_pos2(org_pos);
665 return sParams;
667 else
668 message("find_matchin_paren failed");
671 _restore_pos2(org_pos);
672 return false;
678 * Enumerates the parameters to the function.
679 * @param sParams Parameter string from k_func_getparams.
680 * @param iParam The index (0-based) of the parameter to get.
681 * @param sType Type. (output)
682 * @param sName Name. (output)
683 * @param sDefault Default value. (output)
684 * @remark Doesn't perhaps handle function pointers very well (I think)?
685 * @remark Should be reimplemented to use tags (if someone can figure out how to query that stuff).
687 static int k_func_enumparams(_str sParams, int iParam, _str &sType, _str &sName, _str &sDefault)
689 int i;
690 int iParLevel;
691 int iCurParam;
692 int iStartParam;
694 sType = sName = sDefault = "";
696 /* no use working on empty string! */
697 if (length(sParams) == 0)
698 return -1;
700 /* find the parameter in question */
701 for (iStartParam = i = 1, iParLevel = iCurParam = 0; i <= length(sParams); i++)
703 _str ch = substr(sParams, i, 1);
704 if (ch == ',' && iParLevel == 0)
706 /* is it this parameter ? */
707 if (iParam == iCurParam)
708 break;
710 iCurParam++;
711 iStartParam = i + 1;
713 else if (ch == '(')
714 iParLevel++;
715 else if (ch == ')')
716 iParLevel--;
719 /* did we find the parameter? */
720 if (iParam == iCurParam)
721 { /* (yeah, we did!) */
722 _str sArg = strip(substr(sParams, iStartParam, i - iStartParam));
723 /* remove M$ stuff */
724 sArg = stranslate(sArg, "", "IN", "E");
725 sArg = stranslate(sArg, "", "OUT", "E");
726 sArg = stranslate(sArg, "", "OPTIONAL", "E");
727 sArg = strip(sArg);
729 /* lazy approach, which doens't support function types */
731 if (pos('=', sParams) > 0) /* default */
733 sDefault = strip(substr(sParams, pos('=', sParams) + 1));
734 sArg = strip(substr(sArg, 1, pos('=', sParams) - 1));
737 for (i = length(sArg); i > 1; i--)
739 _str ch = substr(sArg, i, 1);
740 if ( !(ch >= 'a' && ch <= 'z')
741 && !(ch >= 'A' && ch <= 'Z')
742 && !(ch >= '0' && ch <= '9')
743 && ch != '_' && ch != '$')
744 break;
746 if (sArg == "...")
747 i = 0;
748 sName = strip(substr(sArg, i + 1));
749 sType = strip(substr(sArg, 1, i));
751 return 0;
754 return -1;
759 * Counts the parameters to the function.
760 * @param sParams Parameter string from k_func_getparams.
761 * @remark Should be reimplemented to use tags (if someone can figure out how to query that stuff).
763 static int k_func_countparams(_str sParams)
765 int i;
766 int iParLevel;
767 int iCurParam;
768 _str sType = "", sName = "", sDefault = "";
770 /* check for 0 parameters */
771 if (length(sParams) == 0)
772 return 0;
774 /* find the parameter in question */
775 for (i = 1, iParLevel = iCurParam = 0; i <= length(sParams); i++)
777 _str ch = substr(sParams, i, 1);
778 if (ch == ',' && iParLevel == 0)
780 iCurParam++;
782 else if (ch == '(')
783 iParLevel++;
784 else if (ch == ')')
785 iParLevel--;
788 return iCurParam + 1;
793 * Gets the return type.
795 static _str k_func_getreturntype(boolean fPureType = false)
797 typeless org_pos;
798 _save_pos2(org_pos);
801 * Go to nearest function.
803 if (!k_func_goto_nearest_function())
806 * Return type is from function start to function name...
808 typeless posStart;
809 _save_pos2(posStart);
810 long offStart = _QROffset();
812 if (!k_func_searchcode("(")) /* makes some assumptions. */
814 prev_word();
815 long offEnd = _QROffset();
816 _restore_pos2(posStart);
817 _str sTypeRaw = strip(get_text((int)(offEnd - offStart)));
819 //say 'sTypeRaw='sTypeRaw;
821 * Remove static, inline, _Optlink, stdcall, EXPENTRY etc.
823 if (fPureType)
825 sTypeRaw = stranslate(sTypeRaw, "", "__static__", "I");
826 sTypeRaw = stranslate(sTypeRaw, "", "__static", "I");
827 sTypeRaw = stranslate(sTypeRaw, "", "static__", "I");
828 sTypeRaw = stranslate(sTypeRaw, "", "static", "I");
829 sTypeRaw = stranslate(sTypeRaw, "", "__inline__", "I");
830 sTypeRaw = stranslate(sTypeRaw, "", "__inline", "I");
831 sTypeRaw = stranslate(sTypeRaw, "", "inline__", "I");
832 sTypeRaw = stranslate(sTypeRaw, "", "inline", "I");
833 sTypeRaw = stranslate(sTypeRaw, "", "EXPENTRY", "I");
834 sTypeRaw = stranslate(sTypeRaw, "", "_Optlink", "I");
835 sTypeRaw = stranslate(sTypeRaw, "", "__stdcall", "I");
836 sTypeRaw = stranslate(sTypeRaw, "", "__cdecl", "I");
837 sTypeRaw = stranslate(sTypeRaw, "", "_cdecl", "I");
838 sTypeRaw = stranslate(sTypeRaw, "", "cdecl", "I");
839 sTypeRaw = stranslate(sTypeRaw, "", "__PASCAL", "I");
840 sTypeRaw = stranslate(sTypeRaw, "", "_PASCAL", "I");
841 sTypeRaw = stranslate(sTypeRaw, "", "PASCAL", "I");
842 sTypeRaw = stranslate(sTypeRaw, "", "__Far32__", "I");
843 sTypeRaw = stranslate(sTypeRaw, "", "__Far32", "I");
844 sTypeRaw = stranslate(sTypeRaw, "", "Far32__", "I");
845 sTypeRaw = stranslate(sTypeRaw, "", "_Far32_", "I");
846 sTypeRaw = stranslate(sTypeRaw, "", "_Far32", "I");
847 sTypeRaw = stranslate(sTypeRaw, "", "Far32_", "I");
848 sTypeRaw = stranslate(sTypeRaw, "", "Far32", "I");
849 sTypeRaw = stranslate(sTypeRaw, "", "__far", "I");
850 sTypeRaw = stranslate(sTypeRaw, "", "_far", "I");
851 sTypeRaw = stranslate(sTypeRaw, "", "far", "I");
852 sTypeRaw = stranslate(sTypeRaw, "", "__near", "I");
853 sTypeRaw = stranslate(sTypeRaw, "", "_near", "I");
854 sTypeRaw = stranslate(sTypeRaw, "", "near", "I");
855 sTypeRaw = stranslate(sTypeRaw, "", "__loadds__", "I");
856 sTypeRaw = stranslate(sTypeRaw, "", "__loadds", "I");
857 sTypeRaw = stranslate(sTypeRaw, "", "loadds__", "I");
858 sTypeRaw = stranslate(sTypeRaw, "", "_loadds_", "I");
859 sTypeRaw = stranslate(sTypeRaw, "", "_loadds", "I");
860 sTypeRaw = stranslate(sTypeRaw, "", "loadds_", "I");
861 sTypeRaw = stranslate(sTypeRaw, "", "loadds", "I");
862 sTypeRaw = stranslate(sTypeRaw, "", "__loades__", "I");
863 sTypeRaw = stranslate(sTypeRaw, "", "__loades", "I");
864 sTypeRaw = stranslate(sTypeRaw, "", "loades__", "I");
865 sTypeRaw = stranslate(sTypeRaw, "", "_loades_", "I");
866 sTypeRaw = stranslate(sTypeRaw, "", "_loades", "I");
867 sTypeRaw = stranslate(sTypeRaw, "", "loades_", "I");
868 sTypeRaw = stranslate(sTypeRaw, "", "loades", "I");
869 sTypeRaw = stranslate(sTypeRaw, "", "WIN32API", "I");
870 sTypeRaw = stranslate(sTypeRaw, "", "WINAPI", "I");
871 sTypeRaw = stranslate(sTypeRaw, "", "LDRCALL", "I");
872 sTypeRaw = stranslate(sTypeRaw, "", "KRNLCALL", "I");
873 sTypeRaw = stranslate(sTypeRaw, "", "__operator__", "I"); /* operator fix */
874 sTypeRaw = stranslate(sTypeRaw, "", "__operator", "I"); /* operator fix */
875 sTypeRaw = stranslate(sTypeRaw, "", "operator__", "I"); /* operator fix */
876 sTypeRaw = stranslate(sTypeRaw, "", "operator", "I"); /* operator fix */
877 sTypeRaw = stranslate(sTypeRaw, "", "IN", "E");
878 sTypeRaw = stranslate(sTypeRaw, "", "OUT", "E");
879 sTypeRaw = stranslate(sTypeRaw, "", "OPTIONAL", "E");
883 * Remove new lines and double spaces within params.
885 _str sType = "";
887 int i;
888 _str chPrev;
889 for (i = 1, chPrev = ' '; i <= length(sTypeRaw); i++)
891 _str ch = substr(sTypeRaw, i, 1);
894 * Do fixups.
896 if (ch == " " && chPrev == " ")
897 continue;
899 if ((ch :== "\n") || (ch :== "\r") || (ch :== "\t"))
901 if (chPrev == ' ')
902 continue;
903 ch = ' ';
906 if (ch == ',' && chPrev == ' ')
908 sType = substr(sType, 1, length(sType) - 1);
911 if (ch == '*')
913 if (chPrev != ' ')
914 sType = sType :+ ' * ';
915 else
916 sType = sType :+ '* ';
917 chPrev = ' ';
919 else
921 sType = sType :+ ch;
922 chPrev = ch;
925 } /* for */
927 sType = strip(sType);
929 _restore_pos2(org_pos);
930 return sType;
932 else
933 message('k_func_getreturntype: can''t find ''(''.');
936 _restore_pos2(org_pos);
937 return false;
942 * Search for some piece of code.
944 static int k_func_searchcode(_str sSearchString, _str sOptions = "E+")
946 int rc;
947 rc = search(sSearchString, sOptions);
948 while (!rc && !k_func_in_code())
950 p_col++;
951 rc = search(sSearchString, sOptions);
953 return rc;
958 * Checks if cursor is in code or in comment.
959 * @return True if cursor in code.
961 static boolean k_func_in_code()
963 typeless searchsave;
964 _save_pos2(searchsave);
965 boolean fRc = !_in_comment();
966 _restore_pos2(searchsave);
967 return fRc;
972 * Gets the next piece of code.
974 static _str k_func_get_next_code_text()
976 typeless searchsave;
977 _save_pos2(searchsave);
978 _str ch = k_func_get_next_code_text2();
979 _restore_pos2(searchsave);
980 return ch;
985 * Checks if there is more code on the line.
987 static boolean k_func_more_code_on_line()
989 boolean fRc;
990 int curline = p_line;
991 typeless searchsave;
992 _save_pos2(searchsave);
993 k_func_get_next_code_text2();
994 fRc = curline == p_line;
995 _restore_pos2(searchsave);
997 return fRc;
1002 * Gets the next piece of code.
1003 * Doesn't preserver cursor position.
1005 static _str k_func_get_next_code_text2()
1007 _str ch;
1010 int curcol = ++p_col;
1011 end_line();
1012 if (p_col <= curcol)
1014 p_line++;
1015 p_col = 1;
1017 else
1018 p_col = curcol;
1020 ch = get_text();
1021 //say ch ' ('_asc(ch)')';
1022 while (ch == "#") /* preprocessor stuff */
1024 p_col = 1;
1025 p_line++;
1026 ch = get_text();
1027 //say ch ' ('_asc(ch)')';
1028 continue;
1030 } while (ch :== ' ' || ch :== "\t" || ch :== "\n" || ch :== "\r" || !k_func_in_code());
1032 return ch;
1038 /*******************************************************************************
1039 * JAVA DOC STYLED WORKERS *
1040 *******************************************************************************/
1042 /** starts a javadoc documentation box. */
1043 static void k_javadoc_box_start(_str sStr = '', boolean fDouble = true)
1045 _str sLeft, sRight;
1046 int iColumn;
1047 if (!k_commentconfig(sLeft, sRight, iColumn))
1048 return;
1049 _begin_line();
1050 if (iColumn >= 0)
1051 while (p_col < iColumn)
1052 _insert_text(" ");
1054 _str sText = sLeft;
1055 if (fDouble)
1056 sText = sLeft:+substr(sLeft, length(sLeft), 1);
1057 if (sStr != '')
1058 sText = sText:+' ':+sStr;
1059 sText = sText:+"\n";
1061 _insert_text(sText);
1064 /** inserts a new line in a javadoc documentation box. */
1065 static void k_javadoc_box_line(_str sStr = '', int iPadd = 0, _str sStr2 = '', int iPadd2 = 0, _str sStr3 = '')
1067 _str sLeft, sRight;
1068 int iColumn;
1069 if (!k_commentconfig(sLeft, sRight, iColumn))
1070 return;
1071 if (iColumn >= 0)
1072 while (p_col < iColumn)
1073 _insert_text(" ");
1075 _str sText;
1076 if (k_line_comment())
1077 sText = sLeft;
1078 else
1080 sText = sLeft;
1081 sText = ' ':+substr(sLeft, length(sLeft));
1084 if (sStr != '')
1085 sText = sText:+' ':+sStr;
1086 if (iPadd > 0)
1088 int i;
1089 for (i = length(sText); i < iPadd; i++)
1090 sText = sText:+' ';
1092 if (sStr2 != '')
1093 sText = sText:+sStr2;
1095 if (iPadd2 > 0)
1097 for (i = length(sText); i < iPadd2; i++)
1098 sText = sText:+' ';
1100 if (sStr3 != '')
1101 sText = sText:+sStr3;
1104 sText = sText:+"\n";
1106 _insert_text(sText);
1109 /** ends a javadoc documentation box. */
1110 static void k_javadoc_box_end()
1112 _str sLeft, sRight;
1113 int iColumn;
1114 if (!k_commentconfig(sLeft, sRight, iColumn))
1115 return;
1116 if (iColumn >= 0)
1117 while (p_col < iColumn)
1118 _insert_text(" ");
1120 _str sText;
1121 if (k_line_comment())
1122 sText = sLeft;
1123 else
1125 sText = sRight;
1126 /*if (substr(sText, 1, 1) != '*')
1127 sText = '*':+sText;*/
1128 sText = ' ':+sText;
1130 sText = sText:+"\n";
1132 _insert_text(sText);
1137 * Write a Javadoc styled classbox.
1139 void k_javadoc_classbox()
1141 int iCursorLine;
1142 int iPadd = k_alignup(12, p_SyntaxIndent);
1144 k_javadoc_box_start();
1145 iCursorLine = p_RLine;
1146 k_javadoc_box_line(' ');
1148 if (fkStyleFullHeaders)
1150 k_javadoc_box_line('@shortdesc', iPadd);
1151 k_javadoc_box_line('@dstruct', iPadd);
1152 k_javadoc_box_line('@version', iPadd);
1153 k_javadoc_box_line('@verdesc', iPadd);
1155 k_javadoc_box_line('@author', iPadd, skUserName ' <' skUserEmail '>');
1156 k_javadoc_box_line('@approval', iPadd);
1157 k_javadoc_box_end();
1159 up(p_RLine - iCursorLine);
1160 end_line();
1161 keyin(' ');
1166 * Javadoc - functionbox(/header).
1168 void k_javadoc_funcbox()
1170 int cArgs = 1;
1171 _str sArgs = "";
1172 int iCursorLine;
1173 int iPadd = k_alignup(11, p_SyntaxIndent);
1174 /* look for parameters */
1175 boolean fFoundFn = !k_func_goto_nearest_function();
1176 if (fFoundFn)
1178 sArgs = k_func_getparams();
1179 cArgs = k_func_countparams(sArgs);
1182 k_javadoc_box_start();
1183 iCursorLine = p_RLine;
1184 k_javadoc_box_line(' ');
1185 if (file_eq(p_extension, 'asm'))
1186 k_javadoc_box_line('@cproto', iPadd);
1187 k_javadoc_box_line('@returns', iPadd);
1188 if (fFoundFn)
1191 * Determin parameter description indent.
1193 int iPadd2 = 0;
1194 int i;
1195 for (i = 0; i < cArgs; i++)
1197 _str sName, sType, sDefault;
1198 if (!k_func_enumparams(sArgs, i, sType, sName, sDefault)
1199 && iPadd2 < length(sName))
1200 iPadd2 = length(sName);
1202 iPadd2 = k_alignup((iPadd + iPadd2), p_SyntaxIndent);
1205 * Insert parameter.
1207 for (i = 0; i < cArgs; i++)
1209 _str sName, sType, sDefault;
1210 if (!k_func_enumparams(sArgs, i, sType, sName, sDefault))
1212 _str sStr3 = '';
1213 if (sDefault != "")
1214 sStr3 = '(default='sDefault')';
1215 k_javadoc_box_line('@param', iPadd, sName, iPadd2, sStr3);
1217 else
1218 k_javadoc_box_line('@param', iPadd);
1221 else
1222 k_javadoc_box_line('@param', iPadd);
1224 if (file_eq(p_extension, 'asm'))
1225 k_javadoc_box_line('@uses', iPadd);
1226 if (fkStyleFullHeaders)
1228 k_javadoc_box_line('@equiv', iPadd);
1229 k_javadoc_box_line('@time', iPadd);
1230 k_javadoc_box_line('@sketch', iPadd);
1231 k_javadoc_box_line('@status', iPadd);
1232 k_javadoc_box_line('@author', iPadd, skUserName ' <' skUserEmail '>');
1233 k_javadoc_box_line('@remark', iPadd);
1235 k_javadoc_box_end();
1237 up(p_RLine - iCursorLine);
1238 end_line();
1239 keyin(' ');
1244 * Javadoc module header.
1246 void k_javadoc_moduleheader()
1248 int iCursorLine;
1249 int fSplit = 0;
1251 _insert_text("\n");
1252 up();
1253 _begin_line();
1254 k_insert_comment('$':+'I':+'d: $', KIC_CURSOR_AT_END, -1);
1255 _end_line();
1256 _insert_text("\n");
1258 k_javadoc_box_start('@file');
1259 fSplit = 1;
1260 iCursorLine = p_RLine;
1261 k_javadoc_box_line();
1262 k_javadoc_box_end();
1263 _insert_text("\n");
1264 _insert_text(k_comment() "\n");
1266 if (skLicense == 'Confidential')
1268 k_javadoc_box_line(skCompany ' confidential');
1269 k_javadoc_box_line();
1272 if (skCompany != '')
1274 if (skLicense != 'Confidential')
1275 k_javadoc_box_line('Copyright (C) ' k_year() ' ' skCompany);
1276 else
1278 k_javadoc_box_line('Copyright (c) ' k_year() ' ' skCompany);
1279 k_javadoc_box_line();
1280 k_javadoc_box_line('Author: ' skUserName' <' skUserEmail '>');
1283 else
1284 k_javadoc_box_line('Copyright (c) ' k_year() ' 'skUserName' <' skUserEmail '>');
1285 k_javadoc_box_line();
1286 _str sProg = skProgram;
1287 switch (skLicense)
1289 case 'Odin32':
1290 k_javadoc_box_line('Project Odin Software License can be found in LICENSE.TXT.');
1291 break;
1293 case 'GPL':
1294 if (!fSplit)
1295 k_javadoc_box_line();
1296 if (sProg == '')
1297 sProg = 'This program';
1298 else
1300 k_javadoc_box_line('This file is part of ' sProg '.');
1301 k_javadoc_box_line();
1303 k_javadoc_box_line(sProg ' is free software; you can redistribute it and/or modify');
1304 k_javadoc_box_line('it under the terms of the GNU General Public License as published by');
1305 k_javadoc_box_line('the Free Software Foundation; either version 2 of the License, or');
1306 k_javadoc_box_line('(at your option) any later version.');
1307 k_javadoc_box_line();
1308 k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful,');
1309 k_javadoc_box_line('but WITHOUT ANY WARRANTY; without even the implied warranty of');
1310 k_javadoc_box_line('MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the');
1311 k_javadoc_box_line('GNU General Public License for more details.');
1312 k_javadoc_box_line();
1313 k_javadoc_box_line('You should have received a copy of the GNU General Public License');
1314 k_javadoc_box_line('along with ' sProg '; if not, write to the Free Software');
1315 k_javadoc_box_line('Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA');
1316 break;
1318 case 'LGPL':
1319 if (!fSplit)
1320 k_javadoc_box_line();
1321 if (sProg == '')
1322 sProg = 'This library';
1323 else
1325 k_javadoc_box_line('This file is part of ' sProg '.');
1326 k_javadoc_box_line();
1328 k_javadoc_box_line(sProg ' is free software; you can redistribute it and/or');
1329 k_javadoc_box_line('modify it under the terms of the GNU Lesser General Public');
1330 k_javadoc_box_line('License as published by the Free Software Foundation; either');
1331 k_javadoc_box_line('version 2.1 of the License, or (at your option) any later version.');
1332 k_javadoc_box_line();
1333 k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful,');
1334 k_javadoc_box_line('but WITHOUT ANY WARRANTY; without even the implied warranty of');
1335 k_javadoc_box_line('MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU');
1336 k_javadoc_box_line('Lesser General Public License for more details.');
1337 k_javadoc_box_line();
1338 k_javadoc_box_line('You should have received a copy of the GNU Lesser General Public');
1339 k_javadoc_box_line('License along with ' sProg '; if not, write to the Free Software');
1340 k_javadoc_box_line('Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA');
1341 break;
1343 case 'GPLv3':
1344 if (!fSplit)
1345 k_javadoc_box_line();
1346 if (sProg == '')
1347 sProg = 'This program';
1348 else
1350 k_javadoc_box_line('This file is part of ' sProg '.');
1351 k_javadoc_box_line();
1353 k_javadoc_box_line(sProg ' is free software; you can redistribute it and/or modify');
1354 k_javadoc_box_line('it under the terms of the GNU General Public License as published by');
1355 k_javadoc_box_line('the Free Software Foundation; either version 3 of the License, or');
1356 k_javadoc_box_line('(at your option) any later version.');
1357 k_javadoc_box_line();
1358 k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful,');
1359 k_javadoc_box_line('but WITHOUT ANY WARRANTY; without even the implied warranty of');
1360 k_javadoc_box_line('MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the');
1361 k_javadoc_box_line('GNU General Public License for more details.');
1362 k_javadoc_box_line();
1363 k_javadoc_box_line('You should have received a copy of the GNU General Public License');
1364 k_javadoc_box_line('along with ' sProg '. If not, see <http://www.gnu.org/licenses/>');
1365 break;
1367 case 'LGPLv3':
1368 if (!fSplit)
1369 k_javadoc_box_line();
1370 if (sProg == '')
1371 sProg = 'This program';
1372 else
1374 k_javadoc_box_line('This file is part of ' sProg '.');
1375 k_javadoc_box_line();
1377 k_javadoc_box_line(sProg ' is free software; you can redistribute it and/or');
1378 k_javadoc_box_line('modify it under the terms of the GNU Lesser General Public');
1379 k_javadoc_box_line('License as published by the Free Software Foundation; either');
1380 k_javadoc_box_line('version 3 of the License, or (at your option) any later version.');
1381 k_javadoc_box_line();
1382 k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful,');
1383 k_javadoc_box_line('but WITHOUT ANY WARRANTY; without even the implied warranty of');
1384 k_javadoc_box_line('MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the');
1385 k_javadoc_box_line('GNU Lesser General Public License for more details.');
1386 k_javadoc_box_line();
1387 k_javadoc_box_line('You should have received a copy of the GNU Lesser General Public License');
1388 k_javadoc_box_line('along with ' sProg '. If not, see <http://www.gnu.org/licenses/>');
1389 break;
1391 case 'Confidential':
1392 k_javadoc_box_line('All Rights Reserved');
1393 break;
1395 case 'ConfidentialNoAuthor':
1396 k_javadoc_box_line(skCompany ' confidential');
1397 k_javadoc_box_line('All Rights Reserved');
1398 break;
1400 case 'VirtualBox':
1401 k_javadoc_box_line('This file is part of VirtualBox Open Source Edition (OSE), as')
1402 k_javadoc_box_line('available from http://www.virtualbox.org. This file is free software;')
1403 k_javadoc_box_line('you can redistribute it and/or modify it under the terms of the GNU')
1404 k_javadoc_box_line('General Public License (GPL) as published by the Free Software')
1405 k_javadoc_box_line('Foundation, in version 2 as it comes in the "COPYING" file of the')
1406 k_javadoc_box_line('VirtualBox OSE distribution. VirtualBox OSE is distributed in the')
1407 k_javadoc_box_line('hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.')
1408 k_javadoc_box_line('')
1409 k_javadoc_box_line('Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa')
1410 k_javadoc_box_line('Clara, CA 95054 USA or visit http://www.sun.com if you need')
1411 k_javadoc_box_line('additional information or have any questions.')
1412 break;
1414 case 'VirtualBoxGPLAndCDDL':
1415 k_javadoc_box_line('This file is part of VirtualBox Open Source Edition (OSE), as')
1416 k_javadoc_box_line('available from http://www.virtualbox.org. This file is free software;')
1417 k_javadoc_box_line('you can redistribute it and/or modify it under the terms of the GNU')
1418 k_javadoc_box_line('General Public License (GPL) as published by the Free Software')
1419 k_javadoc_box_line('Foundation, in version 2 as it comes in the "COPYING" file of the')
1420 k_javadoc_box_line('VirtualBox OSE distribution. VirtualBox OSE is distributed in the')
1421 k_javadoc_box_line('hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.')
1422 k_javadoc_box_line('')
1423 k_javadoc_box_line('The contents of this file may alternatively be used under the terms')
1424 k_javadoc_box_line('of the Common Development and Distribution License Version 1.0')
1425 k_javadoc_box_line('(CDDL) only, as it comes in the "COPYING.CDDL" file of the')
1426 k_javadoc_box_line('VirtualBox OSE distribution, in which case the provisions of the')
1427 k_javadoc_box_line('CDDL are applicable instead of those of the GPL.')
1428 k_javadoc_box_line('')
1429 k_javadoc_box_line('You may elect to license modified versions of this file under the')
1430 k_javadoc_box_line('terms and conditions of either the GPL or the CDDL or both.')
1431 k_javadoc_box_line('')
1432 k_javadoc_box_line('Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa')
1433 k_javadoc_box_line('Clara, CA 95054 USA or visit http://www.sun.com if you need')
1434 k_javadoc_box_line('additional information or have any questions.')
1435 break;
1437 default:
1440 k_javadoc_box_line();
1441 k_javadoc_box_end();
1443 up(p_RLine - iCursorLine);
1444 end_line();
1445 keyin(' ');
1454 /*******************************************************************************
1455 * Keyboard Shortcuts *
1456 *******************************************************************************/
1457 /** Makes global box. */
1458 void k_box_globals()
1460 k_box_start('Global');
1461 k_box_line('Global Variables');
1462 k_box_end();
1465 /** Makes header box. */
1466 void k_box_headers()
1468 k_box_start("Header");
1469 k_box_line("Header Files");
1470 k_box_end();
1473 /** Makes internal function box. */
1474 void k_box_intfuncs()
1476 k_box_start("IntFunc");
1477 k_box_line("Internal Functions");
1478 k_box_end();
1481 /** Makes def/const box. */
1482 void k_box_consts()
1484 k_box_start("Const");
1485 k_box_line("Defined Constants And Macros");
1486 k_box_end();
1489 /** Structure box */
1490 void k_box_structs()
1492 k_box_start("Struct");
1493 k_box_line("Structures and Typedefs");
1494 k_box_end();
1497 /** Makes exported symbols box. */
1498 void k_box_exported()
1500 k_box_start('Exported');
1501 k_box_line('Exported Symbols');
1502 k_box_end();
1507 /** oneliner comment */
1508 void k_oneliner()
1510 _str sLeft, sRight;
1511 int iColumn;
1512 if ( k_commentconfig(sLeft, sRight, iColumn)
1513 && iColumn > 0)
1514 { /* column based needs some tricky repositioning. */
1515 _end_line();
1516 if (p_col > iColumn)
1518 _begin_line();
1519 _insert_text("\n\r");
1520 up();
1523 k_insert_comment("", KIC_CURSOR_AT_END, ikStyleOneliner);
1526 /** mark line as modified. */
1527 void k_mark_modified_line()
1529 /* not supported for column based sources */
1530 _str sLeft, sRight;
1531 int iColumn;
1532 if ( !k_commentconfig(sLeft, sRight, iColumn)
1533 || iColumn > 0)
1534 return;
1535 _str sStr;
1536 if (skChange != '')
1537 sStr = skChange ' (' skUserInitials ')';
1538 else
1539 sStr = skUserInitials;
1540 k_insert_comment(sStr, KIC_CURSOR_BEFORE, ikStyleModifyMarkColumn);
1541 down();
1546 * Inserts a signature. Form: "//Initials ISO-date:"
1547 * @remark defeventtab
1549 void k_signature()
1551 /* kso I5-10000 2002-09-10: */
1552 _str sSig;
1553 if (skChange != '')
1554 sSig = skUserInitials ' ' skChange ' ' k_date() ': ';
1555 else
1556 sSig = skUserInitials ' ' k_date() ': ';
1557 k_insert_comment(sSig, KIC_CURSOR_AT_END);
1561 /*******************************************************************************
1562 * kLIB Logging *
1563 *******************************************************************************/
1565 * Hot-Key: Inserts a KLOGENTRY statement at start of nearest function.
1567 void klib_klogentry()
1569 typeless org_pos;
1570 _save_pos2(org_pos);
1573 * Go to nearest function.
1575 if (!k_func_goto_nearest_function())
1578 * Get parameters.
1580 _str sParams = k_func_getparams();
1581 if (sParams)
1583 _str sRetType = k_func_getreturntype(true);
1584 if (!sRetType || sRetType == "")
1585 sRetType = "void"; /* paranoia! */
1588 * Insert text.
1590 if (!k_func_searchcode("{"))
1592 p_col++;
1593 int cArgs = k_func_countparams(sParams);
1594 if (cArgs > 0)
1596 _str sArgs = "";
1597 int i;
1598 for (i = 0; i < cArgs; i++)
1600 _str sType, sName, sDefault;
1601 if (!k_func_enumparams(sParams, i, sType, sName, sDefault))
1602 sArgs = sArgs', 'sName;
1605 _insert_text("\n KLOGENTRY"cArgs"(\""sRetType"\",\""sParams"\""sArgs");"); /* todo tab size.. or smart indent */
1607 else
1608 _insert_text("\n KLOGENTRY0(\""sRetType"\");"); /* todo tab size.. or smart indent */
1611 * Check if the next word is KLOGENTRY.
1613 next_word();
1614 if (def_next_word_style == 'E')
1615 prev_word();
1616 int iIgnorePos = 0;
1617 if (substr(cur_word(iIgnorePos), 1, 9) == "KLOGENTRY")
1618 delete_line();
1621 else
1622 message("didn't find {");
1624 else
1625 message("k_func_getparams failed, sParams=" sParams);
1626 return;
1629 _restore_pos2(org_pos);
1634 * Hot-Key: Inserts a KLOGEXIT statement at cursor location.
1636 void klib_klogexit()
1638 typeless org_pos;
1639 _save_pos2(org_pos);
1642 * Go to nearest function.
1644 if (!prev_proc())
1647 * Get parameters.
1649 _str sType = k_func_getreturntype(true);
1650 _restore_pos2(org_pos);
1651 if (sType)
1653 boolean fReturn = true; /* true if an return statment is following the KLOGEXIT statement. */
1656 * Insert text.
1658 int cur_col = p_col;
1659 if (sType == 'void' || sType == 'VOID')
1660 { /* procedure */
1661 int iIgnorePos;
1662 fReturn = cur_word(iIgnorePos) == 'return';
1663 if (!fReturn)
1665 while (p_col <= p_SyntaxIndent)
1666 keyin(" ");
1669 _insert_text("KLOGEXITVOID();\n");
1671 if (fReturn)
1673 int i;
1674 for (i = 1; i < cur_col; i++)
1675 _insert_text(" ");
1677 search(")","E-");
1679 else
1680 { /* function */
1681 _insert_text("KLOGEXIT();\n");
1682 int i;
1683 for (i = 1; i < cur_col; i++)
1684 _insert_text(" ");
1685 search(")","E-");
1688 * Insert value if possible.
1690 typeless valuepos;
1691 _save_pos2(valuepos);
1692 next_word();
1693 if (def_next_word_style == 'E')
1694 prev_word();
1695 int iIgnorePos;
1696 if (cur_word(iIgnorePos) == 'return')
1698 p_col += length('return');
1699 typeless posStart;
1700 _save_pos2(posStart);
1701 long offStart = _QROffset();
1702 if (!k_func_searchcode(";", "E+"))
1704 long offEnd = _QROffset();
1705 _restore_pos2(posStart);
1706 _str sValue = strip(get_text((int)(offEnd - offStart)));
1707 //say 'sValue = 'sValue;
1708 _restore_pos2(valuepos);
1709 _save_pos2(valuepos);
1710 _insert_text(sValue);
1713 _restore_pos2(valuepos);
1717 * Remove old KLOGEXIT statement on previous line if any.
1719 typeless valuepos;
1720 _save_pos2(valuepos);
1721 int newexitline = p_line;
1722 p_line--; p_col = 1;
1723 next_word();
1724 if (def_next_word_style == 'E')
1725 prev_word();
1726 int iIgnorePos;
1727 if (p_line == newexitline - 1 && substr(cur_word(iIgnorePos), 1, 8) == 'KLOGEXIT')
1728 delete_line();
1729 _restore_pos2(valuepos);
1732 * Check for missing '{...}'.
1734 if (fReturn)
1736 boolean fFound = false;
1737 _save_pos2(valuepos);
1738 p_col--; find_matching_paren(); p_col += 2;
1739 k_func_searchcode(';', 'E+'); /* places us at the ';' of the return. (hopefully) */
1741 _str ch = k_func_get_next_code_text();
1742 if (ch != '}')
1744 _restore_pos2(valuepos);
1745 _save_pos2(valuepos);
1746 p_col--; find_matching_paren(); p_col += 2;
1747 k_func_searchcode(';', 'E+'); /* places us at the ';' of the return. (hopefully) */
1748 p_col++;
1749 if (k_func_more_code_on_line())
1750 _insert_text(' }');
1751 else
1753 typeless returnget;
1754 _save_pos2(returnget);
1755 k_func_searchcode("return", "E-");
1756 int return_col = p_col;
1757 _restore_pos2(returnget);
1759 end_line();
1760 _insert_text("\n");
1761 while (p_col < return_col - p_SyntaxIndent)
1762 _insert_text(' ');
1763 _insert_text('}');
1766 _restore_pos2(valuepos);
1767 _save_pos2(valuepos);
1768 prev_word();
1769 p_col -= p_SyntaxIndent;
1770 int codecol = p_col;
1771 _insert_text("{\n");
1772 while (p_col < codecol)
1773 _insert_text(' ');
1776 _restore_pos2(valuepos);
1779 else
1780 message("k_func_getreturntype failed, sType=" sType);
1781 return;
1784 _restore_pos2(org_pos);
1789 * Processes a file - ask user all the time.
1791 void klib_klog_file_ask()
1793 klib_klog_file_int(true);
1798 * Processes a file - no questions.
1800 void klib_klog_file_no_ask()
1802 klib_klog_file_int(false);
1808 * Processes a file.
1810 static void klib_klog_file_int(boolean fAsk)
1812 show_all();
1813 bottom();
1814 _refresh_scroll();
1816 /* ask question so we can get to the right position somehow.. */
1817 if (fAsk && _message_box("kLog process this file?", "Visual SlickEdit", MB_YESNO | MB_ICONQUESTION) != IDYES)
1818 return;
1821 * Entries.
1823 while (!prev_proc())
1825 //say 'entry main loop: ' k_func_getfunction_name();
1828 * Skip prototypes.
1830 if (k_func_prototype())
1831 continue;
1834 * Ask user.
1836 center_line();
1837 _refresh_scroll();
1838 _str sFunction = k_func_getfunction_name();
1839 rc = fAsk ? _message_box("Process this function ("sFunction")?", "Visual SlickEdit", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
1840 if (rc == IDYES)
1842 typeless procpos;
1843 _save_pos2(procpos);
1844 klib_klogentry();
1845 _restore_pos2(procpos);
1847 else if (rc == IDNO)
1848 continue;
1849 else
1850 break;
1854 * Exits.
1856 bottom(); _refresh_scroll();
1857 boolean fUserCancel = false;
1858 while (!prev_proc() && !fUserCancel)
1860 typeless procpos;
1861 _save_pos2(procpos);
1862 _str sCurFunction = k_func_getfunction_name();
1863 //say 'exit main loop: ' sCurFunction
1866 * Skip prototypes.
1868 if (k_func_prototype())
1869 continue;
1872 * Select procedure.
1874 while ( !k_func_searchcode("return", "WE<+")
1875 && k_func_getfunction_name() == sCurFunction)
1877 //say 'exit sub loop: ' p_line
1879 * Ask User.
1881 center_line();
1882 _refresh_scroll();
1883 _str sFunction = k_func_getfunction_name();
1884 rc = fAsk ? _message_box("Process this exit from "sFunction"?", "Visual SlickEdit", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
1885 deselect();
1886 if (rc == IDYES)
1888 typeless returnpos;
1889 _save_pos2(returnpos);
1890 klib_klogexit();
1891 _restore_pos2(returnpos);
1892 p_line++;
1894 else if (rc != IDNO)
1896 fUserCancel = true;
1897 break;
1899 p_line++; /* just so we won't hit it again. */
1903 * If void function we'll have to check if there is and return; prior to the ending '}'.
1905 _restore_pos2(procpos);
1906 _save_pos2(procpos);
1907 _str sType = k_func_getreturntype(true);
1908 if (!fUserCancel && sType && (sType == 'void' || sType == 'VOID'))
1910 if ( !k_func_searchcode("{", "E+")
1911 && !find_matching_paren())
1913 typeless funcend;
1914 _save_pos2(funcend);
1915 prev_word();
1916 int iIgnorePos;
1917 if (cur_word(iIgnorePos) != "return")
1920 * Ask User.
1922 _restore_pos2(funcend);
1923 center_line();
1924 _refresh_scroll();
1925 _str sFunction = k_func_getfunction_name();
1926 rc = fAsk ? _message_box("Process this exit from "sFunction"?", "Visual SlickEdit", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
1927 deselect();
1928 if (rc == IDYES)
1930 typeless returnpos;
1931 _save_pos2(returnpos);
1932 klib_klogexit();
1933 _restore_pos2(returnpos);
1940 * Next proc.
1942 _restore_pos2(procpos);
1947 /*******************************************************************************
1948 * Odin32 backward compatibility *
1949 *******************************************************************************/
1950 _command void odin32_maketagfile()
1952 /* We'll */
1953 if (file_match('-p 'maybe_quote_filename(strip_filename(_project_name,'e'):+TAG_FILE_EXT),1) != "")
1955 _project_update_files_retag(false,false,false,false);
1957 RetagFilesInTagFile2(project_tag_file, orig_view_id, temp_view_id, rebuild_all, false,
1958 doRemove,false,true,true);*/
1960 else
1961 _project_update_files_retag(true,false,false,true);
1964 _command void odin32_setcurrentdir()
1966 //_ini_get_value(_project_name,"COMPILER","WORKINGDIR", workingdir);
1967 //cd(workingdir);
1968 /* Go the the directory containing the project filename */
1969 cd(strip_filename(_project_name, 'NE'));
1975 /*******************************************************************************
1976 * Styles *
1977 *******************************************************************************/
1978 static _str StyleLanguages[] =
1980 "c",
1981 "e",
1982 "java"
1985 struct StyleScheme
1987 _str name;
1988 _str settings[];
1991 static StyleScheme StyleSchemes[] =
1994 "Opt2Ind4",
1996 "orig_tabsize=4",
1997 "syntax_indent=4",
1998 "tabsize=4",
1999 "align_on_equal=1",
2000 "pad_condition_state=1",
2001 "indent_with_tabs=0",
2002 "nospace_before_paren=0",
2003 "indent_comments=1",
2004 "indent_case=1",
2005 "statement_comment_col=0",
2006 "disable_bestyle=0",
2007 "decl_comment_col=0",
2008 "bestyle_on_functions=0",
2009 "use_relative_indent=1",
2010 "nospace_before_brace=0",
2011 "indent_fl=1",
2012 "statement_comment_state=2",
2013 "indent_pp=1",
2014 "be_style=1",
2015 "parens_on_return=0",
2016 "eat_blank_lines=0",
2017 "brace_indent=0",
2018 "eat_pp_space=1",
2019 "align_on_parens=1",
2020 "continuation_indent=0",
2021 "cuddle_else=0",
2022 "nopad_condition=1",
2023 "pad_condition=0",
2024 "indent_col1_comments=0"
2029 "Opt2Ind3",
2031 "orig_tabsize=3",
2032 "syntax_indent=3",
2033 "tabsize=3",
2034 "align_on_equal=1",
2035 "pad_condition_state=1",
2036 "indent_with_tabs=0",
2037 "nospace_before_paren=0",
2038 "indent_comments=1",
2039 "indent_case=1",
2040 "statement_comment_col=0",
2041 "disable_bestyle=0",
2042 "decl_comment_col=0",
2043 "bestyle_on_functions=0",
2044 "use_relative_indent=1",
2045 "nospace_before_brace=0",
2046 "indent_fl=1",
2047 "statement_comment_state=2",
2048 "indent_pp=1",
2049 "be_style=1",
2050 "parens_on_return=0",
2051 "eat_blank_lines=0",
2052 "brace_indent=0",
2053 "eat_pp_space=1",
2054 "align_on_parens=1",
2055 "continuation_indent=0",
2056 "cuddle_else=0",
2057 "nopad_condition=1",
2058 "pad_condition=0",
2059 "indent_col1_comments=0"
2064 "Opt2Ind8",
2066 "orig_tabsize=8",
2067 "syntax_indent=8",
2068 "tabsize=8",
2069 "align_on_equal=1",
2070 "pad_condition_state=1",
2071 "indent_with_tabs=0",
2072 "nospace_before_paren=0",
2073 "indent_comments=1",
2074 "indent_case=1",
2075 "statement_comment_col=0",
2076 "disable_bestyle=0",
2077 "decl_comment_col=0",
2078 "bestyle_on_functions=0",
2079 "use_relative_indent=1",
2080 "nospace_before_brace=0",
2081 "indent_fl=1",
2082 "statement_comment_state=2",
2083 "indent_pp=1",
2084 "be_style=1",
2085 "parens_on_return=0",
2086 "eat_blank_lines=0",
2087 "brace_indent=0",
2088 "eat_pp_space=1",
2089 "align_on_parens=1",
2090 "continuation_indent=0",
2091 "cuddle_else=0",
2092 "nopad_condition=1",
2093 "pad_condition=0",
2094 "indent_col1_comments=0"
2099 "Opt3Ind4",
2101 "orig_tabsize=4",
2102 "syntax_indent=4",
2103 "tabsize=4",
2104 "align_on_equal=1",
2105 "pad_condition_state=1",
2106 "indent_with_tabs=0",
2107 "nospace_before_paren=0",
2108 "indent_comments=1",
2109 "indent_case=1",
2110 "statement_comment_col=0",
2111 "disable_bestyle=0",
2112 "decl_comment_col=0",
2113 "bestyle_on_functions=0",
2114 "use_relative_indent=1",
2115 "nospace_before_brace=0",
2116 "indent_fl=1",
2117 "statement_comment_state=2",
2118 "indent_pp=1",
2119 "be_style=2",
2120 "parens_on_return=0",
2121 "eat_blank_lines=0",
2122 "brace_indent=0",
2123 "eat_pp_space=1",
2124 "align_on_parens=1",
2125 "continuation_indent=0",
2126 "cuddle_else=0",
2127 "nopad_condition=1",
2128 "pad_condition=0",
2129 "indent_col1_comments=0"
2134 "Opt3Ind3",
2136 "orig_tabsize=3",
2137 "syntax_indent=3",
2138 "tabsize=3",
2139 "align_on_equal=1",
2140 "pad_condition_state=1",
2141 "indent_with_tabs=0",
2142 "nospace_before_paren=0",
2143 "indent_comments=1",
2144 "indent_case=1",
2145 "statement_comment_col=0",
2146 "disable_bestyle=0",
2147 "decl_comment_col=0",
2148 "bestyle_on_functions=0",
2149 "use_relative_indent=1",
2150 "nospace_before_brace=0",
2151 "indent_fl=1",
2152 "statement_comment_state=2",
2153 "indent_pp=1",
2154 "be_style=2",
2155 "parens_on_return=0",
2156 "eat_blank_lines=0",
2157 "brace_indent=0",
2158 "eat_pp_space=1",
2159 "align_on_parens=1",
2160 "continuation_indent=0",
2161 "cuddle_else=0",
2162 "nopad_condition=1",
2163 "pad_condition=0",
2164 "indent_col1_comments=0"
2170 static void k_styles_create()
2173 * Find user format ini file.
2175 _str userini = maybe_quote_filename(_config_path():+'uformat.ini');
2176 if (file_match('-p 'userini, 1) == '')
2178 _str ini = maybe_quote_filename(slick_path_search('uformat.ini'));
2179 if (ini != '') userini = ini;
2184 * Remove any old schemes.
2186 int i,j,tv;
2187 for (i = 0; i < StyleSchemes._length(); i++)
2188 for (j = 0; j < StyleLanguages._length(); j++)
2190 _str sectionname = StyleLanguages[j]:+'-scheme-':+StyleSchemes[i].name;
2191 if (!_ini_get_section(userini, sectionname, tv))
2193 _ini_delete_section(userini, sectionname);
2194 _delete_temp_view(tv);
2195 //message("delete old scheme");
2200 * Create the new schemes.
2202 for (i = 0; i < StyleSchemes._length(); i++)
2204 for (j = 0; j < StyleLanguages._length(); j++)
2206 _str sectionname = StyleLanguages[j]:+'-scheme-':+StyleSchemes[i].name;
2207 int temp_view_id, k;
2208 _str orig_view_id = _create_temp_view(temp_view_id);
2209 activate_view(temp_view_id);
2210 for (k = 0; k < StyleSchemes[i].settings._length(); k++)
2211 insert_line(StyleSchemes[i].settings[k]);
2213 /* Insert the scheme section. */
2214 _ini_replace_section(userini, sectionname, temp_view_id);
2215 //message(userini)
2216 //bogus id - activate_view(orig_view_id);
2220 //last_scheme = last scheme name!!!
2225 * Sets the last used beutify scheme.
2227 static k_styles_set(_str scheme)
2231 * Find user format ini file.
2233 _str userini = maybe_quote_filename(_config_path():+'uformat.ini');
2234 if (file_match('-p 'userini, 1) == '')
2236 _str ini = maybe_quote_filename(slick_path_search('uformat.ini'));
2237 if (ini != '') userini = ini;
2241 * Set the scheme for each language.
2243 int j;
2244 for (j = 0; j < StyleLanguages._length(); j++)
2246 _ini_set_value(userini,
2247 StyleLanguages[j]:+'-scheme-Default',
2248 'last_scheme',
2249 scheme);
2254 static _str defoptions[] =
2256 "def-options-sas",
2257 "def-options-js",
2258 "def-options-bat",
2259 "def-options-c",
2260 "def-options-pas",
2261 "def-options-e",
2262 "def-options-java",
2263 "def-options-bourneshell",
2264 "def-options-csh",
2265 "def-options-vlx",
2266 "def-options-plsql",
2267 "def-options-sqlserver",
2268 "def-options-cmd"
2271 static _str defsetups[] =
2273 "def-setup-sas",
2274 "def-setup-js",
2275 "def-setup-bat",
2276 "def-setup-fundamental",
2277 "def-setup-process",
2278 "def-setup-c",
2279 "def-setup-pas",
2280 "def-setup-e",
2281 "def-setup-asm",
2282 "def-setup-java",
2283 "def-setup-html",
2284 "def-setup-bourneshell",
2285 "def-setup-csh",
2286 "def-setup-vlx",
2287 "def-setup-fileman",
2288 "def-setup-plsql",
2289 "def-setup-sqlserver",
2290 "def-setup-s",
2291 "def-setup-cmd"
2294 static _str defsetupstab8[] =
2296 "def-setup-c"
2300 static void k_styles_setindent(int indent, int iBraceStyle, boolean iWithTabs = false)
2302 if (iBraceStyle < 1 || iBraceStyle > 3)
2304 message('k_styles_setindent: iBraceStyle is bad (=' :+ iBraceStyle :+ ')');
2305 iBraceStyle = 2;
2309 * def-options for extentions known to have that info.
2311 int i;
2312 for (i = 0; i < defoptions._length(); i++)
2314 int idx = find_index(defoptions[i], MISC_TYPE);
2315 if (!idx)
2316 continue;
2318 parse name_info(idx) with syntax_indent o2 o3 o4 flags indent_fl o7 indent_case rest;
2320 /* Begin/end style */
2321 flags = flags & ~(1|2);
2322 flags = flags | (iBraceStyle - 1); /* Set style (0-based) */
2323 flags = flags & ~(16); /* no scape before parent.*/
2324 indent_fl = 1; /* Indent first level */
2325 indent_case = 1; /* Indent case from switch */
2327 sNewOptions = indent' 'o2' 'o3' 'o4' 'flags' 'indent_fl' 'o7' 'indent_case' 'rest;
2328 set_name_info(idx, sNewOptions);
2329 _config_modify |= CFGMODIFY_DEFDATA;
2333 * def-setup for known extentions.
2335 for (i = 0; i < defsetups._length(); i++)
2337 idx = find_index(defsetups[i], MISC_TYPE);
2338 if (!idx)
2339 continue;
2340 sExt = substr(defsetups[i], length('def-setup-') + 1);
2341 sSetup = name_info(idx);
2344 parse sSetup with 'MN=' mode_name ','\
2345 'TABS=' tabs ',' 'MA=' margins ',' 'KEYTAB=' keytab_name ','\
2346 'WW='word_wrap_style ',' 'IWT='indent_with_tabs ','\
2347 'ST='show_tabs ',' 'IN='indent_style ','\
2348 'WC='word_chars',' 'LN='lexer_name',' 'CF='color_flags','\
2349 'LNL='line_numbers_len','rest;
2351 indent_with_tabs = 0; /* Indent with tabs */
2353 /* Make sure all the values are legal */
2354 _ext_init_values(ext, lexer_name, color_flags);
2355 if (!isinteger(line_numbers_len)) line_numbers_len = 0;
2356 if (word_chars == '') word_chars = 'A-Za-z0-9_$';
2357 if (word_wrap_style == '') word_wrap_style = 3;
2358 if (show_tabs == '') show_tabs = 0;
2359 if (indent_style == '') indent_style = INDENT_SMART;
2361 /* Set new indent */
2362 tabs = '+'indent;
2365 sNewSetup = sSetup;
2367 /* Set new indent */
2368 if (pos('TABS=', sNewSetup) > 0)
2371 * If either in defoptions or defsetupstab8 use default tab of 8
2372 * For those supporting separate syntax indent using the normal tabsize
2373 * helps us a lot when reading it...
2375 fTab8 = false;
2376 for (j = 0; !fTab8 && j < defsetupstab8._length(); j++)
2377 if (substr(defsetupstab8[j], lastpos('-', defsetupstab8[j]) + 1) == sExt)
2378 fTab8 = true;
2379 for (j = 0; !fTab8 && j < defoptions._length(); j++)
2380 if (substr(defoptions[j], lastpos('-', defoptions[j]) + 1) == sExt)
2381 fTab8 = true;
2383 parse sNewSetup with sPre 'TABS=' sValue ',' sPost;
2384 if (fTab8)
2385 sNewSetup = sPre 'TABS=+8,' sPost
2386 else
2387 sNewSetup = sPre 'TABS=+' indent ',' sPost
2390 /* Set indent with tabs flag. */
2391 if (pos('IWT=', sNewSetup) > 0)
2393 parse sNewSetup with sPre 'IWT=' sValue ',' sPost;
2394 if (iWithTabs)
2395 sNewSetup = sPre 'IWT=1,' sPost
2396 else
2397 sNewSetup = sPre 'IWT=0,' sPost
2400 /* Do the real changes */
2401 set_name_info(idx, sNewSetup);
2402 _config_modify |= CFGMODIFY_DEFDATA;
2403 _update_buffers(sExt);
2409 * Takes necessary steps to convert a string to integer.
2411 static int k_style_emacs_var_integer(_str sVal)
2413 int i = (int)sVal;
2414 //say 'k_style_emacs_var_integer('sVal') -> 'i;
2415 return (int)sVal;
2420 * Sets a Emacs style variable.
2422 static int k_style_emacs_var(_str sVar, _str sVal)
2424 /* check input. */
2425 if (sVar == '' || sVal == '')
2426 return -1;
2427 //say 'k_style_emacs_var: 'sVar'='sVal;
2430 * Unpack the mode style parameters.
2432 _str sStyle = name_info(_edit_window().p_index);
2433 _str sStyleName = p_mode_name;
2434 typeless iIndentAmount, fExpansion, iMinAbbrivation, fIndentAfterOpenParen, iBeginEndStyle, fIndent1stLevel, iMainStyle, iSwitchStyle,
2435 sRest, sRes0, sRes1;
2436 if (sStyleName == 'Slick-C')
2438 parse sStyle with iMinAbbrivation sRes0 iBeginEndStyle fIndent1stLevel sRes1 iSwitchStyle sRest;
2439 iIndentAmount = p_SyntaxIndent;
2441 else /* C */
2442 parse sStyle with iIndentAmount fExpansion iMinAbbrivation fIndentAfterOpenParen iBeginEndStyle fIndent1stLevel iMainStyle iSwitchStyle sRest;
2446 * Process the variable.
2448 switch (sVar)
2450 case 'mode':
2451 case 'Mode':
2453 switch (sVal)
2455 case 'c':
2456 case 'C':
2457 case 'c++':
2458 case 'C++':
2459 case 'cpp':
2460 case 'CPP':
2461 case 'cxx':
2462 case 'CXX':
2463 p_extension = 'c';
2464 p_mode_name = 'C';
2465 break;
2467 case 'e':
2468 case 'slick-c':
2469 case 'Slick-c':
2470 case 'Slick-C':
2471 p_extension = 'e';
2472 p_mode_name = 'Slick-C';
2473 break;
2475 default:
2476 message('emacs mode "'sVal'" is not known to us');
2477 return -3;
2479 break;
2481 /* relevant emacs code:
2482 (defconst c-style-alist
2483 '(("gnu"
2484 (c-basic-offset . 2)
2485 (c-comment-only-line-offset . (0 . 0))
2486 (c-offsets-alist . ((statement-block-intro . +)
2487 (knr-argdecl-intro . 5)
2488 (substatement-open . +)
2489 (label . 0)
2490 (statement-case-open . +)
2491 (statement-cont . +)
2492 (arglist-intro . c-lineup-arglist-intro-after-paren)
2493 (arglist-close . c-lineup-arglist)
2494 (inline-open . 0)
2495 (brace-list-open . +)
2497 (c-special-indent-hook . c-gnu-impose-minimum)
2498 (c-block-comment-prefix . "")
2500 ("k&r"
2501 (c-basic-offset . 5)
2502 (c-comment-only-line-offset . 0)
2503 (c-offsets-alist . ((statement-block-intro . +)
2504 (knr-argdecl-intro . 0)
2505 (substatement-open . 0)
2506 (label . 0)
2507 (statement-cont . +)
2510 ("bsd"
2511 (c-basic-offset . 8)
2512 (c-comment-only-line-offset . 0)
2513 (c-offsets-alist . ((statement-block-intro . +)
2514 (knr-argdecl-intro . +)
2515 (substatement-open . 0)
2516 (label . 0)
2517 (statement-cont . +)
2518 (inline-open . 0)
2519 (inexpr-class . 0)
2522 ("stroustrup"
2523 (c-basic-offset . 4)
2524 (c-comment-only-line-offset . 0)
2525 (c-offsets-alist . ((statement-block-intro . +)
2526 (substatement-open . 0)
2527 (label . 0)
2528 (statement-cont . +)
2531 ("whitesmith"
2532 (c-basic-offset . 4)
2533 (c-comment-only-line-offset . 0)
2534 (c-offsets-alist . ((knr-argdecl-intro . +)
2535 (label . 0)
2536 (statement-cont . +)
2537 (substatement-open . +)
2538 (block-open . +)
2539 (statement-block-intro . c-lineup-whitesmith-in-block)
2540 (block-close . c-lineup-whitesmith-in-block)
2541 (inline-open . +)
2542 (defun-open . +)
2543 (defun-block-intro . c-lineup-whitesmith-in-block)
2544 (defun-close . c-lineup-whitesmith-in-block)
2545 (brace-list-open . +)
2546 (brace-list-intro . c-lineup-whitesmith-in-block)
2547 (brace-entry-open . c-indent-multi-line-block)
2548 (brace-list-close . c-lineup-whitesmith-in-block)
2549 (class-open . +)
2550 (inclass . c-lineup-whitesmith-in-block)
2551 (class-close . +)
2552 (inexpr-class . 0)
2553 (extern-lang-open . +)
2554 (inextern-lang . c-lineup-whitesmith-in-block)
2555 (extern-lang-close . +)
2556 (namespace-open . +)
2557 (innamespace . c-lineup-whitesmith-in-block)
2558 (namespace-close . +)
2561 ("ellemtel"
2562 (c-basic-offset . 3)
2563 (c-comment-only-line-offset . 0)
2564 (c-hanging-braces-alist . ((substatement-open before after)))
2565 (c-offsets-alist . ((topmost-intro . 0)
2566 (topmost-intro-cont . 0)
2567 (substatement . +)
2568 (substatement-open . 0)
2569 (case-label . +)
2570 (access-label . -)
2571 (inclass . ++)
2572 (inline-open . 0)
2575 ("linux"
2576 (c-basic-offset . 8)
2577 (c-comment-only-line-offset . 0)
2578 (c-hanging-braces-alist . ((brace-list-open)
2579 (brace-entry-open)
2580 (substatement-open after)
2581 (block-close . c-snug-do-while)))
2582 (c-cleanup-list . (brace-else-brace))
2583 (c-offsets-alist . ((statement-block-intro . +)
2584 (knr-argdecl-intro . 0)
2585 (substatement-open . 0)
2586 (label . 0)
2587 (statement-cont . +)
2590 ("python"
2591 (indent-tabs-mode . t)
2592 (fill-column . 78)
2593 (c-basic-offset . 8)
2594 (c-offsets-alist . ((substatement-open . 0)
2595 (inextern-lang . 0)
2596 (arglist-intro . +)
2597 (knr-argdecl-intro . +)
2599 (c-hanging-braces-alist . ((brace-list-open)
2600 (brace-list-intro)
2601 (brace-list-close)
2602 (brace-entry-open)
2603 (substatement-open after)
2604 (block-close . c-snug-do-while)
2606 (c-block-comment-prefix . "")
2608 ("java"
2609 (c-basic-offset . 4)
2610 (c-comment-only-line-offset . (0 . 0))
2611 ;; the following preserves Javadoc starter lines
2612 (c-offsets-alist . ((inline-open . 0)
2613 (topmost-intro-cont . +)
2614 (statement-block-intro . +)
2615 (knr-argdecl-intro . 5)
2616 (substatement-open . +)
2617 (label . +)
2618 (statement-case-open . +)
2619 (statement-cont . +)
2620 (arglist-intro . c-lineup-arglist-intro-after-paren)
2621 (arglist-close . c-lineup-arglist)
2622 (access-label . 0)
2623 (inher-cont . c-lineup-java-inher)
2624 (func-decl-cont . c-lineup-java-throws)
2630 case 'c-file-style':
2631 case 'c-indentation-style':
2632 switch (sVal)
2634 case 'bsd':
2635 case '"bsd"':
2636 case 'BSD':
2637 iBeginEndStyle = 1 | (iBeginEndStyle & ~3);
2638 p_indent_with_tabs = true;
2639 iIndentAmount = 8;
2640 p_SyntaxIndent = 8;
2641 p_tabs = "+8";
2642 //say 'bsd';
2643 break;
2645 case 'k&r':
2646 case '"k&r"':
2647 case 'K&R':
2648 iBeginEndStyle = 0 | (iBeginEndStyle & ~3);
2649 p_indent_with_tabs = false;
2650 iIndentAmount = 4;
2651 p_SyntaxIndent = 4;
2652 p_tabs = "+4";
2653 //say 'k&r';
2654 break;
2656 case 'linux-c':
2657 case '"linux-c"':
2658 iBeginEndStyle = 0 | (iBeginEndStyle & ~3);
2659 p_indent_with_tabs = true;
2660 iIndentAmount = 4;
2661 p_SyntaxIndent = 4;
2662 p_tabs = "+4";
2663 //say 'linux-c';
2664 break;
2666 case 'yet-to-be-found':
2667 iBeginEndStyle = 2 | (iBeginEndStyle & ~3);
2668 p_indent_with_tabs = false;
2669 iIndentAmount = 4;
2670 p_SyntaxIndent = 4;
2671 p_tabs = "+4";
2672 //say 'todo';
2673 break;
2675 default:
2676 message('emacs "'sVar'" value "'sVal'" is not known to us.');
2677 return -3;
2679 break;
2681 case 'c-label-offset':
2683 int i = k_style_emacs_var_integer(sVal);
2684 if (i >= -16 && i <= 16)
2686 if (i == -p_SyntaxIndent)
2687 iSwitchStyle = 0;
2688 else
2689 iSwitchStyle = 1;
2691 break;
2695 case 'indent-tabs-mode':
2696 p_indent_with_tabs = sVal == 't';
2697 break;
2699 case 'c-indent-level':
2700 case 'c-basic-offset':
2702 int i = k_style_emacs_var_integer(sVal);
2703 if (i > 0 && i <= 16)
2705 iIndentAmount = i;
2706 p_SyntaxIndent = i;
2708 else
2710 message('emacs "'sVar'" value "'sVal'" is out of range.');
2711 return -4;
2713 break;
2716 case 'tab-width':
2718 int i = k_style_emacs_var_integer(sVal);
2719 if (i > 0 && i <= 16)
2720 p_tabs = '+'i;
2721 else
2723 message('emacs "'sVar'" value "'sVal'" is out of range.');
2724 return -4;
2726 break;
2729 case 'nuke-trailing-whitespace-p':
2731 _str sName = 'def-koptions-'p_buf_id;
2732 int idx = insert_name(sName, MISC_TYPE, "kstyledoc");
2733 if (!idx)
2734 idx = find_index(sName, MISC_TYPE);
2735 if (idx)
2737 if (sVal == 't')
2738 set_name_info(idx, "saveoptions: +S");
2739 else
2740 set_name_info(idx, "saveoptions: -S");
2741 say 'sVal=' sVal;
2743 break;
2746 default:
2747 message('emacs variable "'sVar'" (value "'sVal'") is unknown to us.');
2748 return -5;
2752 * Update the style?
2754 _str sNewStyle = "";
2755 if (sStyleName == 'Slick-C')
2756 sNewStyle = iMinAbbrivation' 'sRes0' 'iBeginEndStyle' 'fIndent1stLevel' 'sRes1' 'iSwitchStyle' 'sRest;
2757 else
2758 sNewStyle = iIndentAmount' 'fExpansion' 'iMinAbbrivation' 'fIndentAfterOpenParen' 'iBeginEndStyle' 'fIndent1stLevel' 'iMainStyle' 'iSwitchStyle' 'sRest;
2759 if ( sNewStyle != ""
2760 && sNewStyle != sStyle
2761 && sStyleName == p_mode_name)
2763 _str sName = name_name(_edit_window().p_index)
2764 //say ' sStyle='sStyle' p_mode_name='p_mode_name;
2765 //say 'sNewStyle='sNewStyle' sName='sName;
2766 if (pos('kstyledoc-', sName) <= 0)
2768 sName = 'def-kstyledoc-'p_buf_id;
2769 int idx = insert_name(sName, MISC_TYPE, "kstyledoc");
2770 if (!idx)
2771 idx = find_index(sName, MISC_TYPE);
2772 if (idx)
2774 if (!set_name_info(idx, sNewStyle))
2775 _edit_window().p_index = idx;
2777 //say sName'='idx;
2779 else
2780 set_name_info(_edit_window().p_index, sNewStyle);
2783 return 0;
2788 * Parses a string with emacs variables.
2790 * The variables are separated by new line. Junk at
2791 * the start and end of the line is ignored.
2793 static int k_style_emac_vars(_str sVars)
2795 /* process them line by line */
2796 int iLine = 0;
2797 while (sVars != '' && iLine++ < 20)
2799 int iNext, iEnd;
2800 iEnd = iNext = pos("\n", sVars);
2801 if (iEnd <= 0)
2802 iEnd = iNext = length(sVars);
2803 else
2804 iEnd--;
2805 iNext++;
2807 sLine = strip(substr(sVars, 1, iEnd), 'B', " \t\n\r");
2808 sVars = strip(substr(sVars, iNext), 'L', " \t\n\r");
2809 //say 'iLine='iLine' sVars='sVars'<eol>';
2810 //say 'iLine='iLine' sLine='sLine'<eol>';
2811 if (sLine != '')
2813 rc = pos('[^a-zA-Z0-9-_]*([a-zA-Z0-9-_]+)[ \t]*:[ \t]*([^ \t]*)', sLine, 1, 'U');
2814 //say '0={'pos('S0')','pos('0')',"'substr(sLine,pos('S0'),pos('0'))'"'
2815 //say '1={'pos('S1')','pos('1')',"'substr(sLine,pos('S1'),pos('1'))'"'
2816 //say '2={'pos('S2')','pos('2')',"'substr(sLine,pos('S2'),pos('2'))'"'
2817 //say '3={'pos('S3')','pos('3')',"'substr(sLine,pos('S3'),pos('3'))'"'
2818 //say '4={'pos('S4')','pos('4')',"'substr(sLine,pos('S4'),pos('4'))'"'
2819 if (rc > 0)
2820 k_style_emacs_var(substr(sLine,pos('S1'),pos('1')),
2821 substr(sLine,pos('S2'),pos('2')));
2824 return 0;
2828 * Searches for Emacs style specification for the current document.
2830 void k_style_load()
2832 /* save the position before we start looking around the file. */
2833 typeless saved_pos;
2834 _save_pos2(saved_pos);
2836 int rc;
2838 /* Check first line. */
2839 top_of_buffer();
2840 _str sLine;
2841 get_line(sLine);
2842 strip(sLine);
2843 if (pos('-*-[ \t]+(.*:.*)[ \t]+-*-', sLine, 1, 'U'))
2845 _str sVars;
2846 sVars = substr(sLine, pos('S1'), pos('1'));
2847 sVars = translate(sVars, "\n", ";");
2848 k_style_emac_vars(sVars);
2851 /* Look for the "Local Variables:" stuff from the end of the file. */
2852 bottom_of_buffer();
2853 rc = search('Local Variables:[ \t]*\n\om(.*)\ol\n.*End:.*\n', '-EU');
2854 if (!rc)
2856 /* copy the variables out to a buffer. */
2857 _str sVars;
2858 sVars = get_text(match_length("1"), match_length("S1"));
2859 k_style_emac_vars(sVars);
2862 _restore_pos2(saved_pos);
2867 * Callback function for the event of a new buffer.
2869 * This is used to make sure there are no left over per buffer options
2870 * hanging around.
2872 void _buffer_add_kdev(int buf_id)
2874 _str sName = 'def-koptions-'buf_id;
2875 int idx = insert_name(sName, MISC_TYPE, "kstyledoc");
2876 if (!idx)
2877 idx = find_index(sName, MISC_TYPE);
2878 if (idx)
2879 set_name_info(idx, "");
2880 //message("_buffer_add_kdev: " idx);
2885 * Callback function for the event of quitting a buffer.
2887 * This is used to make sure there are no left over per buffer options
2888 * hanging around.
2890 void _cbquit2_kdev(int buf_id)
2892 _str sName = 'def-koptions-'buf_id;
2893 int idx = find_index(sName, MISC_TYPE);
2894 if (idx)
2895 delete_name(idx);
2896 //message("_cbquit2_kdev: " idx " " sName);
2898 sName = 'def-kstyledoc-'buf_id;
2899 idx = find_index(sName, MISC_TYPE);
2900 if (idx)
2901 delete_name(idx);
2906 * Called to get save options for the current buffer.
2908 * This requires a modified loadsave.e!
2910 _str _buffer_save_kdev(int buf_id)
2912 _str sRet = ""
2913 _str sName = 'def-koptions-'buf_id;
2914 int idx = find_index(sName, MISC_TYPE);
2915 if (idx)
2917 _str sOptions = strip(name_info(idx));
2918 if (sOptions != "")
2919 parse sOptions with . "saveoptions:" sRet .
2920 message("_buffer_save_kdev: " idx " " sName " " sOptions);
2922 return sRet;
2927 /*******************************************************************************
2928 * Menu and Menu commands *
2929 *******************************************************************************/
2930 static int iTimer = 0;
2931 static int mhkDev = 0;
2932 static int mhCode = 0;
2933 static int mhDoc = 0;
2934 static int mhLic = 0;
2935 static int mhPre = 0;
2938 * Creates the kDev menu.
2940 static k_menu_create()
2942 if (arg(1) == 'timer')
2943 _kill_timer(iTimer);
2944 menu_handle = _mdi.p_menu_handle;
2945 menu_index = find_index(_cur_mdi_menu,oi2type(OI_MENU));
2948 * Remove any old menu.
2950 mhDelete = iPos = 0;
2951 index = _menu_find(menu_handle, "kDev", mhDelete, iPos, 'C');
2952 //message("index="index " mhDelete="mhDelete " iPos="iPos);
2953 if (index == 0)
2954 _menu_delete(mhDelete, iPos);
2958 * Insert the "kDev" menu.
2960 mhkDev = _menu_insert(menu_handle, 9, MF_SUBMENU, "&kDev", "", "kDev");
2961 mhCode=_menu_insert(mhkDev, -1, MF_ENABLED | MF_SUBMENU, "Coding &Style", "", "coding");
2962 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 2, Syntax Indent 4 (knut)", "k_menu_style Opt2Ind4", "Opt2Ind4");
2963 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 2, Syntax Indent 3", "k_menu_style Opt2Ind3", "Opt2Ind3");
2964 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 2, Syntax Indent 8", "k_menu_style Opt2Ind8", "Opt2Ind8");
2965 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 3, Syntax Indent 4 (giws)", "k_menu_style Opt3Ind4", "Opt3Ind4");
2966 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 3, Syntax Indent 3 (giws)", "k_menu_style Opt3Ind3", "Opt3Ind3");
2968 mhDoc= _menu_insert(mhkDev, -1, MF_ENABLED | MF_SUBMENU, "&Documentation", "", "doc");
2969 mhDSJ= _menu_insert(mhDoc, -1, MF_ENABLED | MF_UNCHECKED, "&Javadoc Style", "k_menu_doc_style javadoc", "javadoc");
2970 mhDSL= _menu_insert(mhDoc, -1, MF_GRAYED | MF_UNCHECKED, "&Linux Kernel Style", "k_menu_doc_style linux", "linux");
2972 mhLic= _menu_insert(mhkDev, -1, MF_ENABLED | MF_SUBMENU, "&License", "", "License");
2973 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&Odin32", "k_menu_license Odin32", "Odin32");
2974 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&GPL", "k_menu_license GPL", "GPL");
2975 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&LGPL", "k_menu_license LGPL", "LGPL");
2976 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&GPLv3", "k_menu_license GPLv3", "GPLv3");
2977 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&LGPLv3", "k_menu_license LGPLv3", "LGPLv3");
2978 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&VirtualBox", "k_menu_license VirtualBox", "VirtualBox");
2979 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&VirtualBox GPL And CDDL","k_menu_license VirtualBoxGPLAndCDDL", "VirtualBoxGPLAndCDDL");
2980 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&Confidential", "k_menu_license Confidential", "Confidential");
2981 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&Confidential No Author", "k_menu_license ConfidentialNoAuthor", "ConfidentialNoAuthor");
2983 rc = _menu_insert(mhkDev, -1, MF_ENABLED, "-", "", "dash vars");
2984 rc = _menu_insert(mhkDev, -1, MF_ENABLED, skChange == '' ? '&Change...' : '&Change (' skChange ')...', "k_menu_change", "");
2985 rc = _menu_insert(mhkDev, -1, MF_ENABLED, skProgram == '' ? '&Program...' : '&Program (' skProgram ')...', "k_menu_program", "");
2986 rc = _menu_insert(mhkDev, -1, MF_ENABLED, skCompany == '' ? 'Co&mpany...' : 'Co&mpany (' skCompany ')...', "k_menu_company", "");
2987 rc = _menu_insert(mhkDev, -1, MF_ENABLED, '&User Name (' skUserName ')...', "k_menu_user_name", "username");
2988 rc = _menu_insert(mhkDev, -1, MF_ENABLED, 'User &e-mail (' skUserEmail ')...', "k_menu_user_email", "useremail");
2989 rc = _menu_insert(mhkDev, -1, MF_ENABLED, 'User &Initials (' skUserInitials ')...', "k_menu_user_initials", "userinitials");
2990 rc = _menu_insert(mhkDev, -1, MF_ENABLED, "-", "", "dash preset");
2991 mhPre= _menu_insert(mhkDev, -1, MF_SUBMENU, "P&resets", "", "");
2992 rc = _menu_insert(mhPre, -1, MF_ENABLED, "The Bird", "k_menu_preset javadoc, GPL, Opt2Ind4", "bird");
2993 rc = _menu_insert(mhPre, -1, MF_ENABLED, "kLIBC", "k_menu_preset javadoc, GPL, Opt2Ind4,, kLIBC", "kLIBC");
2994 rc = _menu_insert(mhPre, -1, MF_ENABLED, "kBuild", "k_menu_preset javadoc, GPLv3, Opt2Ind4,, kBuild", "kBuild");
2995 rc = _menu_insert(mhPre, -1, MF_ENABLED, "kStuff", "k_menu_preset javadoc, GPL, Opt2Ind4,, kStuff", "kStuff");
2996 rc = _menu_insert(mhPre, -1, MF_ENABLED, "sun", "k_menu_preset javadoc, ConfidentialNoAuthor, Opt2Ind4, sun", "sun");
2997 rc = _menu_insert(mhPre, -1, MF_ENABLED, "VirtualBox", "k_menu_preset javadoc, VirtualBox, Opt2Ind4, sun", "VirtualBox");
2999 k_menu_doc_style();
3000 k_menu_license();
3001 k_menu_style();
3006 * Change change Id.
3008 _command k_menu_change()
3010 sRc = show("-modal k_form_simple_input", "Change ID", skChange);
3011 if (sRc != "\r")
3013 skChange = sRc;
3014 k_menu_create();
3020 * Change program name.
3022 _command k_menu_program()
3024 sRc = show("-modal k_form_simple_input", "Program", skProgram);
3025 if (sRc != "\r")
3027 skProgram = sRc;
3028 k_menu_create();
3034 * Change company.
3036 _command k_menu_company()
3038 if (skCompany == '')
3039 sRc = show("-modal k_form_simple_input", "Company", 'innotek GmbH');
3040 else
3041 sRc = show("-modal k_form_simple_input", "Company", skCompany);
3042 if (sRc != "\r")
3044 skCompany = sRc;
3045 k_menu_create();
3051 * Change user name.
3053 _command k_menu_user_name()
3055 sRc = show("-modal k_form_simple_input", "User Name", skUserName);
3056 if (sRc != "\r" && sRc != '')
3058 skUserName = sRc;
3059 k_menu_create();
3065 * Change user email.
3067 _command k_menu_user_email()
3069 sRc = show("-modal k_form_simple_input", "User e-mail", skUserEmail);
3070 if (sRc != "\r" && sRc != '')
3072 skUserEmail = sRc;
3073 k_menu_create();
3079 * Change user initials.
3081 _command k_menu_user_initials()
3083 sRc = show("-modal k_form_simple_input", "User e-mail", skUserInitials);
3084 if (sRc != "\r" && sRc != '')
3086 skUserInitials = sRc;
3087 k_menu_create();
3094 * Checks the correct menu item.
3096 _command void k_menu_doc_style(_str sNewDocStyle = '')
3098 //say 'sNewDocStyle='sNewDocStyle;
3099 if (sNewDocStyle != '')
3100 skDocStyle = sNewDocStyle
3101 _menu_set_state(mhDoc, "javadoc", MF_UNCHECKED);
3102 _menu_set_state(mhDoc, "linux", MF_UNCHECKED | MF_GRAYED);
3104 _menu_set_state(mhDoc, skDocStyle, MF_CHECKED);
3109 * Checks the correct menu item.
3111 _command void k_menu_license(_str sNewLicense = '')
3113 //say 'sNewLicense='sNewLicense;
3114 if (sNewLicense != '')
3115 skLicense = sNewLicense
3116 _menu_set_state(mhLic, "Odin32", MF_UNCHECKED);
3117 _menu_set_state(mhLic, "GPL", MF_UNCHECKED);
3118 _menu_set_state(mhLic, "LGPL", MF_UNCHECKED);
3119 _menu_set_state(mhLic, "GPLv3", MF_UNCHECKED);
3120 _menu_set_state(mhLic, "LGPLv3", MF_UNCHECKED);
3121 _menu_set_state(mhLic, "VirtualBox", MF_UNCHECKED);
3122 _menu_set_state(mhLic, "VirtualBoxGPLAndCDDL", MF_UNCHECKED);
3123 _menu_set_state(mhLic, "Confidential", MF_UNCHECKED);
3124 _menu_set_state(mhLic, "ConfidentialNoAuthor", MF_UNCHECKED);
3126 _menu_set_state(mhLic, skLicense, MF_CHECKED);
3131 * Check the correct style menu item.
3133 _command void k_menu_style(_str sNewStyle = '')
3135 //say 'sNewStyle='sNewStyle;
3136 _menu_set_state(mhCode, "Opt1Ind4", MF_UNCHECKED);
3137 _menu_set_state(mhCode, "Opt1Ind3", MF_UNCHECKED);
3138 _menu_set_state(mhCode, "Opt1Ind8", MF_UNCHECKED);
3139 _menu_set_state(mhCode, "Opt2Ind4", MF_UNCHECKED);
3140 _menu_set_state(mhCode, "Opt2Ind3", MF_UNCHECKED);
3141 _menu_set_state(mhCode, "Opt2Ind8", MF_UNCHECKED);
3142 _menu_set_state(mhCode, "Opt3Ind4", MF_UNCHECKED);
3143 _menu_set_state(mhCode, "Opt3Ind3", MF_UNCHECKED);
3144 _menu_set_state(mhCode, "Opt3Ind8", MF_UNCHECKED);
3146 if (sNewStyle != '')
3148 int iIndent = (int)substr(sNewStyle, 8, 1);
3149 int iBraceStyle = (int)substr(sNewStyle, 4, 1);
3150 skCodeStyle = sNewStyle;
3151 k_styles_setindent(iIndent, iBraceStyle);
3152 k_styles_set(sNewStyle);
3155 _menu_set_state(mhCode, skCodeStyle, MF_CHECKED);
3160 * Load a 'preset'.
3162 _command void k_menu_preset(_str sArgs = '')
3164 parse sArgs with sNewDocStyle ',' sNewLicense ',' sNewStyle ',' sNewCompany ',' sNewProgram ',' sNewChange
3165 sNewDocStyle= strip(sNewDocStyle);
3166 sNewLicense = strip(sNewLicense);
3167 sNewStyle = strip(sNewStyle);
3168 sNewCompany = strip(sNewCompany);
3169 if (sNewCompany == 'sun')
3170 sNewCompany = 'Sun Microsystems, Inc.'
3171 sNewProgram = strip(sNewProgram);
3172 sNewChange = strip(sNewChange);
3174 //say 'k_menu_preset('sNewDocStyle',' sNewLicense',' sNewStyle',' sNewCompany',' sNewProgram')';
3175 k_menu_doc_style(sNewDocStyle);
3176 k_menu_license(sNewLicense);
3177 k_menu_style(sNewStyle);
3178 skCompany = sNewCompany;
3179 skProgram = sNewProgram;
3180 skChange = sNewChange;
3181 k_menu_create();
3186 /* future ones..
3187 _command k_menu_setcolor()
3189 createMyColorSchemeAndUseIt();
3193 _command k_menu_setkeys()
3195 rc = load("d:/knut/VSlickMacros/BoxerDef.e");
3198 _command k_menu_settings()
3200 mySettings();
3205 /*******************************************************************************
3206 * Dialogs *
3207 *******************************************************************************/
3208 _form k_form_simple_input {
3209 p_backcolor=0x80000005
3210 p_border_style=BDS_DIALOG_BOX
3211 p_caption='Simple Input'
3212 p_clip_controls=FALSE
3213 p_forecolor=0x80000008
3214 p_height=1120
3215 p_width=5020
3216 p_x=6660
3217 p_y=6680
3218 _text_box entText {
3219 p_auto_size=TRUE
3220 p_backcolor=0x80000005
3221 p_border_style=BDS_FIXED_SINGLE
3222 p_completion=NONE_ARG
3223 p_font_bold=FALSE
3224 p_font_italic=FALSE
3225 p_font_name='MS Sans Serif'
3226 p_font_size=8
3227 p_font_underline=FALSE
3228 p_forecolor=0x80000008
3229 p_height=270
3230 p_tab_index=1
3231 p_tab_stop=TRUE
3232 p_text='text'
3233 p_width=3180
3234 p_x=1680
3235 p_y=240
3236 p_eventtab2=_ul2_textbox
3238 _label lblLabel {
3239 p_alignment=AL_VCENTERRIGHT
3240 p_auto_size=FALSE
3241 p_backcolor=0x80000005
3242 p_border_style=BDS_NONE
3243 p_caption='Label'
3244 p_font_bold=FALSE
3245 p_font_italic=FALSE
3246 p_font_name='MS Sans Serif'
3247 p_font_size=8
3248 p_font_underline=FALSE
3249 p_forecolor=0x80000008
3250 p_height=240
3251 p_tab_index=2
3252 p_width=1380
3253 p_word_wrap=FALSE
3254 p_x=180
3255 p_y=240
3257 _command_button btnOK {
3258 p_cancel=FALSE
3259 p_caption='&OK'
3260 p_default=TRUE
3261 p_font_bold=FALSE
3262 p_font_italic=FALSE
3263 p_font_name='MS Sans Serif'
3264 p_font_size=8
3265 p_font_underline=FALSE
3266 p_height=360
3267 p_tab_index=3
3268 p_tab_stop=TRUE
3269 p_width=1020
3270 p_x=180
3271 p_y=660
3273 _command_button btnCancel {
3274 p_cancel=TRUE
3275 p_caption='Cancel'
3276 p_default=FALSE
3277 p_font_bold=FALSE
3278 p_font_italic=FALSE
3279 p_font_name='MS Sans Serif'
3280 p_font_size=8
3281 p_font_underline=FALSE
3282 p_height=360
3283 p_tab_index=4
3284 p_tab_stop=TRUE
3285 p_width=840
3286 p_x=1380
3287 p_y=660
3291 defeventtab k_form_simple_input
3292 btnOK.on_create(_str sLabel = '', _str sText = '')
3294 p_active_form.p_caption = sLabel;
3295 lblLabel.p_caption = sLabel;
3296 entText.p_text = sText;
3299 btnOK.lbutton_up()
3301 sText = entText.p_text;
3302 p_active_form._delete_window(sText);
3304 btnCancel.lbutton_up()
3306 sText = entText.p_text;
3307 p_active_form._delete_window("\r");
3313 * Module initiation.
3315 definit()
3317 /* do cleanup. */
3318 for (i = 0; i < 200; i++)
3320 index = name_match("def-koptions-", 1, MISC_TYPE);
3321 if (!index)
3322 break;
3323 delete_name(index);
3326 /* do init */
3327 k_styles_create();
3328 k_menu_create();
3329 iTimer = _set_timer(1000, k_menu_create, "timer");
3330 /* createMyColorSchemeAndUseIt();*/