1 /* $Id$
-*- tab
-width
: 4 c
-indent
-level
: 4 -*- */
3 * Visual SlickEdit Documentation Macros
.
7 * Copyright (c
) 1999-2010 knut st
. osmundsen
<bird
-kBuild
-spamx@anduin
.net
>
9 * This file
is part of kBuild
.
11 * kBuild
is free software
; you can redistribute it
and/or modify
12 * it under the terms of the GNU General Public License
as published by
13 * the Free Software Foundation
; either version
3 of the License
, or
14 * (at your option
) any later version
.
16 * kBuild
is distributed in the hope that it will be useful
,
17 * but WITHOUT ANY WARRANTY
; without even the implied warranty of
18 * MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE
. See the
19 * GNU General Public License for more details
.
21 * You should have received a copy of the GNU General Public License
22 * along with kBuild
. If not, see
<http
://www
.gnu
.org
/licenses
/>
28 * This define the following keys
:
29 *---------------------------------
30 * Ctrl
+Shift
+C
: Class description box
.
31 * Ctrl
+Shift
+F
: Function
/method description box
.
32 * Ctrl
+Shift
+M
: Module(file
) description box
33 * Ctrl
+Shift
+O
: One
-liner (comment
)
35 * Ctrl
+Shift
+G
: Global box
36 * Ctrl
+Shift
+H
: Header box
37 * Ctrl
+Shift
+E
: Exported Symbols
38 * Ctrl
+Shift
+I
: Internal function box
39 * Ctrl
+Shift
+K
: Const
/macro box
40 * Ctrl
+Shift
+S
: Struct
/Typedef box
42 * Ctrl
+Shift
+A
: Signature
+Date marker
43 * Ctrl
+Shift
+P
: Mark line
as change by me
45 * Ctrl
+Shift
+T
: Update project tagfile
.
46 * Ctrl
+Shift
+L
: Load document variables
.
48 * Ctrl
+Shift
+B
: KLOGENTRYX(..)
49 * Ctrl
+Shift
+E
: KLOGEXIT(..)
50 * Ctrl
+Shift
+N
: Do kLog stuff for the
current file
. No questions
.
51 * Ctrl
+Shift
+Q
: Do kLog stuff for the
current file
. Ask a lot of questions
.
53 * Remember to set the correct sOdin32UserName
, sOdin32UserEmail
and sOdin32UserInitials
54 * before compiling
and loading the macros into Visual SlickEdit
.
56 * These macros are compatible with both
3.0(c
) and 4.0(b
).
59 defeventtab default_keys
60 def
'C-S-A' = k_signature
61 //def
'C-S-C' = k_javadoc_classbox
63 def
'C-S-E' = k_box_exported
64 def
'C-S-F' = k_javadoc_funcbox
65 def
'C-S-G' = k_box_globals
66 def
'C-S-H' = k_box_headers
67 def
'C-S-I' = k_box_intfuncs
68 def
'C-S-K' = k_box_consts
70 def
'C-S-M' = k_javadoc_moduleheader
71 def
'C-S-O' = k_oneliner
72 def
'C-S-P' = k_mark_modified_line
73 def
'C-S-S' = k_box_structs
74 def
'C-S-T' = k_rebuild_tagfile
75 def
'C-S-L' = k_style_load
76 def
'C-S-\' = k_newline_escape_selection
79 //def
'C-S-Q' = klib_klog_file_ask
80 //def
'C-S-N' = klib_klog_file_no_ask
81 //def
'C-S-1' = klib_klogentry
82 //def
'C-S-3' = klib_klogexit
85 //MARKER
. Editor searches for this line
!
86 #pragma
option(redeclvars
, on
)
88 #ifndef VS_TAGDETAIL_context_args
89 /* newer vslick version
. */
91 //#pragma
option(strict
,on
)
92 /*#
else: Version
4.0 (OS
/2) */
96 #define KDEV_WITH_MENU
99 /* Remeber to change these
! */
100 static _str skUserInitials
= "bird";
101 static _str skUserName
= "knut st. osmundsen";
102 static _str skUserEmail
= "bird-kBuild-spamx@anduin.net";
105 /*******************************************************************************
107 *******************************************************************************/
108 static _str skCodeStyle
= 'Opt2Ind4'; /* coding style scheme
. */
109 static _str skDocStyle
= 'javadoc';/* options
: javadoc
, */
110 static _str skLicense
= 'GPLv3'; /* options
: GPL
, LGPL
, Odin32
, Confidential
, ++ */
111 static _str skCompany
= ''; /* empty
or company name for copyright
*/
112 static _str skProgram
= ''; /* Current program name
- used by
[L
]GPL
*/
113 static _str skChange
= ''; /* Current change identifier
. */
115 static int ikStyleWidth
= 130; /* The page width of the style
. */
116 static
boolean fkStyleFullHeaders
= false; /* false: omit some tags
. */
117 static int ikStyleOneliner
= 45; /* The oneline comment column
. */
118 static int ikStyleModifyMarkColumn
= 105;
119 static
boolean fkStyleBoxTag
= false; /* true: Include tag in k_box_start
. */
122 /*******************************************************************************
123 * Internal Functions
*
124 *******************************************************************************/
127 * @returns ISO formatted date
.
136 j
= pos("/", date
, i
+1);
137 _str month
= substr(date
, 1, i
-1);
138 if (length(month
) == 1) month
= '0'month
;
139 _str day
= substr(date
, i
+1, j
-i
-1);
140 if (length(day
) == 1) day
= '0'day
;
141 _str year
= substr(date
, j
+1);
142 return year
"-"month
"-"day
;
147 * Get the
current year
.
148 * @returns
Current year
string.
152 _str date
= _date('U');
153 return
substr(date
, pos("/",date
, pos("/",date
)+1)+1, 4);
158 * Aligns a value up to a given alignment
.
160 static int
k_alignup(int iValue
, iAlign
)
164 message('k_alignup: iValue='iValue
' iAlign='iAlign
);
167 return ((iValue intdiv iAlign
) + 1) * iAlign
;
172 * Reads the comment setup for this lexer
/extension
.
174 * @returns Success indicator
.
175 * @param sLeft Left comment
. (output
)
176 * @param sRight Right comment
. (output
)
177 * @param iColumn Comment mark column
. (1-based
) (output
)
178 * @param sExt The extension to lookup defaults to the
current one
.
179 * @param sLexer The lexer to lookup defaults to the
current one
.
180 * @remark This should be exported
from box
.e
, but unfortunately it isn
't.
182 static boolean k_commentconfig(_str &sLeft, _str &sRight, int &iColumn, _str sExt = p_extension, _str sLexer = p_lexer_name)
189 * Get comment setup from the lexer.
195 #if __VERSION__ >= 21.0
196 COMMENT_TYPE aComments[];
197 GetComments(aComments, "M", sLexer);
198 for (i = 0; i < aComments._length(); i++)
199 # if __VERSION__ >= 22.0
200 if (aComments[i].type != 'doc_comment
')
202 if (!aComments[i].isDocumentation)
205 sLeft = aComments[i].delim1;
206 sRight = aComments[i].delim2;
207 iColumn = aComments[i].startcol;
208 if (sLeft != '' && sRight != '')
212 # if __VERSION__ >= 14.0
213 _str aComments[] = null;
214 GetComments(aComments, "mlcomment", sLexer);
215 for (i = 0; i < aComments._length(); i++)
216 if (pos("documentation", aComments[i]) <= 0)
218 sLine = aComments[i];
223 rc = _ini_get_value(slick_path_search("user.vlx"), sLexer, 'mlcomment
', sLine);
225 rc = _ini_get_value(slick_path_search("vslick.vlx"), sLexer, 'mlcomment
', sLine);
229 sLeft = strip(word(sLine, 1));
230 sRight = strip(word(sLine, 2));
231 if (sLeft != '' && sRight != '')
236 /* failed, try single line. */
237 #if __VERSION__ >= 21.0
238 GetComments(aComments, "L", sLexer);
239 for (i = 0; i < aComments._length(); i++)
240 # if __VERSION__ >= 22.0
241 if (aComments[i].type != 'doc_comment
')
243 if (!aComments[i].isDocumentation)
246 sLeft = aComments[i].delim1;
248 iColumn = aComments[i].startcol;
253 # if __VERSION__ >= 14.0
254 GetComments(aComments, "linecomment", sLexer)
255 for (i = 0; i < aComments._length(); i++)
256 if (pos("documentation", aComments[i]) <= 0)
258 sLine = aComments[i];
263 rc = _ini_get_value(slick_path_search("user.vlx"), sLexer, 'linecomment
', sLine);
265 rc = _ini_get_value(slick_path_search("vslick.vlx"), sLexer, 'linecomment
', sLine);
269 sLeft = strip(word(sLine, 1));
272 _str sTmp = word(sLine, 2);
282 * Read the nonboxchars and determin user or default box.ini.
284 _str sFile = slick_path_search("ubox.ini");
285 boolean frc = _ini_get_value(sFile, sExt, 'nonboxchars
', sLine);
288 sFile = slick_path_search("box.ini");
289 frc = _ini_get_value(sFile, sExt, 'nonboxchars
', sLine);
296 sLeft = strip(eq_name2value('left
',sLine));
297 if (sLeft == '\e
') sLeft = '';
298 sRight = strip(eq_name2value('right
',sLine));
299 if (sRight == '\e
') sRight = '';
301 /* Read comment column too */
302 frc = _ini_get_value(sFile, sExt, 'comment_col
', sLine);
305 iColumn = eq_name2value('comment_col
', sLine);
306 if (iColumn == '\e
') iColumn = 0;
322 * Checks if current file only support line comments.
323 * @returns True / False.
324 * @remark Use builtin extension stuff!
326 static boolean k_line_comment()
331 boolean fLineComment = false;
332 if (k_commentconfig(sLeft, sRight, iColumn))
333 fLineComment = (sRight == '' || iColumn > 0);
339 #define KIC_CURSOR_BEFORE 1
340 #define KIC_CURSOR_AFTER 2
341 #define KIC_CURSOR_AT_END 3
344 * Insert a comment at current or best fitting position in the text.
345 * @param sStr The comment to insert.
346 * @param iCursor Where to put the cursor.
347 * @param iPosition Where to start the comment.
348 * Doesn't apply to column based source
.
349 * -1 means at cursor position
. (default
)
350 * >0 means at
end of line
, but
not before this
column (1-based
).
351 * This also
implies a min of one space to EOL
.
353 void
k_insert_comment(_str sStr
, int iCursor
, int iPosition
= -1)
358 if (!k_commentconfig(sLeft
, sRight
, iColumn
))
360 sLeft
= '/*'; sRight
= '*/'; iColumn
= 0;
366 * not column based source
369 /* position us first
*/
375 } while (p_col
< iPosition
);
378 /* insert comment saving the position for _BEFORE
. */
380 _insert_text(sLeft
:+' ':+sStr
);
381 if (iCursor
== KIC_CURSOR_AT_END
)
383 /* right comment delimiter?
*/
385 _insert_text(' ':+sRight
);
389 if (p_col
>= iColumn
)
391 do { _insert_text(" "); } while (p_col
< iColumn
);
392 if (iCursor
== KIC_CURSOR_BEFORE
)
394 _insert_text(sLeft
:+' ':+sStr
);
395 if (iCursor
== KIC_CURSOR_AT_END
)
400 if (iCursor
!= KIC_CURSOR_AFTER
)
406 * Gets the comment
prefix or postfix
.
407 * @returns Comment
prefix or postfix
.
408 * @param fRight
If clear left comment
string - default
.
409 * If set right comment
string.
411 static _str
k_comment(boolean fRight
= false)
415 _str sComment
= '/*';
416 if (k_commentconfig(sLeft
, sRight
, iColumn
))
417 sComment
= (!fRight || iColumn
> 0 ? sLeft
: sRight
);
419 return
strip(sComment
);
423 /*******************************************************************************
425 *******************************************************************************/
428 * Inserts the first line in a box
.
429 * @param sTag
Not used
- box tag
.
431 static void
k_box_start(sTag
)
435 if (!k_commentconfig(sLeft
, sRight
, iColumn
))
439 while (p_col
< iColumn
)
443 if (sTag
!= '' && fkStyleBoxTag
)
445 if (substr(sText
, length(sText
)) != '*')
451 for (i
= length(sText
); i
<= ikStyleWidth
- p_col
; i
++)
460 * Places a
string, sStr
, into a line started
and ended by
'*'.
461 * @param sStr Text to have between the
'*'s
.
463 static void
k_box_line(_str sStr
)
467 if (!k_commentconfig(sLeft
, sRight
, iColumn
))
470 while (p_col
< iColumn
)
474 if (k_line_comment())
476 if (sText
== '' ||
substr(sText
, length(sText
)) != '*')
481 for (i
= length(sText
); i
< p_SyntaxIndent
; i
++)
486 for (i
= length(sText
) + 1; i
<= ikStyleWidth
- p_col
; i
++)
488 sText
= sText
:+"*\n";
495 * Inserts the last line in a box
.
497 static void
k_box_end()
501 if (!k_commentconfig(sLeft
, sRight
, iColumn
))
504 while (p_col
< iColumn
)
508 if (k_line_comment())
510 for (i
= length(sText
) + length(sRight
); i
<= ikStyleWidth
- p_col
; i
++)
512 sText
= sText
:+sRight
:+"\n";
519 /*******************************************************************************
520 * FUNCTION
AND CODE PARSERS
*
521 *******************************************************************************/
523 * Moves cursor to nearest function start
.
527 static int
k_func_goto_nearest_function()
529 boolean fFix
= false; /* cursor at function fix
. (last function
) */
530 int cur_line
= p_line
;
539 if (!prev_proc(1) && p_line
== cur_line
)
541 _restore_pos2(org_pos
);
544 _restore_pos2(org_pos
);
549 p_col
++; /* fixes problem with single function files
. */
556 if (!next_proc(1) && p_line
== cur_line
)
558 _restore_pos2(org_pos
);
561 _restore_pos2(org_pos
);
566 if (prev_line
!= -1 && (next_line
== -1 || cur_line
- prev_line
<= next_line
- cur_line
))
574 if (next_line
!= -1 && (prev_line
== -1 || cur_line
- prev_line
> next_line
- cur_line
))
580 _restore_pos2(org_pos
);
586 * Check if nearest function
is a prototype
.
587 * @returns
True if function prototype
.
588 * False if not function prototype
.
590 static
boolean k_func_prototype()
593 * Check if this
is a
real function implementation
.
597 if (!k_func_goto_nearest_function())
599 int proc_line
= p_line
;
601 if (!k_func_searchcode("{"))
604 if (p_line
!= proc_line
)
606 _restore_pos2(procpos
);
611 _restore_pos2(procpos
);
618 * Gets the name fo the
current function
.
619 * @returns The
current function name
.
621 static _str
k_func_getfunction_name()
623 _str sFunctionName
= current_proc();
626 //say
'functionanme='sFunctionName
;
627 return sFunctionName
;
632 * Goes to the neares function
and gets its parameters
.
633 * @remark Should be reimplemented to use
tags (if someone can figure out how to query that stuff
).
635 static _str
k_func_getparams()
641 * Try use the tags first
.
643 _UpdateContext(true);
644 int context_id
= tag_current_context();
647 k_func_goto_nearest_function();
648 context_id
= tag_current_context();
654 tag_get_detail2(VS_TAGDETAIL_context_args
, context_id
, args
);
655 tag_get_detail2(VS_TAGDETAIL_context_type
, context_id
, type
);
656 if (tag_tree_type_is_func(type
))
658 //caption
= tag_tree_make_caption_fast(VS_TAGMATCH_context
,context_id
,true,true,false);
662 * Go to nearest function
.
664 if ( !k_func_goto_nearest_function()
665 && !k_func_searchcode("(") /* makes some assumptions
. */
672 _save_pos2(posStart
);
673 long offStart
= _QROffset();
674 if (!find_matching_paren())
676 long offEnd
= _QROffset();
677 _restore_pos2(posStart
);
679 _str sParamsRaw
= strip(get_text((int
)(offEnd
- offStart
- 1)));
683 * Remove new lines
and double spaces within params
.
689 for (i
= 1, chPrev
= ' '; i
<= length(sParamsRaw
); i
++)
691 _str ch
= substr(sParamsRaw
, i
, 1);
696 if (ch
== " " && chPrev
== " ")
699 if ((ch
:== "\n") ||
(ch
:== "\r") ||
(ch
:== "\t"))
706 if (ch
== ',' && chPrev
== ' ')
708 sParams
= substr(sParams
, 1, length(sParams
) - 1);
714 sParams
= sParams
:+ ' * ';
716 sParams
= sParams
:+ '* ';
721 sParams
= sParams
:+ ch
;
727 sParams
= strip(sParams
);
728 if (sParams
== 'void' || sParams
== 'VOID')
730 _restore_pos2(org_pos
);
734 message("find_matchin_paren failed");
737 _restore_pos2(org_pos
);
744 * Enumerates the parameters to the function
.
745 * @param sParams Parameter
string from k_func_getparams
.
746 * @param iParam The
index (0-based
) of the parameter to get
.
747 * @param sType Type
. (output
)
748 * @param sName Name
. (output
)
749 * @param sDefault Default value
. (output
)
750 * @remark Doesn
't perhaps handle function pointers very well (I think)?
751 * @remark Should be reimplemented to use tags (if someone can figure out how to query that stuff).
753 static int k_func_enumparams(_str sParams, int iParam, _str &sType, _str &sName, _str &sDefault)
760 sType = sName = sDefault = "";
762 /* no use working on empty string! */
763 if (length(sParams) == 0)
766 /* find the parameter in question */
767 for (iStartParam = i = 1, iParLevel = iCurParam = 0; i <= length(sParams); i++)
769 _str ch = substr(sParams, i, 1);
770 if (ch == ',' && iParLevel == 0)
772 /* is it this parameter ? */
773 if (iParam == iCurParam)
785 /* did we find the parameter? */
786 if (iParam == iCurParam)
787 { /* (yeah, we did!) */
788 _str sArg = strip(substr(sParams, iStartParam, i - iStartParam));
789 /* remove M$ stuff */
790 sArg = stranslate(sArg, "", "IN", "E");
791 sArg = stranslate(sArg, "", "OUT", "E");
792 sArg = stranslate(sArg, "", "OPTIONAL", "E");
795 /* lazy approach, which doens't support function types
*/
797 if (pos('=', sParams
) > 0) /* default
*/
799 sDefault
= strip(substr(sParams
, pos('=', sParams
) + 1));
800 sArg
= strip(substr(sArg
, 1, pos('=', sParams
) - 1));
803 for (i
= length(sArg
); i
> 1; i
--)
805 _str ch
= substr(sArg
, i
, 1);
806 if ( !(ch
>= 'a' && ch
<= 'z')
807 && !(ch
>= 'A' && ch
<= 'Z')
808 && !(ch
>= '0' && ch
<= '9')
809 && ch
!= '_' && ch
!= '$')
814 sName
= strip(substr(sArg
, i
+ 1));
815 sType
= strip(substr(sArg
, 1, i
));
825 * Counts the parameters to the function
.
826 * @param sParams Parameter
string from k_func_getparams
.
827 * @remark Should be reimplemented to use
tags (if someone can figure out how to query that stuff
).
829 static int
k_func_countparams(_str sParams
)
834 _str sType
= "", sName
= "", sDefault
= "";
836 /* check for
0 parameters
*/
837 if (length(sParams
) == 0)
840 /* find the parameter in question
*/
841 for (i
= 1, iParLevel
= iCurParam
= 0; i
<= length(sParams
); i
++)
843 _str ch
= substr(sParams
, i
, 1);
844 if (ch
== ',' && iParLevel
== 0)
854 return iCurParam
+ 1;
859 * Gets the return type
.
861 static _str
k_func_getreturntype(boolean fPureType
= false)
867 * Go to nearest function
.
869 if (!k_func_goto_nearest_function())
872 * Return type
is from function start to function name
...
875 _save_pos2(posStart
);
876 long offStart
= _QROffset();
878 if (!k_func_searchcode("(")) /* makes some assumptions
. */
881 long offEnd
= _QROffset();
882 _restore_pos2(posStart
);
883 _str sTypeRaw
= strip(get_text((int
)(offEnd
- offStart
)));
885 //say
'sTypeRaw='sTypeRaw
;
887 * Remove static
, inline
, _Optlink
, stdcall
, EXPENTRY etc
.
891 sTypeRaw
= stranslate(sTypeRaw
, "", "__static__", "I");
892 sTypeRaw
= stranslate(sTypeRaw
, "", "__static", "I");
893 sTypeRaw
= stranslate(sTypeRaw
, "", "static__", "I");
894 sTypeRaw
= stranslate(sTypeRaw
, "", "static", "I");
895 sTypeRaw
= stranslate(sTypeRaw
, "", "__inline__", "I");
896 sTypeRaw
= stranslate(sTypeRaw
, "", "__inline", "I");
897 sTypeRaw
= stranslate(sTypeRaw
, "", "inline__", "I");
898 sTypeRaw
= stranslate(sTypeRaw
, "", "inline", "I");
899 sTypeRaw
= stranslate(sTypeRaw
, "", "EXPENTRY", "I");
900 sTypeRaw
= stranslate(sTypeRaw
, "", "_Optlink", "I");
901 sTypeRaw
= stranslate(sTypeRaw
, "", "__stdcall", "I");
902 sTypeRaw
= stranslate(sTypeRaw
, "", "__cdecl", "I");
903 sTypeRaw
= stranslate(sTypeRaw
, "", "_cdecl", "I");
904 sTypeRaw
= stranslate(sTypeRaw
, "", "cdecl", "I");
905 sTypeRaw
= stranslate(sTypeRaw
, "", "__PASCAL", "I");
906 sTypeRaw
= stranslate(sTypeRaw
, "", "_PASCAL", "I");
907 sTypeRaw
= stranslate(sTypeRaw
, "", "PASCAL", "I");
908 sTypeRaw
= stranslate(sTypeRaw
, "", "__Far32__", "I");
909 sTypeRaw
= stranslate(sTypeRaw
, "", "__Far32", "I");
910 sTypeRaw
= stranslate(sTypeRaw
, "", "Far32__", "I");
911 sTypeRaw
= stranslate(sTypeRaw
, "", "_Far32_", "I");
912 sTypeRaw
= stranslate(sTypeRaw
, "", "_Far32", "I");
913 sTypeRaw
= stranslate(sTypeRaw
, "", "Far32_", "I");
914 sTypeRaw
= stranslate(sTypeRaw
, "", "Far32", "I");
915 sTypeRaw
= stranslate(sTypeRaw
, "", "__far", "I");
916 sTypeRaw
= stranslate(sTypeRaw
, "", "_far", "I");
917 sTypeRaw
= stranslate(sTypeRaw
, "", "far", "I");
918 sTypeRaw
= stranslate(sTypeRaw
, "", "__near", "I");
919 sTypeRaw
= stranslate(sTypeRaw
, "", "_near", "I");
920 sTypeRaw
= stranslate(sTypeRaw
, "", "near", "I");
921 sTypeRaw
= stranslate(sTypeRaw
, "", "__loadds__", "I");
922 sTypeRaw
= stranslate(sTypeRaw
, "", "__loadds", "I");
923 sTypeRaw
= stranslate(sTypeRaw
, "", "loadds__", "I");
924 sTypeRaw
= stranslate(sTypeRaw
, "", "_loadds_", "I");
925 sTypeRaw
= stranslate(sTypeRaw
, "", "_loadds", "I");
926 sTypeRaw
= stranslate(sTypeRaw
, "", "loadds_", "I");
927 sTypeRaw
= stranslate(sTypeRaw
, "", "loadds", "I");
928 sTypeRaw
= stranslate(sTypeRaw
, "", "__loades__", "I");
929 sTypeRaw
= stranslate(sTypeRaw
, "", "__loades", "I");
930 sTypeRaw
= stranslate(sTypeRaw
, "", "loades__", "I");
931 sTypeRaw
= stranslate(sTypeRaw
, "", "_loades_", "I");
932 sTypeRaw
= stranslate(sTypeRaw
, "", "_loades", "I");
933 sTypeRaw
= stranslate(sTypeRaw
, "", "loades_", "I");
934 sTypeRaw
= stranslate(sTypeRaw
, "", "loades", "I");
935 sTypeRaw
= stranslate(sTypeRaw
, "", "WIN32API", "I");
936 sTypeRaw
= stranslate(sTypeRaw
, "", "WINAPI", "I");
937 sTypeRaw
= stranslate(sTypeRaw
, "", "LDRCALL", "I");
938 sTypeRaw
= stranslate(sTypeRaw
, "", "KRNLCALL", "I");
939 sTypeRaw
= stranslate(sTypeRaw
, "", "__operator__", "I"); /* operator fix
*/
940 sTypeRaw
= stranslate(sTypeRaw
, "", "__operator", "I"); /* operator fix
*/
941 sTypeRaw
= stranslate(sTypeRaw
, "", "operator__", "I"); /* operator fix
*/
942 sTypeRaw
= stranslate(sTypeRaw
, "", "operator", "I"); /* operator fix
*/
943 sTypeRaw
= stranslate(sTypeRaw
, "", "IN", "E");
944 sTypeRaw
= stranslate(sTypeRaw
, "", "OUT", "E");
945 sTypeRaw
= stranslate(sTypeRaw
, "", "OPTIONAL", "E");
949 * Remove new lines
and double spaces within params
.
955 for (i
= 1, chPrev
= ' '; i
<= length(sTypeRaw
); i
++)
957 _str ch
= substr(sTypeRaw
, i
, 1);
962 if (ch
== " " && chPrev
== " ")
965 if ((ch
:== "\n") ||
(ch
:== "\r") ||
(ch
:== "\t"))
972 if (ch
== ',' && chPrev
== ' ')
974 sType
= substr(sType
, 1, length(sType
) - 1);
980 sType
= sType
:+ ' * ';
982 sType
= sType
:+ '* ';
993 sType
= strip(sType
);
995 _restore_pos2(org_pos
);
999 message('k_func_getreturntype: can''t find ''(''.');
1002 _restore_pos2(org_pos
);
1008 * Search for some piece of code
.
1010 static int
k_func_searchcode(_str sSearchString
, _str sOptions
= "E+")
1013 rc
= search(sSearchString
, sOptions
);
1014 while (!rc
&& !k_func_in_code())
1017 rc
= search(sSearchString
, sOptions
);
1024 * Checks
if cursor
is in code
or in comment
.
1025 * @return
True if cursor in code
.
1027 static
boolean k_func_in_code()
1029 typeless searchsave
;
1030 _save_pos2(searchsave
);
1031 boolean fRc
= !_in_comment();
1032 _restore_pos2(searchsave
);
1038 * Gets the next piece of code
.
1040 static _str
k_func_get_next_code_text()
1042 typeless searchsave
;
1043 _save_pos2(searchsave
);
1044 _str ch
= k_func_get_next_code_text2();
1045 _restore_pos2(searchsave
);
1051 * Checks
if there
is more code on the line
.
1053 static
boolean k_func_more_code_on_line()
1056 int curline
= p_line
;
1057 typeless searchsave
;
1058 _save_pos2(searchsave
);
1059 k_func_get_next_code_text2();
1060 fRc
= curline
== p_line
;
1061 _restore_pos2(searchsave
);
1068 * Gets the next piece of code
.
1069 * Doesn
't preserver cursor position.
1071 static _str k_func_get_next_code_text2()
1076 int curcol = ++p_col;
1078 if (p_col <= curcol)
1087 //say ch ' ('_asc(ch)')';
1088 while (ch == "#") /* preprocessor stuff */
1093 //say ch ' ('_asc(ch)')';
1096 } while (ch :== ' ' || ch :== "\t" || ch :== "\n" || ch :== "\r" || !k_func_in_code());
1104 /*******************************************************************************
1105 * JAVA DOC STYLED WORKERS *
1106 *******************************************************************************/
1108 /** starts a javadoc documentation box. */
1109 static void k_javadoc_box_start(_str sStr = '', boolean fDouble = true)
1113 if (!k_commentconfig(sLeft, sRight, iColumn))
1117 while (p_col < iColumn)
1122 sText = sLeft:+substr(sLeft, length(sLeft), 1);
1124 sText = sText:+' ':+sStr;
1125 sText = sText:+"\n";
1127 _insert_text(sText);
1130 /** inserts a new line in a javadoc documentation box. */
1131 static void k_javadoc_box_line(_str sStr = '', int iPadd = 0, _str sStr2 = '', int iPadd2 = 0, _str sStr3 = '')
1135 if (!k_commentconfig(sLeft, sRight, iColumn))
1138 while (p_col < iColumn)
1142 if (k_line_comment())
1147 sText = ' ':+substr(sLeft, length(sLeft));
1151 sText = sText:+' ':+sStr;
1155 for (i = length(sText); i < iPadd; i++)
1159 sText = sText:+sStr2;
1163 for (i = length(sText); i < iPadd2; i++)
1167 sText = sText:+sStr3;
1170 sText = sText:+"\n";
1172 _insert_text(sText);
1175 /** ends a javadoc documentation box. */
1176 static void k_javadoc_box_end()
1180 if (!k_commentconfig(sLeft, sRight, iColumn))
1183 while (p_col < iColumn)
1187 if (k_line_comment())
1192 /*if (substr(sText, 1, 1) != '*')
1193 sText = '*':+sText;*/
1196 sText = sText:+"\n";
1198 _insert_text(sText);
1203 * Write a Javadoc styled classbox.
1205 void k_javadoc_classbox()
1208 int iPadd = k_alignup(12, p_SyntaxIndent);
1210 k_javadoc_box_start();
1211 iCursorLine = p_RLine;
1212 k_javadoc_box_line(' ');
1214 if (fkStyleFullHeaders)
1216 k_javadoc_box_line('@shortdesc
', iPadd);
1217 k_javadoc_box_line('@dstruct
', iPadd);
1218 k_javadoc_box_line('@version
', iPadd);
1219 k_javadoc_box_line('@verdesc
', iPadd);
1221 k_javadoc_box_line('@author
', iPadd, skUserName ' <' skUserEmail '>');
1222 k_javadoc_box_line('@approval
', iPadd);
1223 k_javadoc_box_end();
1225 up(p_RLine - iCursorLine);
1232 * Javadoc - functionbox(/header).
1234 void k_javadoc_funcbox()
1239 int iPadd = k_alignup(11, p_SyntaxIndent);
1241 /* look for parameters */
1242 boolean fFoundFn = !k_func_goto_nearest_function();
1245 sArgs = k_func_getparams();
1246 cArgs = k_func_countparams(sArgs);
1249 k_javadoc_box_start();
1250 iCursorLine = p_RLine;
1251 k_javadoc_box_line(' ');
1252 if (file_eq(p_extension, 'asm
') || file_eq(p_extension, 'masm
'))
1253 k_javadoc_box_line('@cproto
', iPadd);
1254 k_javadoc_box_line('@returns
', iPadd);
1258 * Determin parameter description indent.
1262 for (i = 0; i < cArgs; i++)
1264 _str sName, sType, sDefault;
1265 if ( !k_func_enumparams(sArgs, i, sType, sName, sDefault)
1266 && iPadd2 < length(sName))
1267 iPadd2 = length(sName);
1269 iPadd2 = k_alignup((iPadd + iPadd2), p_SyntaxIndent);
1271 iPadd2 = k_alignup(28, p_SyntaxIndent);
1276 for (i = 0; i < cArgs; i++)
1278 _str sName, sType, sDefault;
1279 if (!k_func_enumparams(sArgs, i, sType, sName, sDefault))
1283 sStr3 = '(default
='sDefault')';
1284 k_javadoc_box_line('@param
', iPadd, sName, iPadd2, sStr3);
1287 k_javadoc_box_line('@param
', iPadd);
1291 k_javadoc_box_line('@param
', iPadd);
1293 if (file_eq(p_extension, 'asm
') || file_eq(p_extension, 'masm
'))
1294 k_javadoc_box_line('@uses
', iPadd);
1295 if (fkStyleFullHeaders)
1297 k_javadoc_box_line('@equiv
', iPadd);
1298 k_javadoc_box_line('@time
', iPadd);
1299 k_javadoc_box_line('@sketch
', iPadd);
1300 k_javadoc_box_line('@status
', iPadd);
1301 k_javadoc_box_line('@author
', iPadd, skUserName ' <' skUserEmail '>');
1302 k_javadoc_box_line('@remark
', iPadd);
1304 k_javadoc_box_end();
1306 up(p_RLine - iCursorLine);
1313 * Javadoc module header.
1315 void k_javadoc_moduleheader()
1323 k_insert_comment('$
':+'I
':+'d
: $
', KIC_CURSOR_AT_END, -1);
1327 k_javadoc_box_start('@file
');
1329 iCursorLine = p_RLine;
1330 k_javadoc_box_line();
1331 k_javadoc_box_end();
1333 _insert_text(k_comment() "\n");
1335 if (skLicense == 'Confidential
')
1337 k_javadoc_box_line(skCompany ' confidential
');
1338 k_javadoc_box_line();
1341 if (skCompany != '')
1343 if (skLicense != 'Confidential
')
1344 k_javadoc_box_line('Copyright (C
) ' k_year() ' ' skCompany);
1347 k_javadoc_box_line('Copyright (c
) ' k_year() ' ' skCompany);
1348 k_javadoc_box_line();
1349 k_javadoc_box_line('Author
: ' skUserName' <' skUserEmail '>');
1353 k_javadoc_box_line('Copyright (c
) ' k_year() ' 'skUserName' <' skUserEmail '>');
1354 k_javadoc_box_line();
1355 _str sProg = skProgram;
1359 k_javadoc_box_line('Project Odin Software License can be found in LICENSE
.TXT
.');
1364 k_javadoc_box_line();
1366 sProg = 'This program
';
1369 k_javadoc_box_line('This file
is part of
' sProg '.');
1370 k_javadoc_box_line();
1372 k_javadoc_box_line(sProg ' is free software
; you can redistribute it
and/or modify
');
1373 k_javadoc_box_line('it under the terms of the GNU General Public License
as published by
');
1374 k_javadoc_box_line('the Free Software Foundation
; either version
2 of the License
, or');
1375 k_javadoc_box_line('(at your option
) any later version
.');
1376 k_javadoc_box_line();
1377 k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful
,');
1378 k_javadoc_box_line('but WITHOUT ANY WARRANTY
; without even the implied warranty of
');
1379 k_javadoc_box_line('MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE
. See the
');
1380 k_javadoc_box_line('GNU General Public License for more details
.');
1381 k_javadoc_box_line();
1382 k_javadoc_box_line('You should have received a copy of the GNU General Public License
');
1383 k_javadoc_box_line('along with
' sProg '; if not, write to the Free Software
');
1384 k_javadoc_box_line('Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301 USA
');
1389 k_javadoc_box_line();
1391 sProg = 'This library
';
1394 k_javadoc_box_line('This file
is part of
' sProg '.');
1395 k_javadoc_box_line();
1397 k_javadoc_box_line(sProg ' is free software
; you can redistribute it
and/or');
1398 k_javadoc_box_line('modify it under the terms of the GNU Lesser General Public
');
1399 k_javadoc_box_line('License
as published by the Free Software Foundation
; either
');
1400 k_javadoc_box_line('version
2.1 of the License
, or (at your option
) any later version
.');
1401 k_javadoc_box_line();
1402 k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful
,');
1403 k_javadoc_box_line('but WITHOUT ANY WARRANTY
; without even the implied warranty of
');
1404 k_javadoc_box_line('MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE
. See the GNU
');
1405 k_javadoc_box_line('Lesser General Public License for more details
.');
1406 k_javadoc_box_line();
1407 k_javadoc_box_line('You should have received a copy of the GNU Lesser General Public
');
1408 k_javadoc_box_line('License along with
' sProg '; if not, write to the Free Software
');
1409 k_javadoc_box_line('Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301 USA
');
1414 k_javadoc_box_line();
1416 sProg = 'This program
';
1419 k_javadoc_box_line('This file
is part of
' sProg '.');
1420 k_javadoc_box_line();
1422 k_javadoc_box_line(sProg ' is free software
; you can redistribute it
and/or modify
');
1423 k_javadoc_box_line('it under the terms of the GNU General Public License
as published by
');
1424 k_javadoc_box_line('the Free Software Foundation
; either version
3 of the License
, or');
1425 k_javadoc_box_line('(at your option
) any later version
.');
1426 k_javadoc_box_line();
1427 k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful
,');
1428 k_javadoc_box_line('but WITHOUT ANY WARRANTY
; without even the implied warranty of
');
1429 k_javadoc_box_line('MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE
. See the
');
1430 k_javadoc_box_line('GNU General Public License for more details
.');
1431 k_javadoc_box_line();
1432 k_javadoc_box_line('You should have received a copy of the GNU General Public License
');
1433 k_javadoc_box_line('along with
' sProg '. If not, see
<http
://www
.gnu
.org
/licenses
/>');
1438 k_javadoc_box_line();
1440 sProg = 'This program
';
1443 k_javadoc_box_line('This file
is part of
' sProg '.');
1444 k_javadoc_box_line();
1446 k_javadoc_box_line(sProg ' is free software
; you can redistribute it
and/or');
1447 k_javadoc_box_line('modify it under the terms of the GNU Lesser General Public
');
1448 k_javadoc_box_line('License
as published by the Free Software Foundation
; either
');
1449 k_javadoc_box_line('version
3 of the License
, or (at your option
) any later version
.');
1450 k_javadoc_box_line();
1451 k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful
,');
1452 k_javadoc_box_line('but WITHOUT ANY WARRANTY
; without even the implied warranty of
');
1453 k_javadoc_box_line('MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE
. See the
');
1454 k_javadoc_box_line('GNU Lesser General Public License for more details
.');
1455 k_javadoc_box_line();
1456 k_javadoc_box_line('You should have received a copy of the GNU Lesser General Public License
');
1457 k_javadoc_box_line('along with
' sProg '. If not, see
<http
://www
.gnu
.org
/licenses
/>');
1460 case 'Confidential
':
1461 k_javadoc_box_line('All Rights Reserved
');
1464 case 'ConfidentialNoAuthor
':
1465 k_javadoc_box_line(skCompany ' confidential
');
1466 k_javadoc_box_line('All Rights Reserved
');
1470 k_javadoc_box_line('This file
is part of VirtualBox Open Source
Edition (OSE
), as')
1471 k_javadoc_box_line('available
from http
://www
.virtualbox
.org
. This file
is free software
;')
1472 k_javadoc_box_line('you can redistribute it
and/or modify it under the terms of the GNU
')
1473 k_javadoc_box_line('General Public
License (GPL
) as published by the Free Software
')
1474 k_javadoc_box_line('Foundation
, in version
2 as it comes in the
"COPYING" file of the
')
1475 k_javadoc_box_line('VirtualBox OSE distribution
. VirtualBox OSE
is distributed in the
')
1476 k_javadoc_box_line('hope that it will be useful
, but WITHOUT ANY WARRANTY of any kind
.')
1477 k_javadoc_box_line('')
1478 k_javadoc_box_line('Please contact Sun Microsystems
, Inc
., 4150 Network Circle
, Santa
')
1479 k_javadoc_box_line('Clara
, CA
95054 USA
or visit http
://www
.sun
.com
if you need
')
1480 k_javadoc_box_line('additional information
or have any questions
.')
1483 case 'VirtualBoxGPLAndCDDL
':
1484 k_javadoc_box_line('This file
is part of VirtualBox Open Source
Edition (OSE
), as')
1485 k_javadoc_box_line('available
from http
://www
.virtualbox
.org
. This file
is free software
;')
1486 k_javadoc_box_line('you can redistribute it
and/or modify it under the terms of the GNU
')
1487 k_javadoc_box_line('General Public
License (GPL
) as published by the Free Software
')
1488 k_javadoc_box_line('Foundation
, in version
2 as it comes in the
"COPYING" file of the
')
1489 k_javadoc_box_line('VirtualBox OSE distribution
. VirtualBox OSE
is distributed in the
')
1490 k_javadoc_box_line('hope that it will be useful
, but WITHOUT ANY WARRANTY of any kind
.')
1491 k_javadoc_box_line('')
1492 k_javadoc_box_line('The contents of this file may alternatively be used under the terms
')
1493 k_javadoc_box_line('of the Common Development
and Distribution License Version
1.0')
1494 k_javadoc_box_line('(CDDL
) only
, as it comes in the
"COPYING.CDDL" file of the
')
1495 k_javadoc_box_line('VirtualBox OSE distribution
, in which case the provisions of the
')
1496 k_javadoc_box_line('CDDL are applicable instead of those of the GPL
.')
1497 k_javadoc_box_line('')
1498 k_javadoc_box_line('You may elect to license modified versions of this file under the
')
1499 k_javadoc_box_line('terms
and conditions of either the GPL
or the CDDL
or both
.')
1500 k_javadoc_box_line('')
1501 k_javadoc_box_line('Please contact Sun Microsystems
, Inc
., 4150 Network Circle
, Santa
')
1502 k_javadoc_box_line('Clara
, CA
95054 USA
or visit http
://www
.sun
.com
if you need
')
1503 k_javadoc_box_line('additional information
or have any questions
.')
1509 k_javadoc_box_line();
1510 k_javadoc_box_end();
1512 up(p_RLine - iCursorLine);
1523 /*******************************************************************************
1524 * Keyboard Shortcuts *
1525 *******************************************************************************/
1526 /** Makes global box. */
1527 void k_box_globals()
1529 k_box_start('Global
');
1530 k_box_line('Global Variables
');
1534 /** Makes header box. */
1535 void k_box_headers()
1537 k_box_start("Header");
1538 k_box_line("Header Files");
1542 /** Makes internal function box. */
1543 void k_box_intfuncs()
1545 k_box_start("IntFunc");
1546 k_box_line("Internal Functions");
1550 /** Makes def/const box. */
1553 k_box_start("Const");
1554 k_box_line("Defined Constants And Macros");
1558 /** Structure box */
1559 void k_box_structs()
1561 k_box_start("Struct");
1562 k_box_line("Structures and Typedefs");
1566 /** Makes exported symbols box. */
1567 void k_box_exported()
1569 k_box_start('Exported
');
1570 k_box_line('Exported Symbols
');
1574 /** oneliner comment */
1579 if ( k_commentconfig(sLeft, sRight, iColumn)
1581 { /* column based needs some tricky repositioning. */
1583 if (p_col > iColumn)
1586 _insert_text("\n\r");
1590 k_insert_comment("", KIC_CURSOR_AT_END, ikStyleOneliner);
1593 /** mark line as modified. */
1594 void k_mark_modified_line()
1596 /* not supported for column based sources */
1599 if ( !k_commentconfig(sLeft, sRight, iColumn)
1604 sStr = skChange ' (' skUserInitials ')';
1606 sStr = skUserInitials;
1607 k_insert_comment(sStr, KIC_CURSOR_BEFORE, ikStyleModifyMarkColumn);
1612 * Inserts a signature. Form: "//Initials ISO-date:"
1613 * @remark defeventtab
1617 /* kso I5-10000 2002-09-10: */
1620 sSig = skUserInitials ' ' skChange ' ' k_date() ': ';
1622 sSig = skUserInitials ' ' k_date() ': ';
1623 k_insert_comment(sSig, KIC_CURSOR_AT_END);
1626 /* Insert a list of NOREF() macro invocations. */
1630 _save_pos2(org_pos);
1633 boolean fFoundFn = !k_func_goto_nearest_function();
1636 _str sArgs = k_func_getparams();
1637 int cArgs = k_func_countparams(sArgs);
1641 for (i = 0; i < cArgs; i++)
1643 _str sName, sType, sDefault;
1644 if (!k_func_enumparams(sArgs, i, sType, sName, sDefault))
1648 sThis = 'NOREF(' sName ');';
1649 if (length(sNoRefs) == 0)
1652 offLine += length(sThis);
1654 else if (offLine + length(sThis) < 130)
1656 sNoRefs = sNoRefs ' ' sThis;
1657 offLine += 1 + length(sThis);
1661 sNoRefs = sNoRefs "\n " sThis;
1662 offLine = 4 + length(sThis);
1665 else if (length(sNoRefs) == 0)
1667 sNoRefs = 'RT_NOREF(' sName;
1668 offLine = length(sNoRefs);
1670 else if (offLine + 2 + length(sName) < 130)
1672 sNoRefs = sNoRefs ', ' sName;
1673 offLine += 2 + length(sName);
1677 sNoRefs = sNoRefs ',\n
' sName;
1678 offLine += 4 + length(sName);
1682 if (length(sNoRefs) > 0 && fVaArgs != 0)
1683 sNoRefs = sNoRefs ');';
1686 _restore_pos2(org_pos);
1687 _insert_text(sNoRefs);
1690 /* Adds newline escape slashes to the current selection. */
1691 void k_newline_escape_selection()
1694 typeless rc = filter_get_string(sLine);
1705 int offNonWhitespace = pos("[^ \t]", sPrev, 1, 'L
');
1706 if (offNonWhitespace > 0)
1707 sLine = _pad(sLine, offNonWhitespace - 1, ' ');
1711 filter_put_string(sLine);
1715 rc = filter_get_string(sLine);
1719 else if (isinteger(rc))
1720 message(get_message(rc));
1726 /*******************************************************************************
1728 *******************************************************************************/
1730 * Hot-Key: Inserts a KLOGENTRY statement at start of nearest function.
1732 void klib_klogentry()
1735 _save_pos2(org_pos);
1738 * Go to nearest function.
1740 if (!k_func_goto_nearest_function())
1745 _str sParams = k_func_getparams();
1748 _str sRetType = k_func_getreturntype(true);
1749 if (!sRetType || sRetType == "")
1750 sRetType = "void"; /* paranoia! */
1755 if (!k_func_searchcode("{"))
1758 int cArgs = k_func_countparams(sParams);
1763 for (i = 0; i < cArgs; i++)
1765 _str sType, sName, sDefault;
1766 if (!k_func_enumparams(sParams, i, sType, sName, sDefault))
1767 sArgs = sArgs', 'sName;
1770 _insert_text("\n KLOGENTRY"cArgs"(\""sRetType"\",\""sParams"\""sArgs");"); /* todo tab size.. or smart indent */
1773 _insert_text("\n KLOGENTRY0(\""sRetType"\");"); /* todo tab size.. or smart indent */
1776 * Check if the next word is KLOGENTRY.
1779 if (def_next_word_style == 'E
')
1782 if (substr(cur_word(iIgnorePos), 1, 9) == "KLOGENTRY")
1787 message("didn't find
{");
1790 message("k_func_getparams failed
, sParams
=" sParams);
1794 _restore_pos2(org_pos);
1799 * Hot-Key: Inserts a KLOGEXIT statement at cursor location.
1801 void klib_klogexit()
1804 _save_pos2(org_pos);
1807 * Go to nearest function.
1814 _str sType = k_func_getreturntype(true);
1815 _restore_pos2(org_pos);
1818 boolean fReturn = true; /* true if an return statment is following the KLOGEXIT statement. */
1823 int cur_col = p_col;
1824 if (sType == 'void' || sType == 'VOID')
1827 fReturn = cur_word(iIgnorePos) == 'return';
1830 while (p_col <= p_SyntaxIndent)
1834 _insert_text("KLOGEXITVOID();\n
");
1839 for (i = 1; i < cur_col; i++)
1846 _insert_text("KLOGEXIT();\n
");
1848 for (i = 1; i < cur_col; i++)
1853 * Insert value if possible.
1856 _save_pos2(valuepos);
1858 if (def_next_word_style == 'E')
1861 if (cur_word(iIgnorePos) == 'return')
1863 p_col += length('return');
1865 _save_pos2(posStart);
1866 long offStart = _QROffset();
1867 if (!k_func_searchcode(";", "E
+"))
1869 long offEnd = _QROffset();
1870 _restore_pos2(posStart);
1871 _str sValue = strip(get_text((int)(offEnd - offStart)));
1872 //say 'sValue = 'sValue;
1873 _restore_pos2(valuepos);
1874 _save_pos2(valuepos);
1875 _insert_text(sValue);
1878 _restore_pos2(valuepos);
1882 * Remove old KLOGEXIT statement on previous line if any.
1885 _save_pos2(valuepos);
1886 int newexitline = p_line;
1887 p_line--; p_col = 1;
1889 if (def_next_word_style == 'E')
1892 if (p_line == newexitline - 1 && substr(cur_word(iIgnorePos), 1, 8) == 'KLOGEXIT')
1894 _restore_pos2(valuepos);
1897 * Check for missing '{...}'.
1901 boolean fFound = false;
1902 _save_pos2(valuepos);
1903 p_col--; find_matching_paren(); p_col += 2;
1904 k_func_searchcode(';', 'E+'); /* places us at the ';' of the return. (hopefully) */
1906 _str ch = k_func_get_next_code_text();
1909 _restore_pos2(valuepos);
1910 _save_pos2(valuepos);
1911 p_col--; find_matching_paren(); p_col += 2;
1912 k_func_searchcode(';', 'E+'); /* places us at the ';' of the return. (hopefully) */
1914 if (k_func_more_code_on_line())
1919 _save_pos2(returnget);
1920 k_func_searchcode("return
", "E
-");
1921 int return_col = p_col;
1922 _restore_pos2(returnget);
1926 while (p_col < return_col - p_SyntaxIndent)
1931 _restore_pos2(valuepos);
1932 _save_pos2(valuepos);
1934 p_col -= p_SyntaxIndent;
1935 int codecol = p_col;
1936 _insert_text("{\n
");
1937 while (p_col < codecol)
1941 _restore_pos2(valuepos);
1945 message("k_func_getreturntype failed
, sType
=" sType);
1949 _restore_pos2(org_pos);
1954 * Processes a file - ask user all the time.
1956 void klib_klog_file_ask()
1958 klib_klog_file_int(true);
1963 * Processes a file - no questions.
1965 void klib_klog_file_no_ask()
1967 klib_klog_file_int(false);
1975 static void klib_klog_file_int(boolean fAsk)
1981 /* ask question so we can get to the right position somehow.. */
1982 if (fAsk && _message_box("kLog process this file?
", "Visual SlickEdit
", MB_YESNO | MB_ICONQUESTION) != IDYES)
1988 while (!prev_proc())
1990 //say 'entry main loop: ' k_func_getfunction_name();
1995 if (k_func_prototype())
2003 _str sFunction = k_func_getfunction_name();
2004 rc = fAsk ? _message_box("Process this
function ("sFunction")?
", "Visual SlickEdit
", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
2008 _save_pos2(procpos);
2010 _restore_pos2(procpos);
2012 else if (rc == IDNO)
2021 bottom(); _refresh_scroll();
2022 boolean fUserCancel = false;
2023 while (!prev_proc() && !fUserCancel)
2026 _save_pos2(procpos);
2027 _str sCurFunction = k_func_getfunction_name();
2028 //say 'exit main loop: ' sCurFunction
2033 if (k_func_prototype())
2039 while ( !k_func_searchcode("return
", "WE
<+")
2040 && k_func_getfunction_name() == sCurFunction)
2042 //say 'exit sub loop: ' p_line
2048 _str sFunction = k_func_getfunction_name();
2049 rc = fAsk ? _message_box("Process this exit
from "sFunction"?
", "Visual SlickEdit
", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
2054 _save_pos2(returnpos);
2056 _restore_pos2(returnpos);
2059 else if (rc != IDNO)
2064 p_line++; /* just so we won't hit it again. */
2068 * If void function we'll have to check if there is and return; prior to the ending '}'.
2070 _restore_pos2(procpos);
2071 _save_pos2(procpos);
2072 _str sType = k_func_getreturntype(true);
2073 if (!fUserCancel && sType && (sType == 'void' || sType == 'VOID'))
2075 if ( !k_func_searchcode("{", "E
+")
2076 && !find_matching_paren())
2079 _save_pos2(funcend);
2082 if (cur_word(iIgnorePos) != "return
")
2087 _restore_pos2(funcend);
2090 _str sFunction = k_func_getfunction_name();
2091 rc = fAsk ? _message_box("Process this exit
from "sFunction"?
", "Visual SlickEdit
", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
2096 _save_pos2(returnpos);
2098 _restore_pos2(returnpos);
2107 _restore_pos2(procpos);
2111 /** @todo move to kkeys.e */
2112 _command void k_rebuild_tagfile()
2114 #if 1 /*__VERSION__ < 14.0*/
2115 if (file_match('-p 'maybe_quote_filename(strip_filename(_project_name,'e'):+TAG_FILE_EXT),1) != "")
2116 _project_update_files_retag(false, false, false, false);
2118 _project_update_files_retag(true, false, false, true);
2120 _str sArgs = "-refs
=on
";
2121 if (file_match('-p 'maybe_quote_filename(strip_filename(_project_name,'e'):+TAG_FILE_EXT),1) != "")
2122 sArgs = sArgs :+ " -retag
";
2123 sArgs = sArgs :+ " " :+ _workspace_filename;
2124 build_workspace_tagfiles(sArgs);
2129 /*******************************************************************************
2131 *******************************************************************************/
2132 static _str StyleLanguages[] =
2145 static StyleScheme StyleSchemes[] =
2154 "pad_condition_state
=1",
2155 "indent_with_tabs
=0",
2156 "nospace_before_paren
=0",
2157 "indent_comments
=1",
2159 "statement_comment_col
=0",
2160 "disable_bestyle
=0",
2161 "decl_comment_col
=0",
2162 "bestyle_on_functions
=0",
2163 "use_relative_indent
=1",
2164 "nospace_before_brace
=0",
2166 "statement_comment_state
=2",
2169 "parens_on_return
=0",
2170 "eat_blank_lines
=0",
2173 "align_on_parens
=1",
2174 "continuation_indent
=0",
2176 "nopad_condition
=1",
2178 "indent_col1_comments
=0"
2189 "pad_condition_state
=1",
2190 "indent_with_tabs
=0",
2191 "nospace_before_paren
=0",
2192 "indent_comments
=1",
2194 "statement_comment_col
=0",
2195 "disable_bestyle
=0",
2196 "decl_comment_col
=0",
2197 "bestyle_on_functions
=0",
2198 "use_relative_indent
=1",
2199 "nospace_before_brace
=0",
2201 "statement_comment_state
=2",
2204 "parens_on_return
=0",
2205 "eat_blank_lines
=0",
2208 "align_on_parens
=1",
2209 "continuation_indent
=0",
2211 "nopad_condition
=1",
2213 "indent_col1_comments
=0"
2224 "pad_condition_state
=1",
2225 "indent_with_tabs
=0",
2226 "nospace_before_paren
=0",
2227 "indent_comments
=1",
2229 "statement_comment_col
=0",
2230 "disable_bestyle
=0",
2231 "decl_comment_col
=0",
2232 "bestyle_on_functions
=0",
2233 "use_relative_indent
=1",
2234 "nospace_before_brace
=0",
2236 "statement_comment_state
=2",
2239 "parens_on_return
=0",
2240 "eat_blank_lines
=0",
2243 "align_on_parens
=1",
2244 "continuation_indent
=0",
2246 "nopad_condition
=1",
2248 "indent_col1_comments
=0"
2259 "pad_condition_state
=1",
2260 "indent_with_tabs
=0",
2261 "nospace_before_paren
=0",
2262 "indent_comments
=1",
2264 "statement_comment_col
=0",
2265 "disable_bestyle
=0",
2266 "decl_comment_col
=0",
2267 "bestyle_on_functions
=0",
2268 "use_relative_indent
=1",
2269 "nospace_before_brace
=0",
2271 "statement_comment_state
=2",
2274 "parens_on_return
=0",
2275 "eat_blank_lines
=0",
2278 "align_on_parens
=1",
2279 "continuation_indent
=0",
2281 "nopad_condition
=1",
2283 "indent_col1_comments
=0"
2294 "pad_condition_state
=1",
2295 "indent_with_tabs
=0",
2296 "nospace_before_paren
=0",
2297 "indent_comments
=1",
2299 "statement_comment_col
=0",
2300 "disable_bestyle
=0",
2301 "decl_comment_col
=0",
2302 "bestyle_on_functions
=0",
2303 "use_relative_indent
=1",
2304 "nospace_before_brace
=0",
2306 "statement_comment_state
=2",
2309 "parens_on_return
=0",
2310 "eat_blank_lines
=0",
2313 "align_on_parens
=1",
2314 "continuation_indent
=0",
2316 "nopad_condition
=1",
2318 "indent_col1_comments
=0"
2324 static void k_styles_create()
2327 * Find user format ini file.
2329 _str userini = maybe_quote_filename(_config_path():+'uformat.ini');
2330 if (file_match('-p 'userini, 1) == '')
2332 _str ini = maybe_quote_filename(slick_path_search('uformat.ini'));
2333 if (ini != '') userini = ini;
2338 * Remove any old schemes.
2341 for (i = 0; i < StyleSchemes._length(); i++)
2342 for (j = 0; j < StyleLanguages._length(); j++)
2344 _str sectionname = StyleLanguages[j]:+'-scheme-':+StyleSchemes[i].name;
2345 if (!_ini_get_section(userini, sectionname, tv))
2347 _ini_delete_section(userini, sectionname);
2348 _delete_temp_view(tv);
2349 //message("delete
old scheme
");
2354 * Create the new schemes.
2356 for (i = 0; i < StyleSchemes._length(); i++)
2358 for (j = 0; j < StyleLanguages._length(); j++)
2360 _str sectionname = StyleLanguages[j]:+'-scheme-':+StyleSchemes[i].name;
2361 int temp_view_id, k;
2362 _str orig_view_id = _create_temp_view(temp_view_id);
2363 activate_view(temp_view_id);
2364 for (k = 0; k < StyleSchemes[i].settings._length(); k++)
2365 insert_line(StyleSchemes[i].settings[k]);
2367 /* Insert the scheme section. */
2368 _ini_replace_section(userini, sectionname, temp_view_id);
2370 //bogus id - activate_view(orig_view_id);
2374 //last_scheme = last scheme name!!!
2379 * Sets the last used beutify scheme.
2381 static k_styles_set(_str scheme)
2385 * Find user format ini file.
2387 _str userini = maybe_quote_filename(_config_path():+'uformat.ini');
2388 if (file_match('-p 'userini, 1) == '')
2390 _str ini = maybe_quote_filename(slick_path_search('uformat.ini'));
2391 if (ini != '') userini = ini;
2395 * Set the scheme for each language.
2398 for (j = 0; j < StyleLanguages._length(); j++)
2400 _ini_set_value(userini,
2401 StyleLanguages[j]:+'-scheme-Default',
2408 static _str defoptions[] =
2417 "def
-options
-bourneshell
",
2420 "def
-options
-plsql
",
2421 "def
-options
-sqlserver
",
2425 static _str defsetups[] =
2430 "def
-setup
-fundamental
",
2431 "def
-setup
-process
",
2438 "def
-setup
-bourneshell
",
2441 "def
-setup
-fileman
",
2443 "def
-setup
-sqlserver
",
2448 static _str defsetupstab8[] =
2454 static void k_styles_setindent(int indent, int iBraceStyle, boolean iWithTabs = false)
2456 if (iBraceStyle < 1 || iBraceStyle > 3)
2458 message('k_styles_setindent: iBraceStyle is bad (=' :+ iBraceStyle :+ ')');
2463 * def-options for extentions known to have that info.
2466 for (i = 0; i < defoptions._length(); i++)
2468 int idx = find_index(defoptions[i], MISC_TYPE);
2472 parse name_info(idx) with syntax_indent o2 o3 o4 flags indent_fl o7 indent_case rest;
2474 /* Begin/end style */
2475 flags = flags & ~(1|2);
2476 flags = flags | (iBraceStyle - 1); /* Set style (0-based) */
2477 flags = flags & ~(16); /* no scape before parent.*/
2478 indent_fl = 1; /* Indent first level */
2479 indent_case = 1; /* Indent case from switch */
2481 sNewOptions = indent' 'o2' 'o3' 'o4' 'flags' 'indent_fl' 'o7' 'indent_case' 'rest;
2482 set_name_info(idx, sNewOptions);
2483 _config_modify |= CFGMODIFY_DEFDATA;
2487 * def-setup for known extentions.
2489 for (i = 0; i < defsetups._length(); i++)
2491 idx = find_index(defsetups[i], MISC_TYPE);
2494 sExt = substr(defsetups[i], length('def-setup-') + 1);
2495 sSetup = name_info(idx);
2498 parse sSetup with 'MN=' mode_name ','\
2499 'TABS=' tabs ',' 'MA=' margins ',' 'KEYTAB=' keytab_name ','\
2500 'WW='word_wrap_style ',' 'IWT='indent_with_tabs ','\
2501 'ST='show_tabs ',' 'IN='indent_style ','\
2502 'WC='word_chars',' 'LN='lexer_name',' 'CF='color_flags','\
2503 'LNL='line_numbers_len','rest;
2505 indent_with_tabs = 0; /* Indent with tabs */
2507 /* Make sure all the values are legal */
2508 _ext_init_values(ext, lexer_name, color_flags);
2509 if (!isinteger(line_numbers_len)) line_numbers_len = 0;
2510 if (word_chars == '') word_chars = 'A-Za-z0-9_$';
2511 if (word_wrap_style == '') word_wrap_style = 3;
2512 if (show_tabs == '') show_tabs = 0;
2513 if (indent_style == '') indent_style = INDENT_SMART;
2515 /* Set new indent */
2521 /* Set new indent */
2522 if (pos('TABS=', sNewSetup) > 0)
2525 * If either in defoptions or defsetupstab8 use default tab of 8
2526 * For those supporting separate syntax indent using the normal tabsize
2527 * helps us a lot when reading it...
2530 for (j = 0; !fTab8 && j < defsetupstab8._length(); j++)
2531 if (substr(defsetupstab8[j], lastpos('-', defsetupstab8[j]) + 1) == sExt)
2533 for (j = 0; !fTab8 && j < defoptions._length(); j++)
2534 if (substr(defoptions[j], lastpos('-', defoptions[j]) + 1) == sExt)
2537 parse sNewSetup with sPre 'TABS=' sValue ',' sPost;
2539 sNewSetup = sPre 'TABS=+8,' sPost
2541 sNewSetup = sPre 'TABS=+' indent ',' sPost
2544 /* Set indent with tabs flag. */
2545 if (pos('IWT=', sNewSetup) > 0)
2547 parse sNewSetup with sPre 'IWT=' sValue ',' sPost;
2549 sNewSetup = sPre 'IWT=1,' sPost
2551 sNewSetup = sPre 'IWT=0,' sPost
2554 /* Do the real changes */
2555 set_name_info(idx, sNewSetup);
2556 _config_modify |= CFGMODIFY_DEFDATA;
2557 _update_buffers(sExt);
2563 * Takes necessary steps to convert a string to integer.
2565 static int k_style_emacs_var_integer(_str sVal)
2568 //say 'k_style_emacs_var_integer('sVal') -> 'i;
2574 * Sets a Emacs style variable.
2576 static int k_style_emacs_var(_str sVar, _str sVal)
2579 if (sVar == '' || sVal == '')
2581 //say 'k_style_emacs_var: 'sVar'='sVal;
2583 #if __VERSION__ >= 21.0
2584 /** @todo figure out p_index. */
2589 * Unpack the mode style parameters.
2591 _str sStyle = name_info(_edit_window().p_index);
2592 _str sStyleName = p_mode_name;
2593 typeless iIndentAmount, fExpansion, iMinAbbrivation, fIndentAfterOpenParen, iBeginEndStyle, fIndent1stLevel, iMainStyle, iSwitchStyle,
2594 sRest, sRes0, sRes1;
2595 if (sStyleName == 'Slick-C')
2597 parse sStyle with iMinAbbrivation sRes0 iBeginEndStyle fIndent1stLevel sRes1 iSwitchStyle sRest;
2598 iIndentAmount = p_SyntaxIndent;
2601 parse sStyle with iIndentAmount fExpansion iMinAbbrivation fIndentAfterOpenParen iBeginEndStyle fIndent1stLevel iMainStyle iSwitchStyle sRest;
2605 * Process the variable.
2631 p_mode_name = 'Slick-C';
2635 message('emacs mode "'sVal'" is not known to us');
2640 /* relevant emacs code:
2641 (defconst c-style-alist
2643 (c-basic-offset . 2)
2644 (c-comment-only-line-offset . (0 . 0))
2645 (c-offsets-alist . ((statement-block-intro . +)
2646 (knr-argdecl-intro . 5)
2647 (substatement-open . +)
2649 (statement-case-open . +)
2650 (statement-cont . +)
2651 (arglist-intro . c-lineup-arglist-intro-after-paren)
2652 (arglist-close . c-lineup-arglist)
2654 (brace-list-open . +)
2656 (c-special-indent-hook . c-gnu-impose-minimum)
2657 (c-block-comment-prefix . "")
2660 (c-basic-offset . 5)
2661 (c-comment-only-line-offset . 0)
2662 (c-offsets-alist . ((statement-block-intro . +)
2663 (knr-argdecl-intro . 0)
2664 (substatement-open . 0)
2666 (statement-cont . +)
2670 (c-basic-offset . 8)
2671 (c-comment-only-line-offset . 0)
2672 (c-offsets-alist . ((statement-block-intro . +)
2673 (knr-argdecl-intro . +)
2674 (substatement-open . 0)
2676 (statement-cont . +)
2682 (c-basic-offset . 4)
2683 (c-comment-only-line-offset . 0)
2684 (c-offsets-alist . ((statement-block-intro . +)
2685 (substatement-open . 0)
2687 (statement-cont . +)
2691 (c-basic-offset . 4)
2692 (c-comment-only-line-offset . 0)
2693 (c-offsets-alist . ((knr-argdecl-intro . +)
2695 (statement-cont . +)
2696 (substatement-open . +)
2698 (statement-block-intro . c-lineup-whitesmith-in-block)
2699 (block-close . c-lineup-whitesmith-in-block)
2702 (defun-block-intro . c-lineup-whitesmith-in-block)
2703 (defun-close . c-lineup-whitesmith-in-block)
2704 (brace-list-open . +)
2705 (brace-list-intro . c-lineup-whitesmith-in-block)
2706 (brace-entry-open . c-indent-multi-line-block)
2707 (brace-list-close . c-lineup-whitesmith-in-block)
2709 (inclass . c-lineup-whitesmith-in-block)
2712 (extern-lang-open . +)
2713 (inextern-lang . c-lineup-whitesmith-in-block)
2714 (extern-lang-close . +)
2715 (namespace-open . +)
2716 (innamespace . c-lineup-whitesmith-in-block)
2717 (namespace-close . +)
2721 (c-basic-offset . 3)
2722 (c-comment-only-line-offset . 0)
2723 (c-hanging-braces-alist . ((substatement-open before after)))
2724 (c-offsets-alist . ((topmost-intro . 0)
2725 (topmost-intro-cont . 0)
2727 (substatement-open . 0)
2735 (c-basic-offset . 8)
2736 (c-comment-only-line-offset . 0)
2737 (c-hanging-braces-alist . ((brace-list-open)
2739 (substatement-open after)
2740 (block-close . c-snug-do-while)))
2741 (c-cleanup-list . (brace-else-brace))
2742 (c-offsets-alist . ((statement-block-intro . +)
2743 (knr-argdecl-intro . 0)
2744 (substatement-open . 0)
2746 (statement-cont . +)
2750 (indent-tabs-mode . t)
2752 (c-basic-offset . 8)
2753 (c-offsets-alist . ((substatement-open . 0)
2756 (knr-argdecl-intro . +)
2758 (c-hanging-braces-alist . ((brace-list-open)
2762 (substatement-open after)
2763 (block-close . c-snug-do-while)
2765 (c-block-comment-prefix . "")
2768 (c-basic-offset . 4)
2769 (c-comment-only-line-offset . (0 . 0))
2770 ;; the following preserves Javadoc starter lines
2771 (c-offsets-alist . ((inline-open . 0)
2772 (topmost-intro-cont . +)
2773 (statement-block-intro . +)
2774 (knr-argdecl-intro . 5)
2775 (substatement-open . +)
2777 (statement-case-open . +)
2778 (statement-cont . +)
2779 (arglist-intro . c-lineup-arglist-intro-after-paren)
2780 (arglist-close . c-lineup-arglist)
2782 (inher-cont . c-lineup-java-inher)
2783 (func-decl-cont . c-lineup-java-throws)
2789 case 'c-file-style':
2790 case 'c-indentation-style':
2796 iBeginEndStyle = 1 | (iBeginEndStyle & ~3);
2797 p_indent_with_tabs = true;
2807 iBeginEndStyle = 0 | (iBeginEndStyle & ~3);
2808 p_indent_with_tabs = false;
2817 iBeginEndStyle = 0 | (iBeginEndStyle & ~3);
2818 p_indent_with_tabs = true;
2825 case 'yet-to-be-found':
2826 iBeginEndStyle = 2 | (iBeginEndStyle & ~3);
2827 p_indent_with_tabs = false;
2835 message('emacs "'sVar'" value "'sVal'" is not known to us.');
2840 case 'c-label-offset':
2842 int i = k_style_emacs_var_integer(sVal);
2843 if (i >= -16 && i <= 16)
2845 if (i == -p_SyntaxIndent)
2854 case 'indent-tabs-mode':
2855 p_indent_with_tabs = sVal == 't';
2858 case 'c-indent-level':
2859 case 'c-basic-offset':
2861 int i = k_style_emacs_var_integer(sVal);
2862 if (i > 0 && i <= 16)
2869 message('emacs "'sVar'" value "'sVal'" is out of range.');
2877 int i = k_style_emacs_var_integer(sVal);
2878 if (i > 0 && i <= 16)
2882 message('emacs "'sVar'" value "'sVal'" is out of range.');
2888 case 'nuke-trailing-whitespace-p':
2891 _str sName = 'def-koptions-'p_buf_id;
2892 int idx = insert_name(sName, MISC_TYPE, "kstyledoc
");
2894 idx = find_index(sName, MISC_TYPE);
2898 set_name_info(idx, "saveoptions
: +S
");
2900 set_name_info(idx, "saveoptions
: -S
");
2908 message('emacs variable "'sVar'" (value "'sVal'") is unknown to us.');
2915 _str sNewStyle = "";
2916 if (sStyleName == 'Slick-C')
2917 sNewStyle = iMinAbbrivation' 'sRes0' 'iBeginEndStyle' 'fIndent1stLevel' 'sRes1' 'iSwitchStyle' 'sRest;
2919 sNewStyle = iIndentAmount' 'fExpansion' 'iMinAbbrivation' 'fIndentAfterOpenParen' 'iBeginEndStyle' 'fIndent1stLevel' 'iMainStyle' 'iSwitchStyle' 'sRest;
2920 if ( sNewStyle != ""
2921 && sNewStyle != sStyle
2922 && sStyleName == p_mode_name)
2924 _str sName = name_name(_edit_window().p_index)
2925 //say ' sStyle='sStyle' p_mode_name='p_mode_name;
2926 //say 'sNewStyle='sNewStyle' sName='sName;
2927 if (pos('kstyledoc-', sName) <= 0)
2929 sName = 'def-kstyledoc-'p_buf_id;
2930 int idx = insert_name(sName, MISC_TYPE, "kstyledoc
");
2932 idx = find_index(sName, MISC_TYPE);
2935 if (!set_name_info(idx, sNewStyle))
2936 _edit_window().p_index = idx;
2941 set_name_info(_edit_window().p_index, sNewStyle);
2950 * Parses a string with emacs variables.
2952 * The variables are separated by new line. Junk at
2953 * the start and end of the line is ignored.
2955 static int k_style_emac_vars(_str sVars)
2957 /* process them line by line */
2959 while (sVars != '' && iLine++ < 20)
2962 iEnd = iNext = pos("\n
", sVars);
2964 iEnd = iNext = length(sVars);
2969 sLine = strip(substr(sVars, 1, iEnd), 'B', " \t\n\r
");
2970 sVars = strip(substr(sVars, iNext), 'L', " \t\n\r
");
2971 //say 'iLine='iLine' sVars='sVars'<eol>';
2972 //say 'iLine='iLine' sLine='sLine'<eol>';
2975 rc = pos('[^a-zA-Z0-9-_]*([a-zA-Z0-9-_]+)[ \t]*:[ \t]*([^ \t]*)', sLine, 1, 'U');
2976 //say '0={'pos('S0')','pos('0')',"'substr(sLine,pos('S0
'),pos('0'))'"'
2977 //say '1={'pos('S1')','pos('1')',"'substr(sLine,pos('S1
'),pos('1'))'"'
2978 //say '2={'pos('S2')','pos('2')',"'substr(sLine,pos('S2
'),pos('2'))'"'
2979 //say '3={'pos('S3')','pos('3')',"'substr(sLine,pos('S3
'),pos('3'))'"'
2980 //say '4={'pos('S4')','pos('4')',"'substr(sLine,pos('S4
'),pos('4'))'"'
2982 k_style_emacs_var(substr(sLine,pos('S1'),pos('1')),
2983 substr(sLine,pos('S2'),pos('2')));
2990 * Searches for Emacs style specification for the current document.
2994 /* save the position before we start looking around the file. */
2996 _save_pos2(saved_pos);
3000 /* Check first line. */
3005 if (pos('-*-[ \t]+(.*:.*)[ \t]+-*-', sLine, 1, 'U'))
3008 sVars = substr(sLine, pos('S1'), pos('1'));
3009 sVars = translate(sVars, "\n
", ";");
3010 k_style_emac_vars(sVars);
3013 /* Look for the "Local Variables
:" stuff from the end of the file. */
3015 rc = search('Local Variables:[ \t]*\n\om(.*)\ol\n.*End:.*\n', '-EU');
3018 /* copy the variables out to a buffer. */
3020 sVars = get_text(match_length("1"), match_length("S1
"));
3021 k_style_emac_vars(sVars);
3024 _restore_pos2(saved_pos);
3029 * Callback function for the event of a new buffer.
3031 * This is used to make sure there are no left over per buffer options
3034 void _buffer_add_kdev(int buf_id)
3036 _str sName = 'def-koptions-'buf_id;
3037 int idx = find_index(sName, MISC_TYPE);
3040 //message("_buffer_add_kdev
: " idx " name
=" sName);
3042 sName = 'def-kstyledoc-'buf_id;
3043 idx = find_index(sName, MISC_TYPE);
3052 * Callback function for the event of quitting a buffer.
3054 * This is used to make sure there are no left over per buffer options
3057 void _cbquit2_kdev(int buf_id)
3059 _str sName = 'def-koptions-'buf_id;
3060 int idx = find_index(sName, MISC_TYPE);
3063 //message("_cbquit2_kdev
: " idx " " sName);
3065 sName = 'def-kstyledoc-'buf_id;
3066 idx = find_index(sName, MISC_TYPE);
3073 * Called to get save options for the current buffer.
3075 * This requires a modified loadsave.e!
3077 _str _buffer_save_kdev(int buf_id)
3080 _str sName = 'def-koptions-'buf_id;
3081 int idx = find_index(sName, MISC_TYPE);
3084 _str sOptions = strip(name_info(idx));
3086 parse sOptions with . "saveoptions
:" sRet .
3087 message("_buffer_save_kdev
: " idx " " sName " " sOptions);
3094 * Command similar to the add() command in math.e, only this
3095 * produces hex and doesn't do the multi line stuff.
3097 _command int k_calc()
3101 typeless rc = filter_get_string(sLine);
3105 rc = eval_exp(sResultHex, sLine, 16);
3109 rc = eval_exp(sResultDec, sLine, 10);
3113 _insert_text(' = ' :+ sResultHex :+ ' (' :+ sResultDec :+ ')');
3120 message(get_message(rc));
3128 /*******************************************************************************
3129 * Menu and Menu commands *
3130 *******************************************************************************/
3131 #ifdef KDEV_WITH_MENU
3132 #if __VERSION__ < 18.0 /* Something with timers are busted, so excusing my code. */
3133 static int iTimer = 0;
3135 static int mhkDev = 0;
3136 static int mhCode = 0;
3137 static int mhDoc = 0;
3138 static int mhLic = 0;
3139 static int mhPre = 0;
3142 * Creates the kDev menu.
3144 static k_menu_create()
3146 # if __VERSION__ < 18.0 /* Something with timers are busted, so excusing my code. */
3147 if (arg(1) == 'timer')
3148 _kill_timer(iTimer);
3150 menu_handle = _mdi.p_menu_handle;
3151 menu_index = find_index(_cur_mdi_menu,oi2type(OI_MENU));
3154 * Remove any old menu.
3156 mhDelete = iPos = 0;
3157 index = _menu_find(menu_handle, "kDev
", mhDelete, iPos, 'C');
3158 //message("index
="index " mhDelete
="mhDelete " iPos
="iPos);
3160 _menu_delete(mhDelete, iPos);
3164 * Insert the "kDev
" menu.
3166 mhkDev = _menu_insert(menu_handle, 9, MF_SUBMENU, "&kDev
", "", "kDev
");
3167 mhCode=_menu_insert(mhkDev, -1, MF_ENABLED | MF_SUBMENU, "Coding
&Style
", "", "coding
");
3168 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces
2, Syntax Indent
4 (knut
)", "k_menu_style Opt2Ind4
", "Opt2Ind4
");
3169 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces
2, Syntax Indent
3", "k_menu_style Opt2Ind3
", "Opt2Ind3
");
3170 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces
2, Syntax Indent
8", "k_menu_style Opt2Ind8
", "Opt2Ind8
");
3171 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces
3, Syntax Indent
4 (giws
)", "k_menu_style Opt3Ind4
", "Opt3Ind4
");
3172 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces
3, Syntax Indent
3 (giws
)", "k_menu_style Opt3Ind3
", "Opt3Ind3
");
3174 mhDoc= _menu_insert(mhkDev, -1, MF_ENABLED | MF_SUBMENU, "&Documentation
", "", "doc
");
3175 mhDSJ= _menu_insert(mhDoc, -1, MF_ENABLED | MF_UNCHECKED, "&Javadoc Style
", "k_menu_doc_style javadoc
", "javadoc
");
3176 mhDSL= _menu_insert(mhDoc, -1, MF_GRAYED | MF_UNCHECKED, "&Linux Kernel Style
", "k_menu_doc_style linux
", "linux
");
3178 mhLic= _menu_insert(mhkDev, -1, MF_ENABLED | MF_SUBMENU, "&License
", "", "License
");
3179 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&Odin32
", "k_menu_license Odin32
", "Odin32
");
3180 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&GPL
", "k_menu_license GPL
", "GPL
");
3181 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&LGPL
", "k_menu_license LGPL
", "LGPL
");
3182 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&GPLv3
", "k_menu_license GPLv3
", "GPLv3
");
3183 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&LGPLv3
", "k_menu_license LGPLv3
", "LGPLv3
");
3184 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&VirtualBox
", "k_menu_license VirtualBox
", "VirtualBox
");
3185 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&VirtualBox GPL
And CDDL
","k_menu_license VirtualBoxGPLAndCDDL
", "VirtualBoxGPLAndCDDL
");
3186 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&Confidential
", "k_menu_license Confidential
", "Confidential
");
3187 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&Confidential No Author
", "k_menu_license ConfidentialNoAuthor
", "ConfidentialNoAuthor
");
3189 rc = _menu_insert(mhkDev, -1, MF_ENABLED, "-", "", "dash vars
");
3190 rc = _menu_insert(mhkDev, -1, MF_ENABLED, skChange == '' ? '&Change...' : '&Change (' skChange ')...', "k_menu_change
", "");
3191 rc = _menu_insert(mhkDev, -1, MF_ENABLED, skProgram == '' ? '&Program...' : '&Program (' skProgram ')...', "k_menu_program
", "");
3192 rc = _menu_insert(mhkDev, -1, MF_ENABLED, skCompany == '' ? 'Co&mpany...' : 'Co&mpany (' skCompany ')...', "k_menu_company
", "");
3193 rc = _menu_insert(mhkDev, -1, MF_ENABLED, '&User Name (' skUserName ')...', "k_menu_user_name
", "username
");
3194 rc = _menu_insert(mhkDev, -1, MF_ENABLED, 'User &e-mail (' skUserEmail ')...', "k_menu_user_email
", "useremail
");
3195 rc = _menu_insert(mhkDev, -1, MF_ENABLED, 'User &Initials (' skUserInitials ')...', "k_menu_user_initials
", "userinitials
");
3196 rc = _menu_insert(mhkDev, -1, MF_ENABLED, "-", "", "dash preset
");
3197 mhPre= _menu_insert(mhkDev, -1, MF_SUBMENU, "P
&resets
", "", "");
3198 rc = _menu_insert(mhPre, -1, MF_ENABLED, "The Bird
", "k_menu_preset javadoc
, GPL
, Opt2Ind4
", "bird
");
3199 rc = _menu_insert(mhPre, -1, MF_ENABLED, "kLIBC
", "k_menu_preset javadoc
, GPL
, Opt2Ind4
,, kLIBC
", "kLIBC
");
3200 rc = _menu_insert(mhPre, -1, MF_ENABLED, "kBuild
", "k_menu_preset javadoc
, GPLv3
, Opt2Ind4
,, kBuild
", "kBuild
");
3201 rc = _menu_insert(mhPre, -1, MF_ENABLED, "kStuff
", "k_menu_preset javadoc
, GPL
, Opt2Ind4
,, kStuff
", "kStuff
");
3202 rc = _menu_insert(mhPre, -1, MF_ENABLED, "sun
", "k_menu_preset javadoc
, ConfidentialNoAuthor
, Opt2Ind4
, sun
", "sun
");
3203 rc = _menu_insert(mhPre, -1, MF_ENABLED, "VirtualBox
", "k_menu_preset javadoc
, VirtualBox
, Opt2Ind4
, sun
", "VirtualBox
");
3214 _command k_menu_change()
3216 sRc = show("-modal k_form_simple_input
", "Change ID
", skChange);
3226 * Change program name.
3228 _command k_menu_program()
3230 sRc = show("-modal k_form_simple_input
", "Program
", skProgram);
3242 _command k_menu_company()
3244 if (skCompany == '')
3245 sRc = show("-modal k_form_simple_input
", "Company
", 'innotek GmbH');
3247 sRc = show("-modal k_form_simple_input
", "Company
", skCompany);
3259 _command k_menu_user_name()
3261 sRc = show("-modal k_form_simple_input
", "User Name
", skUserName);
3262 if (sRc != "\r
" && sRc != '')
3271 * Change user email.
3273 _command k_menu_user_email()
3275 sRc = show("-modal k_form_simple_input
", "User e
-mail
", skUserEmail);
3276 if (sRc != "\r
" && sRc != '')
3285 * Change user initials.
3287 _command k_menu_user_initials()
3289 sRc = show("-modal k_form_simple_input
", "User e
-mail
", skUserInitials);
3290 if (sRc != "\r
" && sRc != '')
3292 skUserInitials = sRc;
3300 * Checks the correct menu item.
3302 _command void k_menu_doc_style(_str sNewDocStyle = '')
3304 //say 'sNewDocStyle='sNewDocStyle;
3305 if (sNewDocStyle != '')
3306 skDocStyle = sNewDocStyle
3307 _menu_set_state(mhDoc, "javadoc
", MF_UNCHECKED);
3308 _menu_set_state(mhDoc, "linux
", MF_UNCHECKED | MF_GRAYED);
3310 _menu_set_state(mhDoc, skDocStyle, MF_CHECKED);
3315 * Checks the correct menu item.
3317 _command void k_menu_license(_str sNewLicense = '')
3319 //say 'sNewLicense='sNewLicense;
3320 if (sNewLicense != '')
3321 skLicense = sNewLicense
3322 _menu_set_state(mhLic, "Odin32
", MF_UNCHECKED);
3323 _menu_set_state(mhLic, "GPL
", MF_UNCHECKED);
3324 _menu_set_state(mhLic, "LGPL
", MF_UNCHECKED);
3325 _menu_set_state(mhLic, "GPLv3
", MF_UNCHECKED);
3326 _menu_set_state(mhLic, "LGPLv3
", MF_UNCHECKED);
3327 _menu_set_state(mhLic, "VirtualBox
", MF_UNCHECKED);
3328 _menu_set_state(mhLic, "VirtualBoxGPLAndCDDL
", MF_UNCHECKED);
3329 _menu_set_state(mhLic, "Confidential
", MF_UNCHECKED);
3330 _menu_set_state(mhLic, "ConfidentialNoAuthor
", MF_UNCHECKED);
3332 _menu_set_state(mhLic, skLicense, MF_CHECKED);
3337 * Check the correct style menu item.
3339 _command void k_menu_style(_str sNewStyle = '')
3341 //say 'sNewStyle='sNewStyle;
3342 _menu_set_state(mhCode, "Opt1Ind4
", MF_UNCHECKED);
3343 _menu_set_state(mhCode, "Opt1Ind3
", MF_UNCHECKED);
3344 _menu_set_state(mhCode, "Opt1Ind8
", MF_UNCHECKED);
3345 _menu_set_state(mhCode, "Opt2Ind4
", MF_UNCHECKED);
3346 _menu_set_state(mhCode, "Opt2Ind3
", MF_UNCHECKED);
3347 _menu_set_state(mhCode, "Opt2Ind8
", MF_UNCHECKED);
3348 _menu_set_state(mhCode, "Opt3Ind4
", MF_UNCHECKED);
3349 _menu_set_state(mhCode, "Opt3Ind3
", MF_UNCHECKED);
3350 _menu_set_state(mhCode, "Opt3Ind8
", MF_UNCHECKED);
3352 if (sNewStyle != '')
3354 int iIndent = (int)substr(sNewStyle, 8, 1);
3355 int iBraceStyle = (int)substr(sNewStyle, 4, 1);
3356 skCodeStyle = sNewStyle;
3357 k_styles_setindent(iIndent, iBraceStyle);
3358 k_styles_set(sNewStyle);
3361 _menu_set_state(mhCode, skCodeStyle, MF_CHECKED);
3368 _command void k_menu_preset(_str sArgs = '')
3370 parse sArgs with sNewDocStyle ',' sNewLicense ',' sNewStyle ',' sNewCompany ',' sNewProgram ',' sNewChange
3371 sNewDocStyle= strip(sNewDocStyle);
3372 sNewLicense = strip(sNewLicense);
3373 sNewStyle = strip(sNewStyle);
3374 sNewCompany = strip(sNewCompany);
3375 if (sNewCompany == 'sun')
3376 sNewCompany = 'Sun Microsystems, Inc.'
3377 sNewProgram = strip(sNewProgram);
3378 sNewChange = strip(sNewChange);
3380 //say 'k_menu_preset('sNewDocStyle',' sNewLicense',' sNewStyle',' sNewCompany',' sNewProgram')';
3381 k_menu_doc_style(sNewDocStyle);
3382 k_menu_license(sNewLicense);
3383 k_menu_style(sNewStyle);
3384 skCompany = sNewCompany;
3385 skProgram = sNewProgram;
3386 skChange = sNewChange;
3393 _command k_menu_setcolor()
3395 createMyColorSchemeAndUseIt();
3399 _command k_menu_setkeys()
3401 rc = load("d
:/knut
/VSlickMacros
/BoxerDef
.e
");
3404 _command k_menu_settings()
3411 #endif /* KDEV_WITH_MENU */
3414 /*******************************************************************************
3416 *******************************************************************************/
3417 _form k_form_simple_input {
3418 p_backcolor=0x80000005
3419 p_border_style=BDS_DIALOG_BOX
3420 p_caption='Simple Input'
3421 p_clip_controls=FALSE
3422 p_forecolor=0x80000008
3429 p_backcolor=0x80000005
3430 p_border_style=BDS_FIXED_SINGLE
3431 p_completion=NONE_ARG
3434 p_font_name='MS Sans Serif'
3436 p_font_underline=FALSE
3437 p_forecolor=0x80000008
3445 p_eventtab2=_ul2_textbox
3448 p_alignment=AL_VCENTERRIGHT
3450 p_backcolor=0x80000005
3451 p_border_style=BDS_NONE
3455 p_font_name='MS Sans Serif'
3457 p_font_underline=FALSE
3458 p_forecolor=0x80000008
3466 _command_button btnOK {
3472 p_font_name='MS Sans Serif'
3474 p_font_underline=FALSE
3482 _command_button btnCancel {
3488 p_font_name='MS Sans Serif'
3490 p_font_underline=FALSE
3500 defeventtab k_form_simple_input
3501 btnOK.on_create(_str sLabel = '', _str sText = '')
3503 p_active_form.p_caption = sLabel;
3504 lblLabel.p_caption = sLabel;
3505 entText.p_text = sText;
3510 sText = entText.p_text;
3511 p_active_form._delete_window(sText);
3513 btnCancel.lbutton_up()
3515 sText = entText.p_text;
3516 p_active_form._delete_window("\r
");
3519 static _str aCLikeIncs[] =
3521 "c
", "ansic
", "java
", "rul
", "vera
", "cs
", "js
", "as", "idl
", "asm
", "s
", "imakefile
", "rc
", "lex
", "yacc
", "antlr
"
3524 static _str aMyLangIds[] =
3530 #if __VERSION__ < 19.0
3559 #if __VERSION__ < 19.0
3571 #if __VERSION__ >= 17.0
3572 # require "se
/lang
/api
/LanguageSettings
.e
"
3573 using se.lang.api.LanguageSettings;
3576 #if __VERSION__ >= 16.0
3577 int def_auto_unsurround_block;
3580 #if __VERSION__ >= 21.0
3581 int def_gui_find_default;
3584 static void kdev_ext_to_lang(_str sExt, _str idLang)
3586 #if __VERSION__ >= 21.0 // dunno when exactly.
3587 _SetExtensionReferTo(sExt, idLang);
3589 replace_def_data("def
-lang
-for
-ext
-" :+ sExt, idLand);
3593 #if __VERSION__ >= 21.0
3595 static _str kdev_load_lexer(_str sFilename)
3597 int rc = cload(sFilename);
3600 return ' Failed to load "' sFilename "': " rc ";";
3603 /** Doesn't seems like there is an API to just load a bunch of profiles, only I
3604 * could find would load one named profile for a specific language, making it
3605 * the new profile for that language. So, a little extra work here. */
3606 static _str kdev_load_beautifier_profiles(_str sFilename)
3610 auto hXml = _xmlcfg_open(sFilename, iStatus);
3614 iStatus = _xmlcfg_find_simple_array(hXml, "//profile
/@n
", asProfiles, TREE_ROOT_INDEX, VSXMLCFG_FIND_VALUES, -1);
3615 _xmlcfg_close(hXml);
3618 foreach (sProfile in asProfiles)
3620 _str asElements[] = split2array(sProfile, '.');
3621 _str sLangId = asElements[1];
3622 _str sProfileName = substr(sProfile, 1 + length(asElements[0])
3623 + 1 + length(asElements[1])
3624 + 1 + length(asElements[2]) + 1);
3625 //say("sLangId
='" sLangId "' sProfileName
='" sProfileName "'; ");
3626 _str sErr = _new_beautifier_config_import_settings(sFilename, sProfileName, sLangId);
3628 sRet = ' Failed to load "' sProfileName "' for
'" sLangId "' from '" sFilename "': " sRet ";";
3632 sRet = " Failed to open
'" sFilename "': " hXml ";";
3639 * Loads the standard bird settings.
3641 _command void kdev_load_settings(_str sScriptDir = "")
3652 _str sMsg = 'Please restart SlickEdit.';
3655 * Validate script dir argument.
3657 sScriptDir = _maybe_unquote_filename(sScriptDir);
3658 if (sScriptDir == "")
3660 message("Need script dir argument
!");
3663 if (!file_exists(sScriptDir :+ "/lexer
-kmk
.cfg
.xml
"))
3665 message("Invalid script dir
'" sScriptDir "' no lexer
-kmk
.cfg
.xml file found
!");
3669 #if __VERSION__ >= 21.0
3671 * Load the color profiles (was lexer).
3673 sMsg = sMsg :+ kdev_load_lexer(sScriptDir :+ "/lexer
-kmk
-v2
.cfg
.xml
");
3676 * Load project templates for kBuild.
3678 int rc = importProjectPacks(sScriptDir :+ "/usrprjtemplates
.vpt
");
3680 sMsg = sMsg :+ " importProjectPacks(usrprjtemplates
.vpt
)->" :+ rc :+ ";";
3683 * Load the beautifier profiles.
3685 sMsg = sMsg :+ kdev_load_beautifier_profiles(sScriptDir :+ "/beautifier
-profiles
.cfg
.xml
");
3688 * Load color and select scheme.
3690 _str sErr = _color_form_import_settings(sScriptDir :+ "/color_profiles
.cfg
.xml
", 'Solarized Dark');
3692 sMsg = sMsg :+ " _color_form_import_settings(color_profiles
.cfg
.xml
)->" :+ sErr :+ ";";
3693 _app_theme('Dark', true);
3699 _default_option('A', '0'); /* ALT menu */
3701 _default_option('R', '130'); /* Vertical line in column 130. */
3702 def_mfsearch_init_flags = 2 | 4; /* MFSEARCH_INIT_CURWORD | MFSEARCH_INIT_SELECTION */
3703 def_line_insert = 'B'; /* insert before */
3704 def_updown_col=0; /* cursor movement */
3705 def_cursorwrap=0; /* ditto. */
3706 def_click_past_end=1; /* ditto */
3707 def_start_on_first=1; /* vs A B C; view A. */
3708 def_vc_system='Subversion' /* svn is default version control */
3709 #if __VERSION__ >= 16.0
3710 def_auto_unsurround_block=0; /* Delete line, not block. */
3712 _config_modify_flags(CFGMODIFY_DEFDATA);
3714 #if __VERSION__ < 21.0 /* I think this is obsolete... */
3715 def_file_types='All Files (*),' /** @todo make this prettier */
3716 'C/C++ Files (*.c;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.h;*.hh;*.hpp;*.hxx;*.inl;*.xpm),'
3717 'Assembler (*.s;*.asm;*.mac;*.S),'
3718 'Makefiles (*;*.mak;*.kmk)'
3720 'Ch Files (*.ch;*.chf;*.chs;*.cpp;*.h),'
3722 'Java Files (*.java),'
3723 'HTML Files (*.htm;*.html;*.shtml;*.asp;*.jsp;*.php;*.php3;*.rhtml;*.css),'
3724 'CFML Files (*.cfm;*.cfml;*.cfc),'
3725 'XML Files (*.xml;*.dtd;*.xsd;*.xmldoc;*.xsl;*.xslt;*.ent;*.tld;*.xhtml;*.build;*.plist),'
3726 'XML/SGML DTD Files (*.xsd;*.dtd),'
3727 'XML/JSP TagLib Files (*.tld;*.xml),'
3728 'Objective-C (*.m;*.mm;*.h),'
3729 'IDL Files (*.idl),'
3730 'Ada Files (*.ada;*.adb;*.ads),'
3731 'Applescript Files (*.applescript),'
3732 'Basic Files (*.vb;*.vbs;*.bas;*.frm),'
3733 'Cobol Files (*.cob;*.cbl;*.ocb),'
3734 'JCL Files (*.jcl),'
3735 'JavaScript (*.js;*.ds),'
3736 'ActionScript (*.as),'
3737 'Pascal Files (*.pas;*.dpr),'
3738 'Fortran Files (*.for;*.f),'
3739 'PL/I Files (*.pl1),'
3740 'InstallScript (*.rul),'
3741 'Perl Files (*.pl;*.pm;*.perl;*.plx),'
3742 'Python Files (*.py),'
3743 'Ruby Files (*.rb;*.rby),'
3744 'Java Properties (*.properties),'
3745 'Lua Files (*.lua),'
3746 'Tcl Files (*.tcl;*.tlib;*.itk;*.itcl;*.exp),'
3748 'Slick-C (*.e;*.sh),'
3749 'SQL Files (*.sql;*.pgsql),'
3750 'SAS Files (*.sas),'
3751 'Text Files (*.txt),'
3752 'Verilog Files (*.v),'
3753 'VHDL Files (*.vhd),'
3754 'SystemVerilog Files (*.sv;*.svh;*.svi),'
3755 'Vera Files (*.vr;*.vrh),'
3756 'Erlang Files (*.erl;*.hrl),'
3760 /* Make it grok: # include <stuff.h> */
3761 for (i = 0; i < aCLikeIncs._length(); i++)
3762 replace_def_data("def
-":+aCLikeIncs[i]:+"-include
",
3763 '^[ \t]*(\#[ \t]*include|include|\#[ \t]*line)[ \t]#({#1:i}[ \t]#|)(<{#0[~>]#}>|"{#
0[~
"]#}")');
3764 replace_def_data("def-m-include", '^
[ \t
]*(\#
[ \t
]*include|\#
[ \t
]*import|include|\#
[ \t
]*line
)[ \t
]#
({#
1:i
}[ \t
]#|
)(<{#
0[~
>]#
}>|
"{#0[~"]#
}")');
3765 replace_def_data("def
-e
-include
", '^[ \t]*(\#[ \t]*include|\#[ \t]*import|\#[ \t]*require|include)[ \t]#(''{#0[~'']#}''|"{#
0[~
"]#}")');
3767 /* Replace the default unicode proportional font with the fixed oned. */
3768 _str sCodeFont = _default_font(CFG_SBCS_DBCS_SOURCE_WINDOW);
3769 _str sUnicodeFont = _default_font(CFG_UNICODE_SOURCE_WINDOW);
3770 if (pos("Default Unicode", sUnicodeFont) > 0 && length(sCodeFont) > 5)
3771 _default_font(CFG_UNICODE_SOURCE_WINDOW,sCodeFont);
3772 if (machine()=='INTELSOLARIS
' || machine()=='SPARCSOLARIS
')
3774 _default_font(CFG_MENU,'DejaVu Sans
,10,0,0,');
3775 _default_font(CFG_DIALOG,'DejaVu Sans
,10,0,,');
3776 _ConfigEnvVar('VSLICKDIALOGFONT
','DejaVu Sans
,10,0,,');
3779 /* Not so important. */
3780 int fSearch = 0x400400; /* VSSEARCHFLAG_WRAP | VSSEARCHFLAG_PROMPT_WRAP */;
3781 _default_option('S
', (_str)fSearch);
3784 #if __VERSION__ >= 17.0
3786 * Language settings via API.
3788 int fNewAff = AFF_BEGIN_END_STYLE \
3789 | AFF_INDENT_WITH_TABS \
3790 | AFF_SYNTAX_INDENT \
3792 | AFF_NO_SPACE_BEFORE_PAREN \
3795 | AFF_KEYWORD_CASING \
3797 | AFF_ATTRIBUTE_CASING \
3798 | AFF_VALUE_CASING \
3799 /*| AFF_HEX_VALUE_CASING*/;
3800 def_adaptive_formatting_flags = ~fNewAff;
3801 replace_def_data("def-adaptive-formatting-flags", def_adaptive_formatting_flags);
3803 foreach (sLangId in aMyLangIds)
3805 LanguageSettings.setIndentCaseFromSwitch(sLangId, true);
3806 LanguageSettings.setBeginEndStyle(sLangId, BES_BEGIN_END_STYLE_2);
3807 LanguageSettings.setIndentWithTabs(sLangId, false);
3808 LanguageSettings.setUseAdaptiveFormatting(sLangId, true);
3809 LanguageSettings.setAdaptiveFormattingFlags(sLangId, ~fNewAff);
3810 LanguageSettings.setSaveStripTrailingSpaces(sLangId, STSO_STRIP_MODIFIED);
3811 LanguageSettings.setTabs(sLangId, "8+");
3812 LanguageSettings.setSyntaxIndent(sLangId, 4);
3814 /* C/C++ setup, fixed comment width of 80 not 64, no max column. */
3815 # if __VERSION__ >= 21.0
3816 _SetCommentWrapFlags(CW_MAX_RIGHT, false, sLangId);
3817 _SetCommentWrapFlags(CW_USE_FIXED_WIDTH, true, sLangId);
3818 if (_LangGetPropertyInt32(sLangId, VSLANGPROPNAME_CW_FIXED_WIDTH_SIZE) < 80)
3819 _LangSetPropertyInt32(sLangId, VSLANGPROPNAME_CW_FIXED_WIDTH_SIZE, 80);
3821 sTmp = LanguageSettings.getCommentWrapOptions(sLangId);
3822 if (length(sTmp) > 10)
3824 typeless ntBlockCommentWrap, ntDocCommentWrap, ntFixedWidth;
3825 parse sTmp with ntBlockCommentWrap ntDocCommentWrap nt3 nt4 nt5 ntFixedWidth sRest;
3826 if ((int)ntFixedWidth < 80)
3827 LanguageSettings.setCommentWrapOptions('c
', ntBlockCommentWrap:+' ':+ntDocCommentWrap:+' ':+nt3:+' ':+nt4:+' ':+nt5:+' 80 ':+sRest);
3828 //replace_def_data("def-comment-wrap-c",'0 1 0 1 1 64 0 0 80 0 80 0 80 0 0 1 '); - default
3829 //replace_def_data("def-comment-wrap-c",'0 1 0 1 1 80 0 0 80 0 80 0 80 0 0 0 '); - disabled
3830 //replace_def_data("def-comment-wrap-c",'1 1 0 1 1 80 0 0 80 0 80 0 80 0 0 1 '); - enable block comment wrap.
3834 /* set the encoding to UTF-8 without any friggin useless signatures. */
3835 idxExt = name_match('def
-lang
-for
-ext
-', 1, MISC_TYPE);
3838 if (name_info(idxExt) == sLangId)
3840 parse name_name(idxExt) with 'def
-lang
-for
-ext
-' auto sExt;
3841 sVarName = 'def
-encoding
-' :+ sExt;
3842 idxExtEncoding = find_index(sVarName, MISC_TYPE);
3843 if (idxExtEncoding != 0)
3844 delete_name(idxExtEncoding);
3846 idxExt = name_match('def
-lang
-for
-ext
-', 0, MISC_TYPE);
3848 //replace_def_data('def
-encoding
-' :+ sLangId, '+futf8
');
3849 idxLangEncoding = find_index('def
-encoding
-' :+ sLangId, MISC_TYPE);
3850 if (idxLangEncoding != 0)
3851 delete_name(idxLangEncoding);
3854 replace_def_data('def
-encoding
', '+futf8
');
3856 LanguageSettings.setIndentWithTabs('mak
', true);
3857 LanguageSettings.setLexerName('mak
', 'kmk
');
3858 LanguageSettings.setSyntaxIndent('mak
', 8);
3860 LanguageSettings.setBeautifierProfileName('c
', "bird's Style
");
3861 LanguageSettings.setBeautifierProfileName('m', "bird
's Objective-C Style");
3863 /* Fix .asm and add .mac, .kmk, .cmd, and .pgsql. */
3864 kdev_ext_to_lang("asm", 'masm
');
3865 kdev_ext_to_lang("mac", 'masm
');
3866 kdev_ext_to_lang("kmk", 'mak
');
3867 kdev_ext_to_lang("cmd", 'bat
');
3868 kdev_ext_to_lang("pgsql", 'plsql
');
3871 * Change the codehelp default.
3873 # if __VERSION__ >= 22.0
3874 VSCodeHelpFlags fOldCodeHelp, fNewCodeHelp;
3876 int fOldCodeHelp, fNewCodeHelp;
3878 fOldCodeHelp = def_codehelp_flags;
3879 fNewCodeHelp = fOldCodeHelp \
3880 | VSCODEHELPFLAG_AUTO_FUNCTION_HELP \
3881 | VSCODEHELPFLAG_AUTO_LIST_MEMBERS \
3882 | VSCODEHELPFLAG_SPACE_INSERTS_SPACE \
3883 | VSCODEHELPFLAG_INSERT_OPEN_PAREN \
3884 | VSCODEHELPFLAG_DISPLAY_MEMBER_COMMENTS \
3885 | VSCODEHELPFLAG_DISPLAY_FUNCTION_COMMENTS \
3886 | VSCODEHELPFLAG_REPLACE_IDENTIFIER \
3887 | VSCODEHELPFLAG_PRESERVE_IDENTIFIER \
3888 | VSCODEHELPFLAG_AUTO_PARAMETER_COMPLETION \
3889 | VSCODEHELPFLAG_AUTO_LIST_PARAMS \
3890 | VSCODEHELPFLAG_PARAMETER_TYPE_MATCHING \
3891 | VSCODEHELPFLAG_NO_SPACE_AFTER_PAREN \
3892 | VSCODEHELPFLAG_RESERVED_ON \
3893 | VSCODEHELPFLAG_MOUSE_OVER_INFO \
3894 | VSCODEHELPFLAG_AUTO_LIST_VALUES \
3895 | VSCODEHELPFLAG_HIGHLIGHT_TAGS \
3896 | VSCODEHELPFLAG_FIND_TAG_PREFERS_ALTERNATE \
3898 fNewCodeHelp &= ~( VSCODEHELPFLAG_SPACE_COMPLETION \
3899 | VSCODEHELPFLAG_AUTO_SYNTAX_HELP \
3900 | VSCODEHELPFLAG_NO_SPACE_AFTER_COMMA \
3901 | VSCODEHELPFLAG_STRICT_LIST_SELECT \
3902 | VSCODEHELPFLAG_AUTO_LIST_VALUES \
3903 | VSCODEHELPFLAG_FIND_TAG_PREFERS_DECLARATION \
3904 | VSCODEHELPFLAG_FIND_TAG_PREFERS_DEFINITION \
3905 | VSCODEHELPFLAG_FIND_TAG_HIDE_OPTIONS \
3907 def_codehelp_flags = fNewCodeHelp;
3908 foreach (sLangId in aMyLangIds)
3910 _str sVarName = 'def
-codehelp
-' :+ sLangId;
3911 int idxVar = find_index(sVarName, MISC_TYPE);
3913 replace_def_data(sVarName, fNewCodeHelp);
3917 # if __VERSION__ >= 21.0
3918 /* Old style search dialog, not mini. */
3919 def_gui_find_default = 1;
3922 _fso_strip_spaces(STSO_STRIP_MODIFIED);
3925 * - Auto restore clipboards
3932 static int kfile_to_array(_str sFile, _str (&asLines)[])
3934 asLines._makeempty();
3938 int rc = _open_temp_view(sFile, idTempView, idOrgView);
3941 _GoToROffset(0); /* top of the file. */
3950 } while (down() == 0);
3952 _delete_temp_view(idTempView);
3953 activate_window(idOrgView);
3959 _command void kload_files(_str sFile = "file-not-specified.lst")
3961 _str sFileDir = absolute(_strip_filename(sFile, 'NE
'));
3963 int rc = kfile_to_array(sFile, asFiles);
3968 for (i = 0; i < asFiles._length(); i++)
3970 _str sFile = strip(asFiles[i]);
3971 if (length(sFile) > 0)
3973 sAbsFile = absolute(sFile, sFileDir);
3974 message("Loading \"" :+ sAbsFile :+ "\"...");
3975 //say("sAbsFile=" :+ sAbsFile);
3981 message("_GetFileContents failed: " :+ rc);
3986 * Module initiation.
3991 for (i = 0; i < 999; i++)
3993 index = name_match("def-koptions-", 1 /*find_first*/, MISC_TYPE);
4001 #ifdef KDEV_WITH_MENU
4003 # if __VERSION__ < 18.0 /* Something with timers are busted, so excusing my code. */
4004 iTimer = _set_timer(1000, k_menu_create, "timer");
4006 /* createMyColorSchemeAndUseIt();*/