VirtualBox

source: kBuild/trunk/VSlickMacros/kdev.e@ 1228

Last change on this file since 1228 was 1100, checked in by bird, 17 years ago

new virtualbox license header.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 92.1 KB
Line 
1/* $Id: kdev.e 1100 2007-09-19 07:32:44Z bird $ -*- tab-width: 4 c-indent-level: 4 -*-
2 *
3 * Visual SlickEdit Documentation Macros.
4 *
5 * Copyright (c) 1999-2007 knut st. osmundsen <[email protected]>
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 * Ctrl+Shift+L: Load document variables.
45 *
46 * Ctrl+Shift+B: KLOGENTRYX(..)
47 * Ctrl+Shift+E: KLOGEXIT(..)
48 * Ctrl+Shift+N: Do kLog stuff for the current file. No questions.
49 * Ctrl+Shift+Q: Do kLog stuff for the current file. Ask a lot of questions.
50 *
51 * Remember to set the correct sOdin32UserName, sOdin32UserEmail and sOdin32UserInitials
52 * before compiling and loading the macros into Visual SlickEdit.
53 *
54 * These macros are compatible with both 3.0(c) and 4.0(b).
55 *
56 */
57defeventtab default_keys
58def 'C-S-A' = k_signature
59def 'C-S-C' = k_javadoc_classbox
60def 'C-S-E' = k_box_exported
61def 'C-S-F' = k_javadoc_funcbox
62def 'C-S-G' = k_box_globals
63def 'C-S-H' = k_box_headers
64def 'C-S-I' = k_box_intfuncs
65def 'C-S-K' = k_box_consts
66def 'C-S-M' = k_javadoc_moduleheader
67def 'C-S-O' = k_oneliner
68def 'C-S-P' = k_mark_modified_line
69def 'C-S-S' = k_box_structs
70def 'C-S-T' = odin32_maketagfile
71def 'C-S-L' = k_style_load
72
73//optional stuff
74//def 'C-S-Q' = klib_klog_file_ask
75//def 'C-S-N' = klib_klog_file_no_ask
76//def 'C-S-1' = klib_klogentry
77//def 'C-S-3' = klib_klogexit
78
79
80//MARKER. Editor searches for this line!
81#pragma option(redeclvars, on)
82#include 'slick.sh'
83#ifndef VS_TAGDETAIL_context_args
84/* newer vslick version. */
85#include 'tagsdb.sh'
86//#pragma option(strict,on)
87/*#else: Version 4.0 (OS/2) */
88#endif
89
90/* Remeber to change these! */
91static _str skUserInitials = "kso";
92static _str skUserName = "knut st. osmundsen";
93static _str skUserEmail = "[email protected]";
94
95
96/*******************************************************************************
97* Global Variables *
98*******************************************************************************/
99static _str skCodeStyle = 'Opt2Ind4'; /* coding style scheme. */
100static _str skDocStyle = 'javadoc';/* options: javadoc, */
101static _str skLicense = 'GPL'; /* options: GPL, LGPL, Odin32, Confidential */
102static _str skCompany = ''; /* empty or company name for copyright */
103static _str skProgram = ''; /* Current program name - used by [L]GPL */
104static _str skChange = ''; /* Current change identifier. */
105
106static int ikStyleWidth = 80; /* The page width of the style. */
107static boolean fkStyleFullHeaders = false; /* false: omit some tags. */
108static int ikStyleOneliner = 41; /* The oneline comment column. */
109static int ikStyleModifyMarkColumn = 105;
110static boolean fkStyleBoxTag = false; /* true: Include tag in k_box_start. */
111
112/*******************************************************************************
113* Internal Functions *
114*******************************************************************************/
115/**
116 * Gets iso date.
117 * @returns ISO formatted date.
118 */
119static _str k_date()
120{
121 int i,j;
122 _str date;
123
124 date = _date('U');
125 i = pos("/", date);
126 j = pos("/", date, i+1);
127 _str month = substr(date, 1, i-1);
128 if (length(month) == 1) month = '0'month;
129 _str day = substr(date, i+1, j-i-1);
130 if (length(day) == 1) day = '0'day;
131 _str year = substr(date, j+1);
132 return year"-"month"-"day;
133}
134
135
136/**
137 * Get the current year.
138 * @returns Current year string.
139 */
140static _str k_year()
141{
142 _str date = _date('U');
143 return substr(date, pos("/",date, pos("/",date)+1)+1, 4);
144}
145
146
147/**
148 * Aligns a value up to a given alignment.
149 */
150static int k_alignup(int iValue, iAlign)
151{
152 if (iAlign <= 0)
153 {
154 message('k_alignup: iValue='iValue ' iAlign='iAlign);
155 iAlign = 4;
156 }
157 return ((iValue intdiv iAlign) + 1) * iAlign;
158}
159
160
161/**
162 * Reads the comment setup for this lexer/extension .
163 *
164 * @returns Success indicator.
165 * @param sLeft Left comment. (output)
166 * @param sRight Right comment. (output)
167 * @param iColumn Comment mark column. (1-based) (output)
168 * @param sExt The extension to lookup defaults to the current one.
169 * @param sLexer The lexer to lookup defaults to the current one.
170 * @remark This should be exported from box.e, but unfortunately it isn't.
171 */
172static boolean k_commentconfig(_str &sLeft, _str &sRight, int &iColumn, _str sExt = p_extension, _str sLexer = p_lexer_name)
173{
174 /* init returns */
175 sLeft = sRight = '';
176 iColumn = 0;
177
178 /*
179 * Get comment setup from the lexer.
180 */
181 _str sLine = '';
182 if (sLexer)
183 {
184 /* multiline */
185 rc = _ini_get_value(slick_path_search("user.vlx"), sLexer, 'mlcomment', sLine);
186 if (rc)
187 rc = _ini_get_value(slick_path_search("vslick.vlx"), sLexer, 'mlcomment', sLine);
188 if (!rc)
189 {
190 sLeft = strip(word(sLine, 1));
191 sRight = strip(word(sLine, 2));
192 if (sLeft != '' && sRight != '')
193 return true;
194 }
195
196 /* failed, try single line. */
197 rc = _ini_get_value(slick_path_search("user.vlx"), sLexer, 'linecomment', sLine);
198 if (rc)
199 rc = _ini_get_value(slick_path_search("vslick.vlx"), sLexer, 'linecomment', sLine);
200 if (!rc)
201 {
202 sLeft = strip(word(sLine, 1));
203 sRight = '';
204 iColumn = 0;
205 _str sTmp = word(sLine, 2);
206 if (isnumber(sTmp))
207 iColumn = (int)sTmp;
208 if (sLeft != '')
209 return true;
210 }
211 }
212
213 /*
214 * Read the nonboxchars and determin user or default box.ini.
215 */
216 _str sFile = slick_path_search("ubox.ini");
217 boolean frc = _ini_get_value(sFile, sExt, 'nonboxchars', sLine);
218 if (frc)
219 {
220 sFile = slick_path_search("box.ini");
221 frc = _ini_get_value(sFile, sExt, 'nonboxchars', sLine);
222 }
223
224 if (!frc)
225 { /*
226 * Found extension.
227 */
228 sLeft = strip(eq_name2value('left',sLine));
229 if (sLeft == '\e') sLeft = '';
230 sRight = strip(eq_name2value('right',sLine));
231 if (sRight == '\e') sRight = '';
232
233 /* Read comment column too */
234 frc = _ini_get_value(sFile, sExt, 'comment_col', sLine);
235 if (frc)
236 {
237 iColumn = eq_name2value('comment_col', sLine);
238 if (iColumn == '\e') iColumn = 0;
239 }
240 else
241 iColumn = 0;
242 return true;
243 }
244
245 /* failure */
246 sLeft = sRight = '';
247 iColumn = 0;
248
249 return false;
250}
251
252
253/**
254 * Checks if current file only support line comments.
255 * @returns True / False.
256 * @remark Use builtin extension stuff!
257 */
258static boolean k_line_comment()
259{
260 _str sRight = '';
261 _str sLeft = '';
262 int iColumn;
263 boolean fLineComment = false;
264 if (k_commentconfig(sLeft, sRight, iColumn))
265 fLineComment = (sRight == '' || iColumn > 0);
266 return fLineComment;
267}
268
269
270
271#define KIC_CURSOR_BEFORE 1
272#define KIC_CURSOR_AFTER 2
273#define KIC_CURSOR_AT_END 3
274
275/**
276 * Insert a comment at current or best fitting position in the text.
277 * @param sStr The comment to insert.
278 * @param iCursor Where to put the cursor.
279 * @param iPosition Where to start the comment.
280 * Doesn't apply to column based source.
281 * -1 means at cursor position. (default)
282 * >0 means at end of line, but not before this column (1-based).
283 * This also implies a min of one space to EOL.
284 */
285void k_insert_comment(_str sStr, int iCursor, int iPosition = -1)
286{
287 _str sLeft;
288 _str sRight;
289 int iColumn;
290 if (!k_commentconfig(sLeft, sRight, iColumn))
291 {
292 sLeft = '/*'; sRight = '*/'; iColumn = 0;
293 }
294
295 int iCol = 0;
296 if (iColumn <= 0)
297 { /*
298 * not column based source
299 */
300
301 /* position us first */
302 if (iPosition > 0)
303 {
304 end_line();
305 do {
306 _insert_text(" ");
307 } while (p_col < iPosition);
308 }
309
310 /* insert comment saving the position for _BEFORE. */
311 iCol = p_col;
312 _insert_text(sLeft:+' ':+sStr);
313 if (iCursor == KIC_CURSOR_AT_END)
314 iCol = p_col;
315 /* right comment delimiter? */
316 if (sRight != '')
317 _insert_text(' ':+sRight);
318 }
319 else
320 {
321 if (p_col >= iColumn)
322 _insert_text("\n");
323 do { _insert_text(" "); } while (p_col < iColumn);
324 if (iCursor == KIC_CURSOR_BEFORE)
325 iCol = p_col;
326 _insert_text(sLeft:+' ':+sStr);
327 if (iCursor == KIC_CURSOR_AT_END)
328 iCol = p_col;
329 }
330
331 /* set cursor. */
332 if (iCursor != KIC_CURSOR_AFTER)
333 p_col = iCol;
334}
335
336
337/**
338 * Gets the comment prefix or postfix.
339 * @returns Comment prefix or postfix.
340 * @param fRight If clear left comment string - default.
341 * If set right comment string.
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 int fSplit = 0;
1248
1249 _begin_line();
1250 k_insert_comment('$':+'I':+'d: $', KIC_CURSOR_AT_END, -1);
1251 _end_line();
1252 _insert_text("\n");
1253
1254 k_javadoc_box_start('@file');
1255 if (skLicense == 'VirtualBox' || 1 /* it's now default */)
1256 {
1257 fSplit = 1;
1258 iCursorLine = p_RLine;
1259 k_javadoc_box_line();
1260 k_javadoc_box_end();
1261 _insert_text("\n");
1262 _insert_text(k_comment() "\n");
1263 }
1264 else
1265 {
1266 k_javadoc_box_line();
1267 iCursorLine = p_RLine;
1268 k_javadoc_box_line();
1269 k_javadoc_box_line();
1270 }
1271
1272 if (skLicense == 'Confidential')
1273 {
1274 k_javadoc_box_line(skCompany ' confidential');
1275 k_javadoc_box_line();
1276 }
1277
1278 if (skCompany != '')
1279 {
1280 if (skLicense == 'VirtualBox')
1281 k_javadoc_box_line('Copyright (C) ' k_year() ' ' skCompany);
1282 else
1283 {
1284 k_javadoc_box_line('Copyright (c) ' k_year() ' ' skCompany);
1285 k_javadoc_box_line();
1286 k_javadoc_box_line('Author: ' skUserName' <' skUserEmail '>');
1287 }
1288 }
1289 else
1290 k_javadoc_box_line('Copyright (c) ' k_year() ' 'skUserName' <' skUserEmail '>');
1291 k_javadoc_box_line();
1292 switch (skLicense)
1293 {
1294 case 'Odin32':
1295 k_javadoc_box_line('Project Odin Software License can be found in LICENSE.TXT.');
1296 break;
1297
1298 case 'GPL':
1299 _str sProg = skProgram;
1300 if (!fSplit)
1301 k_javadoc_box_line();
1302 if (sProg == '')
1303 sProg = 'This program';
1304 else
1305 {
1306 k_javadoc_box_line('This file is part of ' sProg '.');
1307 k_javadoc_box_line();
1308 }
1309 k_javadoc_box_line(sProg ' is free software; you can redistribute it and/or modify');
1310 k_javadoc_box_line('it under the terms of the GNU General Public License as published by');
1311 k_javadoc_box_line('the Free Software Foundation; either version 2 of the License, or');
1312 k_javadoc_box_line('(at your option) any later version.');
1313 k_javadoc_box_line();
1314 k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful,');
1315 k_javadoc_box_line('but WITHOUT ANY WARRANTY; without even the implied warranty of');
1316 k_javadoc_box_line('MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the');
1317 k_javadoc_box_line('GNU General Public License for more details.');
1318 k_javadoc_box_line();
1319 k_javadoc_box_line('You should have received a copy of the GNU General Public License');
1320 k_javadoc_box_line('along with ' sProg '; if not, write to the Free Software');
1321 k_javadoc_box_line('Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA');
1322 break;
1323
1324 case 'LGPL':
1325 sProg = skProgram;
1326 if (!fSplit)
1327 k_javadoc_box_line();
1328 if (sProg == '')
1329 sProg = 'This library';
1330 else
1331 {
1332 k_javadoc_box_line('This file is part of ' sProg '.');
1333 k_javadoc_box_line();
1334 }
1335 k_javadoc_box_line(sProg ' is free software; you can redistribute it and/or');
1336 k_javadoc_box_line('modify it under the terms of the GNU Lesser General Public');
1337 k_javadoc_box_line('License as published by the Free Software Foundation; either');
1338 k_javadoc_box_line('version 2.1 of the License, or (at your option) any later version.');
1339 k_javadoc_box_line();
1340 k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful,');
1341 k_javadoc_box_line('but WITHOUT ANY WARRANTY; without even the implied warranty of');
1342 k_javadoc_box_line('MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU');
1343 k_javadoc_box_line('Lesser General Public License for more details.');
1344 k_javadoc_box_line();
1345 k_javadoc_box_line('You should have received a copy of the GNU Lesser General Public');
1346 k_javadoc_box_line('License along with ' sProg '; if not, write to the Free Software');
1347 k_javadoc_box_line('Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA');
1348 break;
1349
1350 case 'Confidential':
1351 k_javadoc_box_line('All Rights Reserved');
1352 break;
1353
1354 case 'VirtualBox':
1355 k_javadoc_box_line('This file is part of VirtualBox Open Source Edition (OSE), as')
1356 k_javadoc_box_line('available from http://www.virtualbox.org. This file is free software;')
1357 k_javadoc_box_line('you can redistribute it and/or modify it under the terms of the GNU')
1358 k_javadoc_box_line('General Public License as published by the Free Software Foundation,')
1359 k_javadoc_box_line('in version 2 as it comes in the "COPYING" file of the VirtualBox OSE')
1360 k_javadoc_box_line('distribution. VirtualBox OSE is distributed in the hope that it will')
1361 k_javadoc_box_line('be useful, but WITHOUT ANY WARRANTY of any kind.')
1362 break;
1363
1364 default:
1365
1366 }
1367 k_javadoc_box_line();
1368 k_javadoc_box_end();
1369
1370 up(p_RLine - iCursorLine);
1371 end_line();
1372 keyin(' ');
1373}
1374
1375
1376
1377
1378
1379
1380
1381/*******************************************************************************
1382* Keyboard Shortcuts *
1383*******************************************************************************/
1384/** Makes global box. */
1385void k_box_globals()
1386{
1387 k_box_start('Global');
1388 k_box_line('Global Variables');
1389 k_box_end();
1390}
1391
1392/** Makes header box. */
1393void k_box_headers()
1394{
1395 k_box_start("Header");
1396 k_box_line("Header Files");
1397 k_box_end();
1398}
1399
1400/** Makes internal function box. */
1401void k_box_intfuncs()
1402{
1403 k_box_start("IntFunc");
1404 k_box_line("Internal Functions");
1405 k_box_end();
1406}
1407
1408/** Makes def/const box. */
1409void k_box_consts()
1410{
1411 k_box_start("Const");
1412 k_box_line("Defined Constants And Macros");
1413 k_box_end();
1414}
1415
1416/** Structure box */
1417void k_box_structs()
1418{
1419 k_box_start("Struct");
1420 k_box_line("Structures and Typedefs");
1421 k_box_end();
1422}
1423
1424/** Makes exported symbols box. */
1425void k_box_exported()
1426{
1427 k_box_start('Exported');
1428 k_box_line('Exported Symbols');
1429 k_box_end();
1430}
1431
1432
1433
1434/** oneliner comment */
1435void k_oneliner()
1436{
1437 _str sLeft, sRight;
1438 int iColumn;
1439 if ( k_commentconfig(sLeft, sRight, iColumn)
1440 && iColumn > 0)
1441 { /* column based needs some tricky repositioning. */
1442 _end_line();
1443 if (p_col > iColumn)
1444 {
1445 _begin_line();
1446 _insert_text("\n\r");
1447 up();
1448 }
1449 }
1450 k_insert_comment("", KIC_CURSOR_AT_END, ikStyleOneliner);
1451}
1452
1453/** mark line as modified. */
1454void k_mark_modified_line()
1455{
1456 /* not supported for column based sources */
1457 _str sLeft, sRight;
1458 int iColumn;
1459 if ( !k_commentconfig(sLeft, sRight, iColumn)
1460 || iColumn > 0)
1461 return;
1462 _str sStr;
1463 if (skChange != '')
1464 sStr = skChange ' (' skUserInitials ')';
1465 else
1466 sStr = skUserInitials;
1467 k_insert_comment(sStr, KIC_CURSOR_BEFORE, ikStyleModifyMarkColumn);
1468 down();
1469}
1470
1471
1472/**
1473 * Inserts a signature. Form: "//Initials ISO-date:"
1474 * @remark defeventtab
1475 */
1476void k_signature()
1477{
1478 /* kso I5-10000 2002-09-10: */
1479 _str sSig;
1480 if (skChange != '')
1481 sSig = skUserInitials ' ' skChange ' ' k_date() ': ';
1482 else
1483 sSig = skUserInitials ' ' k_date() ': ';
1484 k_insert_comment(sSig, KIC_CURSOR_AT_END);
1485}
1486
1487
1488/*******************************************************************************
1489* kLIB Logging *
1490*******************************************************************************/
1491/**
1492 * Hot-Key: Inserts a KLOGENTRY statement at start of nearest function.
1493 */
1494void klib_klogentry()
1495{
1496 typeless org_pos;
1497 _save_pos2(org_pos);
1498
1499 /*
1500 * Go to nearest function.
1501 */
1502 if (!k_func_goto_nearest_function())
1503 {
1504 /*
1505 * Get parameters.
1506 */
1507 _str sParams = k_func_getparams();
1508 if (sParams)
1509 {
1510 _str sRetType = k_func_getreturntype(true);
1511 if (!sRetType || sRetType == "")
1512 sRetType = "void"; /* paranoia! */
1513
1514 /*
1515 * Insert text.
1516 */
1517 if (!k_func_searchcode("{"))
1518 {
1519 p_col++;
1520 int cArgs = k_func_countparams(sParams);
1521 if (cArgs > 0)
1522 {
1523 _str sArgs = "";
1524 int i;
1525 for (i = 0; i < cArgs; i++)
1526 {
1527 _str sType, sName, sDefault;
1528 if (!k_func_enumparams(sParams, i, sType, sName, sDefault))
1529 sArgs = sArgs', 'sName;
1530 }
1531
1532 _insert_text("\n KLOGENTRY"cArgs"(\""sRetType"\",\""sParams"\""sArgs");"); /* todo tab size.. or smart indent */
1533 }
1534 else
1535 _insert_text("\n KLOGENTRY0(\""sRetType"\");"); /* todo tab size.. or smart indent */
1536
1537 /*
1538 * Check if the next word is KLOGENTRY.
1539 */
1540 next_word();
1541 if (def_next_word_style == 'E')
1542 prev_word();
1543 int iIgnorePos = 0;
1544 if (substr(cur_word(iIgnorePos), 1, 9) == "KLOGENTRY")
1545 delete_line();
1546
1547 }
1548 else
1549 message("didn't find {");
1550 }
1551 else
1552 message("k_func_getparams failed, sParams=" sParams);
1553 return;
1554 }
1555
1556 _restore_pos2(org_pos);
1557}
1558
1559
1560/**
1561 * Hot-Key: Inserts a KLOGEXIT statement at cursor location.
1562 */
1563void klib_klogexit()
1564{
1565 typeless org_pos;
1566 _save_pos2(org_pos);
1567
1568 /*
1569 * Go to nearest function.
1570 */
1571 if (!prev_proc())
1572 {
1573 /*
1574 * Get parameters.
1575 */
1576 _str sType = k_func_getreturntype(true);
1577 _restore_pos2(org_pos);
1578 if (sType)
1579 {
1580 boolean fReturn = true; /* true if an return statment is following the KLOGEXIT statement. */
1581
1582 /*
1583 * Insert text.
1584 */
1585 int cur_col = p_col;
1586 if (sType == 'void' || sType == 'VOID')
1587 { /* procedure */
1588 int iIgnorePos;
1589 fReturn = cur_word(iIgnorePos) == 'return';
1590 if (!fReturn)
1591 {
1592 while (p_col <= p_SyntaxIndent)
1593 keyin(" ");
1594 }
1595
1596 _insert_text("KLOGEXITVOID();\n");
1597
1598 if (fReturn)
1599 {
1600 int i;
1601 for (i = 1; i < cur_col; i++)
1602 _insert_text(" ");
1603 }
1604 search(")","E-");
1605 }
1606 else
1607 { /* function */
1608 _insert_text("KLOGEXIT();\n");
1609 int i;
1610 for (i = 1; i < cur_col; i++)
1611 _insert_text(" ");
1612 search(")","E-");
1613
1614 /*
1615 * Insert value if possible.
1616 */
1617 typeless valuepos;
1618 _save_pos2(valuepos);
1619 next_word();
1620 if (def_next_word_style == 'E')
1621 prev_word();
1622 int iIgnorePos;
1623 if (cur_word(iIgnorePos) == 'return')
1624 {
1625 p_col += length('return');
1626 typeless posStart;
1627 _save_pos2(posStart);
1628 long offStart = _QROffset();
1629 if (!k_func_searchcode(";", "E+"))
1630 {
1631 long offEnd = _QROffset();
1632 _restore_pos2(posStart);
1633 _str sValue = strip(get_text((int)(offEnd - offStart)));
1634 //say 'sValue = 'sValue;
1635 _restore_pos2(valuepos);
1636 _save_pos2(valuepos);
1637 _insert_text(sValue);
1638 }
1639 }
1640 _restore_pos2(valuepos);
1641 }
1642
1643 /*
1644 * Remove old KLOGEXIT statement on previous line if any.
1645 */
1646 typeless valuepos;
1647 _save_pos2(valuepos);
1648 int newexitline = p_line;
1649 p_line--; p_col = 1;
1650 next_word();
1651 if (def_next_word_style == 'E')
1652 prev_word();
1653 int iIgnorePos;
1654 if (p_line == newexitline - 1 && substr(cur_word(iIgnorePos), 1, 8) == 'KLOGEXIT')
1655 delete_line();
1656 _restore_pos2(valuepos);
1657
1658 /*
1659 * Check for missing '{...}'.
1660 */
1661 if (fReturn)
1662 {
1663 boolean fFound = false;
1664 _save_pos2(valuepos);
1665 p_col--; find_matching_paren(); p_col += 2;
1666 k_func_searchcode(';', 'E+'); /* places us at the ';' of the return. (hopefully) */
1667
1668 _str ch = k_func_get_next_code_text();
1669 if (ch != '}')
1670 {
1671 _restore_pos2(valuepos);
1672 _save_pos2(valuepos);
1673 p_col--; find_matching_paren(); p_col += 2;
1674 k_func_searchcode(';', 'E+'); /* places us at the ';' of the return. (hopefully) */
1675 p_col++;
1676 if (k_func_more_code_on_line())
1677 _insert_text(' }');
1678 else
1679 {
1680 typeless returnget;
1681 _save_pos2(returnget);
1682 k_func_searchcode("return", "E-");
1683 int return_col = p_col;
1684 _restore_pos2(returnget);
1685
1686 end_line();
1687 _insert_text("\n");
1688 while (p_col < return_col - p_SyntaxIndent)
1689 _insert_text(' ');
1690 _insert_text('}');
1691 }
1692
1693 _restore_pos2(valuepos);
1694 _save_pos2(valuepos);
1695 prev_word();
1696 p_col -= p_SyntaxIndent;
1697 int codecol = p_col;
1698 _insert_text("{\n");
1699 while (p_col < codecol)
1700 _insert_text(' ');
1701 }
1702
1703 _restore_pos2(valuepos);
1704 }
1705 }
1706 else
1707 message("k_func_getreturntype failed, sType=" sType);
1708 return;
1709 }
1710
1711 _restore_pos2(org_pos);
1712}
1713
1714
1715/**
1716 * Processes a file - ask user all the time.
1717 */
1718void klib_klog_file_ask()
1719{
1720 klib_klog_file_int(true);
1721}
1722
1723
1724/**
1725 * Processes a file - no questions.
1726 */
1727void klib_klog_file_no_ask()
1728{
1729 klib_klog_file_int(false);
1730}
1731
1732
1733
1734/**
1735 * Processes a file.
1736 */
1737static void klib_klog_file_int(boolean fAsk)
1738{
1739 show_all();
1740 bottom();
1741 _refresh_scroll();
1742
1743 /* ask question so we can get to the right position somehow.. */
1744 if (fAsk && _message_box("kLog process this file?", "Visual SlickEdit", MB_YESNO | MB_ICONQUESTION) != IDYES)
1745 return;
1746
1747 /*
1748 * Entries.
1749 */
1750 while (!prev_proc())
1751 {
1752 //say 'entry main loop: ' k_func_getfunction_name();
1753
1754 /*
1755 * Skip prototypes.
1756 */
1757 if (k_func_prototype())
1758 continue;
1759
1760 /*
1761 * Ask user.
1762 */
1763 center_line();
1764 _refresh_scroll();
1765 _str sFunction = k_func_getfunction_name();
1766 rc = fAsk ? _message_box("Process this function ("sFunction")?", "Visual SlickEdit", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
1767 if (rc == IDYES)
1768 {
1769 typeless procpos;
1770 _save_pos2(procpos);
1771 klib_klogentry();
1772 _restore_pos2(procpos);
1773 }
1774 else if (rc == IDNO)
1775 continue;
1776 else
1777 break;
1778 }
1779
1780 /*
1781 * Exits.
1782 */
1783 bottom(); _refresh_scroll();
1784 boolean fUserCancel = false;
1785 while (!prev_proc() && !fUserCancel)
1786 {
1787 typeless procpos;
1788 _save_pos2(procpos);
1789 _str sCurFunction = k_func_getfunction_name();
1790 //say 'exit main loop: ' sCurFunction
1791
1792 /*
1793 * Skip prototypes.
1794 */
1795 if (k_func_prototype())
1796 continue;
1797
1798 /*
1799 * Select procedure.
1800 */
1801 while ( !k_func_searchcode("return", "WE<+")
1802 && k_func_getfunction_name() == sCurFunction)
1803 {
1804 //say 'exit sub loop: ' p_line
1805 /*
1806 * Ask User.
1807 */
1808 center_line();
1809 _refresh_scroll();
1810 _str sFunction = k_func_getfunction_name();
1811 rc = fAsk ? _message_box("Process this exit from "sFunction"?", "Visual SlickEdit", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
1812 deselect();
1813 if (rc == IDYES)
1814 {
1815 typeless returnpos;
1816 _save_pos2(returnpos);
1817 klib_klogexit();
1818 _restore_pos2(returnpos);
1819 p_line++;
1820 }
1821 else if (rc != IDNO)
1822 {
1823 fUserCancel = true;
1824 break;
1825 }
1826 p_line++; /* just so we won't hit it again. */
1827 }
1828
1829 /*
1830 * If void function we'll have to check if there is and return; prior to the ending '}'.
1831 */
1832 _restore_pos2(procpos);
1833 _save_pos2(procpos);
1834 _str sType = k_func_getreturntype(true);
1835 if (!fUserCancel && sType && (sType == 'void' || sType == 'VOID'))
1836 {
1837 if ( !k_func_searchcode("{", "E+")
1838 && !find_matching_paren())
1839 {
1840 typeless funcend;
1841 _save_pos2(funcend);
1842 prev_word();
1843 int iIgnorePos;
1844 if (cur_word(iIgnorePos) != "return")
1845 {
1846 /*
1847 * Ask User.
1848 */
1849 _restore_pos2(funcend);
1850 center_line();
1851 _refresh_scroll();
1852 _str sFunction = k_func_getfunction_name();
1853 rc = fAsk ? _message_box("Process this exit from "sFunction"?", "Visual SlickEdit", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
1854 deselect();
1855 if (rc == IDYES)
1856 {
1857 typeless returnpos;
1858 _save_pos2(returnpos);
1859 klib_klogexit();
1860 _restore_pos2(returnpos);
1861 }
1862 }
1863 }
1864 }
1865
1866 /*
1867 * Next proc.
1868 */
1869 _restore_pos2(procpos);
1870 }
1871}
1872
1873
1874/*******************************************************************************
1875* Odin32 backward compatibility *
1876*******************************************************************************/
1877_command void odin32_maketagfile()
1878{
1879 /* We'll */
1880 if (file_match('-p 'maybe_quote_filename(strip_filename(_project_name,'e'):+TAG_FILE_EXT),1) != "")
1881 {
1882 _project_update_files_retag(false,false,false,false);
1883 /*
1884 RetagFilesInTagFile2(project_tag_file, orig_view_id, temp_view_id, rebuild_all, false,
1885 doRemove,false,true,true);*/
1886 }
1887 else
1888 _project_update_files_retag(true,false,false,true);
1889}
1890
1891_command void odin32_setcurrentdir()
1892{
1893 //_ini_get_value(_project_name,"COMPILER","WORKINGDIR", workingdir);
1894 //cd(workingdir);
1895 /* Go the the directory containing the project filename */
1896 cd(strip_filename(_project_name, 'NE'));
1897}
1898
1899
1900
1901
1902/*******************************************************************************
1903* Styles *
1904*******************************************************************************/
1905static _str StyleLanguages[] =
1906{
1907 "c",
1908 "e",
1909 "java"
1910};
1911
1912struct StyleScheme
1913{
1914 _str name;
1915 _str settings[];
1916};
1917
1918static StyleScheme StyleSchemes[] =
1919{
1920 {
1921 "Opt2Ind4",
1922 {
1923 "orig_tabsize=4",
1924 "syntax_indent=4",
1925 "tabsize=4",
1926 "align_on_equal=1",
1927 "pad_condition_state=1",
1928 "indent_with_tabs=0",
1929 "nospace_before_paren=0",
1930 "indent_comments=1",
1931 "indent_case=1",
1932 "statement_comment_col=0",
1933 "disable_bestyle=0",
1934 "decl_comment_col=0",
1935 "bestyle_on_functions=0",
1936 "use_relative_indent=1",
1937 "nospace_before_brace=0",
1938 "indent_fl=1",
1939 "statement_comment_state=2",
1940 "indent_pp=1",
1941 "be_style=1",
1942 "parens_on_return=0",
1943 "eat_blank_lines=0",
1944 "brace_indent=0",
1945 "eat_pp_space=1",
1946 "align_on_parens=1",
1947 "continuation_indent=0",
1948 "cuddle_else=0",
1949 "nopad_condition=1",
1950 "pad_condition=0",
1951 "indent_col1_comments=0"
1952 }
1953 }
1954 ,
1955 {
1956 "Opt2Ind3",
1957 {
1958 "orig_tabsize=3",
1959 "syntax_indent=3",
1960 "tabsize=3",
1961 "align_on_equal=1",
1962 "pad_condition_state=1",
1963 "indent_with_tabs=0",
1964 "nospace_before_paren=0",
1965 "indent_comments=1",
1966 "indent_case=1",
1967 "statement_comment_col=0",
1968 "disable_bestyle=0",
1969 "decl_comment_col=0",
1970 "bestyle_on_functions=0",
1971 "use_relative_indent=1",
1972 "nospace_before_brace=0",
1973 "indent_fl=1",
1974 "statement_comment_state=2",
1975 "indent_pp=1",
1976 "be_style=1",
1977 "parens_on_return=0",
1978 "eat_blank_lines=0",
1979 "brace_indent=0",
1980 "eat_pp_space=1",
1981 "align_on_parens=1",
1982 "continuation_indent=0",
1983 "cuddle_else=0",
1984 "nopad_condition=1",
1985 "pad_condition=0",
1986 "indent_col1_comments=0"
1987 }
1988 }
1989 ,
1990 {
1991 "Opt2Ind8",
1992 {
1993 "orig_tabsize=8",
1994 "syntax_indent=8",
1995 "tabsize=8",
1996 "align_on_equal=1",
1997 "pad_condition_state=1",
1998 "indent_with_tabs=0",
1999 "nospace_before_paren=0",
2000 "indent_comments=1",
2001 "indent_case=1",
2002 "statement_comment_col=0",
2003 "disable_bestyle=0",
2004 "decl_comment_col=0",
2005 "bestyle_on_functions=0",
2006 "use_relative_indent=1",
2007 "nospace_before_brace=0",
2008 "indent_fl=1",
2009 "statement_comment_state=2",
2010 "indent_pp=1",
2011 "be_style=1",
2012 "parens_on_return=0",
2013 "eat_blank_lines=0",
2014 "brace_indent=0",
2015 "eat_pp_space=1",
2016 "align_on_parens=1",
2017 "continuation_indent=0",
2018 "cuddle_else=0",
2019 "nopad_condition=1",
2020 "pad_condition=0",
2021 "indent_col1_comments=0"
2022 }
2023 }
2024 ,
2025 {
2026 "Opt3Ind4",
2027 {
2028 "orig_tabsize=4",
2029 "syntax_indent=4",
2030 "tabsize=4",
2031 "align_on_equal=1",
2032 "pad_condition_state=1",
2033 "indent_with_tabs=0",
2034 "nospace_before_paren=0",
2035 "indent_comments=1",
2036 "indent_case=1",
2037 "statement_comment_col=0",
2038 "disable_bestyle=0",
2039 "decl_comment_col=0",
2040 "bestyle_on_functions=0",
2041 "use_relative_indent=1",
2042 "nospace_before_brace=0",
2043 "indent_fl=1",
2044 "statement_comment_state=2",
2045 "indent_pp=1",
2046 "be_style=2",
2047 "parens_on_return=0",
2048 "eat_blank_lines=0",
2049 "brace_indent=0",
2050 "eat_pp_space=1",
2051 "align_on_parens=1",
2052 "continuation_indent=0",
2053 "cuddle_else=0",
2054 "nopad_condition=1",
2055 "pad_condition=0",
2056 "indent_col1_comments=0"
2057 }
2058 }
2059 ,
2060 {
2061 "Opt3Ind3",
2062 {
2063 "orig_tabsize=3",
2064 "syntax_indent=3",
2065 "tabsize=3",
2066 "align_on_equal=1",
2067 "pad_condition_state=1",
2068 "indent_with_tabs=0",
2069 "nospace_before_paren=0",
2070 "indent_comments=1",
2071 "indent_case=1",
2072 "statement_comment_col=0",
2073 "disable_bestyle=0",
2074 "decl_comment_col=0",
2075 "bestyle_on_functions=0",
2076 "use_relative_indent=1",
2077 "nospace_before_brace=0",
2078 "indent_fl=1",
2079 "statement_comment_state=2",
2080 "indent_pp=1",
2081 "be_style=2",
2082 "parens_on_return=0",
2083 "eat_blank_lines=0",
2084 "brace_indent=0",
2085 "eat_pp_space=1",
2086 "align_on_parens=1",
2087 "continuation_indent=0",
2088 "cuddle_else=0",
2089 "nopad_condition=1",
2090 "pad_condition=0",
2091 "indent_col1_comments=0"
2092 }
2093 }
2094};
2095
2096
2097static void k_styles_create()
2098{
2099 /*
2100 * Find user format ini file.
2101 */
2102 _str userini = maybe_quote_filename(_config_path():+'uformat.ini');
2103 if (file_match('-p 'userini, 1) == '')
2104 {
2105 _str ini = maybe_quote_filename(slick_path_search('uformat.ini'));
2106 if (ini != '') userini = ini;
2107 }
2108
2109
2110 /*
2111 * Remove any old schemes.
2112 */
2113 int i,j,tv;
2114 for (i = 0; i < StyleSchemes._length(); i++)
2115 for (j = 0; j < StyleLanguages._length(); j++)
2116 {
2117 _str sectionname = StyleLanguages[j]:+'-scheme-':+StyleSchemes[i].name;
2118 if (!_ini_get_section(userini, sectionname, tv))
2119 {
2120 _ini_delete_section(userini, sectionname);
2121 _delete_temp_view(tv);
2122 //message("delete old scheme");
2123 }
2124 }
2125
2126 /*
2127 * Create the new schemes.
2128 */
2129 for (i = 0; i < StyleSchemes._length(); i++)
2130 {
2131 for (j = 0; j < StyleLanguages._length(); j++)
2132 {
2133 _str sectionname = StyleLanguages[j]:+'-scheme-':+StyleSchemes[i].name;
2134 int temp_view_id, k;
2135 _str orig_view_id = _create_temp_view(temp_view_id);
2136 activate_view(temp_view_id);
2137 for (k = 0; k < StyleSchemes[i].settings._length(); k++)
2138 insert_line(StyleSchemes[i].settings[k]);
2139
2140 /* Insert the scheme section. */
2141 _ini_replace_section(userini, sectionname, temp_view_id);
2142 //message(userini)
2143 //bogus id - activate_view(orig_view_id);
2144 }
2145 }
2146
2147 //last_scheme = last scheme name!!!
2148}
2149
2150
2151/*
2152 * Sets the last used beutify scheme.
2153 */
2154static k_styles_set(_str scheme)
2155{
2156
2157 /*
2158 * Find user format ini file.
2159 */
2160 _str userini = maybe_quote_filename(_config_path():+'uformat.ini');
2161 if (file_match('-p 'userini, 1) == '')
2162 {
2163 _str ini = maybe_quote_filename(slick_path_search('uformat.ini'));
2164 if (ini != '') userini = ini;
2165 }
2166
2167 /*
2168 * Set the scheme for each language.
2169 */
2170 int j;
2171 for (j = 0; j < StyleLanguages._length(); j++)
2172 {
2173 _ini_set_value(userini,
2174 StyleLanguages[j]:+'-scheme-Default',
2175 'last_scheme',
2176 scheme);
2177 }
2178}
2179
2180
2181static _str defoptions[] =
2182{
2183 "def-options-sas",
2184 "def-options-js",
2185 "def-options-bat",
2186 "def-options-c",
2187 "def-options-pas",
2188 "def-options-e",
2189 "def-options-java",
2190 "def-options-bourneshell",
2191 "def-options-csh",
2192 "def-options-vlx",
2193 "def-options-plsql",
2194 "def-options-sqlserver",
2195 "def-options-cmd"
2196};
2197
2198static _str defsetups[] =
2199{
2200 "def-setup-sas",
2201 "def-setup-js",
2202 "def-setup-bat",
2203 "def-setup-fundamental",
2204 "def-setup-process",
2205 "def-setup-c",
2206 "def-setup-pas",
2207 "def-setup-e",
2208 "def-setup-asm",
2209 "def-setup-java",
2210 "def-setup-html",
2211 "def-setup-bourneshell",
2212 "def-setup-csh",
2213 "def-setup-vlx",
2214 "def-setup-fileman",
2215 "def-setup-plsql",
2216 "def-setup-sqlserver",
2217 "def-setup-s",
2218 "def-setup-cmd"
2219};
2220
2221static _str defsetupstab8[] =
2222{
2223 "def-setup-c"
2224};
2225
2226
2227static void k_styles_setindent(int indent, int iBraceStyle, boolean iWithTabs = false)
2228{
2229 if (iBraceStyle < 1 || iBraceStyle > 3)
2230 {
2231 message('k_styles_setindent: iBraceStyle is bad (=' :+ iBraceStyle :+ ')');
2232 iBraceStyle = 2;
2233 }
2234
2235 /*
2236 * def-options for extentions known to have that info.
2237 */
2238 int i;
2239 for (i = 0; i < defoptions._length(); i++)
2240 {
2241 int idx = find_index(defoptions[i], MISC_TYPE);
2242 if (!idx)
2243 continue;
2244
2245 parse name_info(idx) with syntax_indent o2 o3 o4 flags indent_fl o7 indent_case rest;
2246
2247 /* Begin/end style */
2248 flags = flags & ~(1|2);
2249 flags = flags | (iBraceStyle - 1); /* Set style (0-based) */
2250 flags = flags & ~(16); /* no scape before parent.*/
2251 indent_fl = 1; /* Indent first level */
2252 indent_case = 1; /* Indent case from switch */
2253
2254 sNewOptions = indent' 'o2' 'o3' 'o4' 'flags' 'indent_fl' 'o7' 'indent_case' 'rest;
2255 set_name_info(idx, sNewOptions);
2256 _config_modify |= CFGMODIFY_DEFDATA;
2257 }
2258
2259 /*
2260 * def-setup for known extentions.
2261 */
2262 for (i = 0; i < defsetups._length(); i++)
2263 {
2264 idx = find_index(defsetups[i], MISC_TYPE);
2265 if (!idx)
2266 continue;
2267 sExt = substr(defsetups[i], length('def-setup-') + 1);
2268 sSetup = name_info(idx);
2269
2270 /*
2271 parse sSetup with 'MN=' mode_name ','\
2272 'TABS=' tabs ',' 'MA=' margins ',' 'KEYTAB=' keytab_name ','\
2273 'WW='word_wrap_style ',' 'IWT='indent_with_tabs ','\
2274 'ST='show_tabs ',' 'IN='indent_style ','\
2275 'WC='word_chars',' 'LN='lexer_name',' 'CF='color_flags','\
2276 'LNL='line_numbers_len','rest;
2277
2278 indent_with_tabs = 0; /* Indent with tabs */
2279
2280 /* Make sure all the values are legal */
2281 _ext_init_values(ext, lexer_name, color_flags);
2282 if (!isinteger(line_numbers_len)) line_numbers_len = 0;
2283 if (word_chars == '') word_chars = 'A-Za-z0-9_$';
2284 if (word_wrap_style == '') word_wrap_style = 3;
2285 if (show_tabs == '') show_tabs = 0;
2286 if (indent_style == '') indent_style = INDENT_SMART;
2287
2288 /* Set new indent */
2289 tabs = '+'indent;
2290 */
2291
2292 sNewSetup = sSetup;
2293
2294 /* Set new indent */
2295 if (pos('TABS=', sNewSetup) > 0)
2296 {
2297 /*
2298 * If either in defoptions or defsetupstab8 use default tab of 8
2299 * For those supporting separate syntax indent using the normal tabsize
2300 * helps us a lot when reading it...
2301 */
2302 fTab8 = false;
2303 for (j = 0; !fTab8 && j < defsetupstab8._length(); j++)
2304 if (substr(defsetupstab8[j], lastpos('-', defsetupstab8[j]) + 1) == sExt)
2305 fTab8 = true;
2306 for (j = 0; !fTab8 && j < defoptions._length(); j++)
2307 if (substr(defoptions[j], lastpos('-', defoptions[j]) + 1) == sExt)
2308 fTab8 = true;
2309
2310 parse sNewSetup with sPre 'TABS=' sValue ',' sPost;
2311 if (fTab8)
2312 sNewSetup = sPre 'TABS=+8,' sPost
2313 else
2314 sNewSetup = sPre 'TABS=+' indent ',' sPost
2315 }
2316
2317 /* Set indent with tabs flag. */
2318 if (pos('IWT=', sNewSetup) > 0)
2319 {
2320 parse sNewSetup with sPre 'IWT=' sValue ',' sPost;
2321 if (iWithTabs)
2322 sNewSetup = sPre 'IWT=1,' sPost
2323 else
2324 sNewSetup = sPre 'IWT=0,' sPost
2325 }
2326
2327 /* Do the real changes */
2328 set_name_info(idx, sNewSetup);
2329 _config_modify |= CFGMODIFY_DEFDATA;
2330 _update_buffers(sExt);
2331 }
2332}
2333
2334
2335/**
2336 * Takes necessary steps to convert a string to integer.
2337 */
2338static int k_style_emacs_var_integer(_str sVal)
2339{
2340 int i = (int)sVal;
2341 //say 'k_style_emacs_var_integer('sVal') -> 'i;
2342 return (int)sVal;
2343}
2344
2345
2346/**
2347 * Sets a Emacs style variable.
2348 */
2349static int k_style_emacs_var(_str sVar, _str sVal)
2350{
2351 /* check input. */
2352 if (sVar == '' || sVal == '')
2353 return -1;
2354 //say 'k_style_emacs_var: 'sVar'='sVal;
2355
2356 /*
2357 * Unpack the mode style parameters.
2358 */
2359 _str sStyle = name_info(_edit_window().p_index);
2360 _str sStyleName = p_mode_name;
2361 typeless iIndentAmount, fExpansion, iMinAbbrivation, fIndentAfterOpenParen, iBeginEndStyle, fIndent1stLevel, iMainStyle, iSwitchStyle,
2362 sRest, sRes0, sRes1;
2363 if (sStyleName == 'Slick-C')
2364 {
2365 parse sStyle with iMinAbbrivation sRes0 iBeginEndStyle fIndent1stLevel sRes1 iSwitchStyle sRest;
2366 iIndentAmount = p_SyntaxIndent;
2367 }
2368 else /* C */
2369 parse sStyle with iIndentAmount fExpansion iMinAbbrivation fIndentAfterOpenParen iBeginEndStyle fIndent1stLevel iMainStyle iSwitchStyle sRest;
2370
2371
2372 /*
2373 * Process the variable.
2374 */
2375 switch (sVar)
2376 {
2377 case 'mode':
2378 case 'Mode':
2379 {
2380 switch (sVal)
2381 {
2382 case 'c':
2383 case 'C':
2384 case 'c++':
2385 case 'C++':
2386 case 'cpp':
2387 case 'CPP':
2388 case 'cxx':
2389 case 'CXX':
2390 p_extension = 'c';
2391 p_mode_name = 'C';
2392 break;
2393
2394 case 'e':
2395 case 'slick-c':
2396 case 'Slick-c':
2397 case 'Slick-C':
2398 p_extension = 'e';
2399 p_mode_name = 'Slick-C';
2400 break;
2401
2402 default:
2403 message('emacs mode "'sVal'" is not known to us');
2404 return -3;
2405 }
2406 break;
2407 }
2408/* relevant emacs code:
2409(defconst c-style-alist
2410 '(("gnu"
2411 (c-basic-offset . 2)
2412 (c-comment-only-line-offset . (0 . 0))
2413 (c-offsets-alist . ((statement-block-intro . +)
2414 (knr-argdecl-intro . 5)
2415 (substatement-open . +)
2416 (label . 0)
2417 (statement-case-open . +)
2418 (statement-cont . +)
2419 (arglist-intro . c-lineup-arglist-intro-after-paren)
2420 (arglist-close . c-lineup-arglist)
2421 (inline-open . 0)
2422 (brace-list-open . +)
2423 ))
2424 (c-special-indent-hook . c-gnu-impose-minimum)
2425 (c-block-comment-prefix . "")
2426 )
2427 ("k&r"
2428 (c-basic-offset . 5)
2429 (c-comment-only-line-offset . 0)
2430 (c-offsets-alist . ((statement-block-intro . +)
2431 (knr-argdecl-intro . 0)
2432 (substatement-open . 0)
2433 (label . 0)
2434 (statement-cont . +)
2435 ))
2436 )
2437 ("bsd"
2438 (c-basic-offset . 8)
2439 (c-comment-only-line-offset . 0)
2440 (c-offsets-alist . ((statement-block-intro . +)
2441 (knr-argdecl-intro . +)
2442 (substatement-open . 0)
2443 (label . 0)
2444 (statement-cont . +)
2445 (inline-open . 0)
2446 (inexpr-class . 0)
2447 ))
2448 )
2449 ("stroustrup"
2450 (c-basic-offset . 4)
2451 (c-comment-only-line-offset . 0)
2452 (c-offsets-alist . ((statement-block-intro . +)
2453 (substatement-open . 0)
2454 (label . 0)
2455 (statement-cont . +)
2456 ))
2457 )
2458 ("whitesmith"
2459 (c-basic-offset . 4)
2460 (c-comment-only-line-offset . 0)
2461 (c-offsets-alist . ((knr-argdecl-intro . +)
2462 (label . 0)
2463 (statement-cont . +)
2464 (substatement-open . +)
2465 (block-open . +)
2466 (statement-block-intro . c-lineup-whitesmith-in-block)
2467 (block-close . c-lineup-whitesmith-in-block)
2468 (inline-open . +)
2469 (defun-open . +)
2470 (defun-block-intro . c-lineup-whitesmith-in-block)
2471 (defun-close . c-lineup-whitesmith-in-block)
2472 (brace-list-open . +)
2473 (brace-list-intro . c-lineup-whitesmith-in-block)
2474 (brace-entry-open . c-indent-multi-line-block)
2475 (brace-list-close . c-lineup-whitesmith-in-block)
2476 (class-open . +)
2477 (inclass . c-lineup-whitesmith-in-block)
2478 (class-close . +)
2479 (inexpr-class . 0)
2480 (extern-lang-open . +)
2481 (inextern-lang . c-lineup-whitesmith-in-block)
2482 (extern-lang-close . +)
2483 (namespace-open . +)
2484 (innamespace . c-lineup-whitesmith-in-block)
2485 (namespace-close . +)
2486 ))
2487 )
2488 ("ellemtel"
2489 (c-basic-offset . 3)
2490 (c-comment-only-line-offset . 0)
2491 (c-hanging-braces-alist . ((substatement-open before after)))
2492 (c-offsets-alist . ((topmost-intro . 0)
2493 (topmost-intro-cont . 0)
2494 (substatement . +)
2495 (substatement-open . 0)
2496 (case-label . +)
2497 (access-label . -)
2498 (inclass . ++)
2499 (inline-open . 0)
2500 ))
2501 )
2502 ("linux"
2503 (c-basic-offset . 8)
2504 (c-comment-only-line-offset . 0)
2505 (c-hanging-braces-alist . ((brace-list-open)
2506 (brace-entry-open)
2507 (substatement-open after)
2508 (block-close . c-snug-do-while)))
2509 (c-cleanup-list . (brace-else-brace))
2510 (c-offsets-alist . ((statement-block-intro . +)
2511 (knr-argdecl-intro . 0)
2512 (substatement-open . 0)
2513 (label . 0)
2514 (statement-cont . +)
2515 ))
2516 )
2517 ("python"
2518 (indent-tabs-mode . t)
2519 (fill-column . 78)
2520 (c-basic-offset . 8)
2521 (c-offsets-alist . ((substatement-open . 0)
2522 (inextern-lang . 0)
2523 (arglist-intro . +)
2524 (knr-argdecl-intro . +)
2525 ))
2526 (c-hanging-braces-alist . ((brace-list-open)
2527 (brace-list-intro)
2528 (brace-list-close)
2529 (brace-entry-open)
2530 (substatement-open after)
2531 (block-close . c-snug-do-while)
2532 ))
2533 (c-block-comment-prefix . "")
2534 )
2535 ("java"
2536 (c-basic-offset . 4)
2537 (c-comment-only-line-offset . (0 . 0))
2538 ;; the following preserves Javadoc starter lines
2539 (c-offsets-alist . ((inline-open . 0)
2540 (topmost-intro-cont . +)
2541 (statement-block-intro . +)
2542 (knr-argdecl-intro . 5)
2543 (substatement-open . +)
2544 (label . +)
2545 (statement-case-open . +)
2546 (statement-cont . +)
2547 (arglist-intro . c-lineup-arglist-intro-after-paren)
2548 (arglist-close . c-lineup-arglist)
2549 (access-label . 0)
2550 (inher-cont . c-lineup-java-inher)
2551 (func-decl-cont . c-lineup-java-throws)
2552 ))
2553 )
2554 )
2555*/
2556
2557 case 'c-file-style':
2558 case 'c-indentation-style':
2559 switch (sVal)
2560 {
2561 case 'bsd':
2562 case '"bsd"':
2563 case 'BSD':
2564 iBeginEndStyle = 1 | (iBeginEndStyle & ~3);
2565 p_indent_with_tabs = true;
2566 iIndentAmount = 8;
2567 p_SyntaxIndent = 8;
2568 p_tabs = "+8";
2569 //say 'bsd';
2570 break;
2571
2572 case 'k&r':
2573 case '"k&r"':
2574 case 'K&R':
2575 iBeginEndStyle = 0 | (iBeginEndStyle & ~3);
2576 p_indent_with_tabs = false;
2577 iIndentAmount = 4;
2578 p_SyntaxIndent = 4;
2579 p_tabs = "+4";
2580 //say 'k&r';
2581 break;
2582
2583 case 'linux-c':
2584 case '"linux-c"':
2585 iBeginEndStyle = 0 | (iBeginEndStyle & ~3);
2586 p_indent_with_tabs = true;
2587 iIndentAmount = 4;
2588 p_SyntaxIndent = 4;
2589 p_tabs = "+4";
2590 //say 'linux-c';
2591 break;
2592
2593 case 'yet-to-be-found':
2594 iBeginEndStyle = 2 | (iBeginEndStyle & ~3);
2595 p_indent_with_tabs = false;
2596 iIndentAmount = 4;
2597 p_SyntaxIndent = 4;
2598 p_tabs = "+4";
2599 //say 'todo';
2600 break;
2601
2602 default:
2603 message('emacs "'sVar'" value "'sVal'" is not known to us.');
2604 return -3;
2605 }
2606 break;
2607
2608 case 'c-label-offset':
2609 {
2610 int i = k_style_emacs_var_integer(sVal);
2611 if (i >= -16 && i <= 16)
2612 {
2613 if (i == -p_SyntaxIndent)
2614 iSwitchStyle = 0;
2615 else
2616 iSwitchStyle = 1;
2617 }
2618 break;
2619 }
2620
2621
2622 case 'indent-tabs-mode':
2623 p_indent_with_tabs = sVal == 't';
2624 break;
2625
2626 case 'c-indent-level':
2627 case 'c-basic-offset':
2628 {
2629 int i = k_style_emacs_var_integer(sVal);
2630 if (i > 0 && i <= 16)
2631 {
2632 iIndentAmount = i;
2633 p_SyntaxIndent = i;
2634 }
2635 else
2636 {
2637 message('emacs "'sVar'" value "'sVal'" is out of range.');
2638 return -4;
2639 }
2640 break;
2641 }
2642
2643 case 'tab-width':
2644 {
2645 int i = k_style_emacs_var_integer(sVal);
2646 if (i > 0 && i <= 16)
2647 p_tabs = '+'i;
2648 else
2649 {
2650 message('emacs "'sVar'" value "'sVal'" is out of range.');
2651 return -4;
2652 }
2653 break;
2654 }
2655
2656 case 'nuke-trailing-whitespace-p':
2657 {
2658 _str sName = 'def-koptions-'p_buf_id;
2659 int idx = insert_name(sName, MISC_TYPE, "kstyledoc");
2660 if (!idx)
2661 idx = find_index(sName, MISC_TYPE);
2662 if (idx)
2663 {
2664 if (sVal == 't')
2665 set_name_info(idx, "saveoptions: +S");
2666 else
2667 set_name_info(idx, "saveoptions: -S");
2668 say 'sVal=' sVal;
2669 }
2670 break;
2671 }
2672
2673 default:
2674 message('emacs variable "'sVar'" (value "'sVal'") is unknown to us.');
2675 return -5;
2676 }
2677
2678 /*
2679 * Update the style?
2680 */
2681 _str sNewStyle = "";
2682 if (sStyleName == 'Slick-C')
2683 sNewStyle = iMinAbbrivation' 'sRes0' 'iBeginEndStyle' 'fIndent1stLevel' 'sRes1' 'iSwitchStyle' 'sRest;
2684 else
2685 sNewStyle = iIndentAmount' 'fExpansion' 'iMinAbbrivation' 'fIndentAfterOpenParen' 'iBeginEndStyle' 'fIndent1stLevel' 'iMainStyle' 'iSwitchStyle' 'sRest;
2686 if ( sNewStyle != ""
2687 && sNewStyle != sStyle
2688 && sStyleName == p_mode_name)
2689 {
2690 _str sName = name_name(_edit_window().p_index)
2691 //say ' sStyle='sStyle' p_mode_name='p_mode_name;
2692 //say 'sNewStyle='sNewStyle' sName='sName;
2693 if (pos('kstyledoc-', sName) <= 0)
2694 {
2695 sName = 'def-kstyledoc-'p_buf_id;
2696 int idx = insert_name(sName, MISC_TYPE, "kstyledoc");
2697 if (!idx)
2698 idx = find_index(sName, MISC_TYPE);
2699 if (idx)
2700 {
2701 if (!set_name_info(idx, sNewStyle))
2702 _edit_window().p_index = idx;
2703 }
2704 //say sName'='idx;
2705 }
2706 else
2707 set_name_info(_edit_window().p_index, sNewStyle);
2708 }
2709
2710 return 0;
2711}
2712
2713
2714/**
2715 * Parses a string with emacs variables.
2716 *
2717 * The variables are separated by new line. Junk at
2718 * the start and end of the line is ignored.
2719 */
2720static int k_style_emac_vars(_str sVars)
2721{
2722 /* process them line by line */
2723 int iLine = 0;
2724 while (sVars != '' && iLine++ < 20)
2725 {
2726 int iNext, iEnd;
2727 iEnd = iNext = pos("\n", sVars);
2728 if (iEnd <= 0)
2729 iEnd = iNext = length(sVars);
2730 else
2731 iEnd--;
2732 iNext++;
2733
2734 sLine = strip(substr(sVars, 1, iEnd), 'B', " \t\n\r");
2735 sVars = strip(substr(sVars, iNext), 'L', " \t\n\r");
2736 //say 'iLine='iLine' sVars='sVars'<eol>';
2737 //say 'iLine='iLine' sLine='sLine'<eol>';
2738 if (sLine != '')
2739 {
2740 rc = pos('[^a-zA-Z0-9-_]*([a-zA-Z0-9-_]+)[ \t]*:[ \t]*([^ \t]*)', sLine, 1, 'U');
2741 //say '0={'pos('S0')','pos('0')',"'substr(sLine,pos('S0'),pos('0'))'"'
2742 //say '1={'pos('S1')','pos('1')',"'substr(sLine,pos('S1'),pos('1'))'"'
2743 //say '2={'pos('S2')','pos('2')',"'substr(sLine,pos('S2'),pos('2'))'"'
2744 //say '3={'pos('S3')','pos('3')',"'substr(sLine,pos('S3'),pos('3'))'"'
2745 //say '4={'pos('S4')','pos('4')',"'substr(sLine,pos('S4'),pos('4'))'"'
2746 if (rc > 0)
2747 k_style_emacs_var(substr(sLine,pos('S1'),pos('1')),
2748 substr(sLine,pos('S2'),pos('2')));
2749 }
2750 }
2751 return 0;
2752}
2753
2754/**
2755 * Searches for Emacs style specification for the current document.
2756 */
2757void k_style_load()
2758{
2759 /* save the position before we start looking around the file. */
2760 typeless saved_pos;
2761 _save_pos2(saved_pos);
2762
2763 int rc;
2764
2765 /* Check first line. */
2766 top_of_buffer();
2767 _str sLine;
2768 get_line(sLine);
2769 strip(sLine);
2770 if (pos('-*-[ \t]+(.*:.*)[ \t]+-*-', sLine, 1, 'U'))
2771 {
2772 _str sVars;
2773 sVars = substr(sLine, pos('S1'), pos('1'));
2774 sVars = translate(sVars, "\n", ";");
2775 k_style_emac_vars(sVars);
2776 }
2777
2778 /* Look for the "Local Variables:" stuff from the end of the file. */
2779 bottom_of_buffer();
2780 rc = search('Local Variables:[ \t]*\n\om(.*)\ol\n.*End:.*\n', '-EU');
2781 if (!rc)
2782 {
2783 /* copy the variables out to a buffer. */
2784 _str sVars;
2785 sVars = get_text(match_length("1"), match_length("S1"));
2786 k_style_emac_vars(sVars);
2787 }
2788
2789 _restore_pos2(saved_pos);
2790}
2791
2792
2793/**
2794 * Callback function for the event of a new buffer.
2795 *
2796 * This is used to make sure there are no left over per buffer options
2797 * hanging around.
2798 */
2799void _buffer_add_kdev(int buf_id)
2800{
2801 _str sName = 'def-koptions-'buf_id;
2802 int idx = insert_name(sName, MISC_TYPE, "kstyledoc");
2803 if (!idx)
2804 idx = find_index(sName, MISC_TYPE);
2805 if (idx)
2806 set_name_info(idx, "");
2807 //message("_buffer_add_kdev: " idx);
2808}
2809
2810
2811/**
2812 * Callback function for the event of quitting a buffer.
2813 *
2814 * This is used to make sure there are no left over per buffer options
2815 * hanging around.
2816 */
2817void _cbquit2_kdev(int buf_id)
2818{
2819 _str sName = 'def-koptions-'buf_id;
2820 int idx = find_index(sName, MISC_TYPE);
2821 if (idx)
2822 delete_name(idx);
2823 //message("_cbquit2_kdev: " idx " " sName);
2824
2825 sName = 'def-kstyledoc-'buf_id;
2826 idx = find_index(sName, MISC_TYPE);
2827 if (idx)
2828 delete_name(idx);
2829}
2830
2831
2832/**
2833 * Called to get save options for the current buffer.
2834 *
2835 * This requires a modified loadsave.e!
2836 */
2837_str _buffer_save_kdev(int buf_id)
2838{
2839 _str sRet = ""
2840 _str sName = 'def-koptions-'buf_id;
2841 int idx = find_index(sName, MISC_TYPE);
2842 if (idx)
2843 {
2844 _str sOptions = strip(name_info(idx));
2845 if (sOptions != "")
2846 parse sOptions with . "saveoptions:" sRet .
2847 message("_buffer_save_kdev: " idx " " sName " " sOptions);
2848 }
2849 return sRet;
2850}
2851
2852
2853
2854/*******************************************************************************
2855* Menu and Menu commands *
2856*******************************************************************************/
2857static int iTimer = 0;
2858static int mhkDev = 0;
2859static int mhCode = 0;
2860static int mhDoc = 0;
2861static int mhLic = 0;
2862static int mhPre = 0;
2863
2864/*
2865 * Creates the kDev menu.
2866 */
2867static k_menu_create()
2868{
2869 if (arg(1) == 'timer')
2870 _kill_timer(iTimer);
2871 menu_handle = _mdi.p_menu_handle;
2872 menu_index = find_index(_cur_mdi_menu,oi2type(OI_MENU));
2873
2874 /*
2875 * Remove any old menu.
2876 */
2877 mhDelete = iPos = 0;
2878 index = _menu_find(menu_handle, "kDev", mhDelete, iPos, 'C');
2879 //message("index="index " mhDelete="mhDelete " iPos="iPos);
2880 if (index == 0)
2881 _menu_delete(mhDelete, iPos);
2882
2883
2884 /*
2885 * Insert the "kDev" menu.
2886 */
2887 mhkDev = _menu_insert(menu_handle, 9, MF_SUBMENU, "&kDev", "", "kDev");
2888 mhCode=_menu_insert(mhkDev, -1, MF_ENABLED | MF_SUBMENU, "Coding &Style", "", "coding");
2889 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 2, Syntax Indent 4 (knut)", "k_menu_style Opt2Ind4", "Opt2Ind4");
2890 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 2, Syntax Indent 3", "k_menu_style Opt2Ind3", "Opt2Ind3");
2891 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 2, Syntax Indent 8", "k_menu_style Opt2Ind8", "Opt2Ind8");
2892 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 3, Syntax Indent 4 (giws)", "k_menu_style Opt3Ind4", "Opt3Ind4");
2893 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 3, Syntax Indent 3 (giws)", "k_menu_style Opt3Ind3", "Opt3Ind3");
2894
2895 mhDoc= _menu_insert(mhkDev, -1, MF_ENABLED | MF_SUBMENU, "&Documentation", "", "doc");
2896 mhDSJ= _menu_insert(mhDoc, -1, MF_ENABLED | MF_UNCHECKED, "&Javadoc Style", "k_menu_doc_style javadoc", "javadoc");
2897 mhDSL= _menu_insert(mhDoc, -1, MF_GRAYED | MF_UNCHECKED, "&Linux Kernel Style", "k_menu_doc_style linux", "linux");
2898
2899 mhLic= _menu_insert(mhkDev, -1, MF_ENABLED | MF_SUBMENU, "&License", "", "License");
2900 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&Odin32", "k_menu_license Odin32", "Odin32");
2901 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&GPL", "k_menu_license GPL", "GPL");
2902 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&LGPL", "k_menu_license LGPL", "LGPL");
2903 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&VirtualBox", "k_menu_license VirtualBox", "VirtualBox");
2904 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&Confidential", "k_menu_license Confidential", "Confidential");
2905
2906 rc = _menu_insert(mhkDev, -1, MF_ENABLED, "-", "", "dash vars");
2907 rc = _menu_insert(mhkDev, -1, MF_ENABLED, skChange == '' ? '&Change...' : '&Change (' skChange ')...', "k_menu_change", "");
2908 rc = _menu_insert(mhkDev, -1, MF_ENABLED, skProgram == '' ? '&Program...' : '&Program (' skProgram ')...', "k_menu_program", "");
2909 rc = _menu_insert(mhkDev, -1, MF_ENABLED, skCompany == '' ? 'Co&mpany...' : 'Co&mpany (' skCompany ')...', "k_menu_company", "");
2910 rc = _menu_insert(mhkDev, -1, MF_ENABLED, '&User Name (' skUserName ')...', "k_menu_user_name", "username");
2911 rc = _menu_insert(mhkDev, -1, MF_ENABLED, 'User &e-mail (' skUserEmail ')...', "k_menu_user_email", "useremail");
2912 rc = _menu_insert(mhkDev, -1, MF_ENABLED, 'User &Initials (' skUserInitials ')...', "k_menu_user_initials", "userinitials");
2913 rc = _menu_insert(mhkDev, -1, MF_ENABLED, "-", "", "dash preset");
2914 mhPre= _menu_insert(mhkDev, -1, MF_SUBMENU, "P&resets", "", "");
2915 rc = _menu_insert(mhPre, -1, MF_ENABLED, "Odin32", "k_menu_preset javadoc, Odin32, Opt2Ind4,,Odin32", "odin32");
2916 rc = _menu_insert(mhPre, -1, MF_ENABLED, "Linux Kernel","k_menu_preset linux, GPL, Opt1Ind4,,Linux", "linux");
2917 rc = _menu_insert(mhPre, -1, MF_ENABLED, "The Bird", "k_menu_preset javadoc, GPL, Opt2Ind4", "bird");
2918 rc = _menu_insert(mhPre, -1, MF_ENABLED, "kLIBC", "k_menu_preset javadoc, GPL, Opt2Ind4,, kLIBC", "kLIBC");
2919 rc = _menu_insert(mhPre, -1, MF_ENABLED, "kBuild", "k_menu_preset javadoc, GPL, Opt2Ind4,, kBuild", "kBuild");
2920 rc = _menu_insert(mhPre, -1, MF_ENABLED, "InnoTek", "k_menu_preset javadoc, Confidential, Opt2Ind4, InnoTek Systemberatung GmbH", "InnoTek");
2921 rc = _menu_insert(mhPre, -1, MF_ENABLED, "VirtualBox", "k_menu_preset javadoc, VirtualBox, Opt2Ind4, InnoTek Systemberatung GmbH", "InnoTek");
2922
2923 k_menu_doc_style();
2924 k_menu_license();
2925 k_menu_style();
2926}
2927
2928
2929/**
2930 * Change change Id.
2931 */
2932_command k_menu_change()
2933{
2934 sRc = show("-modal k_form_simple_input", "Change ID", skChange);
2935 if (sRc != "\r")
2936 {
2937 skChange = sRc;
2938 k_menu_create();
2939 }
2940}
2941
2942
2943/**
2944 * Change program name.
2945 */
2946_command k_menu_program()
2947{
2948 sRc = show("-modal k_form_simple_input", "Program", skProgram);
2949 if (sRc != "\r")
2950 {
2951 skProgram = sRc;
2952 k_menu_create();
2953 }
2954}
2955
2956
2957/**
2958 * Change company.
2959 */
2960_command k_menu_company()
2961{
2962 if (skCompany == '')
2963 sRc = show("-modal k_form_simple_input", "Company", 'InnoTek Systemberatung GmbH');
2964 else
2965 sRc = show("-modal k_form_simple_input", "Company", skCompany);
2966 if (sRc != "\r")
2967 {
2968 skCompany = sRc;
2969 k_menu_create();
2970 }
2971}
2972
2973
2974/**
2975 * Change user name.
2976 */
2977_command k_menu_user_name()
2978{
2979 sRc = show("-modal k_form_simple_input", "User Name", skUserName);
2980 if (sRc != "\r" && sRc != '')
2981 {
2982 skUserName = sRc;
2983 k_menu_create();
2984 }
2985}
2986
2987
2988/**
2989 * Change user email.
2990 */
2991_command k_menu_user_email()
2992{
2993 sRc = show("-modal k_form_simple_input", "User e-mail", skUserEmail);
2994 if (sRc != "\r" && sRc != '')
2995 {
2996 skUserEmail = sRc;
2997 k_menu_create();
2998 }
2999}
3000
3001
3002/**
3003 * Change user initials.
3004 */
3005_command k_menu_user_initials()
3006{
3007 sRc = show("-modal k_form_simple_input", "User e-mail", skUserInitials);
3008 if (sRc != "\r" && sRc != '')
3009 {
3010 skUserInitials = sRc;
3011 k_menu_create();
3012 }
3013}
3014
3015
3016
3017/**
3018 * Checks the correct menu item.
3019 */
3020_command void k_menu_doc_style(_str sNewDocStyle = '')
3021{
3022 //say 'sNewDocStyle='sNewDocStyle;
3023 if (sNewDocStyle != '')
3024 skDocStyle = sNewDocStyle
3025 _menu_set_state(mhDoc, "javadoc", MF_UNCHECKED);
3026 _menu_set_state(mhDoc, "linux", MF_UNCHECKED | MF_GRAYED);
3027 _menu_set_state(mhDoc, skDocStyle, MF_CHECKED);
3028}
3029
3030
3031/**
3032 * Checks the correct menu item.
3033 */
3034_command void k_menu_license(_str sNewLicense = '')
3035{
3036 //say 'sNewLicense='sNewLicense;
3037 if (sNewLicense != '')
3038 skLicense = sNewLicense
3039 _menu_set_state(mhLic, "Odin32", MF_UNCHECKED);
3040 _menu_set_state(mhLic, "GPL", MF_UNCHECKED);
3041 _menu_set_state(mhLic, "LGPL", MF_UNCHECKED);
3042 _menu_set_state(mhLic, "Confidential", MF_UNCHECKED);
3043 _menu_set_state(mhLic, skLicense, MF_CHECKED);
3044}
3045
3046
3047/**
3048 * Check the correct style menu item.
3049 */
3050_command void k_menu_style(_str sNewStyle = '')
3051{
3052 //say 'sNewStyle='sNewStyle;
3053 _menu_set_state(mhCode, "Opt1Ind4", MF_UNCHECKED);
3054 _menu_set_state(mhCode, "Opt1Ind3", MF_UNCHECKED);
3055 _menu_set_state(mhCode, "Opt1Ind8", MF_UNCHECKED);
3056 _menu_set_state(mhCode, "Opt2Ind4", MF_UNCHECKED);
3057 _menu_set_state(mhCode, "Opt2Ind3", MF_UNCHECKED);
3058 _menu_set_state(mhCode, "Opt2Ind8", MF_UNCHECKED);
3059 _menu_set_state(mhCode, "Opt3Ind4", MF_UNCHECKED);
3060 _menu_set_state(mhCode, "Opt3Ind3", MF_UNCHECKED);
3061 _menu_set_state(mhCode, "Opt3Ind8", MF_UNCHECKED);
3062
3063 if (sNewStyle != '')
3064 {
3065 int iIndent = (int)substr(sNewStyle, 8, 1);
3066 int iBraceStyle = (int)substr(sNewStyle, 4, 1);
3067 skCodeStyle = sNewStyle;
3068 k_styles_setindent(iIndent, iBraceStyle);
3069 k_styles_set(sNewStyle);
3070 }
3071
3072 _menu_set_state(mhCode, skCodeStyle, MF_CHECKED);
3073}
3074
3075
3076/**
3077 * Load a 'preset'.
3078 */
3079_command void k_menu_preset(_str sArgs = '')
3080{
3081 parse sArgs with sNewDocStyle ',' sNewLicense ',' sNewStyle ',' sNewCompany ',' sNewProgram ',' sNewChange
3082 sNewDocStyle= strip(sNewDocStyle);
3083 sNewLicense = strip(sNewLicense);
3084 sNewStyle = strip(sNewStyle);
3085 sNewCompany = strip(sNewCompany);
3086 sNewProgram = strip(sNewProgram);
3087 sNewChange = strip(sNewChange);
3088
3089 //say 'k_menu_preset('sNewDocStyle',' sNewLicense',' sNewStyle',' sNewCompany',' sNewProgram')';
3090 k_menu_doc_style(sNewDocStyle);
3091 k_menu_license(sNewLicense);
3092 k_menu_style(sNewStyle);
3093 skCompany = sNewCompany;
3094 skProgram = sNewProgram;
3095 skChange = sNewChange;
3096 k_menu_create();
3097}
3098
3099
3100
3101/* future ones..
3102_command k_menu_setcolor()
3103{
3104 createMyColorSchemeAndUseIt();
3105}
3106
3107
3108_command k_menu_setkeys()
3109{
3110 rc = load("d:/knut/VSlickMacros/BoxerDef.e");
3111}
3112
3113_command k_menu_settings()
3114{
3115 mySettings();
3116}
3117*/
3118
3119
3120/*******************************************************************************
3121* Dialogs *
3122*******************************************************************************/
3123_form k_form_simple_input {
3124 p_backcolor=0x80000005
3125 p_border_style=BDS_DIALOG_BOX
3126 p_caption='Simple Input'
3127 p_clip_controls=FALSE
3128 p_forecolor=0x80000008
3129 p_height=1120
3130 p_width=5020
3131 p_x=6660
3132 p_y=6680
3133 _text_box entText {
3134 p_auto_size=TRUE
3135 p_backcolor=0x80000005
3136 p_border_style=BDS_FIXED_SINGLE
3137 p_completion=NONE_ARG
3138 p_font_bold=FALSE
3139 p_font_italic=FALSE
3140 p_font_name='MS Sans Serif'
3141 p_font_size=8
3142 p_font_underline=FALSE
3143 p_forecolor=0x80000008
3144 p_height=270
3145 p_tab_index=1
3146 p_tab_stop=TRUE
3147 p_text='text'
3148 p_width=3180
3149 p_x=1680
3150 p_y=240
3151 p_eventtab2=_ul2_textbox
3152 }
3153 _label lblLabel {
3154 p_alignment=AL_VCENTERRIGHT
3155 p_auto_size=FALSE
3156 p_backcolor=0x80000005
3157 p_border_style=BDS_NONE
3158 p_caption='Label'
3159 p_font_bold=FALSE
3160 p_font_italic=FALSE
3161 p_font_name='MS Sans Serif'
3162 p_font_size=8
3163 p_font_underline=FALSE
3164 p_forecolor=0x80000008
3165 p_height=240
3166 p_tab_index=2
3167 p_width=1380
3168 p_word_wrap=FALSE
3169 p_x=180
3170 p_y=240
3171 }
3172 _command_button btnOK {
3173 p_cancel=FALSE
3174 p_caption='&OK'
3175 p_default=TRUE
3176 p_font_bold=FALSE
3177 p_font_italic=FALSE
3178 p_font_name='MS Sans Serif'
3179 p_font_size=8
3180 p_font_underline=FALSE
3181 p_height=360
3182 p_tab_index=3
3183 p_tab_stop=TRUE
3184 p_width=1020
3185 p_x=180
3186 p_y=660
3187 }
3188 _command_button btnCancel {
3189 p_cancel=TRUE
3190 p_caption='Cancel'
3191 p_default=FALSE
3192 p_font_bold=FALSE
3193 p_font_italic=FALSE
3194 p_font_name='MS Sans Serif'
3195 p_font_size=8
3196 p_font_underline=FALSE
3197 p_height=360
3198 p_tab_index=4
3199 p_tab_stop=TRUE
3200 p_width=840
3201 p_x=1380
3202 p_y=660
3203 }
3204}
3205
3206defeventtab k_form_simple_input
3207btnOK.on_create(_str sLabel = '', _str sText = '')
3208{
3209 p_active_form.p_caption = sLabel;
3210 lblLabel.p_caption = sLabel;
3211 entText.p_text = sText;
3212}
3213
3214btnOK.lbutton_up()
3215{
3216 sText = entText.p_text;
3217 p_active_form._delete_window(sText);
3218}
3219btnCancel.lbutton_up()
3220{
3221 sText = entText.p_text;
3222 p_active_form._delete_window("\r");
3223}
3224
3225
3226
3227/**
3228 * Module initiation.
3229 */
3230definit()
3231{
3232 /* do cleanup. */
3233 for (i = 0; i < 200; i++)
3234 {
3235 index = name_match("def-koptions-", 1, MISC_TYPE);
3236 if (!index)
3237 break;
3238 delete_name(index);
3239 }
3240
3241 /* do init */
3242 k_styles_create();
3243 k_menu_create();
3244 iTimer = _set_timer(1000, k_menu_create, "timer");
3245 /* createMyColorSchemeAndUseIt();*/
3246}
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette