VirtualBox

source: kBuild/branches/kBuild-0.1.5/VSlickMacros/kdev.e@ 2421

Last change on this file since 2421 was 2243, checked in by bird, 16 years ago

*: Updated copyright to 2009 and normalized name & email.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 97.5 KB
Line 
1/* $Id: kdev.e 2243 2009-01-10 02:24:02Z bird $ -*- tab-width: 4 c-indent-level: 4 -*- */
2/** @file
3 * Visual SlickEdit Documentation Macros.
4 */
5
6/*
7 * Copyright (c) 1999-2009 knut st. osmundsen <[email protected]>
8 *
9 * This file is part of kBuild.
10 *
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.
15 *
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.
20 *
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/>
23 *
24 */
25
26/***
27 *
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)
34 *
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
41 *
42 * Ctrl+Shift+A: Signature+Date marker
43 * Ctrl+Shift+P: Mark line as change by me
44 *
45 * Ctrl+Shift+T: Update project tagfile.
46 * Ctrl+Shift+L: Load document variables.
47 *
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.
52 *
53 * Remember to set the correct sOdin32UserName, sOdin32UserEmail and sOdin32UserInitials
54 * before compiling and loading the macros into Visual SlickEdit.
55 *
56 * These macros are compatible with both 3.0(c) and 4.0(b).
57 *
58 */
59defeventtab default_keys
60def 'C-S-A' = k_signature
61def 'C-S-C' = k_javadoc_classbox
62def 'C-S-E' = k_box_exported
63def 'C-S-F' = k_javadoc_funcbox
64def 'C-S-G' = k_box_globals
65def 'C-S-H' = k_box_headers
66def 'C-S-I' = k_box_intfuncs
67def 'C-S-K' = k_box_consts
68def 'C-S-M' = k_javadoc_moduleheader
69def 'C-S-O' = k_oneliner
70def 'C-S-P' = k_mark_modified_line
71def 'C-S-S' = k_box_structs
72def 'C-S-T' = odin32_maketagfile
73def 'C-S-L' = k_style_load
74
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
80
81
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
91
92/* Remeber to change these! */
93static _str skUserInitials = "bird";
94static _str skUserName = "knut st. osmundsen";
95static _str skUserEmail = "[email protected]";
96
97
98/*******************************************************************************
99* Global Variables *
100*******************************************************************************/
101static _str skCodeStyle = 'Opt2Ind4'; /* coding style scheme. */
102static _str skDocStyle = 'javadoc';/* options: javadoc, */
103static _str skLicense = 'GPLv3'; /* options: GPL, LGPL, Odin32, Confidential, ++ */
104static _str skCompany = ''; /* empty or company name for copyright */
105static _str skProgram = ''; /* Current program name - used by [L]GPL */
106static _str skChange = ''; /* Current change identifier. */
107
108static int ikStyleWidth = 80; /* The page width of the style. */
109static boolean fkStyleFullHeaders = false; /* false: omit some tags. */
110static int ikStyleOneliner = 41; /* The oneline comment column. */
111static int ikStyleModifyMarkColumn = 105;
112static boolean fkStyleBoxTag = false; /* true: Include tag in k_box_start. */
113
114/*******************************************************************************
115* Internal Functions *
116*******************************************************************************/
117/**
118 * Gets iso date.
119 * @returns ISO formatted date.
120 */
121static _str k_date()
122{
123 int i,j;
124 _str date;
125
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;
135}
136
137
138/**
139 * Get the current year.
140 * @returns Current year string.
141 */
142static _str k_year()
143{
144 _str date = _date('U');
145 return substr(date, pos("/",date, pos("/",date)+1)+1, 4);
146}
147
148
149/**
150 * Aligns a value up to a given alignment.
151 */
152static int k_alignup(int iValue, iAlign)
153{
154 if (iAlign <= 0)
155 {
156 message('k_alignup: iValue='iValue ' iAlign='iAlign);
157 iAlign = 4;
158 }
159 return ((iValue intdiv iAlign) + 1) * iAlign;
160}
161
162
163/**
164 * Reads the comment setup for this lexer/extension .
165 *
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.
173 */
174static boolean k_commentconfig(_str &sLeft, _str &sRight, int &iColumn, _str sExt = p_extension, _str sLexer = p_lexer_name)
175{
176 /* init returns */
177 sLeft = sRight = '';
178 iColumn = 0;
179
180 /*
181 * Get comment setup from the lexer.
182 */
183 _str sLine = '';
184 if (sLexer)
185 {
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)
191 {
192 sLeft = strip(word(sLine, 1));
193 sRight = strip(word(sLine, 2));
194 if (sLeft != '' && sRight != '')
195 return true;
196 }
197
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)
203 {
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;
212 }
213 }
214
215 /*
216 * Read the nonboxchars and determin user or default box.ini.
217 */
218 _str sFile = slick_path_search("ubox.ini");
219 boolean frc = _ini_get_value(sFile, sExt, 'nonboxchars', sLine);
220 if (frc)
221 {
222 sFile = slick_path_search("box.ini");
223 frc = _ini_get_value(sFile, sExt, 'nonboxchars', sLine);
224 }
225
226 if (!frc)
227 { /*
228 * Found extension.
229 */
230 sLeft = strip(eq_name2value('left',sLine));
231 if (sLeft == '\e') sLeft = '';
232 sRight = strip(eq_name2value('right',sLine));
233 if (sRight == '\e') sRight = '';
234
235 /* Read comment column too */
236 frc = _ini_get_value(sFile, sExt, 'comment_col', sLine);
237 if (frc)
238 {
239 iColumn = eq_name2value('comment_col', sLine);
240 if (iColumn == '\e') iColumn = 0;
241 }
242 else
243 iColumn = 0;
244 return true;
245 }
246
247 /* failure */
248 sLeft = sRight = '';
249 iColumn = 0;
250
251 return false;
252}
253
254
255/**
256 * Checks if current file only support line comments.
257 * @returns True / False.
258 * @remark Use builtin extension stuff!
259 */
260static boolean k_line_comment()
261{
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;
269}
270
271
272
273#define KIC_CURSOR_BEFORE 1
274#define KIC_CURSOR_AFTER 2
275#define KIC_CURSOR_AT_END 3
276
277/**
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.
286 */
287void k_insert_comment(_str sStr, int iCursor, int iPosition = -1)
288{
289 _str sLeft;
290 _str sRight;
291 int iColumn;
292 if (!k_commentconfig(sLeft, sRight, iColumn))
293 {
294 sLeft = '/*'; sRight = '*/'; iColumn = 0;
295 }
296
297 int iCol = 0;
298 if (iColumn <= 0)
299 { /*
300 * not column based source
301 */
302
303 /* position us first */
304 if (iPosition > 0)
305 {
306 end_line();
307 do {
308 _insert_text(" ");
309 } while (p_col < iPosition);
310 }
311
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);
320 }
321 else
322 {
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;
331 }
332
333 /* set cursor. */
334 if (iCursor != KIC_CURSOR_AFTER)
335 p_col = iCol;
336}
337
338
339/**
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.
344 */
345static _str k_comment(boolean fRight = false)
346{
347 _str sLeft, sRight;
348 int iColumn;
349 _str sComment = '/*';
350 if (k_commentconfig(sLeft, sRight, iColumn))
351 sComment = (!fRight || iColumn > 0 ? sLeft : sRight);
352
353 return strip(sComment);
354}
355
356
357/*******************************************************************************
358* BOXES *
359*******************************************************************************/
360
361/**
362 * Inserts the first line in a box.
363 * @param sTag Not used - box tag.
364 */
365static void k_box_start(sTag)
366{
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(" ");
375
376 _str sText = sLeft;
377 if (sTag != '' && fkStyleBoxTag)
378 {
379 if (substr(sText, length(sText)) != '*')
380 sText = sText:+'*';
381 sText = sText:+sTag;
382 }
383
384 int i;
385 for (i = length(sText); i <= ikStyleWidth - p_col; i++)
386 sText = sText:+'*';
387 sText = sText:+"\n";
388
389 _insert_text(sText);
390}
391
392
393/**
394 * Places a string, sStr, into a line started and ended by '*'.
395 * @param sStr Text to have between the '*'s.
396 */
397static void k_box_line(_str sStr)
398{
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(" ");
406
407 _str sText = '';
408 if (k_line_comment())
409 sText = sLeft;
410 if (sText == '' || substr(sText, length(sText)) != '*')
411 sText = sText:+'*';
412
413 sText = sText:+' ';
414 int i;
415 for (i = length(sText); i < p_SyntaxIndent; i++)
416 sText = sText:+' ';
417
418 sText = sText:+sStr;
419
420 for (i = length(sText) + 1; i <= ikStyleWidth - p_col; i++)
421 sText = sText:+' ';
422 sText = sText:+"*\n";
423
424 _insert_text(sText);
425}
426
427
428/**
429 * Inserts the last line in a box.
430 */
431static void k_box_end()
432{
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(" ");
440
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";
447
448 _insert_text(sText);
449}
450
451
452
453/*******************************************************************************
454* FUNCTION AND CODE PARSERS *
455*******************************************************************************/
456/**
457 * Moves cursor to nearest function start.
458 * @returns 0 if ok.
459 * -1 on failure.
460 */
461static int k_func_goto_nearest_function()
462{
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);
469
470 if (!next_proc(1))
471 {
472 next_line = p_line;
473 if (!prev_proc(1) && p_line == cur_line)
474 {
475 _restore_pos2(org_pos);
476 return 0;
477 }
478 _restore_pos2(org_pos);
479 _save_pos2(org_pos);
480 }
481 else
482 {
483 p_col++; /* fixes problem with single function files. */
484 fFix = true;
485 }
486
487 if (!prev_proc(1))
488 {
489 prev_line = p_line;
490 if (!next_proc(1) && p_line == cur_line)
491 {
492 _restore_pos2(org_pos);
493 return 0;
494 }
495 _restore_pos2(org_pos);
496 _save_pos2(org_pos);
497 }
498
499
500 if (prev_line != -1 && (next_line == -1 || cur_line - prev_line <= next_line - cur_line))
501 {
502 if (fFix)
503 p_col++;
504 prev_proc(1);
505 return 0;
506 }
507
508 if (next_line != -1 && (prev_line == -1 || cur_line - prev_line > next_line - cur_line))
509 {
510 next_proc();
511 return 0;
512 }
513
514 _restore_pos2(org_pos);
515 return -1;
516}
517
518
519/**
520 * Check if nearest function is a prototype.
521 * @returns True if function prototype.
522 * False if not function prototype.
523 */
524static boolean k_func_prototype()
525{
526 /*
527 * Check if this is a real function implementation.
528 */
529 typeless procpos;
530 _save_pos2(procpos);
531 if (!k_func_goto_nearest_function())
532 {
533 int proc_line = p_line;
534
535 if (!k_func_searchcode("{"))
536 {
537 prev_proc();
538 if (p_line != proc_line)
539 {
540 _restore_pos2(procpos);
541 return true;
542 }
543 }
544 }
545 _restore_pos2(procpos);
546
547 return false;
548}
549
550
551/**
552 * Gets the name fo the current function.
553 * @returns The current function name.
554 */
555static _str k_func_getfunction_name()
556{
557 _str sFunctionName = current_proc();
558 if (!sFunctionName)
559 sFunctionName = "";
560 //say 'functionanme='sFunctionName;
561 return sFunctionName;
562}
563
564
565/**
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).
568 */
569static _str k_func_getparams()
570{
571 typeless org_pos;
572 _save_pos2(org_pos);
573
574 /*
575 * Try use the tags first.
576 */
577 _UpdateContext(true);
578 int context_id = tag_current_context();
579 if (context_id <= 0)
580 {
581 k_func_goto_nearest_function();
582 context_id = tag_current_context();
583 }
584 if (context_id > 0)
585 {
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);
593 }
594
595 /*
596 * Go to nearest function.
597 */
598 if ( !k_func_goto_nearest_function()
599 && !k_func_searchcode("(") /* makes some assumptions. */
600 )
601 {
602 /*
603 * Get parameters.
604 */
605 typeless posStart;
606 _save_pos2(posStart);
607 long offStart = _QROffset();
608 if (!find_matching_paren())
609 {
610 long offEnd = _QROffset();
611 _restore_pos2(posStart);
612 p_col++;
613 _str sParamsRaw = strip(get_text((int)(offEnd - offStart - 1)));
614
615
616 /*
617 * Remove new lines and double spaces within params.
618 */
619 _str sParams = "";
620
621 int i;
622 _str chPrev;
623 for (i = 1, chPrev = ' '; i <= length(sParamsRaw); i++)
624 {
625 _str ch = substr(sParamsRaw, i, 1);
626
627 /*
628 * Do fixups.
629 */
630 if (ch == " " && chPrev == " ")
631 continue;
632
633 if ((ch :== "\n") || (ch :== "\r") || (ch :== "\t"))
634 {
635 if (chPrev == ' ')
636 continue;
637 ch = ' ';
638 }
639
640 if (ch == ',' && chPrev == ' ')
641 {
642 sParams = substr(sParams, 1, length(sParams) - 1);
643 }
644
645 if (ch == '*')
646 {
647 if (chPrev != ' ')
648 sParams = sParams :+ ' * ';
649 else
650 sParams = sParams :+ '* ';
651 chPrev = ' ';
652 }
653 else
654 {
655 sParams = sParams :+ ch;
656 chPrev = ch;
657 }
658
659 } /* for */
660
661 sParams = strip(sParams);
662 if (sParams == 'void' || sParams == 'VOID')
663 sParams = "";
664 _restore_pos2(org_pos);
665 return sParams;
666 }
667 else
668 message("find_matchin_paren failed");
669 }
670
671 _restore_pos2(org_pos);
672 return false;
673}
674
675
676
677/**
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).
686 */
687static int k_func_enumparams(_str sParams, int iParam, _str &sType, _str &sName, _str &sDefault)
688{
689 int i;
690 int iParLevel;
691 int iCurParam;
692 int iStartParam;
693
694 sType = sName = sDefault = "";
695
696 /* no use working on empty string! */
697 if (length(sParams) == 0)
698 return -1;
699
700 /* find the parameter in question */
701 for (iStartParam = i = 1, iParLevel = iCurParam = 0; i <= length(sParams); i++)
702 {
703 _str ch = substr(sParams, i, 1);
704 if (ch == ',' && iParLevel == 0)
705 {
706 /* is it this parameter ? */
707 if (iParam == iCurParam)
708 break;
709
710 iCurParam++;
711 iStartParam = i + 1;
712 }
713 else if (ch == '(')
714 iParLevel++;
715 else if (ch == ')')
716 iParLevel--;
717 }
718
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);
728
729 /* lazy approach, which doens't support function types */
730
731 if (pos('=', sParams) > 0) /* default */
732 {
733 sDefault = strip(substr(sParams, pos('=', sParams) + 1));
734 sArg = strip(substr(sArg, 1, pos('=', sParams) - 1));
735 }
736
737 for (i = length(sArg); i > 1; i--)
738 {
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;
745 }
746 if (sArg == "...")
747 i = 0;
748 sName = strip(substr(sArg, i + 1));
749 sType = strip(substr(sArg, 1, i));
750
751 return 0;
752 }
753
754 return -1;
755}
756
757
758/**
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).
762 */
763static int k_func_countparams(_str sParams)
764{
765 int i;
766 int iParLevel;
767 int iCurParam;
768 _str sType = "", sName = "", sDefault = "";
769
770 /* check for 0 parameters */
771 if (length(sParams) == 0)
772 return 0;
773
774 /* find the parameter in question */
775 for (i = 1, iParLevel = iCurParam = 0; i <= length(sParams); i++)
776 {
777 _str ch = substr(sParams, i, 1);
778 if (ch == ',' && iParLevel == 0)
779 {
780 iCurParam++;
781 }
782 else if (ch == '(')
783 iParLevel++;
784 else if (ch == ')')
785 iParLevel--;
786 }
787
788 return iCurParam + 1;
789}
790
791
792/**
793 * Gets the return type.
794 */
795static _str k_func_getreturntype(boolean fPureType = false)
796{
797 typeless org_pos;
798 _save_pos2(org_pos);
799
800 /*
801 * Go to nearest function.
802 */
803 if (!k_func_goto_nearest_function())
804 {
805 /*
806 * Return type is from function start to function name...
807 */
808 typeless posStart;
809 _save_pos2(posStart);
810 long offStart = _QROffset();
811
812 if (!k_func_searchcode("(")) /* makes some assumptions. */
813 {
814 prev_word();
815 long offEnd = _QROffset();
816 _restore_pos2(posStart);
817 _str sTypeRaw = strip(get_text((int)(offEnd - offStart)));
818
819 //say 'sTypeRaw='sTypeRaw;
820 /*
821 * Remove static, inline, _Optlink, stdcall, EXPENTRY etc.
822 */
823 if (fPureType)
824 {
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");
880 }
881
882 /*
883 * Remove new lines and double spaces within params.
884 */
885 _str sType = "";
886
887 int i;
888 _str chPrev;
889 for (i = 1, chPrev = ' '; i <= length(sTypeRaw); i++)
890 {
891 _str ch = substr(sTypeRaw, i, 1);
892
893 /*
894 * Do fixups.
895 */
896 if (ch == " " && chPrev == " ")
897 continue;
898
899 if ((ch :== "\n") || (ch :== "\r") || (ch :== "\t"))
900 {
901 if (chPrev == ' ')
902 continue;
903 ch = ' ';
904 }
905
906 if (ch == ',' && chPrev == ' ')
907 {
908 sType = substr(sType, 1, length(sType) - 1);
909 }
910
911 if (ch == '*')
912 {
913 if (chPrev != ' ')
914 sType = sType :+ ' * ';
915 else
916 sType = sType :+ '* ';
917 chPrev = ' ';
918 }
919 else
920 {
921 sType = sType :+ ch;
922 chPrev = ch;
923 }
924
925 } /* for */
926
927 sType = strip(sType);
928
929 _restore_pos2(org_pos);
930 return sType;
931 }
932 else
933 message('k_func_getreturntype: can''t find ''(''.');
934 }
935
936 _restore_pos2(org_pos);
937 return false;
938}
939
940
941/**
942 * Search for some piece of code.
943 */
944static int k_func_searchcode(_str sSearchString, _str sOptions = "E+")
945{
946 int rc;
947 rc = search(sSearchString, sOptions);
948 while (!rc && !k_func_in_code())
949 {
950 p_col++;
951 rc = search(sSearchString, sOptions);
952 }
953 return rc;
954}
955
956
957/**
958 * Checks if cursor is in code or in comment.
959 * @return True if cursor in code.
960 */
961static boolean k_func_in_code()
962{
963 typeless searchsave;
964 _save_pos2(searchsave);
965 boolean fRc = !_in_comment();
966 _restore_pos2(searchsave);
967 return fRc;
968}
969
970
971/*
972 * Gets the next piece of code.
973 */
974static _str k_func_get_next_code_text()
975{
976 typeless searchsave;
977 _save_pos2(searchsave);
978 _str ch = k_func_get_next_code_text2();
979 _restore_pos2(searchsave);
980 return ch;
981}
982
983
984/**
985 * Checks if there is more code on the line.
986 */
987static boolean k_func_more_code_on_line()
988{
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);
996
997 return fRc;
998}
999
1000
1001/**
1002 * Gets the next piece of code.
1003 * Doesn't preserver cursor position.
1004 */
1005static _str k_func_get_next_code_text2()
1006{
1007 _str ch;
1008 do
1009 {
1010 int curcol = ++p_col;
1011 end_line();
1012 if (p_col <= curcol)
1013 {
1014 p_line++;
1015 p_col = 1;
1016 }
1017 else
1018 p_col = curcol;
1019
1020 ch = get_text();
1021 //say ch ' ('_asc(ch)')';
1022 while (ch == "#") /* preprocessor stuff */
1023 {
1024 p_col = 1;
1025 p_line++;
1026 ch = get_text();
1027 //say ch ' ('_asc(ch)')';
1028 continue;
1029 }
1030 } while (ch :== ' ' || ch :== "\t" || ch :== "\n" || ch :== "\r" || !k_func_in_code());
1031
1032 return ch;
1033}
1034
1035
1036
1037
1038/*******************************************************************************
1039* JAVA DOC STYLED WORKERS *
1040*******************************************************************************/
1041
1042/** starts a javadoc documentation box. */
1043static void k_javadoc_box_start(_str sStr = '', boolean fDouble = true)
1044{
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(" ");
1053
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";
1060
1061 _insert_text(sText);
1062}
1063
1064/** inserts a new line in a javadoc documentation box. */
1065static void k_javadoc_box_line(_str sStr = '', int iPadd = 0, _str sStr2 = '', int iPadd2 = 0, _str sStr3 = '')
1066{
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(" ");
1074
1075 _str sText;
1076 if (k_line_comment())
1077 sText = sLeft;
1078 else
1079 {
1080 sText = sLeft;
1081 sText = ' ':+substr(sLeft, length(sLeft));
1082 }
1083
1084 if (sStr != '')
1085 sText = sText:+' ':+sStr;
1086 if (iPadd > 0)
1087 {
1088 int i;
1089 for (i = length(sText); i < iPadd; i++)
1090 sText = sText:+' ';
1091
1092 if (sStr2 != '')
1093 sText = sText:+sStr2;
1094
1095 if (iPadd2 > 0)
1096 {
1097 for (i = length(sText); i < iPadd2; i++)
1098 sText = sText:+' ';
1099
1100 if (sStr3 != '')
1101 sText = sText:+sStr3;
1102 }
1103 }
1104 sText = sText:+"\n";
1105
1106 _insert_text(sText);
1107}
1108
1109/** ends a javadoc documentation box. */
1110static void k_javadoc_box_end()
1111{
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(" ");
1119
1120 _str sText;
1121 if (k_line_comment())
1122 sText = sLeft;
1123 else
1124 {
1125 sText = sRight;
1126 /*if (substr(sText, 1, 1) != '*')
1127 sText = '*':+sText;*/
1128 sText = ' ':+sText;
1129 }
1130 sText = sText:+"\n";
1131
1132 _insert_text(sText);
1133}
1134
1135
1136/**
1137 * Write a Javadoc styled classbox.
1138 */
1139void k_javadoc_classbox()
1140{
1141 int iCursorLine;
1142 int iPadd = k_alignup(12, p_SyntaxIndent);
1143
1144 k_javadoc_box_start();
1145 iCursorLine = p_RLine;
1146 k_javadoc_box_line(' ');
1147
1148 if (fkStyleFullHeaders)
1149 {
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);
1154 }
1155 k_javadoc_box_line('@author', iPadd, skUserName ' <' skUserEmail '>');
1156 k_javadoc_box_line('@approval', iPadd);
1157 k_javadoc_box_end();
1158
1159 up(p_RLine - iCursorLine);
1160 end_line();
1161 keyin(' ');
1162}
1163
1164
1165/**
1166 * Javadoc - functionbox(/header).
1167 */
1168void k_javadoc_funcbox()
1169{
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)
1177 {
1178 sArgs = k_func_getparams();
1179 cArgs = k_func_countparams(sArgs);
1180 }
1181
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)
1189 {
1190 /*
1191 * Determin parameter description indent.
1192 */
1193 int iPadd2 = 0;
1194 int i;
1195 for (i = 0; i < cArgs; i++)
1196 {
1197 _str sName, sType, sDefault;
1198 if (!k_func_enumparams(sArgs, i, sType, sName, sDefault)
1199 && iPadd2 < length(sName))
1200 iPadd2 = length(sName);
1201 }
1202 iPadd2 = k_alignup((iPadd + iPadd2), p_SyntaxIndent);
1203
1204 /*
1205 * Insert parameter.
1206 */
1207 for (i = 0; i < cArgs; i++)
1208 {
1209 _str sName, sType, sDefault;
1210 if (!k_func_enumparams(sArgs, i, sType, sName, sDefault))
1211 {
1212 _str sStr3 = '';
1213 if (sDefault != "")
1214 sStr3 = '(default='sDefault')';
1215 k_javadoc_box_line('@param', iPadd, sName, iPadd2, sStr3);
1216 }
1217 else
1218 k_javadoc_box_line('@param', iPadd);
1219 }
1220 }
1221 else
1222 k_javadoc_box_line('@param', iPadd);
1223
1224 if (file_eq(p_extension, 'asm'))
1225 k_javadoc_box_line('@uses', iPadd);
1226 if (fkStyleFullHeaders)
1227 {
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);
1234 }
1235 k_javadoc_box_end();
1236
1237 up(p_RLine - iCursorLine);
1238 end_line();
1239 keyin(' ');
1240}
1241
1242
1243/**
1244 * Javadoc module header.
1245 */
1246void k_javadoc_moduleheader()
1247{
1248 int iCursorLine;
1249 int fSplit = 0;
1250
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");
1257
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");
1265
1266 if (skLicense == 'Confidential')
1267 {
1268 k_javadoc_box_line(skCompany ' confidential');
1269 k_javadoc_box_line();
1270 }
1271
1272 if (skCompany != '')
1273 {
1274 if (skLicense != 'Confidential')
1275 k_javadoc_box_line('Copyright (C) ' k_year() ' ' skCompany);
1276 else
1277 {
1278 k_javadoc_box_line('Copyright (c) ' k_year() ' ' skCompany);
1279 k_javadoc_box_line();
1280 k_javadoc_box_line('Author: ' skUserName' <' skUserEmail '>');
1281 }
1282 }
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)
1288 {
1289 case 'Odin32':
1290 k_javadoc_box_line('Project Odin Software License can be found in LICENSE.TXT.');
1291 break;
1292
1293 case 'GPL':
1294 if (!fSplit)
1295 k_javadoc_box_line();
1296 if (sProg == '')
1297 sProg = 'This program';
1298 else
1299 {
1300 k_javadoc_box_line('This file is part of ' sProg '.');
1301 k_javadoc_box_line();
1302 }
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;
1317
1318 case 'LGPL':
1319 if (!fSplit)
1320 k_javadoc_box_line();
1321 if (sProg == '')
1322 sProg = 'This library';
1323 else
1324 {
1325 k_javadoc_box_line('This file is part of ' sProg '.');
1326 k_javadoc_box_line();
1327 }
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;
1342
1343 case 'GPLv3':
1344 if (!fSplit)
1345 k_javadoc_box_line();
1346 if (sProg == '')
1347 sProg = 'This program';
1348 else
1349 {
1350 k_javadoc_box_line('This file is part of ' sProg '.');
1351 k_javadoc_box_line();
1352 }
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;
1366
1367 case 'LGPLv3':
1368 if (!fSplit)
1369 k_javadoc_box_line();
1370 if (sProg == '')
1371 sProg = 'This program';
1372 else
1373 {
1374 k_javadoc_box_line('This file is part of ' sProg '.');
1375 k_javadoc_box_line();
1376 }
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;
1390
1391 case 'Confidential':
1392 k_javadoc_box_line('All Rights Reserved');
1393 break;
1394
1395 case 'ConfidentialNoAuthor':
1396 k_javadoc_box_line(skCompany ' confidential');
1397 k_javadoc_box_line('All Rights Reserved');
1398 break;
1399
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;
1413
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;
1436
1437 default:
1438
1439 }
1440 k_javadoc_box_line();
1441 k_javadoc_box_end();
1442
1443 up(p_RLine - iCursorLine);
1444 end_line();
1445 keyin(' ');
1446}
1447
1448
1449
1450
1451
1452
1453
1454/*******************************************************************************
1455* Keyboard Shortcuts *
1456*******************************************************************************/
1457/** Makes global box. */
1458void k_box_globals()
1459{
1460 k_box_start('Global');
1461 k_box_line('Global Variables');
1462 k_box_end();
1463}
1464
1465/** Makes header box. */
1466void k_box_headers()
1467{
1468 k_box_start("Header");
1469 k_box_line("Header Files");
1470 k_box_end();
1471}
1472
1473/** Makes internal function box. */
1474void k_box_intfuncs()
1475{
1476 k_box_start("IntFunc");
1477 k_box_line("Internal Functions");
1478 k_box_end();
1479}
1480
1481/** Makes def/const box. */
1482void k_box_consts()
1483{
1484 k_box_start("Const");
1485 k_box_line("Defined Constants And Macros");
1486 k_box_end();
1487}
1488
1489/** Structure box */
1490void k_box_structs()
1491{
1492 k_box_start("Struct");
1493 k_box_line("Structures and Typedefs");
1494 k_box_end();
1495}
1496
1497/** Makes exported symbols box. */
1498void k_box_exported()
1499{
1500 k_box_start('Exported');
1501 k_box_line('Exported Symbols');
1502 k_box_end();
1503}
1504
1505
1506
1507/** oneliner comment */
1508void k_oneliner()
1509{
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)
1517 {
1518 _begin_line();
1519 _insert_text("\n\r");
1520 up();
1521 }
1522 }
1523 k_insert_comment("", KIC_CURSOR_AT_END, ikStyleOneliner);
1524}
1525
1526/** mark line as modified. */
1527void k_mark_modified_line()
1528{
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();
1542}
1543
1544
1545/**
1546 * Inserts a signature. Form: "//Initials ISO-date:"
1547 * @remark defeventtab
1548 */
1549void k_signature()
1550{
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);
1558}
1559
1560
1561/*******************************************************************************
1562* kLIB Logging *
1563*******************************************************************************/
1564/**
1565 * Hot-Key: Inserts a KLOGENTRY statement at start of nearest function.
1566 */
1567void klib_klogentry()
1568{
1569 typeless org_pos;
1570 _save_pos2(org_pos);
1571
1572 /*
1573 * Go to nearest function.
1574 */
1575 if (!k_func_goto_nearest_function())
1576 {
1577 /*
1578 * Get parameters.
1579 */
1580 _str sParams = k_func_getparams();
1581 if (sParams)
1582 {
1583 _str sRetType = k_func_getreturntype(true);
1584 if (!sRetType || sRetType == "")
1585 sRetType = "void"; /* paranoia! */
1586
1587 /*
1588 * Insert text.
1589 */
1590 if (!k_func_searchcode("{"))
1591 {
1592 p_col++;
1593 int cArgs = k_func_countparams(sParams);
1594 if (cArgs > 0)
1595 {
1596 _str sArgs = "";
1597 int i;
1598 for (i = 0; i < cArgs; i++)
1599 {
1600 _str sType, sName, sDefault;
1601 if (!k_func_enumparams(sParams, i, sType, sName, sDefault))
1602 sArgs = sArgs', 'sName;
1603 }
1604
1605 _insert_text("\n KLOGENTRY"cArgs"(\""sRetType"\",\""sParams"\""sArgs");"); /* todo tab size.. or smart indent */
1606 }
1607 else
1608 _insert_text("\n KLOGENTRY0(\""sRetType"\");"); /* todo tab size.. or smart indent */
1609
1610 /*
1611 * Check if the next word is KLOGENTRY.
1612 */
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();
1619
1620 }
1621 else
1622 message("didn't find {");
1623 }
1624 else
1625 message("k_func_getparams failed, sParams=" sParams);
1626 return;
1627 }
1628
1629 _restore_pos2(org_pos);
1630}
1631
1632
1633/**
1634 * Hot-Key: Inserts a KLOGEXIT statement at cursor location.
1635 */
1636void klib_klogexit()
1637{
1638 typeless org_pos;
1639 _save_pos2(org_pos);
1640
1641 /*
1642 * Go to nearest function.
1643 */
1644 if (!prev_proc())
1645 {
1646 /*
1647 * Get parameters.
1648 */
1649 _str sType = k_func_getreturntype(true);
1650 _restore_pos2(org_pos);
1651 if (sType)
1652 {
1653 boolean fReturn = true; /* true if an return statment is following the KLOGEXIT statement. */
1654
1655 /*
1656 * Insert text.
1657 */
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)
1664 {
1665 while (p_col <= p_SyntaxIndent)
1666 keyin(" ");
1667 }
1668
1669 _insert_text("KLOGEXITVOID();\n");
1670
1671 if (fReturn)
1672 {
1673 int i;
1674 for (i = 1; i < cur_col; i++)
1675 _insert_text(" ");
1676 }
1677 search(")","E-");
1678 }
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-");
1686
1687 /*
1688 * Insert value if possible.
1689 */
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')
1697 {
1698 p_col += length('return');
1699 typeless posStart;
1700 _save_pos2(posStart);
1701 long offStart = _QROffset();
1702 if (!k_func_searchcode(";", "E+"))
1703 {
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);
1711 }
1712 }
1713 _restore_pos2(valuepos);
1714 }
1715
1716 /*
1717 * Remove old KLOGEXIT statement on previous line if any.
1718 */
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);
1730
1731 /*
1732 * Check for missing '{...}'.
1733 */
1734 if (fReturn)
1735 {
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) */
1740
1741 _str ch = k_func_get_next_code_text();
1742 if (ch != '}')
1743 {
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
1752 {
1753 typeless returnget;
1754 _save_pos2(returnget);
1755 k_func_searchcode("return", "E-");
1756 int return_col = p_col;
1757 _restore_pos2(returnget);
1758
1759 end_line();
1760 _insert_text("\n");
1761 while (p_col < return_col - p_SyntaxIndent)
1762 _insert_text(' ');
1763 _insert_text('}');
1764 }
1765
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(' ');
1774 }
1775
1776 _restore_pos2(valuepos);
1777 }
1778 }
1779 else
1780 message("k_func_getreturntype failed, sType=" sType);
1781 return;
1782 }
1783
1784 _restore_pos2(org_pos);
1785}
1786
1787
1788/**
1789 * Processes a file - ask user all the time.
1790 */
1791void klib_klog_file_ask()
1792{
1793 klib_klog_file_int(true);
1794}
1795
1796
1797/**
1798 * Processes a file - no questions.
1799 */
1800void klib_klog_file_no_ask()
1801{
1802 klib_klog_file_int(false);
1803}
1804
1805
1806
1807/**
1808 * Processes a file.
1809 */
1810static void klib_klog_file_int(boolean fAsk)
1811{
1812 show_all();
1813 bottom();
1814 _refresh_scroll();
1815
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;
1819
1820 /*
1821 * Entries.
1822 */
1823 while (!prev_proc())
1824 {
1825 //say 'entry main loop: ' k_func_getfunction_name();
1826
1827 /*
1828 * Skip prototypes.
1829 */
1830 if (k_func_prototype())
1831 continue;
1832
1833 /*
1834 * Ask user.
1835 */
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)
1841 {
1842 typeless procpos;
1843 _save_pos2(procpos);
1844 klib_klogentry();
1845 _restore_pos2(procpos);
1846 }
1847 else if (rc == IDNO)
1848 continue;
1849 else
1850 break;
1851 }
1852
1853 /*
1854 * Exits.
1855 */
1856 bottom(); _refresh_scroll();
1857 boolean fUserCancel = false;
1858 while (!prev_proc() && !fUserCancel)
1859 {
1860 typeless procpos;
1861 _save_pos2(procpos);
1862 _str sCurFunction = k_func_getfunction_name();
1863 //say 'exit main loop: ' sCurFunction
1864
1865 /*
1866 * Skip prototypes.
1867 */
1868 if (k_func_prototype())
1869 continue;
1870
1871 /*
1872 * Select procedure.
1873 */
1874 while ( !k_func_searchcode("return", "WE<+")
1875 && k_func_getfunction_name() == sCurFunction)
1876 {
1877 //say 'exit sub loop: ' p_line
1878 /*
1879 * Ask User.
1880 */
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)
1887 {
1888 typeless returnpos;
1889 _save_pos2(returnpos);
1890 klib_klogexit();
1891 _restore_pos2(returnpos);
1892 p_line++;
1893 }
1894 else if (rc != IDNO)
1895 {
1896 fUserCancel = true;
1897 break;
1898 }
1899 p_line++; /* just so we won't hit it again. */
1900 }
1901
1902 /*
1903 * If void function we'll have to check if there is and return; prior to the ending '}'.
1904 */
1905 _restore_pos2(procpos);
1906 _save_pos2(procpos);
1907 _str sType = k_func_getreturntype(true);
1908 if (!fUserCancel && sType && (sType == 'void' || sType == 'VOID'))
1909 {
1910 if ( !k_func_searchcode("{", "E+")
1911 && !find_matching_paren())
1912 {
1913 typeless funcend;
1914 _save_pos2(funcend);
1915 prev_word();
1916 int iIgnorePos;
1917 if (cur_word(iIgnorePos) != "return")
1918 {
1919 /*
1920 * Ask User.
1921 */
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)
1929 {
1930 typeless returnpos;
1931 _save_pos2(returnpos);
1932 klib_klogexit();
1933 _restore_pos2(returnpos);
1934 }
1935 }
1936 }
1937 }
1938
1939 /*
1940 * Next proc.
1941 */
1942 _restore_pos2(procpos);
1943 }
1944}
1945
1946
1947/*******************************************************************************
1948* Odin32 backward compatibility *
1949*******************************************************************************/
1950_command void odin32_maketagfile()
1951{
1952 /* We'll */
1953 if (file_match('-p 'maybe_quote_filename(strip_filename(_project_name,'e'):+TAG_FILE_EXT),1) != "")
1954 {
1955 _project_update_files_retag(false,false,false,false);
1956 /*
1957 RetagFilesInTagFile2(project_tag_file, orig_view_id, temp_view_id, rebuild_all, false,
1958 doRemove,false,true,true);*/
1959 }
1960 else
1961 _project_update_files_retag(true,false,false,true);
1962}
1963
1964_command void odin32_setcurrentdir()
1965{
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'));
1970}
1971
1972
1973
1974
1975/*******************************************************************************
1976* Styles *
1977*******************************************************************************/
1978static _str StyleLanguages[] =
1979{
1980 "c",
1981 "e",
1982 "java"
1983};
1984
1985struct StyleScheme
1986{
1987 _str name;
1988 _str settings[];
1989};
1990
1991static StyleScheme StyleSchemes[] =
1992{
1993 {
1994 "Opt2Ind4",
1995 {
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"
2025 }
2026 }
2027 ,
2028 {
2029 "Opt2Ind3",
2030 {
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"
2060 }
2061 }
2062 ,
2063 {
2064 "Opt2Ind8",
2065 {
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"
2095 }
2096 }
2097 ,
2098 {
2099 "Opt3Ind4",
2100 {
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"
2130 }
2131 }
2132 ,
2133 {
2134 "Opt3Ind3",
2135 {
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"
2165 }
2166 }
2167};
2168
2169
2170static void k_styles_create()
2171{
2172 /*
2173 * Find user format ini file.
2174 */
2175 _str userini = maybe_quote_filename(_config_path():+'uformat.ini');
2176 if (file_match('-p 'userini, 1) == '')
2177 {
2178 _str ini = maybe_quote_filename(slick_path_search('uformat.ini'));
2179 if (ini != '') userini = ini;
2180 }
2181
2182
2183 /*
2184 * Remove any old schemes.
2185 */
2186 int i,j,tv;
2187 for (i = 0; i < StyleSchemes._length(); i++)
2188 for (j = 0; j < StyleLanguages._length(); j++)
2189 {
2190 _str sectionname = StyleLanguages[j]:+'-scheme-':+StyleSchemes[i].name;
2191 if (!_ini_get_section(userini, sectionname, tv))
2192 {
2193 _ini_delete_section(userini, sectionname);
2194 _delete_temp_view(tv);
2195 //message("delete old scheme");
2196 }
2197 }
2198
2199 /*
2200 * Create the new schemes.
2201 */
2202 for (i = 0; i < StyleSchemes._length(); i++)
2203 {
2204 for (j = 0; j < StyleLanguages._length(); j++)
2205 {
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]);
2212
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);
2217 }
2218 }
2219
2220 //last_scheme = last scheme name!!!
2221}
2222
2223
2224/*
2225 * Sets the last used beutify scheme.
2226 */
2227static k_styles_set(_str scheme)
2228{
2229
2230 /*
2231 * Find user format ini file.
2232 */
2233 _str userini = maybe_quote_filename(_config_path():+'uformat.ini');
2234 if (file_match('-p 'userini, 1) == '')
2235 {
2236 _str ini = maybe_quote_filename(slick_path_search('uformat.ini'));
2237 if (ini != '') userini = ini;
2238 }
2239
2240 /*
2241 * Set the scheme for each language.
2242 */
2243 int j;
2244 for (j = 0; j < StyleLanguages._length(); j++)
2245 {
2246 _ini_set_value(userini,
2247 StyleLanguages[j]:+'-scheme-Default',
2248 'last_scheme',
2249 scheme);
2250 }
2251}
2252
2253
2254static _str defoptions[] =
2255{
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"
2269};
2270
2271static _str defsetups[] =
2272{
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"
2292};
2293
2294static _str defsetupstab8[] =
2295{
2296 "def-setup-c"
2297};
2298
2299
2300static void k_styles_setindent(int indent, int iBraceStyle, boolean iWithTabs = false)
2301{
2302 if (iBraceStyle < 1 || iBraceStyle > 3)
2303 {
2304 message('k_styles_setindent: iBraceStyle is bad (=' :+ iBraceStyle :+ ')');
2305 iBraceStyle = 2;
2306 }
2307
2308 /*
2309 * def-options for extentions known to have that info.
2310 */
2311 int i;
2312 for (i = 0; i < defoptions._length(); i++)
2313 {
2314 int idx = find_index(defoptions[i], MISC_TYPE);
2315 if (!idx)
2316 continue;
2317
2318 parse name_info(idx) with syntax_indent o2 o3 o4 flags indent_fl o7 indent_case rest;
2319
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 */
2326
2327 sNewOptions = indent' 'o2' 'o3' 'o4' 'flags' 'indent_fl' 'o7' 'indent_case' 'rest;
2328 set_name_info(idx, sNewOptions);
2329 _config_modify |= CFGMODIFY_DEFDATA;
2330 }
2331
2332 /*
2333 * def-setup for known extentions.
2334 */
2335 for (i = 0; i < defsetups._length(); i++)
2336 {
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);
2342
2343 /*
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;
2350
2351 indent_with_tabs = 0; /* Indent with tabs */
2352
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;
2360
2361 /* Set new indent */
2362 tabs = '+'indent;
2363 */
2364
2365 sNewSetup = sSetup;
2366
2367 /* Set new indent */
2368 if (pos('TABS=', sNewSetup) > 0)
2369 {
2370 /*
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...
2374 */
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;
2382
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
2388 }
2389
2390 /* Set indent with tabs flag. */
2391 if (pos('IWT=', sNewSetup) > 0)
2392 {
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
2398 }
2399
2400 /* Do the real changes */
2401 set_name_info(idx, sNewSetup);
2402 _config_modify |= CFGMODIFY_DEFDATA;
2403 _update_buffers(sExt);
2404 }
2405}
2406
2407
2408/**
2409 * Takes necessary steps to convert a string to integer.
2410 */
2411static int k_style_emacs_var_integer(_str sVal)
2412{
2413 int i = (int)sVal;
2414 //say 'k_style_emacs_var_integer('sVal') -> 'i;
2415 return (int)sVal;
2416}
2417
2418
2419/**
2420 * Sets a Emacs style variable.
2421 */
2422static int k_style_emacs_var(_str sVar, _str sVal)
2423{
2424 /* check input. */
2425 if (sVar == '' || sVal == '')
2426 return -1;
2427 //say 'k_style_emacs_var: 'sVar'='sVal;
2428
2429 /*
2430 * Unpack the mode style parameters.
2431 */
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')
2437 {
2438 parse sStyle with iMinAbbrivation sRes0 iBeginEndStyle fIndent1stLevel sRes1 iSwitchStyle sRest;
2439 iIndentAmount = p_SyntaxIndent;
2440 }
2441 else /* C */
2442 parse sStyle with iIndentAmount fExpansion iMinAbbrivation fIndentAfterOpenParen iBeginEndStyle fIndent1stLevel iMainStyle iSwitchStyle sRest;
2443
2444
2445 /*
2446 * Process the variable.
2447 */
2448 switch (sVar)
2449 {
2450 case 'mode':
2451 case 'Mode':
2452 {
2453 switch (sVal)
2454 {
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;
2466
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;
2474
2475 default:
2476 message('emacs mode "'sVal'" is not known to us');
2477 return -3;
2478 }
2479 break;
2480 }
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 . +)
2496 ))
2497 (c-special-indent-hook . c-gnu-impose-minimum)
2498 (c-block-comment-prefix . "")
2499 )
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 . +)
2508 ))
2509 )
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)
2520 ))
2521 )
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 . +)
2529 ))
2530 )
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 . +)
2559 ))
2560 )
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)
2573 ))
2574 )
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 . +)
2588 ))
2589 )
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 . +)
2598 ))
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)
2605 ))
2606 (c-block-comment-prefix . "")
2607 )
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)
2625 ))
2626 )
2627 )
2628*/
2629
2630 case 'c-file-style':
2631 case 'c-indentation-style':
2632 switch (sVal)
2633 {
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;
2644
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;
2655
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;
2665
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;
2674
2675 default:
2676 message('emacs "'sVar'" value "'sVal'" is not known to us.');
2677 return -3;
2678 }
2679 break;
2680
2681 case 'c-label-offset':
2682 {
2683 int i = k_style_emacs_var_integer(sVal);
2684 if (i >= -16 && i <= 16)
2685 {
2686 if (i == -p_SyntaxIndent)
2687 iSwitchStyle = 0;
2688 else
2689 iSwitchStyle = 1;
2690 }
2691 break;
2692 }
2693
2694
2695 case 'indent-tabs-mode':
2696 p_indent_with_tabs = sVal == 't';
2697 break;
2698
2699 case 'c-indent-level':
2700 case 'c-basic-offset':
2701 {
2702 int i = k_style_emacs_var_integer(sVal);
2703 if (i > 0 && i <= 16)
2704 {
2705 iIndentAmount = i;
2706 p_SyntaxIndent = i;
2707 }
2708 else
2709 {
2710 message('emacs "'sVar'" value "'sVal'" is out of range.');
2711 return -4;
2712 }
2713 break;
2714 }
2715
2716 case 'tab-width':
2717 {
2718 int i = k_style_emacs_var_integer(sVal);
2719 if (i > 0 && i <= 16)
2720 p_tabs = '+'i;
2721 else
2722 {
2723 message('emacs "'sVar'" value "'sVal'" is out of range.');
2724 return -4;
2725 }
2726 break;
2727 }
2728
2729 case 'nuke-trailing-whitespace-p':
2730 {
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)
2736 {
2737 if (sVal == 't')
2738 set_name_info(idx, "saveoptions: +S");
2739 else
2740 set_name_info(idx, "saveoptions: -S");
2741 say 'sVal=' sVal;
2742 }
2743 break;
2744 }
2745
2746 default:
2747 message('emacs variable "'sVar'" (value "'sVal'") is unknown to us.');
2748 return -5;
2749 }
2750
2751 /*
2752 * Update the style?
2753 */
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)
2762 {
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)
2767 {
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)
2773 {
2774 if (!set_name_info(idx, sNewStyle))
2775 _edit_window().p_index = idx;
2776 }
2777 //say sName'='idx;
2778 }
2779 else
2780 set_name_info(_edit_window().p_index, sNewStyle);
2781 }
2782
2783 return 0;
2784}
2785
2786
2787/**
2788 * Parses a string with emacs variables.
2789 *
2790 * The variables are separated by new line. Junk at
2791 * the start and end of the line is ignored.
2792 */
2793static int k_style_emac_vars(_str sVars)
2794{
2795 /* process them line by line */
2796 int iLine = 0;
2797 while (sVars != '' && iLine++ < 20)
2798 {
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++;
2806
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 != '')
2812 {
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')));
2822 }
2823 }
2824 return 0;
2825}
2826
2827/**
2828 * Searches for Emacs style specification for the current document.
2829 */
2830void k_style_load()
2831{
2832 /* save the position before we start looking around the file. */
2833 typeless saved_pos;
2834 _save_pos2(saved_pos);
2835
2836 int rc;
2837
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'))
2844 {
2845 _str sVars;
2846 sVars = substr(sLine, pos('S1'), pos('1'));
2847 sVars = translate(sVars, "\n", ";");
2848 k_style_emac_vars(sVars);
2849 }
2850
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)
2855 {
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);
2860 }
2861
2862 _restore_pos2(saved_pos);
2863}
2864
2865
2866/**
2867 * Callback function for the event of a new buffer.
2868 *
2869 * This is used to make sure there are no left over per buffer options
2870 * hanging around.
2871 */
2872void _buffer_add_kdev(int buf_id)
2873{
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);
2881}
2882
2883
2884/**
2885 * Callback function for the event of quitting a buffer.
2886 *
2887 * This is used to make sure there are no left over per buffer options
2888 * hanging around.
2889 */
2890void _cbquit2_kdev(int buf_id)
2891{
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);
2897
2898 sName = 'def-kstyledoc-'buf_id;
2899 idx = find_index(sName, MISC_TYPE);
2900 if (idx)
2901 delete_name(idx);
2902}
2903
2904
2905/**
2906 * Called to get save options for the current buffer.
2907 *
2908 * This requires a modified loadsave.e!
2909 */
2910_str _buffer_save_kdev(int buf_id)
2911{
2912 _str sRet = ""
2913 _str sName = 'def-koptions-'buf_id;
2914 int idx = find_index(sName, MISC_TYPE);
2915 if (idx)
2916 {
2917 _str sOptions = strip(name_info(idx));
2918 if (sOptions != "")
2919 parse sOptions with . "saveoptions:" sRet .
2920 message("_buffer_save_kdev: " idx " " sName " " sOptions);
2921 }
2922 return sRet;
2923}
2924
2925
2926
2927/*******************************************************************************
2928* Menu and Menu commands *
2929*******************************************************************************/
2930static int iTimer = 0;
2931static int mhkDev = 0;
2932static int mhCode = 0;
2933static int mhDoc = 0;
2934static int mhLic = 0;
2935static int mhPre = 0;
2936
2937/*
2938 * Creates the kDev menu.
2939 */
2940static k_menu_create()
2941{
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));
2946
2947 /*
2948 * Remove any old menu.
2949 */
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);
2955
2956
2957 /*
2958 * Insert the "kDev" menu.
2959 */
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");
2967
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");
2971
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");
2982
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");
2998
2999 k_menu_doc_style();
3000 k_menu_license();
3001 k_menu_style();
3002}
3003
3004
3005/**
3006 * Change change Id.
3007 */
3008_command k_menu_change()
3009{
3010 sRc = show("-modal k_form_simple_input", "Change ID", skChange);
3011 if (sRc != "\r")
3012 {
3013 skChange = sRc;
3014 k_menu_create();
3015 }
3016}
3017
3018
3019/**
3020 * Change program name.
3021 */
3022_command k_menu_program()
3023{
3024 sRc = show("-modal k_form_simple_input", "Program", skProgram);
3025 if (sRc != "\r")
3026 {
3027 skProgram = sRc;
3028 k_menu_create();
3029 }
3030}
3031
3032
3033/**
3034 * Change company.
3035 */
3036_command k_menu_company()
3037{
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")
3043 {
3044 skCompany = sRc;
3045 k_menu_create();
3046 }
3047}
3048
3049
3050/**
3051 * Change user name.
3052 */
3053_command k_menu_user_name()
3054{
3055 sRc = show("-modal k_form_simple_input", "User Name", skUserName);
3056 if (sRc != "\r" && sRc != '')
3057 {
3058 skUserName = sRc;
3059 k_menu_create();
3060 }
3061}
3062
3063
3064/**
3065 * Change user email.
3066 */
3067_command k_menu_user_email()
3068{
3069 sRc = show("-modal k_form_simple_input", "User e-mail", skUserEmail);
3070 if (sRc != "\r" && sRc != '')
3071 {
3072 skUserEmail = sRc;
3073 k_menu_create();
3074 }
3075}
3076
3077
3078/**
3079 * Change user initials.
3080 */
3081_command k_menu_user_initials()
3082{
3083 sRc = show("-modal k_form_simple_input", "User e-mail", skUserInitials);
3084 if (sRc != "\r" && sRc != '')
3085 {
3086 skUserInitials = sRc;
3087 k_menu_create();
3088 }
3089}
3090
3091
3092
3093/**
3094 * Checks the correct menu item.
3095 */
3096_command void k_menu_doc_style(_str sNewDocStyle = '')
3097{
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);
3103
3104 _menu_set_state(mhDoc, skDocStyle, MF_CHECKED);
3105}
3106
3107
3108/**
3109 * Checks the correct menu item.
3110 */
3111_command void k_menu_license(_str sNewLicense = '')
3112{
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);
3125
3126 _menu_set_state(mhLic, skLicense, MF_CHECKED);
3127}
3128
3129
3130/**
3131 * Check the correct style menu item.
3132 */
3133_command void k_menu_style(_str sNewStyle = '')
3134{
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);
3145
3146 if (sNewStyle != '')
3147 {
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);
3153 }
3154
3155 _menu_set_state(mhCode, skCodeStyle, MF_CHECKED);
3156}
3157
3158
3159/**
3160 * Load a 'preset'.
3161 */
3162_command void k_menu_preset(_str sArgs = '')
3163{
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);
3173
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();
3182}
3183
3184
3185
3186/* future ones..
3187_command k_menu_setcolor()
3188{
3189 createMyColorSchemeAndUseIt();
3190}
3191
3192
3193_command k_menu_setkeys()
3194{
3195 rc = load("d:/knut/VSlickMacros/BoxerDef.e");
3196}
3197
3198_command k_menu_settings()
3199{
3200 mySettings();
3201}
3202*/
3203
3204
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
3237 }
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
3256 }
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
3272 }
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
3288 }
3289}
3290
3291defeventtab k_form_simple_input
3292btnOK.on_create(_str sLabel = '', _str sText = '')
3293{
3294 p_active_form.p_caption = sLabel;
3295 lblLabel.p_caption = sLabel;
3296 entText.p_text = sText;
3297}
3298
3299btnOK.lbutton_up()
3300{
3301 sText = entText.p_text;
3302 p_active_form._delete_window(sText);
3303}
3304btnCancel.lbutton_up()
3305{
3306 sText = entText.p_text;
3307 p_active_form._delete_window("\r");
3308}
3309
3310
3311
3312/**
3313 * Module initiation.
3314 */
3315definit()
3316{
3317 /* do cleanup. */
3318 for (i = 0; i < 200; i++)
3319 {
3320 index = name_match("def-koptions-", 1, MISC_TYPE);
3321 if (!index)
3322 break;
3323 delete_name(index);
3324 }
3325
3326 /* do init */
3327 k_styles_create();
3328 k_menu_create();
3329 iTimer = _set_timer(1000, k_menu_create, "timer");
3330 /* createMyColorSchemeAndUseIt();*/
3331}
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