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
78 //def
'C-S-Q' = klib_klog_file_ask
79 //def
'C-S-N' = klib_klog_file_no_ask
80 //def
'C-S-1' = klib_klogentry
81 //def
'C-S-3' = klib_klogexit
84 //MARKER
. Editor searches for this line
!
85 #pragma
option(redeclvars
, on
)
87 #ifndef VS_TAGDETAIL_context_args
88 /* newer vslick version
. */
90 //#pragma
option(strict
,on
)
91 /*#
else: Version
4.0 (OS
/2) */
95 #define KDEV_WITH_MENU
98 /* Remeber to change these
! */
99 static _str skUserInitials
= "bird";
100 static _str skUserName
= "knut st. osmundsen";
101 static _str skUserEmail
= "bird-kBuild-spamx@anduin.net";
104 /*******************************************************************************
106 *******************************************************************************/
107 static _str skCodeStyle
= 'Opt2Ind4'; /* coding style scheme
. */
108 static _str skDocStyle
= 'javadoc';/* options
: javadoc
, */
109 static _str skLicense
= 'GPLv3'; /* options
: GPL
, LGPL
, Odin32
, Confidential
, ++ */
110 static _str skCompany
= ''; /* empty
or company name for copyright
*/
111 static _str skProgram
= ''; /* Current program name
- used by
[L
]GPL
*/
112 static _str skChange
= ''; /* Current change identifier
. */
114 static int ikStyleWidth
= 130; /* The page width of the style
. */
115 static
boolean fkStyleFullHeaders
= false; /* false: omit some tags
. */
116 static int ikStyleOneliner
= 45; /* The oneline comment column
. */
117 static int ikStyleModifyMarkColumn
= 105;
118 static
boolean fkStyleBoxTag
= false; /* true: Include tag in k_box_start
. */
121 /*******************************************************************************
122 * Internal Functions
*
123 *******************************************************************************/
126 * @returns ISO formatted date
.
135 j
= pos("/", date
, i
+1);
136 _str month
= substr(date
, 1, i
-1);
137 if (length(month
) == 1) month
= '0'month
;
138 _str day
= substr(date
, i
+1, j
-i
-1);
139 if (length(day
) == 1) day
= '0'day
;
140 _str year
= substr(date
, j
+1);
141 return year
"-"month
"-"day
;
146 * Get the
current year
.
147 * @returns
Current year
string.
151 _str date
= _date('U');
152 return
substr(date
, pos("/",date
, pos("/",date
)+1)+1, 4);
157 * Aligns a value up to a given alignment
.
159 static int
k_alignup(int iValue
, iAlign
)
163 message('k_alignup: iValue='iValue
' iAlign='iAlign
);
166 return ((iValue intdiv iAlign
) + 1) * iAlign
;
171 * Reads the comment setup for this lexer
/extension
.
173 * @returns Success indicator
.
174 * @param sLeft Left comment
. (output
)
175 * @param sRight Right comment
. (output
)
176 * @param iColumn Comment mark column
. (1-based
) (output
)
177 * @param sExt The extension to lookup defaults to the
current one
.
178 * @param sLexer The lexer to lookup defaults to the
current one
.
179 * @remark This should be exported
from box
.e
, but unfortunately it isn
't.
181 static boolean k_commentconfig(_str &sLeft, _str &sRight, int &iColumn, _str sExt = p_extension, _str sLexer = p_lexer_name)
188 * Get comment setup from the lexer.
194 #if __VERSION__ >= 21.0
195 COMMENT_TYPE aComments[];
196 GetComments(aComments, "M", sLexer);
197 for (i = 0; i < aComments._length(); i++)
198 # if __VERSION__ >= 22.0
199 if (aComments[i].type != 'doc_comment
')
201 if (!aComments[i].isDocumentation)
204 sLeft = aComments[i].delim1;
205 sRight = aComments[i].delim2;
206 iColumn = aComments[i].startcol;
207 if (sLeft != '' && sRight != '')
211 # if __VERSION__ >= 14.0
212 _str aComments[] = null;
213 GetComments(aComments, "mlcomment", sLexer);
214 for (i = 0; i < aComments._length(); i++)
215 if (pos("documentation", aComments[i]) <= 0)
217 sLine = aComments[i];
222 rc = _ini_get_value(slick_path_search("user.vlx"), sLexer, 'mlcomment
', sLine);
224 rc = _ini_get_value(slick_path_search("vslick.vlx"), sLexer, 'mlcomment
', sLine);
228 sLeft = strip(word(sLine, 1));
229 sRight = strip(word(sLine, 2));
230 if (sLeft != '' && sRight != '')
235 /* failed, try single line. */
236 #if __VERSION__ >= 21.0
237 GetComments(aComments, "L", sLexer);
238 for (i = 0; i < aComments._length(); i++)
239 # if __VERSION__ >= 22.0
240 if (aComments[i].type != 'doc_comment
')
242 if (!aComments[i].isDocumentation)
245 sLeft = aComments[i].delim1;
247 iColumn = aComments[i].startcol;
252 # if __VERSION__ >= 14.0
253 GetComments(aComments, "linecomment", sLexer)
254 for (i = 0; i < aComments._length(); i++)
255 if (pos("documentation", aComments[i]) <= 0)
257 sLine = aComments[i];
262 rc = _ini_get_value(slick_path_search("user.vlx"), sLexer, 'linecomment
', sLine);
264 rc = _ini_get_value(slick_path_search("vslick.vlx"), sLexer, 'linecomment
', sLine);
268 sLeft = strip(word(sLine, 1));
271 _str sTmp = word(sLine, 2);
281 * Read the nonboxchars and determin user or default box.ini.
283 _str sFile = slick_path_search("ubox.ini");
284 boolean frc = _ini_get_value(sFile, sExt, 'nonboxchars
', sLine);
287 sFile = slick_path_search("box.ini");
288 frc = _ini_get_value(sFile, sExt, 'nonboxchars
', sLine);
295 sLeft = strip(eq_name2value('left
',sLine));
296 if (sLeft == '\e
') sLeft = '';
297 sRight = strip(eq_name2value('right
',sLine));
298 if (sRight == '\e
') sRight = '';
300 /* Read comment column too */
301 frc = _ini_get_value(sFile, sExt, 'comment_col
', sLine);
304 iColumn = eq_name2value('comment_col
', sLine);
305 if (iColumn == '\e
') iColumn = 0;
321 * Checks if current file only support line comments.
322 * @returns True / False.
323 * @remark Use builtin extension stuff!
325 static boolean k_line_comment()
330 boolean fLineComment = false;
331 if (k_commentconfig(sLeft, sRight, iColumn))
332 fLineComment = (sRight == '' || iColumn > 0);
338 #define KIC_CURSOR_BEFORE 1
339 #define KIC_CURSOR_AFTER 2
340 #define KIC_CURSOR_AT_END 3
343 * Insert a comment at current or best fitting position in the text.
344 * @param sStr The comment to insert.
345 * @param iCursor Where to put the cursor.
346 * @param iPosition Where to start the comment.
347 * Doesn't apply to column based source
.
348 * -1 means at cursor position
. (default
)
349 * >0 means at
end of line
, but
not before this
column (1-based
).
350 * This also
implies a min of one space to EOL
.
352 void
k_insert_comment(_str sStr
, int iCursor
, int iPosition
= -1)
357 if (!k_commentconfig(sLeft
, sRight
, iColumn
))
359 sLeft
= '/*'; sRight
= '*/'; iColumn
= 0;
365 * not column based source
368 /* position us first
*/
374 } while (p_col
< iPosition
);
377 /* insert comment saving the position for _BEFORE
. */
379 _insert_text(sLeft
:+' ':+sStr
);
380 if (iCursor
== KIC_CURSOR_AT_END
)
382 /* right comment delimiter?
*/
384 _insert_text(' ':+sRight
);
388 if (p_col
>= iColumn
)
390 do { _insert_text(" "); } while (p_col
< iColumn
);
391 if (iCursor
== KIC_CURSOR_BEFORE
)
393 _insert_text(sLeft
:+' ':+sStr
);
394 if (iCursor
== KIC_CURSOR_AT_END
)
399 if (iCursor
!= KIC_CURSOR_AFTER
)
405 * Gets the comment
prefix or postfix
.
406 * @returns Comment
prefix or postfix
.
407 * @param fRight
If clear left comment
string - default
.
408 * If set right comment
string.
410 static _str
k_comment(boolean fRight
= false)
414 _str sComment
= '/*';
415 if (k_commentconfig(sLeft
, sRight
, iColumn
))
416 sComment
= (!fRight || iColumn
> 0 ? sLeft
: sRight
);
418 return
strip(sComment
);
422 /*******************************************************************************
424 *******************************************************************************/
427 * Inserts the first line in a box
.
428 * @param sTag
Not used
- box tag
.
430 static void
k_box_start(sTag
)
434 if (!k_commentconfig(sLeft
, sRight
, iColumn
))
438 while (p_col
< iColumn
)
442 if (sTag
!= '' && fkStyleBoxTag
)
444 if (substr(sText
, length(sText
)) != '*')
450 for (i
= length(sText
); i
<= ikStyleWidth
- p_col
; i
++)
459 * Places a
string, sStr
, into a line started
and ended by
'*'.
460 * @param sStr Text to have between the
'*'s
.
462 static void
k_box_line(_str sStr
)
466 if (!k_commentconfig(sLeft
, sRight
, iColumn
))
469 while (p_col
< iColumn
)
473 if (k_line_comment())
475 if (sText
== '' ||
substr(sText
, length(sText
)) != '*')
480 for (i
= length(sText
); i
< p_SyntaxIndent
; i
++)
485 for (i
= length(sText
) + 1; i
<= ikStyleWidth
- p_col
; i
++)
487 sText
= sText
:+"*\n";
494 * Inserts the last line in a box
.
496 static void
k_box_end()
500 if (!k_commentconfig(sLeft
, sRight
, iColumn
))
503 while (p_col
< iColumn
)
507 if (k_line_comment())
509 for (i
= length(sText
) + length(sRight
); i
<= ikStyleWidth
- p_col
; i
++)
511 sText
= sText
:+sRight
:+"\n";
518 /*******************************************************************************
519 * FUNCTION
AND CODE PARSERS
*
520 *******************************************************************************/
522 * Moves cursor to nearest function start
.
526 static int
k_func_goto_nearest_function()
528 boolean fFix
= false; /* cursor at function fix
. (last function
) */
529 int cur_line
= p_line
;
538 if (!prev_proc(1) && p_line
== cur_line
)
540 _restore_pos2(org_pos
);
543 _restore_pos2(org_pos
);
548 p_col
++; /* fixes problem with single function files
. */
555 if (!next_proc(1) && p_line
== cur_line
)
557 _restore_pos2(org_pos
);
560 _restore_pos2(org_pos
);
565 if (prev_line
!= -1 && (next_line
== -1 || cur_line
- prev_line
<= next_line
- cur_line
))
573 if (next_line
!= -1 && (prev_line
== -1 || cur_line
- prev_line
> next_line
- cur_line
))
579 _restore_pos2(org_pos
);
585 * Check if nearest function
is a prototype
.
586 * @returns
True if function prototype
.
587 * False if not function prototype
.
589 static
boolean k_func_prototype()
592 * Check if this
is a
real function implementation
.
596 if (!k_func_goto_nearest_function())
598 int proc_line
= p_line
;
600 if (!k_func_searchcode("{"))
603 if (p_line
!= proc_line
)
605 _restore_pos2(procpos
);
610 _restore_pos2(procpos
);
617 * Gets the name fo the
current function
.
618 * @returns The
current function name
.
620 static _str
k_func_getfunction_name()
622 _str sFunctionName
= current_proc();
625 //say
'functionanme='sFunctionName
;
626 return sFunctionName
;
631 * Goes to the neares function
and gets its parameters
.
632 * @remark Should be reimplemented to use
tags (if someone can figure out how to query that stuff
).
634 static _str
k_func_getparams()
640 * Try use the tags first
.
642 _UpdateContext(true);
643 int context_id
= tag_current_context();
646 k_func_goto_nearest_function();
647 context_id
= tag_current_context();
653 tag_get_detail2(VS_TAGDETAIL_context_args
, context_id
, args
);
654 tag_get_detail2(VS_TAGDETAIL_context_type
, context_id
, type
);
655 if (tag_tree_type_is_func(type
))
657 //caption
= tag_tree_make_caption_fast(VS_TAGMATCH_context
,context_id
,true,true,false);
661 * Go to nearest function
.
663 if ( !k_func_goto_nearest_function()
664 && !k_func_searchcode("(") /* makes some assumptions
. */
671 _save_pos2(posStart
);
672 long offStart
= _QROffset();
673 if (!find_matching_paren())
675 long offEnd
= _QROffset();
676 _restore_pos2(posStart
);
678 _str sParamsRaw
= strip(get_text((int
)(offEnd
- offStart
- 1)));
682 * Remove new lines
and double spaces within params
.
688 for (i
= 1, chPrev
= ' '; i
<= length(sParamsRaw
); i
++)
690 _str ch
= substr(sParamsRaw
, i
, 1);
695 if (ch
== " " && chPrev
== " ")
698 if ((ch
:== "\n") ||
(ch
:== "\r") ||
(ch
:== "\t"))
705 if (ch
== ',' && chPrev
== ' ')
707 sParams
= substr(sParams
, 1, length(sParams
) - 1);
713 sParams
= sParams
:+ ' * ';
715 sParams
= sParams
:+ '* ';
720 sParams
= sParams
:+ ch
;
726 sParams
= strip(sParams
);
727 if (sParams
== 'void' || sParams
== 'VOID')
729 _restore_pos2(org_pos
);
733 message("find_matchin_paren failed");
736 _restore_pos2(org_pos
);
743 * Enumerates the parameters to the function
.
744 * @param sParams Parameter
string from k_func_getparams
.
745 * @param iParam The
index (0-based
) of the parameter to get
.
746 * @param sType Type
. (output
)
747 * @param sName Name
. (output
)
748 * @param sDefault Default value
. (output
)
749 * @remark Doesn
't perhaps handle function pointers very well (I think)?
750 * @remark Should be reimplemented to use tags (if someone can figure out how to query that stuff).
752 static int k_func_enumparams(_str sParams, int iParam, _str &sType, _str &sName, _str &sDefault)
759 sType = sName = sDefault = "";
761 /* no use working on empty string! */
762 if (length(sParams) == 0)
765 /* find the parameter in question */
766 for (iStartParam = i = 1, iParLevel = iCurParam = 0; i <= length(sParams); i++)
768 _str ch = substr(sParams, i, 1);
769 if (ch == ',' && iParLevel == 0)
771 /* is it this parameter ? */
772 if (iParam == iCurParam)
784 /* did we find the parameter? */
785 if (iParam == iCurParam)
786 { /* (yeah, we did!) */
787 _str sArg = strip(substr(sParams, iStartParam, i - iStartParam));
788 /* remove M$ stuff */
789 sArg = stranslate(sArg, "", "IN", "E");
790 sArg = stranslate(sArg, "", "OUT", "E");
791 sArg = stranslate(sArg, "", "OPTIONAL", "E");
794 /* lazy approach, which doens't support function types
*/
796 if (pos('=', sParams
) > 0) /* default
*/
798 sDefault
= strip(substr(sParams
, pos('=', sParams
) + 1));
799 sArg
= strip(substr(sArg
, 1, pos('=', sParams
) - 1));
802 for (i
= length(sArg
); i
> 1; i
--)
804 _str ch
= substr(sArg
, i
, 1);
805 if ( !(ch
>= 'a' && ch
<= 'z')
806 && !(ch
>= 'A' && ch
<= 'Z')
807 && !(ch
>= '0' && ch
<= '9')
808 && ch
!= '_' && ch
!= '$')
813 sName
= strip(substr(sArg
, i
+ 1));
814 sType
= strip(substr(sArg
, 1, i
));
824 * Counts the parameters to the function
.
825 * @param sParams Parameter
string from k_func_getparams
.
826 * @remark Should be reimplemented to use
tags (if someone can figure out how to query that stuff
).
828 static int
k_func_countparams(_str sParams
)
833 _str sType
= "", sName
= "", sDefault
= "";
835 /* check for
0 parameters
*/
836 if (length(sParams
) == 0)
839 /* find the parameter in question
*/
840 for (i
= 1, iParLevel
= iCurParam
= 0; i
<= length(sParams
); i
++)
842 _str ch
= substr(sParams
, i
, 1);
843 if (ch
== ',' && iParLevel
== 0)
853 return iCurParam
+ 1;
858 * Gets the return type
.
860 static _str
k_func_getreturntype(boolean fPureType
= false)
866 * Go to nearest function
.
868 if (!k_func_goto_nearest_function())
871 * Return type
is from function start to function name
...
874 _save_pos2(posStart
);
875 long offStart
= _QROffset();
877 if (!k_func_searchcode("(")) /* makes some assumptions
. */
880 long offEnd
= _QROffset();
881 _restore_pos2(posStart
);
882 _str sTypeRaw
= strip(get_text((int
)(offEnd
- offStart
)));
884 //say
'sTypeRaw='sTypeRaw
;
886 * Remove static
, inline
, _Optlink
, stdcall
, EXPENTRY etc
.
890 sTypeRaw
= stranslate(sTypeRaw
, "", "__static__", "I");
891 sTypeRaw
= stranslate(sTypeRaw
, "", "__static", "I");
892 sTypeRaw
= stranslate(sTypeRaw
, "", "static__", "I");
893 sTypeRaw
= stranslate(sTypeRaw
, "", "static", "I");
894 sTypeRaw
= stranslate(sTypeRaw
, "", "__inline__", "I");
895 sTypeRaw
= stranslate(sTypeRaw
, "", "__inline", "I");
896 sTypeRaw
= stranslate(sTypeRaw
, "", "inline__", "I");
897 sTypeRaw
= stranslate(sTypeRaw
, "", "inline", "I");
898 sTypeRaw
= stranslate(sTypeRaw
, "", "EXPENTRY", "I");
899 sTypeRaw
= stranslate(sTypeRaw
, "", "_Optlink", "I");
900 sTypeRaw
= stranslate(sTypeRaw
, "", "__stdcall", "I");
901 sTypeRaw
= stranslate(sTypeRaw
, "", "__cdecl", "I");
902 sTypeRaw
= stranslate(sTypeRaw
, "", "_cdecl", "I");
903 sTypeRaw
= stranslate(sTypeRaw
, "", "cdecl", "I");
904 sTypeRaw
= stranslate(sTypeRaw
, "", "__PASCAL", "I");
905 sTypeRaw
= stranslate(sTypeRaw
, "", "_PASCAL", "I");
906 sTypeRaw
= stranslate(sTypeRaw
, "", "PASCAL", "I");
907 sTypeRaw
= stranslate(sTypeRaw
, "", "__Far32__", "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
, "", "__far", "I");
915 sTypeRaw
= stranslate(sTypeRaw
, "", "_far", "I");
916 sTypeRaw
= stranslate(sTypeRaw
, "", "far", "I");
917 sTypeRaw
= stranslate(sTypeRaw
, "", "__near", "I");
918 sTypeRaw
= stranslate(sTypeRaw
, "", "_near", "I");
919 sTypeRaw
= stranslate(sTypeRaw
, "", "near", "I");
920 sTypeRaw
= stranslate(sTypeRaw
, "", "__loadds__", "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
, "", "__loades__", "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
, "", "WIN32API", "I");
935 sTypeRaw
= stranslate(sTypeRaw
, "", "WINAPI", "I");
936 sTypeRaw
= stranslate(sTypeRaw
, "", "LDRCALL", "I");
937 sTypeRaw
= stranslate(sTypeRaw
, "", "KRNLCALL", "I");
938 sTypeRaw
= stranslate(sTypeRaw
, "", "__operator__", "I"); /* operator fix
*/
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
, "", "IN", "E");
943 sTypeRaw
= stranslate(sTypeRaw
, "", "OUT", "E");
944 sTypeRaw
= stranslate(sTypeRaw
, "", "OPTIONAL", "E");
948 * Remove new lines
and double spaces within params
.
954 for (i
= 1, chPrev
= ' '; i
<= length(sTypeRaw
); i
++)
956 _str ch
= substr(sTypeRaw
, i
, 1);
961 if (ch
== " " && chPrev
== " ")
964 if ((ch
:== "\n") ||
(ch
:== "\r") ||
(ch
:== "\t"))
971 if (ch
== ',' && chPrev
== ' ')
973 sType
= substr(sType
, 1, length(sType
) - 1);
979 sType
= sType
:+ ' * ';
981 sType
= sType
:+ '* ';
992 sType
= strip(sType
);
994 _restore_pos2(org_pos
);
998 message('k_func_getreturntype: can''t find ''(''.');
1001 _restore_pos2(org_pos
);
1007 * Search for some piece of code
.
1009 static int
k_func_searchcode(_str sSearchString
, _str sOptions
= "E+")
1012 rc
= search(sSearchString
, sOptions
);
1013 while (!rc
&& !k_func_in_code())
1016 rc
= search(sSearchString
, sOptions
);
1023 * Checks
if cursor
is in code
or in comment
.
1024 * @return
True if cursor in code
.
1026 static
boolean k_func_in_code()
1028 typeless searchsave
;
1029 _save_pos2(searchsave
);
1030 boolean fRc
= !_in_comment();
1031 _restore_pos2(searchsave
);
1037 * Gets the next piece of code
.
1039 static _str
k_func_get_next_code_text()
1041 typeless searchsave
;
1042 _save_pos2(searchsave
);
1043 _str ch
= k_func_get_next_code_text2();
1044 _restore_pos2(searchsave
);
1050 * Checks
if there
is more code on the line
.
1052 static
boolean k_func_more_code_on_line()
1055 int curline
= p_line
;
1056 typeless searchsave
;
1057 _save_pos2(searchsave
);
1058 k_func_get_next_code_text2();
1059 fRc
= curline
== p_line
;
1060 _restore_pos2(searchsave
);
1067 * Gets the next piece of code
.
1068 * Doesn
't preserver cursor position.
1070 static _str k_func_get_next_code_text2()
1075 int curcol = ++p_col;
1077 if (p_col <= curcol)
1086 //say ch ' ('_asc(ch)')';
1087 while (ch == "#") /* preprocessor stuff */
1092 //say ch ' ('_asc(ch)')';
1095 } while (ch :== ' ' || ch :== "\t" || ch :== "\n" || ch :== "\r" || !k_func_in_code());
1103 /*******************************************************************************
1104 * JAVA DOC STYLED WORKERS *
1105 *******************************************************************************/
1107 /** starts a javadoc documentation box. */
1108 static void k_javadoc_box_start(_str sStr = '', boolean fDouble = true)
1112 if (!k_commentconfig(sLeft, sRight, iColumn))
1116 while (p_col < iColumn)
1121 sText = sLeft:+substr(sLeft, length(sLeft), 1);
1123 sText = sText:+' ':+sStr;
1124 sText = sText:+"\n";
1126 _insert_text(sText);
1129 /** inserts a new line in a javadoc documentation box. */
1130 static void k_javadoc_box_line(_str sStr = '', int iPadd = 0, _str sStr2 = '', int iPadd2 = 0, _str sStr3 = '')
1134 if (!k_commentconfig(sLeft, sRight, iColumn))
1137 while (p_col < iColumn)
1141 if (k_line_comment())
1146 sText = ' ':+substr(sLeft, length(sLeft));
1150 sText = sText:+' ':+sStr;
1154 for (i = length(sText); i < iPadd; i++)
1158 sText = sText:+sStr2;
1162 for (i = length(sText); i < iPadd2; i++)
1166 sText = sText:+sStr3;
1169 sText = sText:+"\n";
1171 _insert_text(sText);
1174 /** ends a javadoc documentation box. */
1175 static void k_javadoc_box_end()
1179 if (!k_commentconfig(sLeft, sRight, iColumn))
1182 while (p_col < iColumn)
1186 if (k_line_comment())
1191 /*if (substr(sText, 1, 1) != '*')
1192 sText = '*':+sText;*/
1195 sText = sText:+"\n";
1197 _insert_text(sText);
1202 * Write a Javadoc styled classbox.
1204 void k_javadoc_classbox()
1207 int iPadd = k_alignup(12, p_SyntaxIndent);
1209 k_javadoc_box_start();
1210 iCursorLine = p_RLine;
1211 k_javadoc_box_line(' ');
1213 if (fkStyleFullHeaders)
1215 k_javadoc_box_line('@shortdesc
', iPadd);
1216 k_javadoc_box_line('@dstruct
', iPadd);
1217 k_javadoc_box_line('@version
', iPadd);
1218 k_javadoc_box_line('@verdesc
', iPadd);
1220 k_javadoc_box_line('@author
', iPadd, skUserName ' <' skUserEmail '>');
1221 k_javadoc_box_line('@approval
', iPadd);
1222 k_javadoc_box_end();
1224 up(p_RLine - iCursorLine);
1231 * Javadoc - functionbox(/header).
1233 void k_javadoc_funcbox()
1238 int iPadd = k_alignup(11, p_SyntaxIndent);
1240 /* look for parameters */
1241 boolean fFoundFn = !k_func_goto_nearest_function();
1244 sArgs = k_func_getparams();
1245 cArgs = k_func_countparams(sArgs);
1248 k_javadoc_box_start();
1249 iCursorLine = p_RLine;
1250 k_javadoc_box_line(' ');
1251 if (file_eq(p_extension, 'asm
') || file_eq(p_extension, 'masm
'))
1252 k_javadoc_box_line('@cproto
', iPadd);
1253 k_javadoc_box_line('@returns
', iPadd);
1257 * Determin parameter description indent.
1261 for (i = 0; i < cArgs; i++)
1263 _str sName, sType, sDefault;
1264 if ( !k_func_enumparams(sArgs, i, sType, sName, sDefault)
1265 && iPadd2 < length(sName))
1266 iPadd2 = length(sName);
1268 iPadd2 = k_alignup((iPadd + iPadd2), p_SyntaxIndent);
1270 iPadd2 = k_alignup(28, p_SyntaxIndent);
1275 for (i = 0; i < cArgs; i++)
1277 _str sName, sType, sDefault;
1278 if (!k_func_enumparams(sArgs, i, sType, sName, sDefault))
1282 sStr3 = '(default
='sDefault')';
1283 k_javadoc_box_line('@param
', iPadd, sName, iPadd2, sStr3);
1286 k_javadoc_box_line('@param
', iPadd);
1290 k_javadoc_box_line('@param
', iPadd);
1292 if (file_eq(p_extension, 'asm
') || file_eq(p_extension, 'masm
'))
1293 k_javadoc_box_line('@uses
', iPadd);
1294 if (fkStyleFullHeaders)
1296 k_javadoc_box_line('@equiv
', iPadd);
1297 k_javadoc_box_line('@time
', iPadd);
1298 k_javadoc_box_line('@sketch
', iPadd);
1299 k_javadoc_box_line('@status
', iPadd);
1300 k_javadoc_box_line('@author
', iPadd, skUserName ' <' skUserEmail '>');
1301 k_javadoc_box_line('@remark
', iPadd);
1303 k_javadoc_box_end();
1305 up(p_RLine - iCursorLine);
1312 * Javadoc module header.
1314 void k_javadoc_moduleheader()
1322 k_insert_comment('$
':+'I
':+'d
: $
', KIC_CURSOR_AT_END, -1);
1326 k_javadoc_box_start('@file
');
1328 iCursorLine = p_RLine;
1329 k_javadoc_box_line();
1330 k_javadoc_box_end();
1332 _insert_text(k_comment() "\n");
1334 if (skLicense == 'Confidential
')
1336 k_javadoc_box_line(skCompany ' confidential
');
1337 k_javadoc_box_line();
1340 if (skCompany != '')
1342 if (skLicense != 'Confidential
')
1343 k_javadoc_box_line('Copyright (C
) ' k_year() ' ' skCompany);
1346 k_javadoc_box_line('Copyright (c
) ' k_year() ' ' skCompany);
1347 k_javadoc_box_line();
1348 k_javadoc_box_line('Author
: ' skUserName' <' skUserEmail '>');
1352 k_javadoc_box_line('Copyright (c
) ' k_year() ' 'skUserName' <' skUserEmail '>');
1353 k_javadoc_box_line();
1354 _str sProg = skProgram;
1358 k_javadoc_box_line('Project Odin Software License can be found in LICENSE
.TXT
.');
1363 k_javadoc_box_line();
1365 sProg = 'This program
';
1368 k_javadoc_box_line('This file
is part of
' sProg '.');
1369 k_javadoc_box_line();
1371 k_javadoc_box_line(sProg ' is free software
; you can redistribute it
and/or modify
');
1372 k_javadoc_box_line('it under the terms of the GNU General Public License
as published by
');
1373 k_javadoc_box_line('the Free Software Foundation
; either version
2 of the License
, or');
1374 k_javadoc_box_line('(at your option
) any later version
.');
1375 k_javadoc_box_line();
1376 k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful
,');
1377 k_javadoc_box_line('but WITHOUT ANY WARRANTY
; without even the implied warranty of
');
1378 k_javadoc_box_line('MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE
. See the
');
1379 k_javadoc_box_line('GNU General Public License for more details
.');
1380 k_javadoc_box_line();
1381 k_javadoc_box_line('You should have received a copy of the GNU General Public License
');
1382 k_javadoc_box_line('along with
' sProg '; if not, write to the Free Software
');
1383 k_javadoc_box_line('Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301 USA
');
1388 k_javadoc_box_line();
1390 sProg = 'This library
';
1393 k_javadoc_box_line('This file
is part of
' sProg '.');
1394 k_javadoc_box_line();
1396 k_javadoc_box_line(sProg ' is free software
; you can redistribute it
and/or');
1397 k_javadoc_box_line('modify it under the terms of the GNU Lesser General Public
');
1398 k_javadoc_box_line('License
as published by the Free Software Foundation
; either
');
1399 k_javadoc_box_line('version
2.1 of the License
, or (at your option
) any later version
.');
1400 k_javadoc_box_line();
1401 k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful
,');
1402 k_javadoc_box_line('but WITHOUT ANY WARRANTY
; without even the implied warranty of
');
1403 k_javadoc_box_line('MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE
. See the GNU
');
1404 k_javadoc_box_line('Lesser General Public License for more details
.');
1405 k_javadoc_box_line();
1406 k_javadoc_box_line('You should have received a copy of the GNU Lesser General Public
');
1407 k_javadoc_box_line('License along with
' sProg '; if not, write to the Free Software
');
1408 k_javadoc_box_line('Foundation
, Inc
., 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301 USA
');
1413 k_javadoc_box_line();
1415 sProg = 'This program
';
1418 k_javadoc_box_line('This file
is part of
' sProg '.');
1419 k_javadoc_box_line();
1421 k_javadoc_box_line(sProg ' is free software
; you can redistribute it
and/or modify
');
1422 k_javadoc_box_line('it under the terms of the GNU General Public License
as published by
');
1423 k_javadoc_box_line('the Free Software Foundation
; either version
3 of the License
, or');
1424 k_javadoc_box_line('(at your option
) any later version
.');
1425 k_javadoc_box_line();
1426 k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful
,');
1427 k_javadoc_box_line('but WITHOUT ANY WARRANTY
; without even the implied warranty of
');
1428 k_javadoc_box_line('MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE
. See the
');
1429 k_javadoc_box_line('GNU General Public License for more details
.');
1430 k_javadoc_box_line();
1431 k_javadoc_box_line('You should have received a copy of the GNU General Public License
');
1432 k_javadoc_box_line('along with
' sProg '. If not, see
<http
://www
.gnu
.org
/licenses
/>');
1437 k_javadoc_box_line();
1439 sProg = 'This program
';
1442 k_javadoc_box_line('This file
is part of
' sProg '.');
1443 k_javadoc_box_line();
1445 k_javadoc_box_line(sProg ' is free software
; you can redistribute it
and/or');
1446 k_javadoc_box_line('modify it under the terms of the GNU Lesser General Public
');
1447 k_javadoc_box_line('License
as published by the Free Software Foundation
; either
');
1448 k_javadoc_box_line('version
3 of the License
, or (at your option
) any later version
.');
1449 k_javadoc_box_line();
1450 k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful
,');
1451 k_javadoc_box_line('but WITHOUT ANY WARRANTY
; without even the implied warranty of
');
1452 k_javadoc_box_line('MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE
. See the
');
1453 k_javadoc_box_line('GNU Lesser General Public License for more details
.');
1454 k_javadoc_box_line();
1455 k_javadoc_box_line('You should have received a copy of the GNU Lesser General Public License
');
1456 k_javadoc_box_line('along with
' sProg '. If not, see
<http
://www
.gnu
.org
/licenses
/>');
1459 case 'Confidential
':
1460 k_javadoc_box_line('All Rights Reserved
');
1463 case 'ConfidentialNoAuthor
':
1464 k_javadoc_box_line(skCompany ' confidential
');
1465 k_javadoc_box_line('All Rights Reserved
');
1469 k_javadoc_box_line('This file
is part of VirtualBox Open Source
Edition (OSE
), as')
1470 k_javadoc_box_line('available
from http
://www
.virtualbox
.org
. This file
is free software
;')
1471 k_javadoc_box_line('you can redistribute it
and/or modify it under the terms of the GNU
')
1472 k_javadoc_box_line('General Public
License (GPL
) as published by the Free Software
')
1473 k_javadoc_box_line('Foundation
, in version
2 as it comes in the
"COPYING" file of the
')
1474 k_javadoc_box_line('VirtualBox OSE distribution
. VirtualBox OSE
is distributed in the
')
1475 k_javadoc_box_line('hope that it will be useful
, but WITHOUT ANY WARRANTY of any kind
.')
1476 k_javadoc_box_line('')
1477 k_javadoc_box_line('Please contact Sun Microsystems
, Inc
., 4150 Network Circle
, Santa
')
1478 k_javadoc_box_line('Clara
, CA
95054 USA
or visit http
://www
.sun
.com
if you need
')
1479 k_javadoc_box_line('additional information
or have any questions
.')
1482 case 'VirtualBoxGPLAndCDDL
':
1483 k_javadoc_box_line('This file
is part of VirtualBox Open Source
Edition (OSE
), as')
1484 k_javadoc_box_line('available
from http
://www
.virtualbox
.org
. This file
is free software
;')
1485 k_javadoc_box_line('you can redistribute it
and/or modify it under the terms of the GNU
')
1486 k_javadoc_box_line('General Public
License (GPL
) as published by the Free Software
')
1487 k_javadoc_box_line('Foundation
, in version
2 as it comes in the
"COPYING" file of the
')
1488 k_javadoc_box_line('VirtualBox OSE distribution
. VirtualBox OSE
is distributed in the
')
1489 k_javadoc_box_line('hope that it will be useful
, but WITHOUT ANY WARRANTY of any kind
.')
1490 k_javadoc_box_line('')
1491 k_javadoc_box_line('The contents of this file may alternatively be used under the terms
')
1492 k_javadoc_box_line('of the Common Development
and Distribution License Version
1.0')
1493 k_javadoc_box_line('(CDDL
) only
, as it comes in the
"COPYING.CDDL" file of the
')
1494 k_javadoc_box_line('VirtualBox OSE distribution
, in which case the provisions of the
')
1495 k_javadoc_box_line('CDDL are applicable instead of those of the GPL
.')
1496 k_javadoc_box_line('')
1497 k_javadoc_box_line('You may elect to license modified versions of this file under the
')
1498 k_javadoc_box_line('terms
and conditions of either the GPL
or the CDDL
or both
.')
1499 k_javadoc_box_line('')
1500 k_javadoc_box_line('Please contact Sun Microsystems
, Inc
., 4150 Network Circle
, Santa
')
1501 k_javadoc_box_line('Clara
, CA
95054 USA
or visit http
://www
.sun
.com
if you need
')
1502 k_javadoc_box_line('additional information
or have any questions
.')
1508 k_javadoc_box_line();
1509 k_javadoc_box_end();
1511 up(p_RLine - iCursorLine);
1522 /*******************************************************************************
1523 * Keyboard Shortcuts *
1524 *******************************************************************************/
1525 /** Makes global box. */
1526 void k_box_globals()
1528 k_box_start('Global
');
1529 k_box_line('Global Variables
');
1533 /** Makes header box. */
1534 void k_box_headers()
1536 k_box_start("Header");
1537 k_box_line("Header Files");
1541 /** Makes internal function box. */
1542 void k_box_intfuncs()
1544 k_box_start("IntFunc");
1545 k_box_line("Internal Functions");
1549 /** Makes def/const box. */
1552 k_box_start("Const");
1553 k_box_line("Defined Constants And Macros");
1557 /** Structure box */
1558 void k_box_structs()
1560 k_box_start("Struct");
1561 k_box_line("Structures and Typedefs");
1565 /** Makes exported symbols box. */
1566 void k_box_exported()
1568 k_box_start('Exported
');
1569 k_box_line('Exported Symbols
');
1573 /** oneliner comment */
1578 if ( k_commentconfig(sLeft, sRight, iColumn)
1580 { /* column based needs some tricky repositioning. */
1582 if (p_col > iColumn)
1585 _insert_text("\n\r");
1589 k_insert_comment("", KIC_CURSOR_AT_END, ikStyleOneliner);
1592 /** mark line as modified. */
1593 void k_mark_modified_line()
1595 /* not supported for column based sources */
1598 if ( !k_commentconfig(sLeft, sRight, iColumn)
1603 sStr = skChange ' (' skUserInitials ')';
1605 sStr = skUserInitials;
1606 k_insert_comment(sStr, KIC_CURSOR_BEFORE, ikStyleModifyMarkColumn);
1611 * Inserts a signature. Form: "//Initials ISO-date:"
1612 * @remark defeventtab
1616 /* kso I5-10000 2002-09-10: */
1619 sSig = skUserInitials ' ' skChange ' ' k_date() ': ';
1621 sSig = skUserInitials ' ' k_date() ': ';
1622 k_insert_comment(sSig, KIC_CURSOR_AT_END);
1625 /* Insert a list of NOREF() macro invocations. */
1629 _save_pos2(org_pos);
1632 boolean fFoundFn = !k_func_goto_nearest_function();
1635 _str sArgs = k_func_getparams();
1636 int cArgs = k_func_countparams(sArgs);
1640 for (i = 0; i < cArgs; i++)
1642 _str sName, sType, sDefault;
1643 if (!k_func_enumparams(sArgs, i, sType, sName, sDefault))
1647 sThis = 'NOREF(' sName ');';
1648 if (length(sNoRefs) == 0)
1651 offLine += length(sThis);
1653 else if (offLine + length(sThis) < 130)
1655 sNoRefs = sNoRefs ' ' sThis;
1656 offLine += 1 + length(sThis);
1660 sNoRefs = sNoRefs "\n " sThis;
1661 offLine = 4 + length(sThis);
1664 else if (length(sNoRefs) == 0)
1666 sNoRefs = 'RT_NOREF(' sName;
1667 offLine = length(sNoRefs);
1669 else if (offLine + 2 + length(sName) < 130)
1671 sNoRefs = sNoRefs ', ' sName;
1672 offLine += 2 + length(sName);
1676 sNoRefs = sNoRefs ',\n
' sName;
1677 offLine += 4 + length(sName);
1681 if (length(sNoRefs) > 0 && fVaArgs != 0)
1682 sNoRefs = sNoRefs ');';
1685 _restore_pos2(org_pos);
1686 _insert_text(sNoRefs);
1689 /*******************************************************************************
1691 *******************************************************************************/
1693 * Hot-Key: Inserts a KLOGENTRY statement at start of nearest function.
1695 void klib_klogentry()
1698 _save_pos2(org_pos);
1701 * Go to nearest function.
1703 if (!k_func_goto_nearest_function())
1708 _str sParams = k_func_getparams();
1711 _str sRetType = k_func_getreturntype(true);
1712 if (!sRetType || sRetType == "")
1713 sRetType = "void"; /* paranoia! */
1718 if (!k_func_searchcode("{"))
1721 int cArgs = k_func_countparams(sParams);
1726 for (i = 0; i < cArgs; i++)
1728 _str sType, sName, sDefault;
1729 if (!k_func_enumparams(sParams, i, sType, sName, sDefault))
1730 sArgs = sArgs', 'sName;
1733 _insert_text("\n KLOGENTRY"cArgs"(\""sRetType"\",\""sParams"\""sArgs");"); /* todo tab size.. or smart indent */
1736 _insert_text("\n KLOGENTRY0(\""sRetType"\");"); /* todo tab size.. or smart indent */
1739 * Check if the next word is KLOGENTRY.
1742 if (def_next_word_style == 'E
')
1745 if (substr(cur_word(iIgnorePos), 1, 9) == "KLOGENTRY")
1750 message("didn't find
{");
1753 message("k_func_getparams failed
, sParams
=" sParams);
1757 _restore_pos2(org_pos);
1762 * Hot-Key: Inserts a KLOGEXIT statement at cursor location.
1764 void klib_klogexit()
1767 _save_pos2(org_pos);
1770 * Go to nearest function.
1777 _str sType = k_func_getreturntype(true);
1778 _restore_pos2(org_pos);
1781 boolean fReturn = true; /* true if an return statment is following the KLOGEXIT statement. */
1786 int cur_col = p_col;
1787 if (sType == 'void' || sType == 'VOID')
1790 fReturn = cur_word(iIgnorePos) == 'return';
1793 while (p_col <= p_SyntaxIndent)
1797 _insert_text("KLOGEXITVOID();\n
");
1802 for (i = 1; i < cur_col; i++)
1809 _insert_text("KLOGEXIT();\n
");
1811 for (i = 1; i < cur_col; i++)
1816 * Insert value if possible.
1819 _save_pos2(valuepos);
1821 if (def_next_word_style == 'E')
1824 if (cur_word(iIgnorePos) == 'return')
1826 p_col += length('return');
1828 _save_pos2(posStart);
1829 long offStart = _QROffset();
1830 if (!k_func_searchcode(";", "E
+"))
1832 long offEnd = _QROffset();
1833 _restore_pos2(posStart);
1834 _str sValue = strip(get_text((int)(offEnd - offStart)));
1835 //say 'sValue = 'sValue;
1836 _restore_pos2(valuepos);
1837 _save_pos2(valuepos);
1838 _insert_text(sValue);
1841 _restore_pos2(valuepos);
1845 * Remove old KLOGEXIT statement on previous line if any.
1848 _save_pos2(valuepos);
1849 int newexitline = p_line;
1850 p_line--; p_col = 1;
1852 if (def_next_word_style == 'E')
1855 if (p_line == newexitline - 1 && substr(cur_word(iIgnorePos), 1, 8) == 'KLOGEXIT')
1857 _restore_pos2(valuepos);
1860 * Check for missing '{...}'.
1864 boolean fFound = false;
1865 _save_pos2(valuepos);
1866 p_col--; find_matching_paren(); p_col += 2;
1867 k_func_searchcode(';', 'E+'); /* places us at the ';' of the return. (hopefully) */
1869 _str ch = k_func_get_next_code_text();
1872 _restore_pos2(valuepos);
1873 _save_pos2(valuepos);
1874 p_col--; find_matching_paren(); p_col += 2;
1875 k_func_searchcode(';', 'E+'); /* places us at the ';' of the return. (hopefully) */
1877 if (k_func_more_code_on_line())
1882 _save_pos2(returnget);
1883 k_func_searchcode("return
", "E
-");
1884 int return_col = p_col;
1885 _restore_pos2(returnget);
1889 while (p_col < return_col - p_SyntaxIndent)
1894 _restore_pos2(valuepos);
1895 _save_pos2(valuepos);
1897 p_col -= p_SyntaxIndent;
1898 int codecol = p_col;
1899 _insert_text("{\n
");
1900 while (p_col < codecol)
1904 _restore_pos2(valuepos);
1908 message("k_func_getreturntype failed
, sType
=" sType);
1912 _restore_pos2(org_pos);
1917 * Processes a file - ask user all the time.
1919 void klib_klog_file_ask()
1921 klib_klog_file_int(true);
1926 * Processes a file - no questions.
1928 void klib_klog_file_no_ask()
1930 klib_klog_file_int(false);
1938 static void klib_klog_file_int(boolean fAsk)
1944 /* ask question so we can get to the right position somehow.. */
1945 if (fAsk && _message_box("kLog process this file?
", "Visual SlickEdit
", MB_YESNO | MB_ICONQUESTION) != IDYES)
1951 while (!prev_proc())
1953 //say 'entry main loop: ' k_func_getfunction_name();
1958 if (k_func_prototype())
1966 _str sFunction = k_func_getfunction_name();
1967 rc = fAsk ? _message_box("Process this
function ("sFunction")?
", "Visual SlickEdit
", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
1971 _save_pos2(procpos);
1973 _restore_pos2(procpos);
1975 else if (rc == IDNO)
1984 bottom(); _refresh_scroll();
1985 boolean fUserCancel = false;
1986 while (!prev_proc() && !fUserCancel)
1989 _save_pos2(procpos);
1990 _str sCurFunction = k_func_getfunction_name();
1991 //say 'exit main loop: ' sCurFunction
1996 if (k_func_prototype())
2002 while ( !k_func_searchcode("return
", "WE
<+")
2003 && k_func_getfunction_name() == sCurFunction)
2005 //say 'exit sub loop: ' p_line
2011 _str sFunction = k_func_getfunction_name();
2012 rc = fAsk ? _message_box("Process this exit
from "sFunction"?
", "Visual SlickEdit
", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
2017 _save_pos2(returnpos);
2019 _restore_pos2(returnpos);
2022 else if (rc != IDNO)
2027 p_line++; /* just so we won't hit it again. */
2031 * If void function we'll have to check if there is and return; prior to the ending '}'.
2033 _restore_pos2(procpos);
2034 _save_pos2(procpos);
2035 _str sType = k_func_getreturntype(true);
2036 if (!fUserCancel && sType && (sType == 'void' || sType == 'VOID'))
2038 if ( !k_func_searchcode("{", "E
+")
2039 && !find_matching_paren())
2042 _save_pos2(funcend);
2045 if (cur_word(iIgnorePos) != "return
")
2050 _restore_pos2(funcend);
2053 _str sFunction = k_func_getfunction_name();
2054 rc = fAsk ? _message_box("Process this exit
from "sFunction"?
", "Visual SlickEdit
", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
2059 _save_pos2(returnpos);
2061 _restore_pos2(returnpos);
2070 _restore_pos2(procpos);
2074 /** @todo move to kkeys.e */
2075 _command void k_rebuild_tagfile()
2077 #if 1 /*__VERSION__ < 14.0*/
2078 if (file_match('-p 'maybe_quote_filename(strip_filename(_project_name,'e'):+TAG_FILE_EXT),1) != "")
2079 _project_update_files_retag(false, false, false, false);
2081 _project_update_files_retag(true, false, false, true);
2083 _str sArgs = "-refs
=on
";
2084 if (file_match('-p 'maybe_quote_filename(strip_filename(_project_name,'e'):+TAG_FILE_EXT),1) != "")
2085 sArgs = sArgs :+ " -retag
";
2086 sArgs = sArgs :+ " " :+ _workspace_filename;
2087 build_workspace_tagfiles(sArgs);
2092 /*******************************************************************************
2094 *******************************************************************************/
2095 static _str StyleLanguages[] =
2108 static StyleScheme StyleSchemes[] =
2117 "pad_condition_state
=1",
2118 "indent_with_tabs
=0",
2119 "nospace_before_paren
=0",
2120 "indent_comments
=1",
2122 "statement_comment_col
=0",
2123 "disable_bestyle
=0",
2124 "decl_comment_col
=0",
2125 "bestyle_on_functions
=0",
2126 "use_relative_indent
=1",
2127 "nospace_before_brace
=0",
2129 "statement_comment_state
=2",
2132 "parens_on_return
=0",
2133 "eat_blank_lines
=0",
2136 "align_on_parens
=1",
2137 "continuation_indent
=0",
2139 "nopad_condition
=1",
2141 "indent_col1_comments
=0"
2152 "pad_condition_state
=1",
2153 "indent_with_tabs
=0",
2154 "nospace_before_paren
=0",
2155 "indent_comments
=1",
2157 "statement_comment_col
=0",
2158 "disable_bestyle
=0",
2159 "decl_comment_col
=0",
2160 "bestyle_on_functions
=0",
2161 "use_relative_indent
=1",
2162 "nospace_before_brace
=0",
2164 "statement_comment_state
=2",
2167 "parens_on_return
=0",
2168 "eat_blank_lines
=0",
2171 "align_on_parens
=1",
2172 "continuation_indent
=0",
2174 "nopad_condition
=1",
2176 "indent_col1_comments
=0"
2187 "pad_condition_state
=1",
2188 "indent_with_tabs
=0",
2189 "nospace_before_paren
=0",
2190 "indent_comments
=1",
2192 "statement_comment_col
=0",
2193 "disable_bestyle
=0",
2194 "decl_comment_col
=0",
2195 "bestyle_on_functions
=0",
2196 "use_relative_indent
=1",
2197 "nospace_before_brace
=0",
2199 "statement_comment_state
=2",
2202 "parens_on_return
=0",
2203 "eat_blank_lines
=0",
2206 "align_on_parens
=1",
2207 "continuation_indent
=0",
2209 "nopad_condition
=1",
2211 "indent_col1_comments
=0"
2222 "pad_condition_state
=1",
2223 "indent_with_tabs
=0",
2224 "nospace_before_paren
=0",
2225 "indent_comments
=1",
2227 "statement_comment_col
=0",
2228 "disable_bestyle
=0",
2229 "decl_comment_col
=0",
2230 "bestyle_on_functions
=0",
2231 "use_relative_indent
=1",
2232 "nospace_before_brace
=0",
2234 "statement_comment_state
=2",
2237 "parens_on_return
=0",
2238 "eat_blank_lines
=0",
2241 "align_on_parens
=1",
2242 "continuation_indent
=0",
2244 "nopad_condition
=1",
2246 "indent_col1_comments
=0"
2257 "pad_condition_state
=1",
2258 "indent_with_tabs
=0",
2259 "nospace_before_paren
=0",
2260 "indent_comments
=1",
2262 "statement_comment_col
=0",
2263 "disable_bestyle
=0",
2264 "decl_comment_col
=0",
2265 "bestyle_on_functions
=0",
2266 "use_relative_indent
=1",
2267 "nospace_before_brace
=0",
2269 "statement_comment_state
=2",
2272 "parens_on_return
=0",
2273 "eat_blank_lines
=0",
2276 "align_on_parens
=1",
2277 "continuation_indent
=0",
2279 "nopad_condition
=1",
2281 "indent_col1_comments
=0"
2287 static void k_styles_create()
2290 * Find user format ini file.
2292 _str userini = maybe_quote_filename(_config_path():+'uformat.ini');
2293 if (file_match('-p 'userini, 1) == '')
2295 _str ini = maybe_quote_filename(slick_path_search('uformat.ini'));
2296 if (ini != '') userini = ini;
2301 * Remove any old schemes.
2304 for (i = 0; i < StyleSchemes._length(); i++)
2305 for (j = 0; j < StyleLanguages._length(); j++)
2307 _str sectionname = StyleLanguages[j]:+'-scheme-':+StyleSchemes[i].name;
2308 if (!_ini_get_section(userini, sectionname, tv))
2310 _ini_delete_section(userini, sectionname);
2311 _delete_temp_view(tv);
2312 //message("delete
old scheme
");
2317 * Create the new schemes.
2319 for (i = 0; i < StyleSchemes._length(); i++)
2321 for (j = 0; j < StyleLanguages._length(); j++)
2323 _str sectionname = StyleLanguages[j]:+'-scheme-':+StyleSchemes[i].name;
2324 int temp_view_id, k;
2325 _str orig_view_id = _create_temp_view(temp_view_id);
2326 activate_view(temp_view_id);
2327 for (k = 0; k < StyleSchemes[i].settings._length(); k++)
2328 insert_line(StyleSchemes[i].settings[k]);
2330 /* Insert the scheme section. */
2331 _ini_replace_section(userini, sectionname, temp_view_id);
2333 //bogus id - activate_view(orig_view_id);
2337 //last_scheme = last scheme name!!!
2342 * Sets the last used beutify scheme.
2344 static k_styles_set(_str scheme)
2348 * Find user format ini file.
2350 _str userini = maybe_quote_filename(_config_path():+'uformat.ini');
2351 if (file_match('-p 'userini, 1) == '')
2353 _str ini = maybe_quote_filename(slick_path_search('uformat.ini'));
2354 if (ini != '') userini = ini;
2358 * Set the scheme for each language.
2361 for (j = 0; j < StyleLanguages._length(); j++)
2363 _ini_set_value(userini,
2364 StyleLanguages[j]:+'-scheme-Default',
2371 static _str defoptions[] =
2380 "def
-options
-bourneshell
",
2383 "def
-options
-plsql
",
2384 "def
-options
-sqlserver
",
2388 static _str defsetups[] =
2393 "def
-setup
-fundamental
",
2394 "def
-setup
-process
",
2401 "def
-setup
-bourneshell
",
2404 "def
-setup
-fileman
",
2406 "def
-setup
-sqlserver
",
2411 static _str defsetupstab8[] =
2417 static void k_styles_setindent(int indent, int iBraceStyle, boolean iWithTabs = false)
2419 if (iBraceStyle < 1 || iBraceStyle > 3)
2421 message('k_styles_setindent: iBraceStyle is bad (=' :+ iBraceStyle :+ ')');
2426 * def-options for extentions known to have that info.
2429 for (i = 0; i < defoptions._length(); i++)
2431 int idx = find_index(defoptions[i], MISC_TYPE);
2435 parse name_info(idx) with syntax_indent o2 o3 o4 flags indent_fl o7 indent_case rest;
2437 /* Begin/end style */
2438 flags = flags & ~(1|2);
2439 flags = flags | (iBraceStyle - 1); /* Set style (0-based) */
2440 flags = flags & ~(16); /* no scape before parent.*/
2441 indent_fl = 1; /* Indent first level */
2442 indent_case = 1; /* Indent case from switch */
2444 sNewOptions = indent' 'o2' 'o3' 'o4' 'flags' 'indent_fl' 'o7' 'indent_case' 'rest;
2445 set_name_info(idx, sNewOptions);
2446 _config_modify |= CFGMODIFY_DEFDATA;
2450 * def-setup for known extentions.
2452 for (i = 0; i < defsetups._length(); i++)
2454 idx = find_index(defsetups[i], MISC_TYPE);
2457 sExt = substr(defsetups[i], length('def-setup-') + 1);
2458 sSetup = name_info(idx);
2461 parse sSetup with 'MN=' mode_name ','\
2462 'TABS=' tabs ',' 'MA=' margins ',' 'KEYTAB=' keytab_name ','\
2463 'WW='word_wrap_style ',' 'IWT='indent_with_tabs ','\
2464 'ST='show_tabs ',' 'IN='indent_style ','\
2465 'WC='word_chars',' 'LN='lexer_name',' 'CF='color_flags','\
2466 'LNL='line_numbers_len','rest;
2468 indent_with_tabs = 0; /* Indent with tabs */
2470 /* Make sure all the values are legal */
2471 _ext_init_values(ext, lexer_name, color_flags);
2472 if (!isinteger(line_numbers_len)) line_numbers_len = 0;
2473 if (word_chars == '') word_chars = 'A-Za-z0-9_$';
2474 if (word_wrap_style == '') word_wrap_style = 3;
2475 if (show_tabs == '') show_tabs = 0;
2476 if (indent_style == '') indent_style = INDENT_SMART;
2478 /* Set new indent */
2484 /* Set new indent */
2485 if (pos('TABS=', sNewSetup) > 0)
2488 * If either in defoptions or defsetupstab8 use default tab of 8
2489 * For those supporting separate syntax indent using the normal tabsize
2490 * helps us a lot when reading it...
2493 for (j = 0; !fTab8 && j < defsetupstab8._length(); j++)
2494 if (substr(defsetupstab8[j], lastpos('-', defsetupstab8[j]) + 1) == sExt)
2496 for (j = 0; !fTab8 && j < defoptions._length(); j++)
2497 if (substr(defoptions[j], lastpos('-', defoptions[j]) + 1) == sExt)
2500 parse sNewSetup with sPre 'TABS=' sValue ',' sPost;
2502 sNewSetup = sPre 'TABS=+8,' sPost
2504 sNewSetup = sPre 'TABS=+' indent ',' sPost
2507 /* Set indent with tabs flag. */
2508 if (pos('IWT=', sNewSetup) > 0)
2510 parse sNewSetup with sPre 'IWT=' sValue ',' sPost;
2512 sNewSetup = sPre 'IWT=1,' sPost
2514 sNewSetup = sPre 'IWT=0,' sPost
2517 /* Do the real changes */
2518 set_name_info(idx, sNewSetup);
2519 _config_modify |= CFGMODIFY_DEFDATA;
2520 _update_buffers(sExt);
2526 * Takes necessary steps to convert a string to integer.
2528 static int k_style_emacs_var_integer(_str sVal)
2531 //say 'k_style_emacs_var_integer('sVal') -> 'i;
2537 * Sets a Emacs style variable.
2539 static int k_style_emacs_var(_str sVar, _str sVal)
2542 if (sVar == '' || sVal == '')
2544 //say 'k_style_emacs_var: 'sVar'='sVal;
2546 #if __VERSION__ >= 21.0
2547 /** @todo figure out p_index. */
2552 * Unpack the mode style parameters.
2554 _str sStyle = name_info(_edit_window().p_index);
2555 _str sStyleName = p_mode_name;
2556 typeless iIndentAmount, fExpansion, iMinAbbrivation, fIndentAfterOpenParen, iBeginEndStyle, fIndent1stLevel, iMainStyle, iSwitchStyle,
2557 sRest, sRes0, sRes1;
2558 if (sStyleName == 'Slick-C')
2560 parse sStyle with iMinAbbrivation sRes0 iBeginEndStyle fIndent1stLevel sRes1 iSwitchStyle sRest;
2561 iIndentAmount = p_SyntaxIndent;
2564 parse sStyle with iIndentAmount fExpansion iMinAbbrivation fIndentAfterOpenParen iBeginEndStyle fIndent1stLevel iMainStyle iSwitchStyle sRest;
2568 * Process the variable.
2594 p_mode_name = 'Slick-C';
2598 message('emacs mode "'sVal'" is not known to us');
2603 /* relevant emacs code:
2604 (defconst c-style-alist
2606 (c-basic-offset . 2)
2607 (c-comment-only-line-offset . (0 . 0))
2608 (c-offsets-alist . ((statement-block-intro . +)
2609 (knr-argdecl-intro . 5)
2610 (substatement-open . +)
2612 (statement-case-open . +)
2613 (statement-cont . +)
2614 (arglist-intro . c-lineup-arglist-intro-after-paren)
2615 (arglist-close . c-lineup-arglist)
2617 (brace-list-open . +)
2619 (c-special-indent-hook . c-gnu-impose-minimum)
2620 (c-block-comment-prefix . "")
2623 (c-basic-offset . 5)
2624 (c-comment-only-line-offset . 0)
2625 (c-offsets-alist . ((statement-block-intro . +)
2626 (knr-argdecl-intro . 0)
2627 (substatement-open . 0)
2629 (statement-cont . +)
2633 (c-basic-offset . 8)
2634 (c-comment-only-line-offset . 0)
2635 (c-offsets-alist . ((statement-block-intro . +)
2636 (knr-argdecl-intro . +)
2637 (substatement-open . 0)
2639 (statement-cont . +)
2645 (c-basic-offset . 4)
2646 (c-comment-only-line-offset . 0)
2647 (c-offsets-alist . ((statement-block-intro . +)
2648 (substatement-open . 0)
2650 (statement-cont . +)
2654 (c-basic-offset . 4)
2655 (c-comment-only-line-offset . 0)
2656 (c-offsets-alist . ((knr-argdecl-intro . +)
2658 (statement-cont . +)
2659 (substatement-open . +)
2661 (statement-block-intro . c-lineup-whitesmith-in-block)
2662 (block-close . c-lineup-whitesmith-in-block)
2665 (defun-block-intro . c-lineup-whitesmith-in-block)
2666 (defun-close . c-lineup-whitesmith-in-block)
2667 (brace-list-open . +)
2668 (brace-list-intro . c-lineup-whitesmith-in-block)
2669 (brace-entry-open . c-indent-multi-line-block)
2670 (brace-list-close . c-lineup-whitesmith-in-block)
2672 (inclass . c-lineup-whitesmith-in-block)
2675 (extern-lang-open . +)
2676 (inextern-lang . c-lineup-whitesmith-in-block)
2677 (extern-lang-close . +)
2678 (namespace-open . +)
2679 (innamespace . c-lineup-whitesmith-in-block)
2680 (namespace-close . +)
2684 (c-basic-offset . 3)
2685 (c-comment-only-line-offset . 0)
2686 (c-hanging-braces-alist . ((substatement-open before after)))
2687 (c-offsets-alist . ((topmost-intro . 0)
2688 (topmost-intro-cont . 0)
2690 (substatement-open . 0)
2698 (c-basic-offset . 8)
2699 (c-comment-only-line-offset . 0)
2700 (c-hanging-braces-alist . ((brace-list-open)
2702 (substatement-open after)
2703 (block-close . c-snug-do-while)))
2704 (c-cleanup-list . (brace-else-brace))
2705 (c-offsets-alist . ((statement-block-intro . +)
2706 (knr-argdecl-intro . 0)
2707 (substatement-open . 0)
2709 (statement-cont . +)
2713 (indent-tabs-mode . t)
2715 (c-basic-offset . 8)
2716 (c-offsets-alist . ((substatement-open . 0)
2719 (knr-argdecl-intro . +)
2721 (c-hanging-braces-alist . ((brace-list-open)
2725 (substatement-open after)
2726 (block-close . c-snug-do-while)
2728 (c-block-comment-prefix . "")
2731 (c-basic-offset . 4)
2732 (c-comment-only-line-offset . (0 . 0))
2733 ;; the following preserves Javadoc starter lines
2734 (c-offsets-alist . ((inline-open . 0)
2735 (topmost-intro-cont . +)
2736 (statement-block-intro . +)
2737 (knr-argdecl-intro . 5)
2738 (substatement-open . +)
2740 (statement-case-open . +)
2741 (statement-cont . +)
2742 (arglist-intro . c-lineup-arglist-intro-after-paren)
2743 (arglist-close . c-lineup-arglist)
2745 (inher-cont . c-lineup-java-inher)
2746 (func-decl-cont . c-lineup-java-throws)
2752 case 'c-file-style':
2753 case 'c-indentation-style':
2759 iBeginEndStyle = 1 | (iBeginEndStyle & ~3);
2760 p_indent_with_tabs = true;
2770 iBeginEndStyle = 0 | (iBeginEndStyle & ~3);
2771 p_indent_with_tabs = false;
2780 iBeginEndStyle = 0 | (iBeginEndStyle & ~3);
2781 p_indent_with_tabs = true;
2788 case 'yet-to-be-found':
2789 iBeginEndStyle = 2 | (iBeginEndStyle & ~3);
2790 p_indent_with_tabs = false;
2798 message('emacs "'sVar'" value "'sVal'" is not known to us.');
2803 case 'c-label-offset':
2805 int i = k_style_emacs_var_integer(sVal);
2806 if (i >= -16 && i <= 16)
2808 if (i == -p_SyntaxIndent)
2817 case 'indent-tabs-mode':
2818 p_indent_with_tabs = sVal == 't';
2821 case 'c-indent-level':
2822 case 'c-basic-offset':
2824 int i = k_style_emacs_var_integer(sVal);
2825 if (i > 0 && i <= 16)
2832 message('emacs "'sVar'" value "'sVal'" is out of range.');
2840 int i = k_style_emacs_var_integer(sVal);
2841 if (i > 0 && i <= 16)
2845 message('emacs "'sVar'" value "'sVal'" is out of range.');
2851 case 'nuke-trailing-whitespace-p':
2854 _str sName = 'def-koptions-'p_buf_id;
2855 int idx = insert_name(sName, MISC_TYPE, "kstyledoc
");
2857 idx = find_index(sName, MISC_TYPE);
2861 set_name_info(idx, "saveoptions
: +S
");
2863 set_name_info(idx, "saveoptions
: -S
");
2871 message('emacs variable "'sVar'" (value "'sVal'") is unknown to us.');
2878 _str sNewStyle = "";
2879 if (sStyleName == 'Slick-C')
2880 sNewStyle = iMinAbbrivation' 'sRes0' 'iBeginEndStyle' 'fIndent1stLevel' 'sRes1' 'iSwitchStyle' 'sRest;
2882 sNewStyle = iIndentAmount' 'fExpansion' 'iMinAbbrivation' 'fIndentAfterOpenParen' 'iBeginEndStyle' 'fIndent1stLevel' 'iMainStyle' 'iSwitchStyle' 'sRest;
2883 if ( sNewStyle != ""
2884 && sNewStyle != sStyle
2885 && sStyleName == p_mode_name)
2887 _str sName = name_name(_edit_window().p_index)
2888 //say ' sStyle='sStyle' p_mode_name='p_mode_name;
2889 //say 'sNewStyle='sNewStyle' sName='sName;
2890 if (pos('kstyledoc-', sName) <= 0)
2892 sName = 'def-kstyledoc-'p_buf_id;
2893 int idx = insert_name(sName, MISC_TYPE, "kstyledoc
");
2895 idx = find_index(sName, MISC_TYPE);
2898 if (!set_name_info(idx, sNewStyle))
2899 _edit_window().p_index = idx;
2904 set_name_info(_edit_window().p_index, sNewStyle);
2913 * Parses a string with emacs variables.
2915 * The variables are separated by new line. Junk at
2916 * the start and end of the line is ignored.
2918 static int k_style_emac_vars(_str sVars)
2920 /* process them line by line */
2922 while (sVars != '' && iLine++ < 20)
2925 iEnd = iNext = pos("\n
", sVars);
2927 iEnd = iNext = length(sVars);
2932 sLine = strip(substr(sVars, 1, iEnd), 'B', " \t\n\r
");
2933 sVars = strip(substr(sVars, iNext), 'L', " \t\n\r
");
2934 //say 'iLine='iLine' sVars='sVars'<eol>';
2935 //say 'iLine='iLine' sLine='sLine'<eol>';
2938 rc = pos('[^a-zA-Z0-9-_]*([a-zA-Z0-9-_]+)[ \t]*:[ \t]*([^ \t]*)', sLine, 1, 'U');
2939 //say '0={'pos('S0')','pos('0')',"'substr(sLine,pos('S0
'),pos('0'))'"'
2940 //say '1={'pos('S1')','pos('1')',"'substr(sLine,pos('S1
'),pos('1'))'"'
2941 //say '2={'pos('S2')','pos('2')',"'substr(sLine,pos('S2
'),pos('2'))'"'
2942 //say '3={'pos('S3')','pos('3')',"'substr(sLine,pos('S3
'),pos('3'))'"'
2943 //say '4={'pos('S4')','pos('4')',"'substr(sLine,pos('S4
'),pos('4'))'"'
2945 k_style_emacs_var(substr(sLine,pos('S1'),pos('1')),
2946 substr(sLine,pos('S2'),pos('2')));
2953 * Searches for Emacs style specification for the current document.
2957 /* save the position before we start looking around the file. */
2959 _save_pos2(saved_pos);
2963 /* Check first line. */
2968 if (pos('-*-[ \t]+(.*:.*)[ \t]+-*-', sLine, 1, 'U'))
2971 sVars = substr(sLine, pos('S1'), pos('1'));
2972 sVars = translate(sVars, "\n
", ";");
2973 k_style_emac_vars(sVars);
2976 /* Look for the "Local Variables
:" stuff from the end of the file. */
2978 rc = search('Local Variables:[ \t]*\n\om(.*)\ol\n.*End:.*\n', '-EU');
2981 /* copy the variables out to a buffer. */
2983 sVars = get_text(match_length("1"), match_length("S1
"));
2984 k_style_emac_vars(sVars);
2987 _restore_pos2(saved_pos);
2992 * Callback function for the event of a new buffer.
2994 * This is used to make sure there are no left over per buffer options
2997 void _buffer_add_kdev(int buf_id)
2999 _str sName = 'def-koptions-'buf_id;
3000 int idx = find_index(sName, MISC_TYPE);
3003 //message("_buffer_add_kdev
: " idx " name
=" sName);
3005 sName = 'def-kstyledoc-'buf_id;
3006 idx = find_index(sName, MISC_TYPE);
3015 * Callback function for the event of quitting a buffer.
3017 * This is used to make sure there are no left over per buffer options
3020 void _cbquit2_kdev(int buf_id)
3022 _str sName = 'def-koptions-'buf_id;
3023 int idx = find_index(sName, MISC_TYPE);
3026 //message("_cbquit2_kdev
: " idx " " sName);
3028 sName = 'def-kstyledoc-'buf_id;
3029 idx = find_index(sName, MISC_TYPE);
3036 * Called to get save options for the current buffer.
3038 * This requires a modified loadsave.e!
3040 _str _buffer_save_kdev(int buf_id)
3043 _str sName = 'def-koptions-'buf_id;
3044 int idx = find_index(sName, MISC_TYPE);
3047 _str sOptions = strip(name_info(idx));
3049 parse sOptions with . "saveoptions
:" sRet .
3050 message("_buffer_save_kdev
: " idx " " sName " " sOptions);
3057 * Command similar to the add() command in math.e, only this
3058 * produces hex and doesn't do the multi line stuff.
3060 _command int k_calc()
3064 typeless rc = filter_get_string(sLine);
3068 rc = eval_exp(sResultHex, sLine, 16);
3072 rc = eval_exp(sResultDec, sLine, 10);
3076 _insert_text(' = ' :+ sResultHex :+ ' (' :+ sResultDec :+ ')');
3083 message(get_message(rc));
3091 /*******************************************************************************
3092 * Menu and Menu commands *
3093 *******************************************************************************/
3094 #ifdef KDEV_WITH_MENU
3095 #if __VERSION__ < 18.0 /* Something with timers are busted, so excusing my code. */
3096 static int iTimer = 0;
3098 static int mhkDev = 0;
3099 static int mhCode = 0;
3100 static int mhDoc = 0;
3101 static int mhLic = 0;
3102 static int mhPre = 0;
3105 * Creates the kDev menu.
3107 static k_menu_create()
3109 # if __VERSION__ < 18.0 /* Something with timers are busted, so excusing my code. */
3110 if (arg(1) == 'timer')
3111 _kill_timer(iTimer);
3113 menu_handle = _mdi.p_menu_handle;
3114 menu_index = find_index(_cur_mdi_menu,oi2type(OI_MENU));
3117 * Remove any old menu.
3119 mhDelete = iPos = 0;
3120 index = _menu_find(menu_handle, "kDev
", mhDelete, iPos, 'C');
3121 //message("index
="index " mhDelete
="mhDelete " iPos
="iPos);
3123 _menu_delete(mhDelete, iPos);
3127 * Insert the "kDev
" menu.
3129 mhkDev = _menu_insert(menu_handle, 9, MF_SUBMENU, "&kDev
", "", "kDev
");
3130 mhCode=_menu_insert(mhkDev, -1, MF_ENABLED | MF_SUBMENU, "Coding
&Style
", "", "coding
");
3131 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces
2, Syntax Indent
4 (knut
)", "k_menu_style Opt2Ind4
", "Opt2Ind4
");
3132 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces
2, Syntax Indent
3", "k_menu_style Opt2Ind3
", "Opt2Ind3
");
3133 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces
2, Syntax Indent
8", "k_menu_style Opt2Ind8
", "Opt2Ind8
");
3134 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces
3, Syntax Indent
4 (giws
)", "k_menu_style Opt3Ind4
", "Opt3Ind4
");
3135 rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces
3, Syntax Indent
3 (giws
)", "k_menu_style Opt3Ind3
", "Opt3Ind3
");
3137 mhDoc= _menu_insert(mhkDev, -1, MF_ENABLED | MF_SUBMENU, "&Documentation
", "", "doc
");
3138 mhDSJ= _menu_insert(mhDoc, -1, MF_ENABLED | MF_UNCHECKED, "&Javadoc Style
", "k_menu_doc_style javadoc
", "javadoc
");
3139 mhDSL= _menu_insert(mhDoc, -1, MF_GRAYED | MF_UNCHECKED, "&Linux Kernel Style
", "k_menu_doc_style linux
", "linux
");
3141 mhLic= _menu_insert(mhkDev, -1, MF_ENABLED | MF_SUBMENU, "&License
", "", "License
");
3142 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&Odin32
", "k_menu_license Odin32
", "Odin32
");
3143 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&GPL
", "k_menu_license GPL
", "GPL
");
3144 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&LGPL
", "k_menu_license LGPL
", "LGPL
");
3145 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&GPLv3
", "k_menu_license GPLv3
", "GPLv3
");
3146 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&LGPLv3
", "k_menu_license LGPLv3
", "LGPLv3
");
3147 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&VirtualBox
", "k_menu_license VirtualBox
", "VirtualBox
");
3148 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&VirtualBox GPL
And CDDL
","k_menu_license VirtualBoxGPLAndCDDL
", "VirtualBoxGPLAndCDDL
");
3149 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&Confidential
", "k_menu_license Confidential
", "Confidential
");
3150 rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&Confidential No Author
", "k_menu_license ConfidentialNoAuthor
", "ConfidentialNoAuthor
");
3152 rc = _menu_insert(mhkDev, -1, MF_ENABLED, "-", "", "dash vars
");
3153 rc = _menu_insert(mhkDev, -1, MF_ENABLED, skChange == '' ? '&Change...' : '&Change (' skChange ')...', "k_menu_change
", "");
3154 rc = _menu_insert(mhkDev, -1, MF_ENABLED, skProgram == '' ? '&Program...' : '&Program (' skProgram ')...', "k_menu_program
", "");
3155 rc = _menu_insert(mhkDev, -1, MF_ENABLED, skCompany == '' ? 'Co&mpany...' : 'Co&mpany (' skCompany ')...', "k_menu_company
", "");
3156 rc = _menu_insert(mhkDev, -1, MF_ENABLED, '&User Name (' skUserName ')...', "k_menu_user_name
", "username
");
3157 rc = _menu_insert(mhkDev, -1, MF_ENABLED, 'User &e-mail (' skUserEmail ')...', "k_menu_user_email
", "useremail
");
3158 rc = _menu_insert(mhkDev, -1, MF_ENABLED, 'User &Initials (' skUserInitials ')...', "k_menu_user_initials
", "userinitials
");
3159 rc = _menu_insert(mhkDev, -1, MF_ENABLED, "-", "", "dash preset
");
3160 mhPre= _menu_insert(mhkDev, -1, MF_SUBMENU, "P
&resets
", "", "");
3161 rc = _menu_insert(mhPre, -1, MF_ENABLED, "The Bird
", "k_menu_preset javadoc
, GPL
, Opt2Ind4
", "bird
");
3162 rc = _menu_insert(mhPre, -1, MF_ENABLED, "kLIBC
", "k_menu_preset javadoc
, GPL
, Opt2Ind4
,, kLIBC
", "kLIBC
");
3163 rc = _menu_insert(mhPre, -1, MF_ENABLED, "kBuild
", "k_menu_preset javadoc
, GPLv3
, Opt2Ind4
,, kBuild
", "kBuild
");
3164 rc = _menu_insert(mhPre, -1, MF_ENABLED, "kStuff
", "k_menu_preset javadoc
, GPL
, Opt2Ind4
,, kStuff
", "kStuff
");
3165 rc = _menu_insert(mhPre, -1, MF_ENABLED, "sun
", "k_menu_preset javadoc
, ConfidentialNoAuthor
, Opt2Ind4
, sun
", "sun
");
3166 rc = _menu_insert(mhPre, -1, MF_ENABLED, "VirtualBox
", "k_menu_preset javadoc
, VirtualBox
, Opt2Ind4
, sun
", "VirtualBox
");
3177 _command k_menu_change()
3179 sRc = show("-modal k_form_simple_input
", "Change ID
", skChange);
3189 * Change program name.
3191 _command k_menu_program()
3193 sRc = show("-modal k_form_simple_input
", "Program
", skProgram);
3205 _command k_menu_company()
3207 if (skCompany == '')
3208 sRc = show("-modal k_form_simple_input
", "Company
", 'innotek GmbH');
3210 sRc = show("-modal k_form_simple_input
", "Company
", skCompany);
3222 _command k_menu_user_name()
3224 sRc = show("-modal k_form_simple_input
", "User Name
", skUserName);
3225 if (sRc != "\r
" && sRc != '')
3234 * Change user email.
3236 _command k_menu_user_email()
3238 sRc = show("-modal k_form_simple_input
", "User e
-mail
", skUserEmail);
3239 if (sRc != "\r
" && sRc != '')
3248 * Change user initials.
3250 _command k_menu_user_initials()
3252 sRc = show("-modal k_form_simple_input
", "User e
-mail
", skUserInitials);
3253 if (sRc != "\r
" && sRc != '')
3255 skUserInitials = sRc;
3263 * Checks the correct menu item.
3265 _command void k_menu_doc_style(_str sNewDocStyle = '')
3267 //say 'sNewDocStyle='sNewDocStyle;
3268 if (sNewDocStyle != '')
3269 skDocStyle = sNewDocStyle
3270 _menu_set_state(mhDoc, "javadoc
", MF_UNCHECKED);
3271 _menu_set_state(mhDoc, "linux
", MF_UNCHECKED | MF_GRAYED);
3273 _menu_set_state(mhDoc, skDocStyle, MF_CHECKED);
3278 * Checks the correct menu item.
3280 _command void k_menu_license(_str sNewLicense = '')
3282 //say 'sNewLicense='sNewLicense;
3283 if (sNewLicense != '')
3284 skLicense = sNewLicense
3285 _menu_set_state(mhLic, "Odin32
", MF_UNCHECKED);
3286 _menu_set_state(mhLic, "GPL
", MF_UNCHECKED);
3287 _menu_set_state(mhLic, "LGPL
", MF_UNCHECKED);
3288 _menu_set_state(mhLic, "GPLv3
", MF_UNCHECKED);
3289 _menu_set_state(mhLic, "LGPLv3
", MF_UNCHECKED);
3290 _menu_set_state(mhLic, "VirtualBox
", MF_UNCHECKED);
3291 _menu_set_state(mhLic, "VirtualBoxGPLAndCDDL
", MF_UNCHECKED);
3292 _menu_set_state(mhLic, "Confidential
", MF_UNCHECKED);
3293 _menu_set_state(mhLic, "ConfidentialNoAuthor
", MF_UNCHECKED);
3295 _menu_set_state(mhLic, skLicense, MF_CHECKED);
3300 * Check the correct style menu item.
3302 _command void k_menu_style(_str sNewStyle = '')
3304 //say 'sNewStyle='sNewStyle;
3305 _menu_set_state(mhCode, "Opt1Ind4
", MF_UNCHECKED);
3306 _menu_set_state(mhCode, "Opt1Ind3
", MF_UNCHECKED);
3307 _menu_set_state(mhCode, "Opt1Ind8
", MF_UNCHECKED);
3308 _menu_set_state(mhCode, "Opt2Ind4
", MF_UNCHECKED);
3309 _menu_set_state(mhCode, "Opt2Ind3
", MF_UNCHECKED);
3310 _menu_set_state(mhCode, "Opt2Ind8
", MF_UNCHECKED);
3311 _menu_set_state(mhCode, "Opt3Ind4
", MF_UNCHECKED);
3312 _menu_set_state(mhCode, "Opt3Ind3
", MF_UNCHECKED);
3313 _menu_set_state(mhCode, "Opt3Ind8
", MF_UNCHECKED);
3315 if (sNewStyle != '')
3317 int iIndent = (int)substr(sNewStyle, 8, 1);
3318 int iBraceStyle = (int)substr(sNewStyle, 4, 1);
3319 skCodeStyle = sNewStyle;
3320 k_styles_setindent(iIndent, iBraceStyle);
3321 k_styles_set(sNewStyle);
3324 _menu_set_state(mhCode, skCodeStyle, MF_CHECKED);
3331 _command void k_menu_preset(_str sArgs = '')
3333 parse sArgs with sNewDocStyle ',' sNewLicense ',' sNewStyle ',' sNewCompany ',' sNewProgram ',' sNewChange
3334 sNewDocStyle= strip(sNewDocStyle);
3335 sNewLicense = strip(sNewLicense);
3336 sNewStyle = strip(sNewStyle);
3337 sNewCompany = strip(sNewCompany);
3338 if (sNewCompany == 'sun')
3339 sNewCompany = 'Sun Microsystems, Inc.'
3340 sNewProgram = strip(sNewProgram);
3341 sNewChange = strip(sNewChange);
3343 //say 'k_menu_preset('sNewDocStyle',' sNewLicense',' sNewStyle',' sNewCompany',' sNewProgram')';
3344 k_menu_doc_style(sNewDocStyle);
3345 k_menu_license(sNewLicense);
3346 k_menu_style(sNewStyle);
3347 skCompany = sNewCompany;
3348 skProgram = sNewProgram;
3349 skChange = sNewChange;
3356 _command k_menu_setcolor()
3358 createMyColorSchemeAndUseIt();
3362 _command k_menu_setkeys()
3364 rc = load("d
:/knut
/VSlickMacros
/BoxerDef
.e
");
3367 _command k_menu_settings()
3374 #endif /* KDEV_WITH_MENU */
3377 /*******************************************************************************
3379 *******************************************************************************/
3380 _form k_form_simple_input {
3381 p_backcolor=0x80000005
3382 p_border_style=BDS_DIALOG_BOX
3383 p_caption='Simple Input'
3384 p_clip_controls=FALSE
3385 p_forecolor=0x80000008
3392 p_backcolor=0x80000005
3393 p_border_style=BDS_FIXED_SINGLE
3394 p_completion=NONE_ARG
3397 p_font_name='MS Sans Serif'
3399 p_font_underline=FALSE
3400 p_forecolor=0x80000008
3408 p_eventtab2=_ul2_textbox
3411 p_alignment=AL_VCENTERRIGHT
3413 p_backcolor=0x80000005
3414 p_border_style=BDS_NONE
3418 p_font_name='MS Sans Serif'
3420 p_font_underline=FALSE
3421 p_forecolor=0x80000008
3429 _command_button btnOK {
3435 p_font_name='MS Sans Serif'
3437 p_font_underline=FALSE
3445 _command_button btnCancel {
3451 p_font_name='MS Sans Serif'
3453 p_font_underline=FALSE
3463 defeventtab k_form_simple_input
3464 btnOK.on_create(_str sLabel = '', _str sText = '')
3466 p_active_form.p_caption = sLabel;
3467 lblLabel.p_caption = sLabel;
3468 entText.p_text = sText;
3473 sText = entText.p_text;
3474 p_active_form._delete_window(sText);
3476 btnCancel.lbutton_up()
3478 sText = entText.p_text;
3479 p_active_form._delete_window("\r
");
3482 static _str aCLikeIncs[] =
3484 "c
", "ansic
", "java
", "rul
", "vera
", "cs
", "js
", "as", "idl
", "asm
", "s
", "imakefile
", "rc
", "lex
", "yacc
", "antlr
"
3487 static _str aMyLangIds[] =
3493 #if __VERSION__ < 19.0
3522 #if __VERSION__ < 19.0
3534 #if __VERSION__ >= 17.0
3535 # require "se
/lang
/api
/LanguageSettings
.e
"
3536 using se.lang.api.LanguageSettings;
3539 #if __VERSION__ >= 16.0
3540 int def_auto_unsurround_block;
3543 #if __VERSION__ >= 21.0
3544 int def_gui_find_default;
3547 static void kdev_ext_to_lang(_str sExt, _str idLang)
3549 #if __VERSION__ >= 21.0 // dunno when exactly.
3550 _SetExtensionReferTo(sExt, idLang);
3552 replace_def_data("def
-lang
-for
-ext
-" :+ sExt, idLand);
3556 #if __VERSION__ >= 21.0
3558 static _str kdev_load_lexer(_str sFilename)
3560 int rc = cload(sFilename);
3563 return ' Failed to load "' sFilename "': " rc ";";
3566 /** Doesn't seems like there is an API to just load a bunch of profiles, only I
3567 * could find would load one named profile for a specific language, making it
3568 * the new profile for that language. So, a little extra work here. */
3569 static _str kdev_load_beautifier_profiles(_str sFilename)
3573 auto hXml = _xmlcfg_open(sFilename, iStatus);
3577 iStatus = _xmlcfg_find_simple_array(hXml, "//profile
/@n
", asProfiles, TREE_ROOT_INDEX, VSXMLCFG_FIND_VALUES, -1);
3578 _xmlcfg_close(hXml);
3581 foreach (sProfile in asProfiles)
3583 _str asElements[] = split2array(sProfile, '.');
3584 _str sLangId = asElements[1];
3585 _str sProfileName = substr(sProfile, 1 + length(asElements[0])
3586 + 1 + length(asElements[1])
3587 + 1 + length(asElements[2]) + 1);
3588 //say("sLangId
='" sLangId "' sProfileName
='" sProfileName "'; ");
3589 _str sErr = _new_beautifier_config_import_settings(sFilename, sProfileName, sLangId);
3591 sRet = ' Failed to load "' sProfileName "' for
'" sLangId "' from '" sFilename "': " sRet ";";
3595 sRet = " Failed to open
'" sFilename "': " hXml ";";
3602 * Loads the standard bird settings.
3604 _command void kdev_load_settings(_str sScriptDir = "")
3615 _str sMsg = 'Please restart SlickEdit.';
3618 * Validate script dir argument.
3620 sScriptDir = _maybe_unquote_filename(sScriptDir);
3621 if (sScriptDir == "")
3623 message("Need script dir argument
!");
3626 if (!file_exists(sScriptDir :+ "/lexer
-kmk
.cfg
.xml
"))
3628 message("Invalid script dir
'" sScriptDir "' no lexer
-kmk
.cfg
.xml file found
!");
3632 #if __VERSION__ >= 21.0
3634 * Load the color profiles (was lexer).
3636 sMsg = sMsg :+ kdev_load_lexer(sScriptDir :+ "/lexer
-kmk
-v2
.cfg
.xml
");
3639 * Load project templates for kBuild.
3641 int rc = importProjectPacks(sScriptDir :+ "/usrprjtemplates
.vpt
");
3643 sMsg = sMsg :+ " importProjectPacks(usrprjtemplates
.vpt
)->" :+ rc :+ ";";
3646 * Load the beautifier profiles.
3648 sMsg = sMsg :+ kdev_load_beautifier_profiles(sScriptDir :+ "/beautifier
-profiles
.cfg
.xml
");
3651 * Load color and select scheme.
3653 _str sErr = _color_form_import_settings(sScriptDir :+ "/color_profiles
.cfg
.xml
", 'Solarized Dark');
3655 sMsg = sMsg :+ " _color_form_import_settings(color_profiles
.cfg
.xml
)->" :+ sErr :+ ";";
3656 _app_theme('Dark', true);
3662 _default_option('A', '0'); /* ALT menu */
3664 _default_option('R', '130'); /* Vertical line in column 130. */
3665 def_mfsearch_init_flags = 2 | 4; /* MFSEARCH_INIT_CURWORD | MFSEARCH_INIT_SELECTION */
3666 def_line_insert = 'B'; /* insert before */
3667 def_updown_col=0; /* cursor movement */
3668 def_cursorwrap=0; /* ditto. */
3669 def_click_past_end=1; /* ditto */
3670 def_start_on_first=1; /* vs A B C; view A. */
3671 def_vc_system='Subversion' /* svn is default version control */
3672 #if __VERSION__ >= 16.0
3673 def_auto_unsurround_block=0; /* Delete line, not block. */
3675 _config_modify_flags(CFGMODIFY_DEFDATA);
3677 #if __VERSION__ < 21.0 /* I think this is obsolete... */
3678 def_file_types='All Files (*),' /** @todo make this prettier */
3679 'C/C++ Files (*.c;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.h;*.hh;*.hpp;*.hxx;*.inl;*.xpm),'
3680 'Assembler (*.s;*.asm;*.mac;*.S),'
3681 'Makefiles (*;*.mak;*.kmk)'
3683 'Ch Files (*.ch;*.chf;*.chs;*.cpp;*.h),'
3685 'Java Files (*.java),'
3686 'HTML Files (*.htm;*.html;*.shtml;*.asp;*.jsp;*.php;*.php3;*.rhtml;*.css),'
3687 'CFML Files (*.cfm;*.cfml;*.cfc),'
3688 'XML Files (*.xml;*.dtd;*.xsd;*.xmldoc;*.xsl;*.xslt;*.ent;*.tld;*.xhtml;*.build;*.plist),'
3689 'XML/SGML DTD Files (*.xsd;*.dtd),'
3690 'XML/JSP TagLib Files (*.tld;*.xml),'
3691 'Objective-C (*.m;*.mm;*.h),'
3692 'IDL Files (*.idl),'
3693 'Ada Files (*.ada;*.adb;*.ads),'
3694 'Applescript Files (*.applescript),'
3695 'Basic Files (*.vb;*.vbs;*.bas;*.frm),'
3696 'Cobol Files (*.cob;*.cbl;*.ocb),'
3697 'JCL Files (*.jcl),'
3698 'JavaScript (*.js;*.ds),'
3699 'ActionScript (*.as),'
3700 'Pascal Files (*.pas;*.dpr),'
3701 'Fortran Files (*.for;*.f),'
3702 'PL/I Files (*.pl1),'
3703 'InstallScript (*.rul),'
3704 'Perl Files (*.pl;*.pm;*.perl;*.plx),'
3705 'Python Files (*.py),'
3706 'Ruby Files (*.rb;*.rby),'
3707 'Java Properties (*.properties),'
3708 'Lua Files (*.lua),'
3709 'Tcl Files (*.tcl;*.tlib;*.itk;*.itcl;*.exp),'
3711 'Slick-C (*.e;*.sh),'
3712 'SQL Files (*.sql;*.pgsql),'
3713 'SAS Files (*.sas),'
3714 'Text Files (*.txt),'
3715 'Verilog Files (*.v),'
3716 'VHDL Files (*.vhd),'
3717 'SystemVerilog Files (*.sv;*.svh;*.svi),'
3718 'Vera Files (*.vr;*.vrh),'
3719 'Erlang Files (*.erl;*.hrl),'
3723 /* Make it grok: # include <stuff.h> */
3724 for (i = 0; i < aCLikeIncs._length(); i++)
3725 replace_def_data("def
-":+aCLikeIncs[i]:+"-include
",
3726 '^[ \t]*(\#[ \t]*include|include|\#[ \t]*line)[ \t]#({#1:i}[ \t]#|)(<{#0[~>]#}>|"{#
0[~
"]#}")');
3727 replace_def_data("def-m-include", '^
[ \t
]*(\#
[ \t
]*include|\#
[ \t
]*import|include|\#
[ \t
]*line
)[ \t
]#
({#
1:i
}[ \t
]#|
)(<{#
0[~
>]#
}>|
"{#0[~"]#
}")');
3728 replace_def_data("def
-e
-include
", '^[ \t]*(\#[ \t]*include|\#[ \t]*import|\#[ \t]*require|include)[ \t]#(''{#0[~'']#}''|"{#
0[~
"]#}")');
3730 /* Replace the default unicode proportional font with the fixed oned. */
3731 _str sCodeFont = _default_font(CFG_SBCS_DBCS_SOURCE_WINDOW);
3732 _str sUnicodeFont = _default_font(CFG_UNICODE_SOURCE_WINDOW);
3733 if (pos("Default Unicode", sUnicodeFont) > 0 && length(sCodeFont) > 5)
3734 _default_font(CFG_UNICODE_SOURCE_WINDOW,sCodeFont);
3735 if (machine()=='INTELSOLARIS
' || machine()=='SPARCSOLARIS
')
3737 _default_font(CFG_MENU,'DejaVu Sans
,10,0,0,');
3738 _default_font(CFG_DIALOG,'DejaVu Sans
,10,0,,');
3739 _ConfigEnvVar('VSLICKDIALOGFONT
','DejaVu Sans
,10,0,,');
3742 /* Not so important. */
3743 int fSearch = 0x400400; /* VSSEARCHFLAG_WRAP | VSSEARCHFLAG_PROMPT_WRAP */;
3744 _default_option('S
', (_str)fSearch);
3747 #if __VERSION__ >= 17.0
3749 * Language settings via API.
3751 int fNewAff = AFF_BEGIN_END_STYLE \
3752 | AFF_INDENT_WITH_TABS \
3753 | AFF_SYNTAX_INDENT \
3755 | AFF_NO_SPACE_BEFORE_PAREN \
3758 | AFF_KEYWORD_CASING \
3760 | AFF_ATTRIBUTE_CASING \
3761 | AFF_VALUE_CASING \
3762 /*| AFF_HEX_VALUE_CASING*/;
3763 def_adaptive_formatting_flags = ~fNewAff;
3764 replace_def_data("def-adaptive-formatting-flags", def_adaptive_formatting_flags);
3766 foreach (sLangId in aMyLangIds)
3768 LanguageSettings.setIndentCaseFromSwitch(sLangId, true);
3769 LanguageSettings.setBeginEndStyle(sLangId, BES_BEGIN_END_STYLE_2);
3770 LanguageSettings.setIndentWithTabs(sLangId, false);
3771 LanguageSettings.setUseAdaptiveFormatting(sLangId, true);
3772 LanguageSettings.setAdaptiveFormattingFlags(sLangId, ~fNewAff);
3773 LanguageSettings.setSaveStripTrailingSpaces(sLangId, STSO_STRIP_MODIFIED);
3774 LanguageSettings.setTabs(sLangId, "8+");
3775 LanguageSettings.setSyntaxIndent(sLangId, 4);
3777 /* C/C++ setup, fixed comment width of 80 not 64, no max column. */
3778 # if __VERSION__ >= 21.0
3779 _SetCommentWrapFlags(CW_MAX_RIGHT, false, sLangId);
3780 _SetCommentWrapFlags(CW_USE_FIXED_WIDTH, true, sLangId);
3781 if (_LangGetPropertyInt32(sLangId, VSLANGPROPNAME_CW_FIXED_WIDTH_SIZE) < 80)
3782 _LangSetPropertyInt32(sLangId, VSLANGPROPNAME_CW_FIXED_WIDTH_SIZE, 80);
3784 sTmp = LanguageSettings.getCommentWrapOptions(sLangId);
3785 if (length(sTmp) > 10)
3787 typeless ntBlockCommentWrap, ntDocCommentWrap, ntFixedWidth;
3788 parse sTmp with ntBlockCommentWrap ntDocCommentWrap nt3 nt4 nt5 ntFixedWidth sRest;
3789 if ((int)ntFixedWidth < 80)
3790 LanguageSettings.setCommentWrapOptions('c
', ntBlockCommentWrap:+' ':+ntDocCommentWrap:+' ':+nt3:+' ':+nt4:+' ':+nt5:+' 80 ':+sRest);
3791 //replace_def_data("def-comment-wrap-c",'0 1 0 1 1 64 0 0 80 0 80 0 80 0 0 1 '); - default
3792 //replace_def_data("def-comment-wrap-c",'0 1 0 1 1 80 0 0 80 0 80 0 80 0 0 0 '); - disabled
3793 //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.
3797 /* set the encoding to UTF-8 without any friggin useless signatures. */
3798 idxExt = name_match('def
-lang
-for
-ext
-', 1, MISC_TYPE);
3801 if (name_info(idxExt) == sLangId)
3803 parse name_name(idxExt) with 'def
-lang
-for
-ext
-' auto sExt;
3804 sVarName = 'def
-encoding
-' :+ sExt;
3805 idxExtEncoding = find_index(sVarName, MISC_TYPE);
3806 if (idxExtEncoding != 0)
3807 delete_name(idxExtEncoding);
3809 idxExt = name_match('def
-lang
-for
-ext
-', 0, MISC_TYPE);
3811 //replace_def_data('def
-encoding
-' :+ sLangId, '+futf8
');
3812 idxLangEncoding = find_index('def
-encoding
-' :+ sLangId, MISC_TYPE);
3813 if (idxLangEncoding != 0)
3814 delete_name(idxLangEncoding);
3817 replace_def_data('def
-encoding
', '+futf8
');
3819 LanguageSettings.setIndentWithTabs('mak
', true);
3820 LanguageSettings.setLexerName('mak
', 'kmk
');
3821 LanguageSettings.setSyntaxIndent('mak
', 8);
3823 LanguageSettings.setBeautifierProfileName('c
', "bird's Style
");
3824 LanguageSettings.setBeautifierProfileName('m', "bird
's Objective-C Style");
3826 /* Fix .asm and add .mac, .kmk, .cmd, and .pgsql. */
3827 kdev_ext_to_lang("asm", 'masm
');
3828 kdev_ext_to_lang("mac", 'masm
');
3829 kdev_ext_to_lang("kmk", 'mak
');
3830 kdev_ext_to_lang("cmd", 'bat
');
3831 kdev_ext_to_lang("pgsql", 'plsql
');
3834 * Change the codehelp default.
3836 # if __VERSION__ >= 22.0
3837 VSCodeHelpFlags fOldCodeHelp, fNewCodeHelp;
3839 int fOldCodeHelp, fNewCodeHelp;
3841 fOldCodeHelp = def_codehelp_flags;
3842 fNewCodeHelp = fOldCodeHelp \
3843 | VSCODEHELPFLAG_AUTO_FUNCTION_HELP \
3844 | VSCODEHELPFLAG_AUTO_LIST_MEMBERS \
3845 | VSCODEHELPFLAG_SPACE_INSERTS_SPACE \
3846 | VSCODEHELPFLAG_INSERT_OPEN_PAREN \
3847 | VSCODEHELPFLAG_DISPLAY_MEMBER_COMMENTS \
3848 | VSCODEHELPFLAG_DISPLAY_FUNCTION_COMMENTS \
3849 | VSCODEHELPFLAG_REPLACE_IDENTIFIER \
3850 | VSCODEHELPFLAG_PRESERVE_IDENTIFIER \
3851 | VSCODEHELPFLAG_AUTO_PARAMETER_COMPLETION \
3852 | VSCODEHELPFLAG_AUTO_LIST_PARAMS \
3853 | VSCODEHELPFLAG_PARAMETER_TYPE_MATCHING \
3854 | VSCODEHELPFLAG_NO_SPACE_AFTER_PAREN \
3855 | VSCODEHELPFLAG_RESERVED_ON \
3856 | VSCODEHELPFLAG_MOUSE_OVER_INFO \
3857 | VSCODEHELPFLAG_AUTO_LIST_VALUES \
3858 | VSCODEHELPFLAG_HIGHLIGHT_TAGS \
3859 | VSCODEHELPFLAG_FIND_TAG_PREFERS_ALTERNATE \
3861 fNewCodeHelp &= ~( VSCODEHELPFLAG_SPACE_COMPLETION \
3862 | VSCODEHELPFLAG_AUTO_SYNTAX_HELP \
3863 | VSCODEHELPFLAG_NO_SPACE_AFTER_COMMA \
3864 | VSCODEHELPFLAG_STRICT_LIST_SELECT \
3865 | VSCODEHELPFLAG_AUTO_LIST_VALUES \
3866 | VSCODEHELPFLAG_FIND_TAG_PREFERS_DECLARATION \
3867 | VSCODEHELPFLAG_FIND_TAG_PREFERS_DEFINITION \
3868 | VSCODEHELPFLAG_FIND_TAG_HIDE_OPTIONS \
3870 def_codehelp_flags = fNewCodeHelp;
3871 foreach (sLangId in aMyLangIds)
3873 _str sVarName = 'def
-codehelp
-' :+ sLangId;
3874 int idxVar = find_index(sVarName, MISC_TYPE);
3876 replace_def_data(sVarName, fNewCodeHelp);
3880 # if __VERSION__ >= 21.0
3881 /* Old style search dialog, not mini. */
3882 def_gui_find_default = 1;
3885 _fso_strip_spaces(STSO_STRIP_MODIFIED);
3888 * - Auto restore clipboards
3895 static int kfile_to_array(_str sFile, _str (&asLines)[])
3897 asLines._makeempty();
3901 int rc = _open_temp_view(sFile, idTempView, idOrgView);
3904 _GoToROffset(0); /* top of the file. */
3913 } while (down() == 0);
3915 _delete_temp_view(idTempView);
3916 activate_window(idOrgView);
3922 _command void kload_files(_str sFile = "file-not-specified.lst")
3924 _str sFileDir = absolute(_strip_filename(sFile, 'NE
'));
3926 int rc = kfile_to_array(sFile, asFiles);
3931 for (i = 0; i < asFiles._length(); i++)
3933 _str sFile = strip(asFiles[i]);
3934 if (length(sFile) > 0)
3936 sAbsFile = absolute(sFile, sFileDir);
3937 message("Loading \"" :+ sAbsFile :+ "\"...");
3938 //say("sAbsFile=" :+ sAbsFile);
3944 message("_GetFileContents failed: " :+ rc);
3949 * Module initiation.
3954 for (i = 0; i < 999; i++)
3956 index = name_match("def-koptions-", 1 /*find_first*/, MISC_TYPE);
3964 #ifdef KDEV_WITH_MENU
3966 # if __VERSION__ < 18.0 /* Something with timers are busted, so excusing my code. */
3967 iTimer = _set_timer(1000, k_menu_create, "timer");
3969 /* createMyColorSchemeAndUseIt();*/