1 | /* $Id: kdev.e 3604 2024-02-04 23:19:33Z bird $ -*- tab-width: 4 c-indent-level: 4 -*- */
|
---|
2 | /** @file
|
---|
3 | * Visual SlickEdit Documentation Macros.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (c) 1999-2010 knut st. osmundsen <[email protected]>
|
---|
8 | *
|
---|
9 | * This file is part of kBuild.
|
---|
10 | *
|
---|
11 | * kBuild is free software; you can redistribute it and/or modify
|
---|
12 | * it under the terms of the GNU General Public License as published by
|
---|
13 | * the Free Software Foundation; either version 3 of the License, or
|
---|
14 | * (at your option) any later version.
|
---|
15 | *
|
---|
16 | * kBuild is distributed in the hope that it will be useful,
|
---|
17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
19 | * GNU General Public License for more details.
|
---|
20 | *
|
---|
21 | * You should have received a copy of the GNU General Public License
|
---|
22 | * along with kBuild. If not, see <http://www.gnu.org/licenses/>
|
---|
23 | *
|
---|
24 | */
|
---|
25 |
|
---|
26 | /***
|
---|
27 | *
|
---|
28 | * This define the following keys:
|
---|
29 | *---------------------------------
|
---|
30 | * Ctrl+Shift+C: Class description box.
|
---|
31 | * Ctrl+Shift+F: Function/method description box.
|
---|
32 | * Ctrl+Shift+M: Module(file) description box
|
---|
33 | * Ctrl+Shift+O: One-liner (comment)
|
---|
34 | *
|
---|
35 | * Ctrl+Shift+G: Global box
|
---|
36 | * Ctrl+Shift+H: Header box
|
---|
37 | * Ctrl+Shift+E: Exported Symbols
|
---|
38 | * Ctrl+Shift+I: Internal function box
|
---|
39 | * Ctrl+Shift+K: Const/macro box
|
---|
40 | * Ctrl+Shift+S: Struct/Typedef box
|
---|
41 | *
|
---|
42 | * Ctrl+Shift+A: Signature+Date marker
|
---|
43 | * Ctrl+Shift+P: Mark line as change by me
|
---|
44 | *
|
---|
45 | * Ctrl+Shift+T: Update project tagfile.
|
---|
46 | * Ctrl+Shift+L: Load document variables.
|
---|
47 | *
|
---|
48 | * Ctrl+Shift+B: KLOGENTRYX(..)
|
---|
49 | * Ctrl+Shift+E: KLOGEXIT(..)
|
---|
50 | * Ctrl+Shift+N: Do kLog stuff for the current file. No questions.
|
---|
51 | * Ctrl+Shift+Q: Do kLog stuff for the current file. Ask a lot of questions.
|
---|
52 | *
|
---|
53 | * Remember to set the correct sOdin32UserName, sOdin32UserEmail and sOdin32UserInitials
|
---|
54 | * before compiling and loading the macros into Visual SlickEdit.
|
---|
55 | *
|
---|
56 | * These macros are compatible with both 3.0(c) and 4.0(b).
|
---|
57 | *
|
---|
58 | */
|
---|
59 | defeventtab default_keys
|
---|
60 | def 'C-S-A' = k_signature
|
---|
61 | //def 'C-S-C' = k_javadoc_classbox
|
---|
62 | def 'C-S-C' = k_calc
|
---|
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
|
---|
69 | def 'C-S-N' = k_noref
|
---|
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
|
---|
77 |
|
---|
78 | //optional stuff
|
---|
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
|
---|
83 |
|
---|
84 |
|
---|
85 | //MARKER. Editor searches for this line!
|
---|
86 | #pragma option(redeclvars, on)
|
---|
87 | #include 'slick.sh'
|
---|
88 | #ifndef VS_TAGDETAIL_context_args
|
---|
89 | /* newer vslick version. */
|
---|
90 | #include 'tagsdb.sh'
|
---|
91 | //#pragma option(strict,on)
|
---|
92 | /*#else: Version 4.0 (OS/2) */
|
---|
93 | #endif
|
---|
94 |
|
---|
95 | #ifndef __MACOSX__
|
---|
96 | #define KDEV_WITH_MENU
|
---|
97 | #endif
|
---|
98 |
|
---|
99 | /* Remeber to change these! */
|
---|
100 | static _str skUserInitials = "bird";
|
---|
101 | static _str skUserName = "knut st. osmundsen";
|
---|
102 | static _str skUserEmail = "[email protected]";
|
---|
103 |
|
---|
104 |
|
---|
105 | /*******************************************************************************
|
---|
106 | * Global Variables *
|
---|
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. */
|
---|
114 |
|
---|
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. */
|
---|
120 |
|
---|
121 |
|
---|
122 | /*******************************************************************************
|
---|
123 | * Internal Functions *
|
---|
124 | *******************************************************************************/
|
---|
125 | /**
|
---|
126 | * Gets iso date.
|
---|
127 | * @returns ISO formatted date.
|
---|
128 | */
|
---|
129 | static _str k_date()
|
---|
130 | {
|
---|
131 | int i,j;
|
---|
132 | _str date;
|
---|
133 |
|
---|
134 | date = _date('U');
|
---|
135 | i = pos("/", 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;
|
---|
143 | }
|
---|
144 |
|
---|
145 |
|
---|
146 | /**
|
---|
147 | * Get the current year.
|
---|
148 | * @returns Current year string.
|
---|
149 | */
|
---|
150 | static _str k_year()
|
---|
151 | {
|
---|
152 | _str date = _date('U');
|
---|
153 | return substr(date, pos("/",date, pos("/",date)+1)+1, 4);
|
---|
154 | }
|
---|
155 |
|
---|
156 |
|
---|
157 | /**
|
---|
158 | * Aligns a value up to a given alignment.
|
---|
159 | */
|
---|
160 | static int k_alignup(int iValue, iAlign)
|
---|
161 | {
|
---|
162 | if (iAlign <= 0)
|
---|
163 | {
|
---|
164 | message('k_alignup: iValue='iValue ' iAlign='iAlign);
|
---|
165 | iAlign = 4;
|
---|
166 | }
|
---|
167 | return ((iValue intdiv iAlign) + 1) * iAlign;
|
---|
168 | }
|
---|
169 |
|
---|
170 |
|
---|
171 | /**
|
---|
172 | * Reads the comment setup for this lexer/extension .
|
---|
173 | *
|
---|
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.
|
---|
181 | */
|
---|
182 | static boolean k_commentconfig(_str &sLeft, _str &sRight, int &iColumn, _str sExt = p_extension, _str sLexer = p_lexer_name)
|
---|
183 | {
|
---|
184 | /* init returns */
|
---|
185 | sLeft = sRight = '';
|
---|
186 | iColumn = 0;
|
---|
187 |
|
---|
188 | /*
|
---|
189 | * Get comment setup from the lexer.
|
---|
190 | */
|
---|
191 | _str sLine = '';
|
---|
192 | if (sLexer)
|
---|
193 | {
|
---|
194 | /* multiline */
|
---|
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')
|
---|
201 | # else
|
---|
202 | if (!aComments[i].isDocumentation)
|
---|
203 | # endif
|
---|
204 | {
|
---|
205 | sLeft = aComments[i].delim1;
|
---|
206 | sRight = aComments[i].delim2;
|
---|
207 | iColumn = aComments[i].startcol;
|
---|
208 | if (sLeft != '' && sRight != '')
|
---|
209 | return true;
|
---|
210 | }
|
---|
211 | #else
|
---|
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)
|
---|
217 | {
|
---|
218 | sLine = aComments[i];
|
---|
219 | break;
|
---|
220 | }
|
---|
221 | if (sLine != '')
|
---|
222 | # else
|
---|
223 | rc = _ini_get_value(slick_path_search("user.vlx"), sLexer, 'mlcomment', sLine);
|
---|
224 | if (rc)
|
---|
225 | rc = _ini_get_value(slick_path_search("vslick.vlx"), sLexer, 'mlcomment', sLine);
|
---|
226 | if (!rc)
|
---|
227 | # endif
|
---|
228 | {
|
---|
229 | sLeft = strip(word(sLine, 1));
|
---|
230 | sRight = strip(word(sLine, 2));
|
---|
231 | if (sLeft != '' && sRight != '')
|
---|
232 | return true;
|
---|
233 | }
|
---|
234 | #endif
|
---|
235 |
|
---|
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')
|
---|
242 | # else
|
---|
243 | if (!aComments[i].isDocumentation)
|
---|
244 | # endif
|
---|
245 | {
|
---|
246 | sLeft = aComments[i].delim1;
|
---|
247 | sRight = '';
|
---|
248 | iColumn = aComments[i].startcol;
|
---|
249 | if (sLeft != '')
|
---|
250 | return true;
|
---|
251 | }
|
---|
252 | #else
|
---|
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)
|
---|
257 | {
|
---|
258 | sLine = aComments[i];
|
---|
259 | break;
|
---|
260 | }
|
---|
261 | if (sLine != '')
|
---|
262 | # else
|
---|
263 | rc = _ini_get_value(slick_path_search("user.vlx"), sLexer, 'linecomment', sLine);
|
---|
264 | if (rc)
|
---|
265 | rc = _ini_get_value(slick_path_search("vslick.vlx"), sLexer, 'linecomment', sLine);
|
---|
266 | if (!rc)
|
---|
267 | # endif
|
---|
268 | {
|
---|
269 | sLeft = strip(word(sLine, 1));
|
---|
270 | sRight = '';
|
---|
271 | iColumn = 0;
|
---|
272 | _str sTmp = word(sLine, 2);
|
---|
273 | if (isnumber(sTmp))
|
---|
274 | iColumn = (int)sTmp;
|
---|
275 | if (sLeft != '')
|
---|
276 | return true;
|
---|
277 | }
|
---|
278 | #endif
|
---|
279 | }
|
---|
280 |
|
---|
281 | /*
|
---|
282 | * Read the nonboxchars and determin user or default box.ini.
|
---|
283 | */
|
---|
284 | _str sFile = slick_path_search("ubox.ini");
|
---|
285 | boolean frc = _ini_get_value(sFile, sExt, 'nonboxchars', sLine);
|
---|
286 | if (frc)
|
---|
287 | {
|
---|
288 | sFile = slick_path_search("box.ini");
|
---|
289 | frc = _ini_get_value(sFile, sExt, 'nonboxchars', sLine);
|
---|
290 | }
|
---|
291 |
|
---|
292 | if (!frc)
|
---|
293 | { /*
|
---|
294 | * Found extension.
|
---|
295 | */
|
---|
296 | sLeft = strip(eq_name2value('left',sLine));
|
---|
297 | if (sLeft == '\e') sLeft = '';
|
---|
298 | sRight = strip(eq_name2value('right',sLine));
|
---|
299 | if (sRight == '\e') sRight = '';
|
---|
300 |
|
---|
301 | /* Read comment column too */
|
---|
302 | frc = _ini_get_value(sFile, sExt, 'comment_col', sLine);
|
---|
303 | if (frc)
|
---|
304 | {
|
---|
305 | iColumn = eq_name2value('comment_col', sLine);
|
---|
306 | if (iColumn == '\e') iColumn = 0;
|
---|
307 | }
|
---|
308 | else
|
---|
309 | iColumn = 0;
|
---|
310 | return true;
|
---|
311 | }
|
---|
312 |
|
---|
313 | /* failure */
|
---|
314 | sLeft = sRight = '';
|
---|
315 | iColumn = 0;
|
---|
316 |
|
---|
317 | return false;
|
---|
318 | }
|
---|
319 |
|
---|
320 |
|
---|
321 | /**
|
---|
322 | * Checks if current file only support line comments.
|
---|
323 | * @returns True / False.
|
---|
324 | * @remark Use builtin extension stuff!
|
---|
325 | */
|
---|
326 | static boolean k_line_comment()
|
---|
327 | {
|
---|
328 | _str sRight = '';
|
---|
329 | _str sLeft = '';
|
---|
330 | int iColumn;
|
---|
331 | boolean fLineComment = false;
|
---|
332 | if (k_commentconfig(sLeft, sRight, iColumn))
|
---|
333 | fLineComment = (sRight == '' || iColumn > 0);
|
---|
334 | return fLineComment;
|
---|
335 | }
|
---|
336 |
|
---|
337 |
|
---|
338 |
|
---|
339 | #define KIC_CURSOR_BEFORE 1
|
---|
340 | #define KIC_CURSOR_AFTER 2
|
---|
341 | #define KIC_CURSOR_AT_END 3
|
---|
342 |
|
---|
343 | /**
|
---|
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.
|
---|
352 | */
|
---|
353 | void k_insert_comment(_str sStr, int iCursor, int iPosition = -1)
|
---|
354 | {
|
---|
355 | _str sLeft;
|
---|
356 | _str sRight;
|
---|
357 | int iColumn;
|
---|
358 | if (!k_commentconfig(sLeft, sRight, iColumn))
|
---|
359 | {
|
---|
360 | sLeft = '/*'; sRight = '*/'; iColumn = 0;
|
---|
361 | }
|
---|
362 |
|
---|
363 | int iCol = 0;
|
---|
364 | if (iColumn <= 0)
|
---|
365 | { /*
|
---|
366 | * not column based source
|
---|
367 | */
|
---|
368 |
|
---|
369 | /* position us first */
|
---|
370 | if (iPosition > 0)
|
---|
371 | {
|
---|
372 | end_line();
|
---|
373 | do {
|
---|
374 | _insert_text(" ");
|
---|
375 | } while (p_col < iPosition);
|
---|
376 | }
|
---|
377 |
|
---|
378 | /* insert comment saving the position for _BEFORE. */
|
---|
379 | iCol = p_col;
|
---|
380 | _insert_text(sLeft:+' ':+sStr);
|
---|
381 | if (iCursor == KIC_CURSOR_AT_END)
|
---|
382 | iCol = p_col;
|
---|
383 | /* right comment delimiter? */
|
---|
384 | if (sRight != '')
|
---|
385 | _insert_text(' ':+sRight);
|
---|
386 | }
|
---|
387 | else
|
---|
388 | {
|
---|
389 | if (p_col >= iColumn)
|
---|
390 | _insert_text("\n");
|
---|
391 | do { _insert_text(" "); } while (p_col < iColumn);
|
---|
392 | if (iCursor == KIC_CURSOR_BEFORE)
|
---|
393 | iCol = p_col;
|
---|
394 | _insert_text(sLeft:+' ':+sStr);
|
---|
395 | if (iCursor == KIC_CURSOR_AT_END)
|
---|
396 | iCol = p_col;
|
---|
397 | }
|
---|
398 |
|
---|
399 | /* set cursor. */
|
---|
400 | if (iCursor != KIC_CURSOR_AFTER)
|
---|
401 | p_col = iCol;
|
---|
402 | }
|
---|
403 |
|
---|
404 |
|
---|
405 | /**
|
---|
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.
|
---|
410 | */
|
---|
411 | static _str k_comment(boolean fRight = false)
|
---|
412 | {
|
---|
413 | _str sLeft, sRight;
|
---|
414 | int iColumn;
|
---|
415 | _str sComment = '/*';
|
---|
416 | if (k_commentconfig(sLeft, sRight, iColumn))
|
---|
417 | sComment = (!fRight || iColumn > 0 ? sLeft : sRight);
|
---|
418 |
|
---|
419 | return strip(sComment);
|
---|
420 | }
|
---|
421 |
|
---|
422 |
|
---|
423 | /*******************************************************************************
|
---|
424 | * BOXES *
|
---|
425 | *******************************************************************************/
|
---|
426 |
|
---|
427 | /**
|
---|
428 | * Inserts the first line in a box.
|
---|
429 | * @param sTag Not used - box tag.
|
---|
430 | */
|
---|
431 | static void k_box_start(sTag)
|
---|
432 | {
|
---|
433 | _str sLeft, sRight;
|
---|
434 | int iColumn;
|
---|
435 | if (!k_commentconfig(sLeft, sRight, iColumn))
|
---|
436 | return;
|
---|
437 | _begin_line();
|
---|
438 | if (iColumn >= 0)
|
---|
439 | while (p_col < iColumn)
|
---|
440 | _insert_text(" ");
|
---|
441 |
|
---|
442 | _str sText = sLeft;
|
---|
443 | if (sTag != '' && fkStyleBoxTag)
|
---|
444 | {
|
---|
445 | if (substr(sText, length(sText)) != '*')
|
---|
446 | sText = sText:+'*';
|
---|
447 | sText = sText:+sTag;
|
---|
448 | }
|
---|
449 |
|
---|
450 | int i;
|
---|
451 | for (i = length(sText); i <= ikStyleWidth - p_col; i++)
|
---|
452 | sText = sText:+'*';
|
---|
453 | sText = sText:+"\n";
|
---|
454 |
|
---|
455 | _insert_text(sText);
|
---|
456 | }
|
---|
457 |
|
---|
458 |
|
---|
459 | /**
|
---|
460 | * Places a string, sStr, into a line started and ended by '*'.
|
---|
461 | * @param sStr Text to have between the '*'s.
|
---|
462 | */
|
---|
463 | static void k_box_line(_str sStr)
|
---|
464 | {
|
---|
465 | _str sLeft, sRight;
|
---|
466 | int iColumn;
|
---|
467 | if (!k_commentconfig(sLeft, sRight, iColumn))
|
---|
468 | return;
|
---|
469 | if (iColumn >= 0)
|
---|
470 | while (p_col < iColumn)
|
---|
471 | _insert_text(" ");
|
---|
472 |
|
---|
473 | _str sText = '';
|
---|
474 | if (k_line_comment())
|
---|
475 | sText = sLeft;
|
---|
476 | if (sText == '' || substr(sText, length(sText)) != '*')
|
---|
477 | sText = sText:+'*';
|
---|
478 |
|
---|
479 | sText = sText:+' ';
|
---|
480 | int i;
|
---|
481 | for (i = length(sText); i < p_SyntaxIndent; i++)
|
---|
482 | sText = sText:+' ';
|
---|
483 |
|
---|
484 | sText = sText:+sStr;
|
---|
485 |
|
---|
486 | for (i = length(sText) + 1; i <= ikStyleWidth - p_col; i++)
|
---|
487 | sText = sText:+' ';
|
---|
488 | sText = sText:+"*\n";
|
---|
489 |
|
---|
490 | _insert_text(sText);
|
---|
491 | }
|
---|
492 |
|
---|
493 |
|
---|
494 | /**
|
---|
495 | * Inserts the last line in a box.
|
---|
496 | */
|
---|
497 | static void k_box_end()
|
---|
498 | {
|
---|
499 | _str sLeft, sRight;
|
---|
500 | int iColumn, i;
|
---|
501 | if (!k_commentconfig(sLeft, sRight, iColumn))
|
---|
502 | return;
|
---|
503 | if (iColumn >= 0)
|
---|
504 | while (p_col < iColumn)
|
---|
505 | _insert_text(" ");
|
---|
506 |
|
---|
507 | _str sText = '';
|
---|
508 | if (k_line_comment())
|
---|
509 | sText = sLeft;
|
---|
510 | for (i = length(sText) + length(sRight); i <= ikStyleWidth - p_col; i++)
|
---|
511 | sText = sText:+'*';
|
---|
512 | sText = sText:+sRight:+"\n";
|
---|
513 |
|
---|
514 | _insert_text(sText);
|
---|
515 | }
|
---|
516 |
|
---|
517 |
|
---|
518 |
|
---|
519 | /*******************************************************************************
|
---|
520 | * FUNCTION AND CODE PARSERS *
|
---|
521 | *******************************************************************************/
|
---|
522 | /**
|
---|
523 | * Moves cursor to nearest function start.
|
---|
524 | * @returns 0 if ok.
|
---|
525 | * -1 on failure.
|
---|
526 | */
|
---|
527 | static int k_func_goto_nearest_function()
|
---|
528 | {
|
---|
529 | boolean fFix = false; /* cursor at function fix. (last function) */
|
---|
530 | int cur_line = p_line;
|
---|
531 | int prev_line = -1;
|
---|
532 | int next_line = -1;
|
---|
533 | typeless org_pos;
|
---|
534 | _save_pos2(org_pos);
|
---|
535 |
|
---|
536 | if (!next_proc(1))
|
---|
537 | {
|
---|
538 | next_line = p_line;
|
---|
539 | if (!prev_proc(1) && p_line == cur_line)
|
---|
540 | {
|
---|
541 | _restore_pos2(org_pos);
|
---|
542 | return 0;
|
---|
543 | }
|
---|
544 | _restore_pos2(org_pos);
|
---|
545 | _save_pos2(org_pos);
|
---|
546 | }
|
---|
547 | else
|
---|
548 | {
|
---|
549 | p_col++; /* fixes problem with single function files. */
|
---|
550 | fFix = true;
|
---|
551 | }
|
---|
552 |
|
---|
553 | if (!prev_proc(1))
|
---|
554 | {
|
---|
555 | prev_line = p_line;
|
---|
556 | if (!next_proc(1) && p_line == cur_line)
|
---|
557 | {
|
---|
558 | _restore_pos2(org_pos);
|
---|
559 | return 0;
|
---|
560 | }
|
---|
561 | _restore_pos2(org_pos);
|
---|
562 | _save_pos2(org_pos);
|
---|
563 | }
|
---|
564 |
|
---|
565 |
|
---|
566 | if (prev_line != -1 && (next_line == -1 || cur_line - prev_line <= next_line - cur_line))
|
---|
567 | {
|
---|
568 | if (fFix)
|
---|
569 | p_col++;
|
---|
570 | prev_proc(1);
|
---|
571 | return 0;
|
---|
572 | }
|
---|
573 |
|
---|
574 | if (next_line != -1 && (prev_line == -1 || cur_line - prev_line > next_line - cur_line))
|
---|
575 | {
|
---|
576 | next_proc();
|
---|
577 | return 0;
|
---|
578 | }
|
---|
579 |
|
---|
580 | _restore_pos2(org_pos);
|
---|
581 | return -1;
|
---|
582 | }
|
---|
583 |
|
---|
584 |
|
---|
585 | /**
|
---|
586 | * Check if nearest function is a prototype.
|
---|
587 | * @returns True if function prototype.
|
---|
588 | * False if not function prototype.
|
---|
589 | */
|
---|
590 | static boolean k_func_prototype()
|
---|
591 | {
|
---|
592 | /*
|
---|
593 | * Check if this is a real function implementation.
|
---|
594 | */
|
---|
595 | typeless procpos;
|
---|
596 | _save_pos2(procpos);
|
---|
597 | if (!k_func_goto_nearest_function())
|
---|
598 | {
|
---|
599 | int proc_line = p_line;
|
---|
600 |
|
---|
601 | if (!k_func_searchcode("{"))
|
---|
602 | {
|
---|
603 | prev_proc();
|
---|
604 | if (p_line != proc_line)
|
---|
605 | {
|
---|
606 | _restore_pos2(procpos);
|
---|
607 | return true;
|
---|
608 | }
|
---|
609 | }
|
---|
610 | }
|
---|
611 | _restore_pos2(procpos);
|
---|
612 |
|
---|
613 | return false;
|
---|
614 | }
|
---|
615 |
|
---|
616 |
|
---|
617 | /**
|
---|
618 | * Gets the name fo the current function.
|
---|
619 | * @returns The current function name.
|
---|
620 | */
|
---|
621 | static _str k_func_getfunction_name()
|
---|
622 | {
|
---|
623 | _str sFunctionName = current_proc();
|
---|
624 | if (!sFunctionName)
|
---|
625 | sFunctionName = "";
|
---|
626 | //say 'functionanme='sFunctionName;
|
---|
627 | return sFunctionName;
|
---|
628 | }
|
---|
629 |
|
---|
630 |
|
---|
631 | /**
|
---|
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).
|
---|
634 | */
|
---|
635 | static _str k_func_getparams()
|
---|
636 | {
|
---|
637 | typeless org_pos;
|
---|
638 | _save_pos2(org_pos);
|
---|
639 |
|
---|
640 | /*
|
---|
641 | * Try use the tags first.
|
---|
642 | */
|
---|
643 | _UpdateContext(true);
|
---|
644 | int context_id = tag_current_context();
|
---|
645 | if (context_id <= 0)
|
---|
646 | {
|
---|
647 | k_func_goto_nearest_function();
|
---|
648 | context_id = tag_current_context();
|
---|
649 | }
|
---|
650 | if (context_id > 0)
|
---|
651 | {
|
---|
652 | _str args = '';
|
---|
653 | _str type = '';
|
---|
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))
|
---|
657 | return args
|
---|
658 | //caption = tag_tree_make_caption_fast(VS_TAGMATCH_context,context_id,true,true,false);
|
---|
659 | }
|
---|
660 |
|
---|
661 | /*
|
---|
662 | * Go to nearest function.
|
---|
663 | */
|
---|
664 | if ( !k_func_goto_nearest_function()
|
---|
665 | && !k_func_searchcode("(") /* makes some assumptions. */
|
---|
666 | )
|
---|
667 | {
|
---|
668 | /*
|
---|
669 | * Get parameters.
|
---|
670 | */
|
---|
671 | typeless posStart;
|
---|
672 | _save_pos2(posStart);
|
---|
673 | long offStart = _QROffset();
|
---|
674 | if (!find_matching_paren())
|
---|
675 | {
|
---|
676 | long offEnd = _QROffset();
|
---|
677 | _restore_pos2(posStart);
|
---|
678 | p_col++;
|
---|
679 | _str sParamsRaw = strip(get_text((int)(offEnd - offStart - 1)));
|
---|
680 |
|
---|
681 |
|
---|
682 | /*
|
---|
683 | * Remove new lines and double spaces within params.
|
---|
684 | */
|
---|
685 | _str sParams = "";
|
---|
686 |
|
---|
687 | int i;
|
---|
688 | _str chPrev;
|
---|
689 | for (i = 1, chPrev = ' '; i <= length(sParamsRaw); i++)
|
---|
690 | {
|
---|
691 | _str ch = substr(sParamsRaw, i, 1);
|
---|
692 |
|
---|
693 | /*
|
---|
694 | * Do fixups.
|
---|
695 | */
|
---|
696 | if (ch == " " && chPrev == " ")
|
---|
697 | continue;
|
---|
698 |
|
---|
699 | if ((ch :== "\n") || (ch :== "\r") || (ch :== "\t"))
|
---|
700 | {
|
---|
701 | if (chPrev == ' ')
|
---|
702 | continue;
|
---|
703 | ch = ' ';
|
---|
704 | }
|
---|
705 |
|
---|
706 | if (ch == ',' && chPrev == ' ')
|
---|
707 | {
|
---|
708 | sParams = substr(sParams, 1, length(sParams) - 1);
|
---|
709 | }
|
---|
710 |
|
---|
711 | if (ch == '*')
|
---|
712 | {
|
---|
713 | if (chPrev != ' ')
|
---|
714 | sParams = sParams :+ ' * ';
|
---|
715 | else
|
---|
716 | sParams = sParams :+ '* ';
|
---|
717 | chPrev = ' ';
|
---|
718 | }
|
---|
719 | else
|
---|
720 | {
|
---|
721 | sParams = sParams :+ ch;
|
---|
722 | chPrev = ch;
|
---|
723 | }
|
---|
724 |
|
---|
725 | } /* for */
|
---|
726 |
|
---|
727 | sParams = strip(sParams);
|
---|
728 | if (sParams == 'void' || sParams == 'VOID')
|
---|
729 | sParams = "";
|
---|
730 | _restore_pos2(org_pos);
|
---|
731 | return sParams;
|
---|
732 | }
|
---|
733 | else
|
---|
734 | message("find_matchin_paren failed");
|
---|
735 | }
|
---|
736 |
|
---|
737 | _restore_pos2(org_pos);
|
---|
738 | return false;
|
---|
739 | }
|
---|
740 |
|
---|
741 |
|
---|
742 |
|
---|
743 | /**
|
---|
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).
|
---|
752 | */
|
---|
753 | static int k_func_enumparams(_str sParams, int iParam, _str &sType, _str &sName, _str &sDefault)
|
---|
754 | {
|
---|
755 | int i;
|
---|
756 | int iParLevel;
|
---|
757 | int iCurParam;
|
---|
758 | int iStartParam;
|
---|
759 |
|
---|
760 | sType = sName = sDefault = "";
|
---|
761 |
|
---|
762 | /* no use working on empty string! */
|
---|
763 | if (length(sParams) == 0)
|
---|
764 | return -1;
|
---|
765 |
|
---|
766 | /* find the parameter in question */
|
---|
767 | for (iStartParam = i = 1, iParLevel = iCurParam = 0; i <= length(sParams); i++)
|
---|
768 | {
|
---|
769 | _str ch = substr(sParams, i, 1);
|
---|
770 | if (ch == ',' && iParLevel == 0)
|
---|
771 | {
|
---|
772 | /* is it this parameter ? */
|
---|
773 | if (iParam == iCurParam)
|
---|
774 | break;
|
---|
775 |
|
---|
776 | iCurParam++;
|
---|
777 | iStartParam = i + 1;
|
---|
778 | }
|
---|
779 | else if (ch == '(')
|
---|
780 | iParLevel++;
|
---|
781 | else if (ch == ')')
|
---|
782 | iParLevel--;
|
---|
783 | }
|
---|
784 |
|
---|
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");
|
---|
793 | sArg = strip(sArg);
|
---|
794 |
|
---|
795 | /* lazy approach, which doens't support function types */
|
---|
796 |
|
---|
797 | if (pos('=', sParams) > 0) /* default */
|
---|
798 | {
|
---|
799 | sDefault = strip(substr(sParams, pos('=', sParams) + 1));
|
---|
800 | sArg = strip(substr(sArg, 1, pos('=', sParams) - 1));
|
---|
801 | }
|
---|
802 |
|
---|
803 | for (i = length(sArg); i > 1; i--)
|
---|
804 | {
|
---|
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 != '$')
|
---|
810 | break;
|
---|
811 | }
|
---|
812 | if (sArg == "...")
|
---|
813 | i = 0;
|
---|
814 | sName = strip(substr(sArg, i + 1));
|
---|
815 | sType = strip(substr(sArg, 1, i));
|
---|
816 |
|
---|
817 | return 0;
|
---|
818 | }
|
---|
819 |
|
---|
820 | return -1;
|
---|
821 | }
|
---|
822 |
|
---|
823 |
|
---|
824 | /**
|
---|
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).
|
---|
828 | */
|
---|
829 | static int k_func_countparams(_str sParams)
|
---|
830 | {
|
---|
831 | int i;
|
---|
832 | int iParLevel;
|
---|
833 | int iCurParam;
|
---|
834 | _str sType = "", sName = "", sDefault = "";
|
---|
835 |
|
---|
836 | /* check for 0 parameters */
|
---|
837 | if (length(sParams) == 0)
|
---|
838 | return 0;
|
---|
839 |
|
---|
840 | /* find the parameter in question */
|
---|
841 | for (i = 1, iParLevel = iCurParam = 0; i <= length(sParams); i++)
|
---|
842 | {
|
---|
843 | _str ch = substr(sParams, i, 1);
|
---|
844 | if (ch == ',' && iParLevel == 0)
|
---|
845 | {
|
---|
846 | iCurParam++;
|
---|
847 | }
|
---|
848 | else if (ch == '(')
|
---|
849 | iParLevel++;
|
---|
850 | else if (ch == ')')
|
---|
851 | iParLevel--;
|
---|
852 | }
|
---|
853 |
|
---|
854 | return iCurParam + 1;
|
---|
855 | }
|
---|
856 |
|
---|
857 |
|
---|
858 | /**
|
---|
859 | * Gets the return type.
|
---|
860 | */
|
---|
861 | static _str k_func_getreturntype(boolean fPureType = false)
|
---|
862 | {
|
---|
863 | typeless org_pos;
|
---|
864 | _save_pos2(org_pos);
|
---|
865 |
|
---|
866 | /*
|
---|
867 | * Go to nearest function.
|
---|
868 | */
|
---|
869 | if (!k_func_goto_nearest_function())
|
---|
870 | {
|
---|
871 | /*
|
---|
872 | * Return type is from function start to function name...
|
---|
873 | */
|
---|
874 | typeless posStart;
|
---|
875 | _save_pos2(posStart);
|
---|
876 | long offStart = _QROffset();
|
---|
877 |
|
---|
878 | if (!k_func_searchcode("(")) /* makes some assumptions. */
|
---|
879 | {
|
---|
880 | prev_word();
|
---|
881 | long offEnd = _QROffset();
|
---|
882 | _restore_pos2(posStart);
|
---|
883 | _str sTypeRaw = strip(get_text((int)(offEnd - offStart)));
|
---|
884 |
|
---|
885 | //say 'sTypeRaw='sTypeRaw;
|
---|
886 | /*
|
---|
887 | * Remove static, inline, _Optlink, stdcall, EXPENTRY etc.
|
---|
888 | */
|
---|
889 | if (fPureType)
|
---|
890 | {
|
---|
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");
|
---|
946 | }
|
---|
947 |
|
---|
948 | /*
|
---|
949 | * Remove new lines and double spaces within params.
|
---|
950 | */
|
---|
951 | _str sType = "";
|
---|
952 |
|
---|
953 | int i;
|
---|
954 | _str chPrev;
|
---|
955 | for (i = 1, chPrev = ' '; i <= length(sTypeRaw); i++)
|
---|
956 | {
|
---|
957 | _str ch = substr(sTypeRaw, i, 1);
|
---|
958 |
|
---|
959 | /*
|
---|
960 | * Do fixups.
|
---|
961 | */
|
---|
962 | if (ch == " " && chPrev == " ")
|
---|
963 | continue;
|
---|
964 |
|
---|
965 | if ((ch :== "\n") || (ch :== "\r") || (ch :== "\t"))
|
---|
966 | {
|
---|
967 | if (chPrev == ' ')
|
---|
968 | continue;
|
---|
969 | ch = ' ';
|
---|
970 | }
|
---|
971 |
|
---|
972 | if (ch == ',' && chPrev == ' ')
|
---|
973 | {
|
---|
974 | sType = substr(sType, 1, length(sType) - 1);
|
---|
975 | }
|
---|
976 |
|
---|
977 | if (ch == '*')
|
---|
978 | {
|
---|
979 | if (chPrev != ' ')
|
---|
980 | sType = sType :+ ' * ';
|
---|
981 | else
|
---|
982 | sType = sType :+ '* ';
|
---|
983 | chPrev = ' ';
|
---|
984 | }
|
---|
985 | else
|
---|
986 | {
|
---|
987 | sType = sType :+ ch;
|
---|
988 | chPrev = ch;
|
---|
989 | }
|
---|
990 |
|
---|
991 | } /* for */
|
---|
992 |
|
---|
993 | sType = strip(sType);
|
---|
994 |
|
---|
995 | _restore_pos2(org_pos);
|
---|
996 | return sType;
|
---|
997 | }
|
---|
998 | else
|
---|
999 | message('k_func_getreturntype: can''t find ''(''.');
|
---|
1000 | }
|
---|
1001 |
|
---|
1002 | _restore_pos2(org_pos);
|
---|
1003 | return false;
|
---|
1004 | }
|
---|
1005 |
|
---|
1006 |
|
---|
1007 | /**
|
---|
1008 | * Search for some piece of code.
|
---|
1009 | */
|
---|
1010 | static int k_func_searchcode(_str sSearchString, _str sOptions = "E+")
|
---|
1011 | {
|
---|
1012 | int rc;
|
---|
1013 | rc = search(sSearchString, sOptions);
|
---|
1014 | while (!rc && !k_func_in_code())
|
---|
1015 | {
|
---|
1016 | p_col++;
|
---|
1017 | rc = search(sSearchString, sOptions);
|
---|
1018 | }
|
---|
1019 | return rc;
|
---|
1020 | }
|
---|
1021 |
|
---|
1022 |
|
---|
1023 | /**
|
---|
1024 | * Checks if cursor is in code or in comment.
|
---|
1025 | * @return True if cursor in code.
|
---|
1026 | */
|
---|
1027 | static boolean k_func_in_code()
|
---|
1028 | {
|
---|
1029 | typeless searchsave;
|
---|
1030 | _save_pos2(searchsave);
|
---|
1031 | boolean fRc = !_in_comment();
|
---|
1032 | _restore_pos2(searchsave);
|
---|
1033 | return fRc;
|
---|
1034 | }
|
---|
1035 |
|
---|
1036 |
|
---|
1037 | /*
|
---|
1038 | * Gets the next piece of code.
|
---|
1039 | */
|
---|
1040 | static _str k_func_get_next_code_text()
|
---|
1041 | {
|
---|
1042 | typeless searchsave;
|
---|
1043 | _save_pos2(searchsave);
|
---|
1044 | _str ch = k_func_get_next_code_text2();
|
---|
1045 | _restore_pos2(searchsave);
|
---|
1046 | return ch;
|
---|
1047 | }
|
---|
1048 |
|
---|
1049 |
|
---|
1050 | /**
|
---|
1051 | * Checks if there is more code on the line.
|
---|
1052 | */
|
---|
1053 | static boolean k_func_more_code_on_line()
|
---|
1054 | {
|
---|
1055 | boolean fRc;
|
---|
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);
|
---|
1062 |
|
---|
1063 | return fRc;
|
---|
1064 | }
|
---|
1065 |
|
---|
1066 |
|
---|
1067 | /**
|
---|
1068 | * Gets the next piece of code.
|
---|
1069 | * Doesn't preserver cursor position.
|
---|
1070 | */
|
---|
1071 | static _str k_func_get_next_code_text2()
|
---|
1072 | {
|
---|
1073 | _str ch;
|
---|
1074 | do
|
---|
1075 | {
|
---|
1076 | int curcol = ++p_col;
|
---|
1077 | end_line();
|
---|
1078 | if (p_col <= curcol)
|
---|
1079 | {
|
---|
1080 | p_line++;
|
---|
1081 | p_col = 1;
|
---|
1082 | }
|
---|
1083 | else
|
---|
1084 | p_col = curcol;
|
---|
1085 |
|
---|
1086 | ch = get_text();
|
---|
1087 | //say ch ' ('_asc(ch)')';
|
---|
1088 | while (ch == "#") /* preprocessor stuff */
|
---|
1089 | {
|
---|
1090 | p_col = 1;
|
---|
1091 | p_line++;
|
---|
1092 | ch = get_text();
|
---|
1093 | //say ch ' ('_asc(ch)')';
|
---|
1094 | continue;
|
---|
1095 | }
|
---|
1096 | } while (ch :== ' ' || ch :== "\t" || ch :== "\n" || ch :== "\r" || !k_func_in_code());
|
---|
1097 |
|
---|
1098 | return ch;
|
---|
1099 | }
|
---|
1100 |
|
---|
1101 |
|
---|
1102 |
|
---|
1103 |
|
---|
1104 | /*******************************************************************************
|
---|
1105 | * JAVA DOC STYLED WORKERS *
|
---|
1106 | *******************************************************************************/
|
---|
1107 |
|
---|
1108 | /** starts a javadoc documentation box. */
|
---|
1109 | static void k_javadoc_box_start(_str sStr = '', boolean fDouble = true)
|
---|
1110 | {
|
---|
1111 | _str sLeft, sRight;
|
---|
1112 | int iColumn;
|
---|
1113 | if (!k_commentconfig(sLeft, sRight, iColumn))
|
---|
1114 | return;
|
---|
1115 | _begin_line();
|
---|
1116 | if (iColumn >= 0)
|
---|
1117 | while (p_col < iColumn)
|
---|
1118 | _insert_text(" ");
|
---|
1119 |
|
---|
1120 | _str sText = sLeft;
|
---|
1121 | if (fDouble)
|
---|
1122 | sText = sLeft:+substr(sLeft, length(sLeft), 1);
|
---|
1123 | if (sStr != '')
|
---|
1124 | sText = sText:+' ':+sStr;
|
---|
1125 | sText = sText:+"\n";
|
---|
1126 |
|
---|
1127 | _insert_text(sText);
|
---|
1128 | }
|
---|
1129 |
|
---|
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 = '')
|
---|
1132 | {
|
---|
1133 | _str sLeft, sRight;
|
---|
1134 | int iColumn;
|
---|
1135 | if (!k_commentconfig(sLeft, sRight, iColumn))
|
---|
1136 | return;
|
---|
1137 | if (iColumn >= 0)
|
---|
1138 | while (p_col < iColumn)
|
---|
1139 | _insert_text(" ");
|
---|
1140 |
|
---|
1141 | _str sText;
|
---|
1142 | if (k_line_comment())
|
---|
1143 | sText = sLeft;
|
---|
1144 | else
|
---|
1145 | {
|
---|
1146 | sText = sLeft;
|
---|
1147 | sText = ' ':+substr(sLeft, length(sLeft));
|
---|
1148 | }
|
---|
1149 |
|
---|
1150 | if (sStr != '')
|
---|
1151 | sText = sText:+' ':+sStr;
|
---|
1152 | if (iPadd > 0)
|
---|
1153 | {
|
---|
1154 | int i;
|
---|
1155 | for (i = length(sText); i < iPadd; i++)
|
---|
1156 | sText = sText:+' ';
|
---|
1157 |
|
---|
1158 | if (sStr2 != '')
|
---|
1159 | sText = sText:+sStr2;
|
---|
1160 |
|
---|
1161 | if (iPadd2 > 0)
|
---|
1162 | {
|
---|
1163 | for (i = length(sText); i < iPadd2; i++)
|
---|
1164 | sText = sText:+' ';
|
---|
1165 |
|
---|
1166 | if (sStr3 != '')
|
---|
1167 | sText = sText:+sStr3;
|
---|
1168 | }
|
---|
1169 | }
|
---|
1170 | sText = sText:+"\n";
|
---|
1171 |
|
---|
1172 | _insert_text(sText);
|
---|
1173 | }
|
---|
1174 |
|
---|
1175 | /** ends a javadoc documentation box. */
|
---|
1176 | static void k_javadoc_box_end()
|
---|
1177 | {
|
---|
1178 | _str sLeft, sRight;
|
---|
1179 | int iColumn;
|
---|
1180 | if (!k_commentconfig(sLeft, sRight, iColumn))
|
---|
1181 | return;
|
---|
1182 | if (iColumn >= 0)
|
---|
1183 | while (p_col < iColumn)
|
---|
1184 | _insert_text(" ");
|
---|
1185 |
|
---|
1186 | _str sText;
|
---|
1187 | if (k_line_comment())
|
---|
1188 | sText = sLeft;
|
---|
1189 | else
|
---|
1190 | {
|
---|
1191 | sText = sRight;
|
---|
1192 | /*if (substr(sText, 1, 1) != '*')
|
---|
1193 | sText = '*':+sText;*/
|
---|
1194 | sText = ' ':+sText;
|
---|
1195 | }
|
---|
1196 | sText = sText:+"\n";
|
---|
1197 |
|
---|
1198 | _insert_text(sText);
|
---|
1199 | }
|
---|
1200 |
|
---|
1201 |
|
---|
1202 | /**
|
---|
1203 | * Write a Javadoc styled classbox.
|
---|
1204 | */
|
---|
1205 | void k_javadoc_classbox()
|
---|
1206 | {
|
---|
1207 | int iCursorLine;
|
---|
1208 | int iPadd = k_alignup(12, p_SyntaxIndent);
|
---|
1209 |
|
---|
1210 | k_javadoc_box_start();
|
---|
1211 | iCursorLine = p_RLine;
|
---|
1212 | k_javadoc_box_line(' ');
|
---|
1213 |
|
---|
1214 | if (fkStyleFullHeaders)
|
---|
1215 | {
|
---|
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);
|
---|
1220 | }
|
---|
1221 | k_javadoc_box_line('@author', iPadd, skUserName ' <' skUserEmail '>');
|
---|
1222 | k_javadoc_box_line('@approval', iPadd);
|
---|
1223 | k_javadoc_box_end();
|
---|
1224 |
|
---|
1225 | up(p_RLine - iCursorLine);
|
---|
1226 | end_line();
|
---|
1227 | keyin(' ');
|
---|
1228 | }
|
---|
1229 |
|
---|
1230 |
|
---|
1231 | /**
|
---|
1232 | * Javadoc - functionbox(/header).
|
---|
1233 | */
|
---|
1234 | void k_javadoc_funcbox()
|
---|
1235 | {
|
---|
1236 | int cArgs = 1;
|
---|
1237 | _str sArgs = "";
|
---|
1238 | int iCursorLine;
|
---|
1239 | int iPadd = k_alignup(11, p_SyntaxIndent);
|
---|
1240 |
|
---|
1241 | /* look for parameters */
|
---|
1242 | boolean fFoundFn = !k_func_goto_nearest_function();
|
---|
1243 | if (fFoundFn)
|
---|
1244 | {
|
---|
1245 | sArgs = k_func_getparams();
|
---|
1246 | cArgs = k_func_countparams(sArgs);
|
---|
1247 | }
|
---|
1248 |
|
---|
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);
|
---|
1255 | if (fFoundFn)
|
---|
1256 | {
|
---|
1257 | /*
|
---|
1258 | * Determin parameter description indent.
|
---|
1259 | */
|
---|
1260 | int iPadd2 = 0;
|
---|
1261 | int i;
|
---|
1262 | for (i = 0; i < cArgs; i++)
|
---|
1263 | {
|
---|
1264 | _str sName, sType, sDefault;
|
---|
1265 | if ( !k_func_enumparams(sArgs, i, sType, sName, sDefault)
|
---|
1266 | && iPadd2 < length(sName))
|
---|
1267 | iPadd2 = length(sName);
|
---|
1268 | }
|
---|
1269 | iPadd2 = k_alignup((iPadd + iPadd2), p_SyntaxIndent);
|
---|
1270 | if (iPadd2 < 28)
|
---|
1271 | iPadd2 = k_alignup(28, p_SyntaxIndent);
|
---|
1272 |
|
---|
1273 | /*
|
---|
1274 | * Insert parameter.
|
---|
1275 | */
|
---|
1276 | for (i = 0; i < cArgs; i++)
|
---|
1277 | {
|
---|
1278 | _str sName, sType, sDefault;
|
---|
1279 | if (!k_func_enumparams(sArgs, i, sType, sName, sDefault))
|
---|
1280 | {
|
---|
1281 | _str sStr3 = '.';
|
---|
1282 | if (sDefault != "")
|
---|
1283 | sStr3 = '(default='sDefault')';
|
---|
1284 | k_javadoc_box_line('@param', iPadd, sName, iPadd2, sStr3);
|
---|
1285 | }
|
---|
1286 | else
|
---|
1287 | k_javadoc_box_line('@param', iPadd);
|
---|
1288 | }
|
---|
1289 | }
|
---|
1290 | else
|
---|
1291 | k_javadoc_box_line('@param', iPadd);
|
---|
1292 |
|
---|
1293 | if (file_eq(p_extension, 'asm') || file_eq(p_extension, 'masm'))
|
---|
1294 | k_javadoc_box_line('@uses', iPadd);
|
---|
1295 | if (fkStyleFullHeaders)
|
---|
1296 | {
|
---|
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);
|
---|
1303 | }
|
---|
1304 | k_javadoc_box_end();
|
---|
1305 |
|
---|
1306 | up(p_RLine - iCursorLine);
|
---|
1307 | end_line();
|
---|
1308 | keyin(' ');
|
---|
1309 | }
|
---|
1310 |
|
---|
1311 |
|
---|
1312 | /**
|
---|
1313 | * Javadoc module header.
|
---|
1314 | */
|
---|
1315 | void k_javadoc_moduleheader()
|
---|
1316 | {
|
---|
1317 | int iCursorLine;
|
---|
1318 | int fSplit = 0;
|
---|
1319 |
|
---|
1320 | _insert_text("\n");
|
---|
1321 | up();
|
---|
1322 | _begin_line();
|
---|
1323 | k_insert_comment('$':+'I':+'d: $', KIC_CURSOR_AT_END, -1);
|
---|
1324 | _end_line();
|
---|
1325 | _insert_text("\n");
|
---|
1326 |
|
---|
1327 | k_javadoc_box_start('@file');
|
---|
1328 | fSplit = 1;
|
---|
1329 | iCursorLine = p_RLine;
|
---|
1330 | k_javadoc_box_line();
|
---|
1331 | k_javadoc_box_end();
|
---|
1332 | _insert_text("\n");
|
---|
1333 | _insert_text(k_comment() "\n");
|
---|
1334 |
|
---|
1335 | if (skLicense == 'Confidential')
|
---|
1336 | {
|
---|
1337 | k_javadoc_box_line(skCompany ' confidential');
|
---|
1338 | k_javadoc_box_line();
|
---|
1339 | }
|
---|
1340 |
|
---|
1341 | if (skCompany != '')
|
---|
1342 | {
|
---|
1343 | if (skLicense != 'Confidential')
|
---|
1344 | k_javadoc_box_line('Copyright (C) ' k_year() ' ' skCompany);
|
---|
1345 | else
|
---|
1346 | {
|
---|
1347 | k_javadoc_box_line('Copyright (c) ' k_year() ' ' skCompany);
|
---|
1348 | k_javadoc_box_line();
|
---|
1349 | k_javadoc_box_line('Author: ' skUserName' <' skUserEmail '>');
|
---|
1350 | }
|
---|
1351 | }
|
---|
1352 | else
|
---|
1353 | k_javadoc_box_line('Copyright (c) ' k_year() ' 'skUserName' <' skUserEmail '>');
|
---|
1354 | k_javadoc_box_line();
|
---|
1355 | _str sProg = skProgram;
|
---|
1356 | switch (skLicense)
|
---|
1357 | {
|
---|
1358 | case 'Odin32':
|
---|
1359 | k_javadoc_box_line('Project Odin Software License can be found in LICENSE.TXT.');
|
---|
1360 | break;
|
---|
1361 |
|
---|
1362 | case 'GPL':
|
---|
1363 | if (!fSplit)
|
---|
1364 | k_javadoc_box_line();
|
---|
1365 | if (sProg == '')
|
---|
1366 | sProg = 'This program';
|
---|
1367 | else
|
---|
1368 | {
|
---|
1369 | k_javadoc_box_line('This file is part of ' sProg '.');
|
---|
1370 | k_javadoc_box_line();
|
---|
1371 | }
|
---|
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');
|
---|
1385 | break;
|
---|
1386 |
|
---|
1387 | case 'LGPL':
|
---|
1388 | if (!fSplit)
|
---|
1389 | k_javadoc_box_line();
|
---|
1390 | if (sProg == '')
|
---|
1391 | sProg = 'This library';
|
---|
1392 | else
|
---|
1393 | {
|
---|
1394 | k_javadoc_box_line('This file is part of ' sProg '.');
|
---|
1395 | k_javadoc_box_line();
|
---|
1396 | }
|
---|
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');
|
---|
1410 | break;
|
---|
1411 |
|
---|
1412 | case 'GPLv3':
|
---|
1413 | if (!fSplit)
|
---|
1414 | k_javadoc_box_line();
|
---|
1415 | if (sProg == '')
|
---|
1416 | sProg = 'This program';
|
---|
1417 | else
|
---|
1418 | {
|
---|
1419 | k_javadoc_box_line('This file is part of ' sProg '.');
|
---|
1420 | k_javadoc_box_line();
|
---|
1421 | }
|
---|
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/>');
|
---|
1434 | break;
|
---|
1435 |
|
---|
1436 | case 'LGPLv3':
|
---|
1437 | if (!fSplit)
|
---|
1438 | k_javadoc_box_line();
|
---|
1439 | if (sProg == '')
|
---|
1440 | sProg = 'This program';
|
---|
1441 | else
|
---|
1442 | {
|
---|
1443 | k_javadoc_box_line('This file is part of ' sProg '.');
|
---|
1444 | k_javadoc_box_line();
|
---|
1445 | }
|
---|
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/>');
|
---|
1458 | break;
|
---|
1459 |
|
---|
1460 | case 'Confidential':
|
---|
1461 | k_javadoc_box_line('All Rights Reserved');
|
---|
1462 | break;
|
---|
1463 |
|
---|
1464 | case 'ConfidentialNoAuthor':
|
---|
1465 | k_javadoc_box_line(skCompany ' confidential');
|
---|
1466 | k_javadoc_box_line('All Rights Reserved');
|
---|
1467 | break;
|
---|
1468 |
|
---|
1469 | case 'VirtualBox':
|
---|
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.')
|
---|
1481 | break;
|
---|
1482 |
|
---|
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.')
|
---|
1504 | break;
|
---|
1505 |
|
---|
1506 | default:
|
---|
1507 |
|
---|
1508 | }
|
---|
1509 | k_javadoc_box_line();
|
---|
1510 | k_javadoc_box_end();
|
---|
1511 |
|
---|
1512 | up(p_RLine - iCursorLine);
|
---|
1513 | end_line();
|
---|
1514 | keyin(' ');
|
---|
1515 | }
|
---|
1516 |
|
---|
1517 |
|
---|
1518 |
|
---|
1519 |
|
---|
1520 |
|
---|
1521 |
|
---|
1522 |
|
---|
1523 | /*******************************************************************************
|
---|
1524 | * Keyboard Shortcuts *
|
---|
1525 | *******************************************************************************/
|
---|
1526 | /** Makes global box. */
|
---|
1527 | void k_box_globals()
|
---|
1528 | {
|
---|
1529 | k_box_start('Global');
|
---|
1530 | k_box_line('Global Variables');
|
---|
1531 | k_box_end();
|
---|
1532 | }
|
---|
1533 |
|
---|
1534 | /** Makes header box. */
|
---|
1535 | void k_box_headers()
|
---|
1536 | {
|
---|
1537 | k_box_start("Header");
|
---|
1538 | k_box_line("Header Files");
|
---|
1539 | k_box_end();
|
---|
1540 | }
|
---|
1541 |
|
---|
1542 | /** Makes internal function box. */
|
---|
1543 | void k_box_intfuncs()
|
---|
1544 | {
|
---|
1545 | k_box_start("IntFunc");
|
---|
1546 | k_box_line("Internal Functions");
|
---|
1547 | k_box_end();
|
---|
1548 | }
|
---|
1549 |
|
---|
1550 | /** Makes def/const box. */
|
---|
1551 | void k_box_consts()
|
---|
1552 | {
|
---|
1553 | k_box_start("Const");
|
---|
1554 | k_box_line("Defined Constants And Macros");
|
---|
1555 | k_box_end();
|
---|
1556 | }
|
---|
1557 |
|
---|
1558 | /** Structure box */
|
---|
1559 | void k_box_structs()
|
---|
1560 | {
|
---|
1561 | k_box_start("Struct");
|
---|
1562 | k_box_line("Structures and Typedefs");
|
---|
1563 | k_box_end();
|
---|
1564 | }
|
---|
1565 |
|
---|
1566 | /** Makes exported symbols box. */
|
---|
1567 | void k_box_exported()
|
---|
1568 | {
|
---|
1569 | k_box_start('Exported');
|
---|
1570 | k_box_line('Exported Symbols');
|
---|
1571 | k_box_end();
|
---|
1572 | }
|
---|
1573 |
|
---|
1574 | /** oneliner comment */
|
---|
1575 | void k_oneliner()
|
---|
1576 | {
|
---|
1577 | _str sLeft, sRight;
|
---|
1578 | int iColumn;
|
---|
1579 | if ( k_commentconfig(sLeft, sRight, iColumn)
|
---|
1580 | && iColumn > 0)
|
---|
1581 | { /* column based needs some tricky repositioning. */
|
---|
1582 | _end_line();
|
---|
1583 | if (p_col > iColumn)
|
---|
1584 | {
|
---|
1585 | _begin_line();
|
---|
1586 | _insert_text("\n\r");
|
---|
1587 | up();
|
---|
1588 | }
|
---|
1589 | }
|
---|
1590 | k_insert_comment("", KIC_CURSOR_AT_END, ikStyleOneliner);
|
---|
1591 | }
|
---|
1592 |
|
---|
1593 | /** mark line as modified. */
|
---|
1594 | void k_mark_modified_line()
|
---|
1595 | {
|
---|
1596 | /* not supported for column based sources */
|
---|
1597 | _str sLeft, sRight;
|
---|
1598 | int iColumn;
|
---|
1599 | if ( !k_commentconfig(sLeft, sRight, iColumn)
|
---|
1600 | || iColumn > 0)
|
---|
1601 | return;
|
---|
1602 | _str sStr;
|
---|
1603 | if (skChange != '')
|
---|
1604 | sStr = skChange ' (' skUserInitials ')';
|
---|
1605 | else
|
---|
1606 | sStr = skUserInitials;
|
---|
1607 | k_insert_comment(sStr, KIC_CURSOR_BEFORE, ikStyleModifyMarkColumn);
|
---|
1608 | down();
|
---|
1609 | }
|
---|
1610 |
|
---|
1611 | /**
|
---|
1612 | * Inserts a signature. Form: "//Initials ISO-date:"
|
---|
1613 | * @remark defeventtab
|
---|
1614 | */
|
---|
1615 | void k_signature()
|
---|
1616 | {
|
---|
1617 | /* kso I5-10000 2002-09-10: */
|
---|
1618 | _str sSig;
|
---|
1619 | if (skChange != '')
|
---|
1620 | sSig = skUserInitials ' ' skChange ' ' k_date() ': ';
|
---|
1621 | else
|
---|
1622 | sSig = skUserInitials ' ' k_date() ': ';
|
---|
1623 | k_insert_comment(sSig, KIC_CURSOR_AT_END);
|
---|
1624 | }
|
---|
1625 |
|
---|
1626 | /* Insert a list of NOREF() macro invocations. */
|
---|
1627 | void k_noref()
|
---|
1628 | {
|
---|
1629 | typeless org_pos;
|
---|
1630 | _save_pos2(org_pos);
|
---|
1631 |
|
---|
1632 | _str sNoRefs = '';
|
---|
1633 | boolean fFoundFn = !k_func_goto_nearest_function();
|
---|
1634 | if (fFoundFn)
|
---|
1635 | {
|
---|
1636 | _str sArgs = k_func_getparams();
|
---|
1637 | int cArgs = k_func_countparams(sArgs);
|
---|
1638 | int fVaArgs = 1;
|
---|
1639 | int i;
|
---|
1640 | int offLine = 4;
|
---|
1641 | for (i = 0; i < cArgs; i++)
|
---|
1642 | {
|
---|
1643 | _str sName, sType, sDefault;
|
---|
1644 | if (!k_func_enumparams(sArgs, i, sType, sName, sDefault))
|
---|
1645 | {
|
---|
1646 | if (!fVaArgs)
|
---|
1647 | {
|
---|
1648 | sThis = 'NOREF(' sName ');';
|
---|
1649 | if (length(sNoRefs) == 0)
|
---|
1650 | {
|
---|
1651 | sNoRefs = sThis;
|
---|
1652 | offLine += length(sThis);
|
---|
1653 | }
|
---|
1654 | else if (offLine + length(sThis) < 130)
|
---|
1655 | {
|
---|
1656 | sNoRefs = sNoRefs ' ' sThis;
|
---|
1657 | offLine += 1 + length(sThis);
|
---|
1658 | }
|
---|
1659 | else
|
---|
1660 | {
|
---|
1661 | sNoRefs = sNoRefs "\n " sThis;
|
---|
1662 | offLine = 4 + length(sThis);
|
---|
1663 | }
|
---|
1664 | }
|
---|
1665 | else if (length(sNoRefs) == 0)
|
---|
1666 | {
|
---|
1667 | sNoRefs = 'RT_NOREF(' sName;
|
---|
1668 | offLine = length(sNoRefs);
|
---|
1669 | }
|
---|
1670 | else if (offLine + 2 + length(sName) < 130)
|
---|
1671 | {
|
---|
1672 | sNoRefs = sNoRefs ', ' sName;
|
---|
1673 | offLine += 2 + length(sName);
|
---|
1674 | }
|
---|
1675 | else
|
---|
1676 | {
|
---|
1677 | sNoRefs = sNoRefs ',\n ' sName;
|
---|
1678 | offLine += 4 + length(sName);
|
---|
1679 | }
|
---|
1680 | }
|
---|
1681 | }
|
---|
1682 | if (length(sNoRefs) > 0 && fVaArgs != 0)
|
---|
1683 | sNoRefs = sNoRefs ');';
|
---|
1684 | }
|
---|
1685 |
|
---|
1686 | _restore_pos2(org_pos);
|
---|
1687 | _insert_text(sNoRefs);
|
---|
1688 | }
|
---|
1689 |
|
---|
1690 | /* Adds newline escape slashes to the current selection. */
|
---|
1691 | void k_newline_escape_selection()
|
---|
1692 | {
|
---|
1693 | filter_init();
|
---|
1694 | typeless rc = filter_get_string(sLine);
|
---|
1695 | if (rc == 0)
|
---|
1696 | {
|
---|
1697 | _str sPrev = '';
|
---|
1698 | do
|
---|
1699 | {
|
---|
1700 | /* */
|
---|
1701 | if (sLine != '')
|
---|
1702 | sLine = sLine ' \';
|
---|
1703 | else
|
---|
1704 | {
|
---|
1705 | int offNonWhitespace = pos("[^ \t]", sPrev, 1, 'L');
|
---|
1706 | if (offNonWhitespace > 0)
|
---|
1707 | sLine = _pad(sLine, offNonWhitespace - 1, ' ');
|
---|
1708 | sLine = sLine '\';
|
---|
1709 | }
|
---|
1710 |
|
---|
1711 | filter_put_string(sLine);
|
---|
1712 |
|
---|
1713 | /* next line */
|
---|
1714 | sPrev = sLine;
|
---|
1715 | rc = filter_get_string(sLine);
|
---|
1716 | } while (rc == 0);
|
---|
1717 |
|
---|
1718 | }
|
---|
1719 | else if (isinteger(rc))
|
---|
1720 | message(get_message(rc));
|
---|
1721 | else
|
---|
1722 | message(rc);
|
---|
1723 | }
|
---|
1724 |
|
---|
1725 |
|
---|
1726 | /*******************************************************************************
|
---|
1727 | * kLIB Logging *
|
---|
1728 | *******************************************************************************/
|
---|
1729 | /**
|
---|
1730 | * Hot-Key: Inserts a KLOGENTRY statement at start of nearest function.
|
---|
1731 | */
|
---|
1732 | void klib_klogentry()
|
---|
1733 | {
|
---|
1734 | typeless org_pos;
|
---|
1735 | _save_pos2(org_pos);
|
---|
1736 |
|
---|
1737 | /*
|
---|
1738 | * Go to nearest function.
|
---|
1739 | */
|
---|
1740 | if (!k_func_goto_nearest_function())
|
---|
1741 | {
|
---|
1742 | /*
|
---|
1743 | * Get parameters.
|
---|
1744 | */
|
---|
1745 | _str sParams = k_func_getparams();
|
---|
1746 | if (sParams)
|
---|
1747 | {
|
---|
1748 | _str sRetType = k_func_getreturntype(true);
|
---|
1749 | if (!sRetType || sRetType == "")
|
---|
1750 | sRetType = "void"; /* paranoia! */
|
---|
1751 |
|
---|
1752 | /*
|
---|
1753 | * Insert text.
|
---|
1754 | */
|
---|
1755 | if (!k_func_searchcode("{"))
|
---|
1756 | {
|
---|
1757 | p_col++;
|
---|
1758 | int cArgs = k_func_countparams(sParams);
|
---|
1759 | if (cArgs > 0)
|
---|
1760 | {
|
---|
1761 | _str sArgs = "";
|
---|
1762 | int i;
|
---|
1763 | for (i = 0; i < cArgs; i++)
|
---|
1764 | {
|
---|
1765 | _str sType, sName, sDefault;
|
---|
1766 | if (!k_func_enumparams(sParams, i, sType, sName, sDefault))
|
---|
1767 | sArgs = sArgs', 'sName;
|
---|
1768 | }
|
---|
1769 |
|
---|
1770 | _insert_text("\n KLOGENTRY"cArgs"(\""sRetType"\",\""sParams"\""sArgs");"); /* todo tab size.. or smart indent */
|
---|
1771 | }
|
---|
1772 | else
|
---|
1773 | _insert_text("\n KLOGENTRY0(\""sRetType"\");"); /* todo tab size.. or smart indent */
|
---|
1774 |
|
---|
1775 | /*
|
---|
1776 | * Check if the next word is KLOGENTRY.
|
---|
1777 | */
|
---|
1778 | next_word();
|
---|
1779 | if (def_next_word_style == 'E')
|
---|
1780 | prev_word();
|
---|
1781 | int iIgnorePos = 0;
|
---|
1782 | if (substr(cur_word(iIgnorePos), 1, 9) == "KLOGENTRY")
|
---|
1783 | delete_line();
|
---|
1784 |
|
---|
1785 | }
|
---|
1786 | else
|
---|
1787 | message("didn't find {");
|
---|
1788 | }
|
---|
1789 | else
|
---|
1790 | message("k_func_getparams failed, sParams=" sParams);
|
---|
1791 | return;
|
---|
1792 | }
|
---|
1793 |
|
---|
1794 | _restore_pos2(org_pos);
|
---|
1795 | }
|
---|
1796 |
|
---|
1797 |
|
---|
1798 | /**
|
---|
1799 | * Hot-Key: Inserts a KLOGEXIT statement at cursor location.
|
---|
1800 | */
|
---|
1801 | void klib_klogexit()
|
---|
1802 | {
|
---|
1803 | typeless org_pos;
|
---|
1804 | _save_pos2(org_pos);
|
---|
1805 |
|
---|
1806 | /*
|
---|
1807 | * Go to nearest function.
|
---|
1808 | */
|
---|
1809 | if (!prev_proc())
|
---|
1810 | {
|
---|
1811 | /*
|
---|
1812 | * Get parameters.
|
---|
1813 | */
|
---|
1814 | _str sType = k_func_getreturntype(true);
|
---|
1815 | _restore_pos2(org_pos);
|
---|
1816 | if (sType)
|
---|
1817 | {
|
---|
1818 | boolean fReturn = true; /* true if an return statment is following the KLOGEXIT statement. */
|
---|
1819 |
|
---|
1820 | /*
|
---|
1821 | * Insert text.
|
---|
1822 | */
|
---|
1823 | int cur_col = p_col;
|
---|
1824 | if (sType == 'void' || sType == 'VOID')
|
---|
1825 | { /* procedure */
|
---|
1826 | int iIgnorePos;
|
---|
1827 | fReturn = cur_word(iIgnorePos) == 'return';
|
---|
1828 | if (!fReturn)
|
---|
1829 | {
|
---|
1830 | while (p_col <= p_SyntaxIndent)
|
---|
1831 | keyin(" ");
|
---|
1832 | }
|
---|
1833 |
|
---|
1834 | _insert_text("KLOGEXITVOID();\n");
|
---|
1835 |
|
---|
1836 | if (fReturn)
|
---|
1837 | {
|
---|
1838 | int i;
|
---|
1839 | for (i = 1; i < cur_col; i++)
|
---|
1840 | _insert_text(" ");
|
---|
1841 | }
|
---|
1842 | search(")","E-");
|
---|
1843 | }
|
---|
1844 | else
|
---|
1845 | { /* function */
|
---|
1846 | _insert_text("KLOGEXIT();\n");
|
---|
1847 | int i;
|
---|
1848 | for (i = 1; i < cur_col; i++)
|
---|
1849 | _insert_text(" ");
|
---|
1850 | search(")","E-");
|
---|
1851 |
|
---|
1852 | /*
|
---|
1853 | * Insert value if possible.
|
---|
1854 | */
|
---|
1855 | typeless valuepos;
|
---|
1856 | _save_pos2(valuepos);
|
---|
1857 | next_word();
|
---|
1858 | if (def_next_word_style == 'E')
|
---|
1859 | prev_word();
|
---|
1860 | int iIgnorePos;
|
---|
1861 | if (cur_word(iIgnorePos) == 'return')
|
---|
1862 | {
|
---|
1863 | p_col += length('return');
|
---|
1864 | typeless posStart;
|
---|
1865 | _save_pos2(posStart);
|
---|
1866 | long offStart = _QROffset();
|
---|
1867 | if (!k_func_searchcode(";", "E+"))
|
---|
1868 | {
|
---|
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);
|
---|
1876 | }
|
---|
1877 | }
|
---|
1878 | _restore_pos2(valuepos);
|
---|
1879 | }
|
---|
1880 |
|
---|
1881 | /*
|
---|
1882 | * Remove old KLOGEXIT statement on previous line if any.
|
---|
1883 | */
|
---|
1884 | typeless valuepos;
|
---|
1885 | _save_pos2(valuepos);
|
---|
1886 | int newexitline = p_line;
|
---|
1887 | p_line--; p_col = 1;
|
---|
1888 | next_word();
|
---|
1889 | if (def_next_word_style == 'E')
|
---|
1890 | prev_word();
|
---|
1891 | int iIgnorePos;
|
---|
1892 | if (p_line == newexitline - 1 && substr(cur_word(iIgnorePos), 1, 8) == 'KLOGEXIT')
|
---|
1893 | delete_line();
|
---|
1894 | _restore_pos2(valuepos);
|
---|
1895 |
|
---|
1896 | /*
|
---|
1897 | * Check for missing '{...}'.
|
---|
1898 | */
|
---|
1899 | if (fReturn)
|
---|
1900 | {
|
---|
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) */
|
---|
1905 |
|
---|
1906 | _str ch = k_func_get_next_code_text();
|
---|
1907 | if (ch != '}')
|
---|
1908 | {
|
---|
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) */
|
---|
1913 | p_col++;
|
---|
1914 | if (k_func_more_code_on_line())
|
---|
1915 | _insert_text(' }');
|
---|
1916 | else
|
---|
1917 | {
|
---|
1918 | typeless returnget;
|
---|
1919 | _save_pos2(returnget);
|
---|
1920 | k_func_searchcode("return", "E-");
|
---|
1921 | int return_col = p_col;
|
---|
1922 | _restore_pos2(returnget);
|
---|
1923 |
|
---|
1924 | end_line();
|
---|
1925 | _insert_text("\n");
|
---|
1926 | while (p_col < return_col - p_SyntaxIndent)
|
---|
1927 | _insert_text(' ');
|
---|
1928 | _insert_text('}');
|
---|
1929 | }
|
---|
1930 |
|
---|
1931 | _restore_pos2(valuepos);
|
---|
1932 | _save_pos2(valuepos);
|
---|
1933 | prev_word();
|
---|
1934 | p_col -= p_SyntaxIndent;
|
---|
1935 | int codecol = p_col;
|
---|
1936 | _insert_text("{\n");
|
---|
1937 | while (p_col < codecol)
|
---|
1938 | _insert_text(' ');
|
---|
1939 | }
|
---|
1940 |
|
---|
1941 | _restore_pos2(valuepos);
|
---|
1942 | }
|
---|
1943 | }
|
---|
1944 | else
|
---|
1945 | message("k_func_getreturntype failed, sType=" sType);
|
---|
1946 | return;
|
---|
1947 | }
|
---|
1948 |
|
---|
1949 | _restore_pos2(org_pos);
|
---|
1950 | }
|
---|
1951 |
|
---|
1952 |
|
---|
1953 | /**
|
---|
1954 | * Processes a file - ask user all the time.
|
---|
1955 | */
|
---|
1956 | void klib_klog_file_ask()
|
---|
1957 | {
|
---|
1958 | klib_klog_file_int(true);
|
---|
1959 | }
|
---|
1960 |
|
---|
1961 |
|
---|
1962 | /**
|
---|
1963 | * Processes a file - no questions.
|
---|
1964 | */
|
---|
1965 | void klib_klog_file_no_ask()
|
---|
1966 | {
|
---|
1967 | klib_klog_file_int(false);
|
---|
1968 | }
|
---|
1969 |
|
---|
1970 |
|
---|
1971 |
|
---|
1972 | /**
|
---|
1973 | * Processes a file.
|
---|
1974 | */
|
---|
1975 | static void klib_klog_file_int(boolean fAsk)
|
---|
1976 | {
|
---|
1977 | show_all();
|
---|
1978 | bottom();
|
---|
1979 | _refresh_scroll();
|
---|
1980 |
|
---|
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)
|
---|
1983 | return;
|
---|
1984 |
|
---|
1985 | /*
|
---|
1986 | * Entries.
|
---|
1987 | */
|
---|
1988 | while (!prev_proc())
|
---|
1989 | {
|
---|
1990 | //say 'entry main loop: ' k_func_getfunction_name();
|
---|
1991 |
|
---|
1992 | /*
|
---|
1993 | * Skip prototypes.
|
---|
1994 | */
|
---|
1995 | if (k_func_prototype())
|
---|
1996 | continue;
|
---|
1997 |
|
---|
1998 | /*
|
---|
1999 | * Ask user.
|
---|
2000 | */
|
---|
2001 | center_line();
|
---|
2002 | _refresh_scroll();
|
---|
2003 | _str sFunction = k_func_getfunction_name();
|
---|
2004 | rc = fAsk ? _message_box("Process this function ("sFunction")?", "Visual SlickEdit", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
|
---|
2005 | if (rc == IDYES)
|
---|
2006 | {
|
---|
2007 | typeless procpos;
|
---|
2008 | _save_pos2(procpos);
|
---|
2009 | klib_klogentry();
|
---|
2010 | _restore_pos2(procpos);
|
---|
2011 | }
|
---|
2012 | else if (rc == IDNO)
|
---|
2013 | continue;
|
---|
2014 | else
|
---|
2015 | break;
|
---|
2016 | }
|
---|
2017 |
|
---|
2018 | /*
|
---|
2019 | * Exits.
|
---|
2020 | */
|
---|
2021 | bottom(); _refresh_scroll();
|
---|
2022 | boolean fUserCancel = false;
|
---|
2023 | while (!prev_proc() && !fUserCancel)
|
---|
2024 | {
|
---|
2025 | typeless procpos;
|
---|
2026 | _save_pos2(procpos);
|
---|
2027 | _str sCurFunction = k_func_getfunction_name();
|
---|
2028 | //say 'exit main loop: ' sCurFunction
|
---|
2029 |
|
---|
2030 | /*
|
---|
2031 | * Skip prototypes.
|
---|
2032 | */
|
---|
2033 | if (k_func_prototype())
|
---|
2034 | continue;
|
---|
2035 |
|
---|
2036 | /*
|
---|
2037 | * Select procedure.
|
---|
2038 | */
|
---|
2039 | while ( !k_func_searchcode("return", "WE<+")
|
---|
2040 | && k_func_getfunction_name() == sCurFunction)
|
---|
2041 | {
|
---|
2042 | //say 'exit sub loop: ' p_line
|
---|
2043 | /*
|
---|
2044 | * Ask User.
|
---|
2045 | */
|
---|
2046 | center_line();
|
---|
2047 | _refresh_scroll();
|
---|
2048 | _str sFunction = k_func_getfunction_name();
|
---|
2049 | rc = fAsk ? _message_box("Process this exit from "sFunction"?", "Visual SlickEdit", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
|
---|
2050 | deselect();
|
---|
2051 | if (rc == IDYES)
|
---|
2052 | {
|
---|
2053 | typeless returnpos;
|
---|
2054 | _save_pos2(returnpos);
|
---|
2055 | klib_klogexit();
|
---|
2056 | _restore_pos2(returnpos);
|
---|
2057 | p_line++;
|
---|
2058 | }
|
---|
2059 | else if (rc != IDNO)
|
---|
2060 | {
|
---|
2061 | fUserCancel = true;
|
---|
2062 | break;
|
---|
2063 | }
|
---|
2064 | p_line++; /* just so we won't hit it again. */
|
---|
2065 | }
|
---|
2066 |
|
---|
2067 | /*
|
---|
2068 | * If void function we'll have to check if there is and return; prior to the ending '}'.
|
---|
2069 | */
|
---|
2070 | _restore_pos2(procpos);
|
---|
2071 | _save_pos2(procpos);
|
---|
2072 | _str sType = k_func_getreturntype(true);
|
---|
2073 | if (!fUserCancel && sType && (sType == 'void' || sType == 'VOID'))
|
---|
2074 | {
|
---|
2075 | if ( !k_func_searchcode("{", "E+")
|
---|
2076 | && !find_matching_paren())
|
---|
2077 | {
|
---|
2078 | typeless funcend;
|
---|
2079 | _save_pos2(funcend);
|
---|
2080 | prev_word();
|
---|
2081 | int iIgnorePos;
|
---|
2082 | if (cur_word(iIgnorePos) != "return")
|
---|
2083 | {
|
---|
2084 | /*
|
---|
2085 | * Ask User.
|
---|
2086 | */
|
---|
2087 | _restore_pos2(funcend);
|
---|
2088 | center_line();
|
---|
2089 | _refresh_scroll();
|
---|
2090 | _str sFunction = k_func_getfunction_name();
|
---|
2091 | rc = fAsk ? _message_box("Process this exit from "sFunction"?", "Visual SlickEdit", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
|
---|
2092 | deselect();
|
---|
2093 | if (rc == IDYES)
|
---|
2094 | {
|
---|
2095 | typeless returnpos;
|
---|
2096 | _save_pos2(returnpos);
|
---|
2097 | klib_klogexit();
|
---|
2098 | _restore_pos2(returnpos);
|
---|
2099 | }
|
---|
2100 | }
|
---|
2101 | }
|
---|
2102 | }
|
---|
2103 |
|
---|
2104 | /*
|
---|
2105 | * Next proc.
|
---|
2106 | */
|
---|
2107 | _restore_pos2(procpos);
|
---|
2108 | }
|
---|
2109 | }
|
---|
2110 |
|
---|
2111 | /** @todo move to kkeys.e */
|
---|
2112 | _command void k_rebuild_tagfile()
|
---|
2113 | {
|
---|
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);
|
---|
2117 | else
|
---|
2118 | _project_update_files_retag(true, false, false, true);
|
---|
2119 | #else
|
---|
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);
|
---|
2125 | #endif
|
---|
2126 | }
|
---|
2127 |
|
---|
2128 |
|
---|
2129 | /*******************************************************************************
|
---|
2130 | * Styles *
|
---|
2131 | *******************************************************************************/
|
---|
2132 | static _str StyleLanguages[] =
|
---|
2133 | {
|
---|
2134 | "c",
|
---|
2135 | "e",
|
---|
2136 | "java"
|
---|
2137 | };
|
---|
2138 |
|
---|
2139 | struct StyleScheme
|
---|
2140 | {
|
---|
2141 | _str name;
|
---|
2142 | _str settings[];
|
---|
2143 | };
|
---|
2144 |
|
---|
2145 | static StyleScheme StyleSchemes[] =
|
---|
2146 | {
|
---|
2147 | {
|
---|
2148 | "Opt2Ind4",
|
---|
2149 | {
|
---|
2150 | "orig_tabsize=4",
|
---|
2151 | "syntax_indent=4",
|
---|
2152 | "tabsize=4",
|
---|
2153 | "align_on_equal=1",
|
---|
2154 | "pad_condition_state=1",
|
---|
2155 | "indent_with_tabs=0",
|
---|
2156 | "nospace_before_paren=0",
|
---|
2157 | "indent_comments=1",
|
---|
2158 | "indent_case=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",
|
---|
2165 | "indent_fl=1",
|
---|
2166 | "statement_comment_state=2",
|
---|
2167 | "indent_pp=1",
|
---|
2168 | "be_style=1",
|
---|
2169 | "parens_on_return=0",
|
---|
2170 | "eat_blank_lines=0",
|
---|
2171 | "brace_indent=0",
|
---|
2172 | "eat_pp_space=1",
|
---|
2173 | "align_on_parens=1",
|
---|
2174 | "continuation_indent=0",
|
---|
2175 | "cuddle_else=0",
|
---|
2176 | "nopad_condition=1",
|
---|
2177 | "pad_condition=0",
|
---|
2178 | "indent_col1_comments=0"
|
---|
2179 | }
|
---|
2180 | }
|
---|
2181 | ,
|
---|
2182 | {
|
---|
2183 | "Opt2Ind3",
|
---|
2184 | {
|
---|
2185 | "orig_tabsize=3",
|
---|
2186 | "syntax_indent=3",
|
---|
2187 | "tabsize=3",
|
---|
2188 | "align_on_equal=1",
|
---|
2189 | "pad_condition_state=1",
|
---|
2190 | "indent_with_tabs=0",
|
---|
2191 | "nospace_before_paren=0",
|
---|
2192 | "indent_comments=1",
|
---|
2193 | "indent_case=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",
|
---|
2200 | "indent_fl=1",
|
---|
2201 | "statement_comment_state=2",
|
---|
2202 | "indent_pp=1",
|
---|
2203 | "be_style=1",
|
---|
2204 | "parens_on_return=0",
|
---|
2205 | "eat_blank_lines=0",
|
---|
2206 | "brace_indent=0",
|
---|
2207 | "eat_pp_space=1",
|
---|
2208 | "align_on_parens=1",
|
---|
2209 | "continuation_indent=0",
|
---|
2210 | "cuddle_else=0",
|
---|
2211 | "nopad_condition=1",
|
---|
2212 | "pad_condition=0",
|
---|
2213 | "indent_col1_comments=0"
|
---|
2214 | }
|
---|
2215 | }
|
---|
2216 | ,
|
---|
2217 | {
|
---|
2218 | "Opt2Ind8",
|
---|
2219 | {
|
---|
2220 | "orig_tabsize=8",
|
---|
2221 | "syntax_indent=8",
|
---|
2222 | "tabsize=8",
|
---|
2223 | "align_on_equal=1",
|
---|
2224 | "pad_condition_state=1",
|
---|
2225 | "indent_with_tabs=0",
|
---|
2226 | "nospace_before_paren=0",
|
---|
2227 | "indent_comments=1",
|
---|
2228 | "indent_case=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",
|
---|
2235 | "indent_fl=1",
|
---|
2236 | "statement_comment_state=2",
|
---|
2237 | "indent_pp=1",
|
---|
2238 | "be_style=1",
|
---|
2239 | "parens_on_return=0",
|
---|
2240 | "eat_blank_lines=0",
|
---|
2241 | "brace_indent=0",
|
---|
2242 | "eat_pp_space=1",
|
---|
2243 | "align_on_parens=1",
|
---|
2244 | "continuation_indent=0",
|
---|
2245 | "cuddle_else=0",
|
---|
2246 | "nopad_condition=1",
|
---|
2247 | "pad_condition=0",
|
---|
2248 | "indent_col1_comments=0"
|
---|
2249 | }
|
---|
2250 | }
|
---|
2251 | ,
|
---|
2252 | {
|
---|
2253 | "Opt3Ind4",
|
---|
2254 | {
|
---|
2255 | "orig_tabsize=4",
|
---|
2256 | "syntax_indent=4",
|
---|
2257 | "tabsize=4",
|
---|
2258 | "align_on_equal=1",
|
---|
2259 | "pad_condition_state=1",
|
---|
2260 | "indent_with_tabs=0",
|
---|
2261 | "nospace_before_paren=0",
|
---|
2262 | "indent_comments=1",
|
---|
2263 | "indent_case=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",
|
---|
2270 | "indent_fl=1",
|
---|
2271 | "statement_comment_state=2",
|
---|
2272 | "indent_pp=1",
|
---|
2273 | "be_style=2",
|
---|
2274 | "parens_on_return=0",
|
---|
2275 | "eat_blank_lines=0",
|
---|
2276 | "brace_indent=0",
|
---|
2277 | "eat_pp_space=1",
|
---|
2278 | "align_on_parens=1",
|
---|
2279 | "continuation_indent=0",
|
---|
2280 | "cuddle_else=0",
|
---|
2281 | "nopad_condition=1",
|
---|
2282 | "pad_condition=0",
|
---|
2283 | "indent_col1_comments=0"
|
---|
2284 | }
|
---|
2285 | }
|
---|
2286 | ,
|
---|
2287 | {
|
---|
2288 | "Opt3Ind3",
|
---|
2289 | {
|
---|
2290 | "orig_tabsize=3",
|
---|
2291 | "syntax_indent=3",
|
---|
2292 | "tabsize=3",
|
---|
2293 | "align_on_equal=1",
|
---|
2294 | "pad_condition_state=1",
|
---|
2295 | "indent_with_tabs=0",
|
---|
2296 | "nospace_before_paren=0",
|
---|
2297 | "indent_comments=1",
|
---|
2298 | "indent_case=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",
|
---|
2305 | "indent_fl=1",
|
---|
2306 | "statement_comment_state=2",
|
---|
2307 | "indent_pp=1",
|
---|
2308 | "be_style=2",
|
---|
2309 | "parens_on_return=0",
|
---|
2310 | "eat_blank_lines=0",
|
---|
2311 | "brace_indent=0",
|
---|
2312 | "eat_pp_space=1",
|
---|
2313 | "align_on_parens=1",
|
---|
2314 | "continuation_indent=0",
|
---|
2315 | "cuddle_else=0",
|
---|
2316 | "nopad_condition=1",
|
---|
2317 | "pad_condition=0",
|
---|
2318 | "indent_col1_comments=0"
|
---|
2319 | }
|
---|
2320 | }
|
---|
2321 | };
|
---|
2322 |
|
---|
2323 |
|
---|
2324 | static void k_styles_create()
|
---|
2325 | {
|
---|
2326 | /*
|
---|
2327 | * Find user format ini file.
|
---|
2328 | */
|
---|
2329 | _str userini = maybe_quote_filename(_config_path():+'uformat.ini');
|
---|
2330 | if (file_match('-p 'userini, 1) == '')
|
---|
2331 | {
|
---|
2332 | _str ini = maybe_quote_filename(slick_path_search('uformat.ini'));
|
---|
2333 | if (ini != '') userini = ini;
|
---|
2334 | }
|
---|
2335 |
|
---|
2336 |
|
---|
2337 | /*
|
---|
2338 | * Remove any old schemes.
|
---|
2339 | */
|
---|
2340 | int i,j,tv;
|
---|
2341 | for (i = 0; i < StyleSchemes._length(); i++)
|
---|
2342 | for (j = 0; j < StyleLanguages._length(); j++)
|
---|
2343 | {
|
---|
2344 | _str sectionname = StyleLanguages[j]:+'-scheme-':+StyleSchemes[i].name;
|
---|
2345 | if (!_ini_get_section(userini, sectionname, tv))
|
---|
2346 | {
|
---|
2347 | _ini_delete_section(userini, sectionname);
|
---|
2348 | _delete_temp_view(tv);
|
---|
2349 | //message("delete old scheme");
|
---|
2350 | }
|
---|
2351 | }
|
---|
2352 |
|
---|
2353 | /*
|
---|
2354 | * Create the new schemes.
|
---|
2355 | */
|
---|
2356 | for (i = 0; i < StyleSchemes._length(); i++)
|
---|
2357 | {
|
---|
2358 | for (j = 0; j < StyleLanguages._length(); j++)
|
---|
2359 | {
|
---|
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]);
|
---|
2366 |
|
---|
2367 | /* Insert the scheme section. */
|
---|
2368 | _ini_replace_section(userini, sectionname, temp_view_id);
|
---|
2369 | //message(userini)
|
---|
2370 | //bogus id - activate_view(orig_view_id);
|
---|
2371 | }
|
---|
2372 | }
|
---|
2373 |
|
---|
2374 | //last_scheme = last scheme name!!!
|
---|
2375 | }
|
---|
2376 |
|
---|
2377 |
|
---|
2378 | /*
|
---|
2379 | * Sets the last used beutify scheme.
|
---|
2380 | */
|
---|
2381 | static k_styles_set(_str scheme)
|
---|
2382 | {
|
---|
2383 |
|
---|
2384 | /*
|
---|
2385 | * Find user format ini file.
|
---|
2386 | */
|
---|
2387 | _str userini = maybe_quote_filename(_config_path():+'uformat.ini');
|
---|
2388 | if (file_match('-p 'userini, 1) == '')
|
---|
2389 | {
|
---|
2390 | _str ini = maybe_quote_filename(slick_path_search('uformat.ini'));
|
---|
2391 | if (ini != '') userini = ini;
|
---|
2392 | }
|
---|
2393 |
|
---|
2394 | /*
|
---|
2395 | * Set the scheme for each language.
|
---|
2396 | */
|
---|
2397 | int j;
|
---|
2398 | for (j = 0; j < StyleLanguages._length(); j++)
|
---|
2399 | {
|
---|
2400 | _ini_set_value(userini,
|
---|
2401 | StyleLanguages[j]:+'-scheme-Default',
|
---|
2402 | 'last_scheme',
|
---|
2403 | scheme);
|
---|
2404 | }
|
---|
2405 | }
|
---|
2406 |
|
---|
2407 |
|
---|
2408 | static _str defoptions[] =
|
---|
2409 | {
|
---|
2410 | "def-options-sas",
|
---|
2411 | "def-options-js",
|
---|
2412 | "def-options-bat",
|
---|
2413 | "def-options-c",
|
---|
2414 | "def-options-pas",
|
---|
2415 | "def-options-e",
|
---|
2416 | "def-options-java",
|
---|
2417 | "def-options-bourneshell",
|
---|
2418 | "def-options-csh",
|
---|
2419 | "def-options-vlx",
|
---|
2420 | "def-options-plsql",
|
---|
2421 | "def-options-sqlserver",
|
---|
2422 | "def-options-cmd"
|
---|
2423 | };
|
---|
2424 |
|
---|
2425 | static _str defsetups[] =
|
---|
2426 | {
|
---|
2427 | "def-setup-sas",
|
---|
2428 | "def-setup-js",
|
---|
2429 | "def-setup-bat",
|
---|
2430 | "def-setup-fundamental",
|
---|
2431 | "def-setup-process",
|
---|
2432 | "def-setup-c",
|
---|
2433 | "def-setup-pas",
|
---|
2434 | "def-setup-e",
|
---|
2435 | "def-setup-asm",
|
---|
2436 | "def-setup-java",
|
---|
2437 | "def-setup-html",
|
---|
2438 | "def-setup-bourneshell",
|
---|
2439 | "def-setup-csh",
|
---|
2440 | "def-setup-vlx",
|
---|
2441 | "def-setup-fileman",
|
---|
2442 | "def-setup-plsql",
|
---|
2443 | "def-setup-sqlserver",
|
---|
2444 | "def-setup-s",
|
---|
2445 | "def-setup-cmd"
|
---|
2446 | };
|
---|
2447 |
|
---|
2448 | static _str defsetupstab8[] =
|
---|
2449 | {
|
---|
2450 | "def-setup-c"
|
---|
2451 | };
|
---|
2452 |
|
---|
2453 |
|
---|
2454 | static void k_styles_setindent(int indent, int iBraceStyle, boolean iWithTabs = false)
|
---|
2455 | {
|
---|
2456 | if (iBraceStyle < 1 || iBraceStyle > 3)
|
---|
2457 | {
|
---|
2458 | message('k_styles_setindent: iBraceStyle is bad (=' :+ iBraceStyle :+ ')');
|
---|
2459 | iBraceStyle = 2;
|
---|
2460 | }
|
---|
2461 |
|
---|
2462 | /*
|
---|
2463 | * def-options for extentions known to have that info.
|
---|
2464 | */
|
---|
2465 | int i;
|
---|
2466 | for (i = 0; i < defoptions._length(); i++)
|
---|
2467 | {
|
---|
2468 | int idx = find_index(defoptions[i], MISC_TYPE);
|
---|
2469 | if (!idx)
|
---|
2470 | continue;
|
---|
2471 |
|
---|
2472 | parse name_info(idx) with syntax_indent o2 o3 o4 flags indent_fl o7 indent_case rest;
|
---|
2473 |
|
---|
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 */
|
---|
2480 |
|
---|
2481 | sNewOptions = indent' 'o2' 'o3' 'o4' 'flags' 'indent_fl' 'o7' 'indent_case' 'rest;
|
---|
2482 | set_name_info(idx, sNewOptions);
|
---|
2483 | _config_modify |= CFGMODIFY_DEFDATA;
|
---|
2484 | }
|
---|
2485 |
|
---|
2486 | /*
|
---|
2487 | * def-setup for known extentions.
|
---|
2488 | */
|
---|
2489 | for (i = 0; i < defsetups._length(); i++)
|
---|
2490 | {
|
---|
2491 | idx = find_index(defsetups[i], MISC_TYPE);
|
---|
2492 | if (!idx)
|
---|
2493 | continue;
|
---|
2494 | sExt = substr(defsetups[i], length('def-setup-') + 1);
|
---|
2495 | sSetup = name_info(idx);
|
---|
2496 |
|
---|
2497 | /*
|
---|
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;
|
---|
2504 |
|
---|
2505 | indent_with_tabs = 0; /* Indent with tabs */
|
---|
2506 |
|
---|
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;
|
---|
2514 |
|
---|
2515 | /* Set new indent */
|
---|
2516 | tabs = '+'indent;
|
---|
2517 | */
|
---|
2518 |
|
---|
2519 | sNewSetup = sSetup;
|
---|
2520 |
|
---|
2521 | /* Set new indent */
|
---|
2522 | if (pos('TABS=', sNewSetup) > 0)
|
---|
2523 | {
|
---|
2524 | /*
|
---|
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...
|
---|
2528 | */
|
---|
2529 | fTab8 = false;
|
---|
2530 | for (j = 0; !fTab8 && j < defsetupstab8._length(); j++)
|
---|
2531 | if (substr(defsetupstab8[j], lastpos('-', defsetupstab8[j]) + 1) == sExt)
|
---|
2532 | fTab8 = true;
|
---|
2533 | for (j = 0; !fTab8 && j < defoptions._length(); j++)
|
---|
2534 | if (substr(defoptions[j], lastpos('-', defoptions[j]) + 1) == sExt)
|
---|
2535 | fTab8 = true;
|
---|
2536 |
|
---|
2537 | parse sNewSetup with sPre 'TABS=' sValue ',' sPost;
|
---|
2538 | if (fTab8)
|
---|
2539 | sNewSetup = sPre 'TABS=+8,' sPost
|
---|
2540 | else
|
---|
2541 | sNewSetup = sPre 'TABS=+' indent ',' sPost
|
---|
2542 | }
|
---|
2543 |
|
---|
2544 | /* Set indent with tabs flag. */
|
---|
2545 | if (pos('IWT=', sNewSetup) > 0)
|
---|
2546 | {
|
---|
2547 | parse sNewSetup with sPre 'IWT=' sValue ',' sPost;
|
---|
2548 | if (iWithTabs)
|
---|
2549 | sNewSetup = sPre 'IWT=1,' sPost
|
---|
2550 | else
|
---|
2551 | sNewSetup = sPre 'IWT=0,' sPost
|
---|
2552 | }
|
---|
2553 |
|
---|
2554 | /* Do the real changes */
|
---|
2555 | set_name_info(idx, sNewSetup);
|
---|
2556 | _config_modify |= CFGMODIFY_DEFDATA;
|
---|
2557 | _update_buffers(sExt);
|
---|
2558 | }
|
---|
2559 | }
|
---|
2560 |
|
---|
2561 |
|
---|
2562 | /**
|
---|
2563 | * Takes necessary steps to convert a string to integer.
|
---|
2564 | */
|
---|
2565 | static int k_style_emacs_var_integer(_str sVal)
|
---|
2566 | {
|
---|
2567 | int i = (int)sVal;
|
---|
2568 | //say 'k_style_emacs_var_integer('sVal') -> 'i;
|
---|
2569 | return (int)sVal;
|
---|
2570 | }
|
---|
2571 |
|
---|
2572 |
|
---|
2573 | /**
|
---|
2574 | * Sets a Emacs style variable.
|
---|
2575 | */
|
---|
2576 | static int k_style_emacs_var(_str sVar, _str sVal)
|
---|
2577 | {
|
---|
2578 | /* check input. */
|
---|
2579 | if (sVar == '' || sVal == '')
|
---|
2580 | return -1;
|
---|
2581 | //say 'k_style_emacs_var: 'sVar'='sVal;
|
---|
2582 |
|
---|
2583 | #if __VERSION__ >= 21.0
|
---|
2584 | /** @todo figure out p_index. */
|
---|
2585 | return 0;
|
---|
2586 | #else
|
---|
2587 |
|
---|
2588 | /*
|
---|
2589 | * Unpack the mode style parameters.
|
---|
2590 | */
|
---|
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')
|
---|
2596 | {
|
---|
2597 | parse sStyle with iMinAbbrivation sRes0 iBeginEndStyle fIndent1stLevel sRes1 iSwitchStyle sRest;
|
---|
2598 | iIndentAmount = p_SyntaxIndent;
|
---|
2599 | }
|
---|
2600 | else /* C */
|
---|
2601 | parse sStyle with iIndentAmount fExpansion iMinAbbrivation fIndentAfterOpenParen iBeginEndStyle fIndent1stLevel iMainStyle iSwitchStyle sRest;
|
---|
2602 |
|
---|
2603 |
|
---|
2604 | /*
|
---|
2605 | * Process the variable.
|
---|
2606 | */
|
---|
2607 | switch (sVar)
|
---|
2608 | {
|
---|
2609 | case 'mode':
|
---|
2610 | case 'Mode':
|
---|
2611 | {
|
---|
2612 | switch (sVal)
|
---|
2613 | {
|
---|
2614 | case 'c':
|
---|
2615 | case 'C':
|
---|
2616 | case 'c++':
|
---|
2617 | case 'C++':
|
---|
2618 | case 'cpp':
|
---|
2619 | case 'CPP':
|
---|
2620 | case 'cxx':
|
---|
2621 | case 'CXX':
|
---|
2622 | p_extension = 'c';
|
---|
2623 | p_mode_name = 'C';
|
---|
2624 | break;
|
---|
2625 |
|
---|
2626 | case 'e':
|
---|
2627 | case 'slick-c':
|
---|
2628 | case 'Slick-c':
|
---|
2629 | case 'Slick-C':
|
---|
2630 | p_extension = 'e';
|
---|
2631 | p_mode_name = 'Slick-C';
|
---|
2632 | break;
|
---|
2633 |
|
---|
2634 | default:
|
---|
2635 | message('emacs mode "'sVal'" is not known to us');
|
---|
2636 | return -3;
|
---|
2637 | }
|
---|
2638 | break;
|
---|
2639 | }
|
---|
2640 | /* relevant emacs code:
|
---|
2641 | (defconst c-style-alist
|
---|
2642 | '(("gnu"
|
---|
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 . +)
|
---|
2648 | (label . 0)
|
---|
2649 | (statement-case-open . +)
|
---|
2650 | (statement-cont . +)
|
---|
2651 | (arglist-intro . c-lineup-arglist-intro-after-paren)
|
---|
2652 | (arglist-close . c-lineup-arglist)
|
---|
2653 | (inline-open . 0)
|
---|
2654 | (brace-list-open . +)
|
---|
2655 | ))
|
---|
2656 | (c-special-indent-hook . c-gnu-impose-minimum)
|
---|
2657 | (c-block-comment-prefix . "")
|
---|
2658 | )
|
---|
2659 | ("k&r"
|
---|
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)
|
---|
2665 | (label . 0)
|
---|
2666 | (statement-cont . +)
|
---|
2667 | ))
|
---|
2668 | )
|
---|
2669 | ("bsd"
|
---|
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)
|
---|
2675 | (label . 0)
|
---|
2676 | (statement-cont . +)
|
---|
2677 | (inline-open . 0)
|
---|
2678 | (inexpr-class . 0)
|
---|
2679 | ))
|
---|
2680 | )
|
---|
2681 | ("stroustrup"
|
---|
2682 | (c-basic-offset . 4)
|
---|
2683 | (c-comment-only-line-offset . 0)
|
---|
2684 | (c-offsets-alist . ((statement-block-intro . +)
|
---|
2685 | (substatement-open . 0)
|
---|
2686 | (label . 0)
|
---|
2687 | (statement-cont . +)
|
---|
2688 | ))
|
---|
2689 | )
|
---|
2690 | ("whitesmith"
|
---|
2691 | (c-basic-offset . 4)
|
---|
2692 | (c-comment-only-line-offset . 0)
|
---|
2693 | (c-offsets-alist . ((knr-argdecl-intro . +)
|
---|
2694 | (label . 0)
|
---|
2695 | (statement-cont . +)
|
---|
2696 | (substatement-open . +)
|
---|
2697 | (block-open . +)
|
---|
2698 | (statement-block-intro . c-lineup-whitesmith-in-block)
|
---|
2699 | (block-close . c-lineup-whitesmith-in-block)
|
---|
2700 | (inline-open . +)
|
---|
2701 | (defun-open . +)
|
---|
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)
|
---|
2708 | (class-open . +)
|
---|
2709 | (inclass . c-lineup-whitesmith-in-block)
|
---|
2710 | (class-close . +)
|
---|
2711 | (inexpr-class . 0)
|
---|
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 . +)
|
---|
2718 | ))
|
---|
2719 | )
|
---|
2720 | ("ellemtel"
|
---|
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)
|
---|
2726 | (substatement . +)
|
---|
2727 | (substatement-open . 0)
|
---|
2728 | (case-label . +)
|
---|
2729 | (access-label . -)
|
---|
2730 | (inclass . ++)
|
---|
2731 | (inline-open . 0)
|
---|
2732 | ))
|
---|
2733 | )
|
---|
2734 | ("linux"
|
---|
2735 | (c-basic-offset . 8)
|
---|
2736 | (c-comment-only-line-offset . 0)
|
---|
2737 | (c-hanging-braces-alist . ((brace-list-open)
|
---|
2738 | (brace-entry-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)
|
---|
2745 | (label . 0)
|
---|
2746 | (statement-cont . +)
|
---|
2747 | ))
|
---|
2748 | )
|
---|
2749 | ("python"
|
---|
2750 | (indent-tabs-mode . t)
|
---|
2751 | (fill-column . 78)
|
---|
2752 | (c-basic-offset . 8)
|
---|
2753 | (c-offsets-alist . ((substatement-open . 0)
|
---|
2754 | (inextern-lang . 0)
|
---|
2755 | (arglist-intro . +)
|
---|
2756 | (knr-argdecl-intro . +)
|
---|
2757 | ))
|
---|
2758 | (c-hanging-braces-alist . ((brace-list-open)
|
---|
2759 | (brace-list-intro)
|
---|
2760 | (brace-list-close)
|
---|
2761 | (brace-entry-open)
|
---|
2762 | (substatement-open after)
|
---|
2763 | (block-close . c-snug-do-while)
|
---|
2764 | ))
|
---|
2765 | (c-block-comment-prefix . "")
|
---|
2766 | )
|
---|
2767 | ("java"
|
---|
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 . +)
|
---|
2776 | (label . +)
|
---|
2777 | (statement-case-open . +)
|
---|
2778 | (statement-cont . +)
|
---|
2779 | (arglist-intro . c-lineup-arglist-intro-after-paren)
|
---|
2780 | (arglist-close . c-lineup-arglist)
|
---|
2781 | (access-label . 0)
|
---|
2782 | (inher-cont . c-lineup-java-inher)
|
---|
2783 | (func-decl-cont . c-lineup-java-throws)
|
---|
2784 | ))
|
---|
2785 | )
|
---|
2786 | )
|
---|
2787 | */
|
---|
2788 |
|
---|
2789 | case 'c-file-style':
|
---|
2790 | case 'c-indentation-style':
|
---|
2791 | switch (sVal)
|
---|
2792 | {
|
---|
2793 | case 'bsd':
|
---|
2794 | case '"bsd"':
|
---|
2795 | case 'BSD':
|
---|
2796 | iBeginEndStyle = 1 | (iBeginEndStyle & ~3);
|
---|
2797 | p_indent_with_tabs = true;
|
---|
2798 | iIndentAmount = 8;
|
---|
2799 | p_SyntaxIndent = 8;
|
---|
2800 | p_tabs = "+8";
|
---|
2801 | //say 'bsd';
|
---|
2802 | break;
|
---|
2803 |
|
---|
2804 | case 'k&r':
|
---|
2805 | case '"k&r"':
|
---|
2806 | case 'K&R':
|
---|
2807 | iBeginEndStyle = 0 | (iBeginEndStyle & ~3);
|
---|
2808 | p_indent_with_tabs = false;
|
---|
2809 | iIndentAmount = 4;
|
---|
2810 | p_SyntaxIndent = 4;
|
---|
2811 | p_tabs = "+4";
|
---|
2812 | //say 'k&r';
|
---|
2813 | break;
|
---|
2814 |
|
---|
2815 | case 'linux-c':
|
---|
2816 | case '"linux-c"':
|
---|
2817 | iBeginEndStyle = 0 | (iBeginEndStyle & ~3);
|
---|
2818 | p_indent_with_tabs = true;
|
---|
2819 | iIndentAmount = 4;
|
---|
2820 | p_SyntaxIndent = 4;
|
---|
2821 | p_tabs = "+4";
|
---|
2822 | //say 'linux-c';
|
---|
2823 | break;
|
---|
2824 |
|
---|
2825 | case 'yet-to-be-found':
|
---|
2826 | iBeginEndStyle = 2 | (iBeginEndStyle & ~3);
|
---|
2827 | p_indent_with_tabs = false;
|
---|
2828 | iIndentAmount = 4;
|
---|
2829 | p_SyntaxIndent = 4;
|
---|
2830 | p_tabs = "+4";
|
---|
2831 | //say 'todo';
|
---|
2832 | break;
|
---|
2833 |
|
---|
2834 | default:
|
---|
2835 | message('emacs "'sVar'" value "'sVal'" is not known to us.');
|
---|
2836 | return -3;
|
---|
2837 | }
|
---|
2838 | break;
|
---|
2839 |
|
---|
2840 | case 'c-label-offset':
|
---|
2841 | {
|
---|
2842 | int i = k_style_emacs_var_integer(sVal);
|
---|
2843 | if (i >= -16 && i <= 16)
|
---|
2844 | {
|
---|
2845 | if (i == -p_SyntaxIndent)
|
---|
2846 | iSwitchStyle = 0;
|
---|
2847 | else
|
---|
2848 | iSwitchStyle = 1;
|
---|
2849 | }
|
---|
2850 | break;
|
---|
2851 | }
|
---|
2852 |
|
---|
2853 |
|
---|
2854 | case 'indent-tabs-mode':
|
---|
2855 | p_indent_with_tabs = sVal == 't';
|
---|
2856 | break;
|
---|
2857 |
|
---|
2858 | case 'c-indent-level':
|
---|
2859 | case 'c-basic-offset':
|
---|
2860 | {
|
---|
2861 | int i = k_style_emacs_var_integer(sVal);
|
---|
2862 | if (i > 0 && i <= 16)
|
---|
2863 | {
|
---|
2864 | iIndentAmount = i;
|
---|
2865 | p_SyntaxIndent = i;
|
---|
2866 | }
|
---|
2867 | else
|
---|
2868 | {
|
---|
2869 | message('emacs "'sVar'" value "'sVal'" is out of range.');
|
---|
2870 | return -4;
|
---|
2871 | }
|
---|
2872 | break;
|
---|
2873 | }
|
---|
2874 |
|
---|
2875 | case 'tab-width':
|
---|
2876 | {
|
---|
2877 | int i = k_style_emacs_var_integer(sVal);
|
---|
2878 | if (i > 0 && i <= 16)
|
---|
2879 | p_tabs = '+'i;
|
---|
2880 | else
|
---|
2881 | {
|
---|
2882 | message('emacs "'sVar'" value "'sVal'" is out of range.');
|
---|
2883 | return -4;
|
---|
2884 | }
|
---|
2885 | break;
|
---|
2886 | }
|
---|
2887 |
|
---|
2888 | case 'nuke-trailing-whitespace-p':
|
---|
2889 | {
|
---|
2890 | #if 0
|
---|
2891 | _str sName = 'def-koptions-'p_buf_id;
|
---|
2892 | int idx = insert_name(sName, MISC_TYPE, "kstyledoc");
|
---|
2893 | if (!idx)
|
---|
2894 | idx = find_index(sName, MISC_TYPE);
|
---|
2895 | if (idx)
|
---|
2896 | {
|
---|
2897 | if (sVal == 't')
|
---|
2898 | set_name_info(idx, "saveoptions: +S");
|
---|
2899 | else
|
---|
2900 | set_name_info(idx, "saveoptions: -S");
|
---|
2901 | say 'sVal=' sVal;
|
---|
2902 | }
|
---|
2903 | #endif
|
---|
2904 | break;
|
---|
2905 | }
|
---|
2906 |
|
---|
2907 | default:
|
---|
2908 | message('emacs variable "'sVar'" (value "'sVal'") is unknown to us.');
|
---|
2909 | return -5;
|
---|
2910 | }
|
---|
2911 |
|
---|
2912 | /*
|
---|
2913 | * Update the style?
|
---|
2914 | */
|
---|
2915 | _str sNewStyle = "";
|
---|
2916 | if (sStyleName == 'Slick-C')
|
---|
2917 | sNewStyle = iMinAbbrivation' 'sRes0' 'iBeginEndStyle' 'fIndent1stLevel' 'sRes1' 'iSwitchStyle' 'sRest;
|
---|
2918 | else
|
---|
2919 | sNewStyle = iIndentAmount' 'fExpansion' 'iMinAbbrivation' 'fIndentAfterOpenParen' 'iBeginEndStyle' 'fIndent1stLevel' 'iMainStyle' 'iSwitchStyle' 'sRest;
|
---|
2920 | if ( sNewStyle != ""
|
---|
2921 | && sNewStyle != sStyle
|
---|
2922 | && sStyleName == p_mode_name)
|
---|
2923 | {
|
---|
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)
|
---|
2928 | {
|
---|
2929 | sName = 'def-kstyledoc-'p_buf_id;
|
---|
2930 | int idx = insert_name(sName, MISC_TYPE, "kstyledoc");
|
---|
2931 | if (!idx)
|
---|
2932 | idx = find_index(sName, MISC_TYPE);
|
---|
2933 | if (idx)
|
---|
2934 | {
|
---|
2935 | if (!set_name_info(idx, sNewStyle))
|
---|
2936 | _edit_window().p_index = idx;
|
---|
2937 | }
|
---|
2938 | //say sName'='idx;
|
---|
2939 | }
|
---|
2940 | else
|
---|
2941 | set_name_info(_edit_window().p_index, sNewStyle);
|
---|
2942 | }
|
---|
2943 |
|
---|
2944 | return 0;
|
---|
2945 | #endif
|
---|
2946 | }
|
---|
2947 |
|
---|
2948 |
|
---|
2949 | /**
|
---|
2950 | * Parses a string with emacs variables.
|
---|
2951 | *
|
---|
2952 | * The variables are separated by new line. Junk at
|
---|
2953 | * the start and end of the line is ignored.
|
---|
2954 | */
|
---|
2955 | static int k_style_emac_vars(_str sVars)
|
---|
2956 | {
|
---|
2957 | /* process them line by line */
|
---|
2958 | int iLine = 0;
|
---|
2959 | while (sVars != '' && iLine++ < 20)
|
---|
2960 | {
|
---|
2961 | int iNext, iEnd;
|
---|
2962 | iEnd = iNext = pos("\n", sVars);
|
---|
2963 | if (iEnd <= 0)
|
---|
2964 | iEnd = iNext = length(sVars);
|
---|
2965 | else
|
---|
2966 | iEnd--;
|
---|
2967 | iNext++;
|
---|
2968 |
|
---|
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>';
|
---|
2973 | if (sLine != '')
|
---|
2974 | {
|
---|
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'))'"'
|
---|
2981 | if (rc > 0)
|
---|
2982 | k_style_emacs_var(substr(sLine,pos('S1'),pos('1')),
|
---|
2983 | substr(sLine,pos('S2'),pos('2')));
|
---|
2984 | }
|
---|
2985 | }
|
---|
2986 | return 0;
|
---|
2987 | }
|
---|
2988 |
|
---|
2989 | /**
|
---|
2990 | * Searches for Emacs style specification for the current document.
|
---|
2991 | */
|
---|
2992 | void k_style_load()
|
---|
2993 | {
|
---|
2994 | /* save the position before we start looking around the file. */
|
---|
2995 | typeless saved_pos;
|
---|
2996 | _save_pos2(saved_pos);
|
---|
2997 |
|
---|
2998 | int rc;
|
---|
2999 |
|
---|
3000 | /* Check first line. */
|
---|
3001 | top_of_buffer();
|
---|
3002 | _str sLine;
|
---|
3003 | get_line(sLine);
|
---|
3004 | strip(sLine);
|
---|
3005 | if (pos('-*-[ \t]+(.*:.*)[ \t]+-*-', sLine, 1, 'U'))
|
---|
3006 | {
|
---|
3007 | _str sVars;
|
---|
3008 | sVars = substr(sLine, pos('S1'), pos('1'));
|
---|
3009 | sVars = translate(sVars, "\n", ";");
|
---|
3010 | k_style_emac_vars(sVars);
|
---|
3011 | }
|
---|
3012 |
|
---|
3013 | /* Look for the "Local Variables:" stuff from the end of the file. */
|
---|
3014 | bottom_of_buffer();
|
---|
3015 | rc = search('Local Variables:[ \t]*\n\om(.*)\ol\n.*End:.*\n', '-EU');
|
---|
3016 | if (!rc)
|
---|
3017 | {
|
---|
3018 | /* copy the variables out to a buffer. */
|
---|
3019 | _str sVars;
|
---|
3020 | sVars = get_text(match_length("1"), match_length("S1"));
|
---|
3021 | k_style_emac_vars(sVars);
|
---|
3022 | }
|
---|
3023 |
|
---|
3024 | _restore_pos2(saved_pos);
|
---|
3025 | }
|
---|
3026 |
|
---|
3027 |
|
---|
3028 | /**
|
---|
3029 | * Callback function for the event of a new buffer.
|
---|
3030 | *
|
---|
3031 | * This is used to make sure there are no left over per buffer options
|
---|
3032 | * hanging around.
|
---|
3033 | */
|
---|
3034 | void _buffer_add_kdev(int buf_id)
|
---|
3035 | {
|
---|
3036 | _str sName = 'def-koptions-'buf_id;
|
---|
3037 | int idx = find_index(sName, MISC_TYPE);
|
---|
3038 | if (idx)
|
---|
3039 | delete_name(idx);
|
---|
3040 | //message("_buffer_add_kdev: " idx " name=" sName);
|
---|
3041 |
|
---|
3042 | sName = 'def-kstyledoc-'buf_id;
|
---|
3043 | idx = find_index(sName, MISC_TYPE);
|
---|
3044 | if (idx)
|
---|
3045 | delete_name(idx);
|
---|
3046 |
|
---|
3047 | //k_style_load();
|
---|
3048 | }
|
---|
3049 |
|
---|
3050 |
|
---|
3051 | /**
|
---|
3052 | * Callback function for the event of quitting a buffer.
|
---|
3053 | *
|
---|
3054 | * This is used to make sure there are no left over per buffer options
|
---|
3055 | * hanging around.
|
---|
3056 | */
|
---|
3057 | void _cbquit2_kdev(int buf_id)
|
---|
3058 | {
|
---|
3059 | _str sName = 'def-koptions-'buf_id;
|
---|
3060 | int idx = find_index(sName, MISC_TYPE);
|
---|
3061 | if (idx)
|
---|
3062 | delete_name(idx);
|
---|
3063 | //message("_cbquit2_kdev: " idx " " sName);
|
---|
3064 |
|
---|
3065 | sName = 'def-kstyledoc-'buf_id;
|
---|
3066 | idx = find_index(sName, MISC_TYPE);
|
---|
3067 | if (idx)
|
---|
3068 | delete_name(idx);
|
---|
3069 | }
|
---|
3070 |
|
---|
3071 |
|
---|
3072 | /**
|
---|
3073 | * Called to get save options for the current buffer.
|
---|
3074 | *
|
---|
3075 | * This requires a modified loadsave.e!
|
---|
3076 | */
|
---|
3077 | _str _buffer_save_kdev(int buf_id)
|
---|
3078 | {
|
---|
3079 | _str sRet = ""
|
---|
3080 | _str sName = 'def-koptions-'buf_id;
|
---|
3081 | int idx = find_index(sName, MISC_TYPE);
|
---|
3082 | if (idx)
|
---|
3083 | {
|
---|
3084 | _str sOptions = strip(name_info(idx));
|
---|
3085 | if (sOptions != "")
|
---|
3086 | parse sOptions with . "saveoptions:" sRet .
|
---|
3087 | message("_buffer_save_kdev: " idx " " sName " " sOptions);
|
---|
3088 | }
|
---|
3089 | return sRet;
|
---|
3090 | }
|
---|
3091 |
|
---|
3092 |
|
---|
3093 | /**
|
---|
3094 | * Command similar to the add() command in math.e, only this
|
---|
3095 | * produces hex and doesn't do the multi line stuff.
|
---|
3096 | */
|
---|
3097 | _command int k_calc()
|
---|
3098 | {
|
---|
3099 | _str sLine;
|
---|
3100 | filter_init();
|
---|
3101 | typeless rc = filter_get_string(sLine);
|
---|
3102 | if (rc == 0)
|
---|
3103 | {
|
---|
3104 | _str sResultHex;
|
---|
3105 | rc = eval_exp(sResultHex, sLine, 16);
|
---|
3106 | if (rc == 0)
|
---|
3107 | {
|
---|
3108 | _str sResultDec;
|
---|
3109 | rc = eval_exp(sResultDec, sLine, 10);
|
---|
3110 | if (rc == 0)
|
---|
3111 | {
|
---|
3112 | _end_select();
|
---|
3113 | _insert_text(' = ' :+ sResultHex :+ ' (' :+ sResultDec :+ ')');
|
---|
3114 | return 0;
|
---|
3115 | }
|
---|
3116 | }
|
---|
3117 | }
|
---|
3118 |
|
---|
3119 | if (isinteger(rc))
|
---|
3120 | message(get_message(rc));
|
---|
3121 | else
|
---|
3122 | message(rc);
|
---|
3123 | return 1;
|
---|
3124 | }
|
---|
3125 |
|
---|
3126 |
|
---|
3127 |
|
---|
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;
|
---|
3134 | #endif
|
---|
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;
|
---|
3140 |
|
---|
3141 | /*
|
---|
3142 | * Creates the kDev menu.
|
---|
3143 | */
|
---|
3144 | static k_menu_create()
|
---|
3145 | {
|
---|
3146 | # if __VERSION__ < 18.0 /* Something with timers are busted, so excusing my code. */
|
---|
3147 | if (arg(1) == 'timer')
|
---|
3148 | _kill_timer(iTimer);
|
---|
3149 | # endif
|
---|
3150 | menu_handle = _mdi.p_menu_handle;
|
---|
3151 | menu_index = find_index(_cur_mdi_menu,oi2type(OI_MENU));
|
---|
3152 |
|
---|
3153 | /*
|
---|
3154 | * Remove any old menu.
|
---|
3155 | */
|
---|
3156 | mhDelete = iPos = 0;
|
---|
3157 | index = _menu_find(menu_handle, "kDev", mhDelete, iPos, 'C');
|
---|
3158 | //message("index="index " mhDelete="mhDelete " iPos="iPos);
|
---|
3159 | if (index == 0)
|
---|
3160 | _menu_delete(mhDelete, iPos);
|
---|
3161 |
|
---|
3162 |
|
---|
3163 | /*
|
---|
3164 | * Insert the "kDev" menu.
|
---|
3165 | */
|
---|
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");
|
---|
3173 |
|
---|
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");
|
---|
3177 |
|
---|
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");
|
---|
3188 |
|
---|
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");
|
---|
3204 |
|
---|
3205 | k_menu_doc_style();
|
---|
3206 | k_menu_license();
|
---|
3207 | k_menu_style();
|
---|
3208 | }
|
---|
3209 |
|
---|
3210 |
|
---|
3211 | /**
|
---|
3212 | * Change change Id.
|
---|
3213 | */
|
---|
3214 | _command k_menu_change()
|
---|
3215 | {
|
---|
3216 | sRc = show("-modal k_form_simple_input", "Change ID", skChange);
|
---|
3217 | if (sRc != "\r")
|
---|
3218 | {
|
---|
3219 | skChange = sRc;
|
---|
3220 | k_menu_create();
|
---|
3221 | }
|
---|
3222 | }
|
---|
3223 |
|
---|
3224 |
|
---|
3225 | /**
|
---|
3226 | * Change program name.
|
---|
3227 | */
|
---|
3228 | _command k_menu_program()
|
---|
3229 | {
|
---|
3230 | sRc = show("-modal k_form_simple_input", "Program", skProgram);
|
---|
3231 | if (sRc != "\r")
|
---|
3232 | {
|
---|
3233 | skProgram = sRc;
|
---|
3234 | k_menu_create();
|
---|
3235 | }
|
---|
3236 | }
|
---|
3237 |
|
---|
3238 |
|
---|
3239 | /**
|
---|
3240 | * Change company.
|
---|
3241 | */
|
---|
3242 | _command k_menu_company()
|
---|
3243 | {
|
---|
3244 | if (skCompany == '')
|
---|
3245 | sRc = show("-modal k_form_simple_input", "Company", 'innotek GmbH');
|
---|
3246 | else
|
---|
3247 | sRc = show("-modal k_form_simple_input", "Company", skCompany);
|
---|
3248 | if (sRc != "\r")
|
---|
3249 | {
|
---|
3250 | skCompany = sRc;
|
---|
3251 | k_menu_create();
|
---|
3252 | }
|
---|
3253 | }
|
---|
3254 |
|
---|
3255 |
|
---|
3256 | /**
|
---|
3257 | * Change user name.
|
---|
3258 | */
|
---|
3259 | _command k_menu_user_name()
|
---|
3260 | {
|
---|
3261 | sRc = show("-modal k_form_simple_input", "User Name", skUserName);
|
---|
3262 | if (sRc != "\r" && sRc != '')
|
---|
3263 | {
|
---|
3264 | skUserName = sRc;
|
---|
3265 | k_menu_create();
|
---|
3266 | }
|
---|
3267 | }
|
---|
3268 |
|
---|
3269 |
|
---|
3270 | /**
|
---|
3271 | * Change user email.
|
---|
3272 | */
|
---|
3273 | _command k_menu_user_email()
|
---|
3274 | {
|
---|
3275 | sRc = show("-modal k_form_simple_input", "User e-mail", skUserEmail);
|
---|
3276 | if (sRc != "\r" && sRc != '')
|
---|
3277 | {
|
---|
3278 | skUserEmail = sRc;
|
---|
3279 | k_menu_create();
|
---|
3280 | }
|
---|
3281 | }
|
---|
3282 |
|
---|
3283 |
|
---|
3284 | /**
|
---|
3285 | * Change user initials.
|
---|
3286 | */
|
---|
3287 | _command k_menu_user_initials()
|
---|
3288 | {
|
---|
3289 | sRc = show("-modal k_form_simple_input", "User e-mail", skUserInitials);
|
---|
3290 | if (sRc != "\r" && sRc != '')
|
---|
3291 | {
|
---|
3292 | skUserInitials = sRc;
|
---|
3293 | k_menu_create();
|
---|
3294 | }
|
---|
3295 | }
|
---|
3296 |
|
---|
3297 |
|
---|
3298 |
|
---|
3299 | /**
|
---|
3300 | * Checks the correct menu item.
|
---|
3301 | */
|
---|
3302 | _command void k_menu_doc_style(_str sNewDocStyle = '')
|
---|
3303 | {
|
---|
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);
|
---|
3309 |
|
---|
3310 | _menu_set_state(mhDoc, skDocStyle, MF_CHECKED);
|
---|
3311 | }
|
---|
3312 |
|
---|
3313 |
|
---|
3314 | /**
|
---|
3315 | * Checks the correct menu item.
|
---|
3316 | */
|
---|
3317 | _command void k_menu_license(_str sNewLicense = '')
|
---|
3318 | {
|
---|
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);
|
---|
3331 |
|
---|
3332 | _menu_set_state(mhLic, skLicense, MF_CHECKED);
|
---|
3333 | }
|
---|
3334 |
|
---|
3335 |
|
---|
3336 | /**
|
---|
3337 | * Check the correct style menu item.
|
---|
3338 | */
|
---|
3339 | _command void k_menu_style(_str sNewStyle = '')
|
---|
3340 | {
|
---|
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);
|
---|
3351 |
|
---|
3352 | if (sNewStyle != '')
|
---|
3353 | {
|
---|
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);
|
---|
3359 | }
|
---|
3360 |
|
---|
3361 | _menu_set_state(mhCode, skCodeStyle, MF_CHECKED);
|
---|
3362 | }
|
---|
3363 |
|
---|
3364 |
|
---|
3365 | /**
|
---|
3366 | * Load a 'preset'.
|
---|
3367 | */
|
---|
3368 | _command void k_menu_preset(_str sArgs = '')
|
---|
3369 | {
|
---|
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);
|
---|
3379 |
|
---|
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;
|
---|
3387 | k_menu_create();
|
---|
3388 | }
|
---|
3389 |
|
---|
3390 |
|
---|
3391 |
|
---|
3392 | /* future ones..
|
---|
3393 | _command k_menu_setcolor()
|
---|
3394 | {
|
---|
3395 | createMyColorSchemeAndUseIt();
|
---|
3396 | }
|
---|
3397 |
|
---|
3398 |
|
---|
3399 | _command k_menu_setkeys()
|
---|
3400 | {
|
---|
3401 | rc = load("d:/knut/VSlickMacros/BoxerDef.e");
|
---|
3402 | }
|
---|
3403 |
|
---|
3404 | _command k_menu_settings()
|
---|
3405 | {
|
---|
3406 | mySettings();
|
---|
3407 | }
|
---|
3408 | */
|
---|
3409 |
|
---|
3410 |
|
---|
3411 | #endif /* KDEV_WITH_MENU */
|
---|
3412 |
|
---|
3413 |
|
---|
3414 | /*******************************************************************************
|
---|
3415 | * Dialogs *
|
---|
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
|
---|
3423 | p_height=1120
|
---|
3424 | p_width=5020
|
---|
3425 | p_x=6660
|
---|
3426 | p_y=6680
|
---|
3427 | _text_box entText {
|
---|
3428 | p_auto_size=TRUE
|
---|
3429 | p_backcolor=0x80000005
|
---|
3430 | p_border_style=BDS_FIXED_SINGLE
|
---|
3431 | p_completion=NONE_ARG
|
---|
3432 | p_font_bold=FALSE
|
---|
3433 | p_font_italic=FALSE
|
---|
3434 | p_font_name='MS Sans Serif'
|
---|
3435 | p_font_size=8
|
---|
3436 | p_font_underline=FALSE
|
---|
3437 | p_forecolor=0x80000008
|
---|
3438 | p_height=270
|
---|
3439 | p_tab_index=1
|
---|
3440 | p_tab_stop=TRUE
|
---|
3441 | p_text='text'
|
---|
3442 | p_width=3180
|
---|
3443 | p_x=1680
|
---|
3444 | p_y=240
|
---|
3445 | p_eventtab2=_ul2_textbox
|
---|
3446 | }
|
---|
3447 | _label lblLabel {
|
---|
3448 | p_alignment=AL_VCENTERRIGHT
|
---|
3449 | p_auto_size=FALSE
|
---|
3450 | p_backcolor=0x80000005
|
---|
3451 | p_border_style=BDS_NONE
|
---|
3452 | p_caption='Label'
|
---|
3453 | p_font_bold=FALSE
|
---|
3454 | p_font_italic=FALSE
|
---|
3455 | p_font_name='MS Sans Serif'
|
---|
3456 | p_font_size=8
|
---|
3457 | p_font_underline=FALSE
|
---|
3458 | p_forecolor=0x80000008
|
---|
3459 | p_height=240
|
---|
3460 | p_tab_index=2
|
---|
3461 | p_width=1380
|
---|
3462 | p_word_wrap=FALSE
|
---|
3463 | p_x=180
|
---|
3464 | p_y=240
|
---|
3465 | }
|
---|
3466 | _command_button btnOK {
|
---|
3467 | p_cancel=FALSE
|
---|
3468 | p_caption='&OK'
|
---|
3469 | p_default=TRUE
|
---|
3470 | p_font_bold=FALSE
|
---|
3471 | p_font_italic=FALSE
|
---|
3472 | p_font_name='MS Sans Serif'
|
---|
3473 | p_font_size=8
|
---|
3474 | p_font_underline=FALSE
|
---|
3475 | p_height=360
|
---|
3476 | p_tab_index=3
|
---|
3477 | p_tab_stop=TRUE
|
---|
3478 | p_width=1020
|
---|
3479 | p_x=180
|
---|
3480 | p_y=660
|
---|
3481 | }
|
---|
3482 | _command_button btnCancel {
|
---|
3483 | p_cancel=TRUE
|
---|
3484 | p_caption='Cancel'
|
---|
3485 | p_default=FALSE
|
---|
3486 | p_font_bold=FALSE
|
---|
3487 | p_font_italic=FALSE
|
---|
3488 | p_font_name='MS Sans Serif'
|
---|
3489 | p_font_size=8
|
---|
3490 | p_font_underline=FALSE
|
---|
3491 | p_height=360
|
---|
3492 | p_tab_index=4
|
---|
3493 | p_tab_stop=TRUE
|
---|
3494 | p_width=840
|
---|
3495 | p_x=1380
|
---|
3496 | p_y=660
|
---|
3497 | }
|
---|
3498 | }
|
---|
3499 |
|
---|
3500 | defeventtab k_form_simple_input
|
---|
3501 | btnOK.on_create(_str sLabel = '', _str sText = '')
|
---|
3502 | {
|
---|
3503 | p_active_form.p_caption = sLabel;
|
---|
3504 | lblLabel.p_caption = sLabel;
|
---|
3505 | entText.p_text = sText;
|
---|
3506 | }
|
---|
3507 |
|
---|
3508 | btnOK.lbutton_up()
|
---|
3509 | {
|
---|
3510 | sText = entText.p_text;
|
---|
3511 | p_active_form._delete_window(sText);
|
---|
3512 | }
|
---|
3513 | btnCancel.lbutton_up()
|
---|
3514 | {
|
---|
3515 | sText = entText.p_text;
|
---|
3516 | p_active_form._delete_window("\r");
|
---|
3517 | }
|
---|
3518 |
|
---|
3519 | static _str aCLikeIncs[] =
|
---|
3520 | {
|
---|
3521 | "c", "ansic", "java", "rul", "vera", "cs", "js", "as", "idl", "asm", "s", "imakefile", "rc", "lex", "yacc", "antlr"
|
---|
3522 | };
|
---|
3523 |
|
---|
3524 | static _str aMyLangIds[] =
|
---|
3525 | {
|
---|
3526 | "applescript",
|
---|
3527 | "ansic",
|
---|
3528 | "antlr",
|
---|
3529 | "as",
|
---|
3530 | #if __VERSION__ < 19.0
|
---|
3531 | "asm",
|
---|
3532 | #endif
|
---|
3533 | "c",
|
---|
3534 | "cs",
|
---|
3535 | "csh",
|
---|
3536 | "css",
|
---|
3537 | "conf",
|
---|
3538 | "d",
|
---|
3539 | "docbook",
|
---|
3540 | "dtd",
|
---|
3541 | "e",
|
---|
3542 | "html",
|
---|
3543 | "idl",
|
---|
3544 | "imakefile",
|
---|
3545 | "ini",
|
---|
3546 | "java",
|
---|
3547 | "js",
|
---|
3548 | "lex",
|
---|
3549 | "mak",
|
---|
3550 | "masm",
|
---|
3551 | "pas",
|
---|
3552 | "phpscript",
|
---|
3553 | "powershell",
|
---|
3554 | "py",
|
---|
3555 | "rexx",
|
---|
3556 | "rc",
|
---|
3557 | "rul",
|
---|
3558 | "tcl",
|
---|
3559 | #if __VERSION__ < 19.0
|
---|
3560 | "s",
|
---|
3561 | #endif
|
---|
3562 | "unixasm",
|
---|
3563 | "vbs",
|
---|
3564 | "xhtml",
|
---|
3565 | "xml",
|
---|
3566 | "xmldoc",
|
---|
3567 | "xsd",
|
---|
3568 | "yacc"
|
---|
3569 | };
|
---|
3570 |
|
---|
3571 | #if __VERSION__ >= 17.0
|
---|
3572 | # require "se/lang/api/LanguageSettings.e"
|
---|
3573 | using se.lang.api.LanguageSettings;
|
---|
3574 | #endif
|
---|
3575 |
|
---|
3576 | #if __VERSION__ >= 16.0
|
---|
3577 | int def_auto_unsurround_block;
|
---|
3578 | #endif
|
---|
3579 |
|
---|
3580 | #if __VERSION__ >= 21.0
|
---|
3581 | int def_gui_find_default;
|
---|
3582 | #endif
|
---|
3583 |
|
---|
3584 | static void kdev_ext_to_lang(_str sExt, _str idLang)
|
---|
3585 | {
|
---|
3586 | #if __VERSION__ >= 21.0 // dunno when exactly.
|
---|
3587 | _SetExtensionReferTo(sExt, idLang);
|
---|
3588 | #else
|
---|
3589 | replace_def_data("def-lang-for-ext-" :+ sExt, idLand);
|
---|
3590 | #endif
|
---|
3591 | }
|
---|
3592 |
|
---|
3593 | #if __VERSION__ >= 21.0
|
---|
3594 |
|
---|
3595 | static _str kdev_load_lexer(_str sFilename)
|
---|
3596 | {
|
---|
3597 | int rc = cload(sFilename);
|
---|
3598 | if (rc == 0)
|
---|
3599 | return "";
|
---|
3600 | return ' Failed to load "' sFilename "': " rc ";";
|
---|
3601 | }
|
---|
3602 |
|
---|
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)
|
---|
3607 | {
|
---|
3608 | _str sRet = '';
|
---|
3609 | int iStatus = 0;
|
---|
3610 | auto hXml = _xmlcfg_open(sFilename, iStatus);
|
---|
3611 | if (hXml >= 0)
|
---|
3612 | {
|
---|
3613 | _str asProfiles[];
|
---|
3614 | iStatus = _xmlcfg_find_simple_array(hXml, "//profile/@n", asProfiles, TREE_ROOT_INDEX, VSXMLCFG_FIND_VALUES, -1);
|
---|
3615 | _xmlcfg_close(hXml);
|
---|
3616 |
|
---|
3617 | _str sProfile;
|
---|
3618 | foreach (sProfile in asProfiles)
|
---|
3619 | {
|
---|
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);
|
---|
3627 | if (sErr != "")
|
---|
3628 | sRet = ' Failed to load "' sProfileName "' for '" sLangId "' from '" sFilename "': " sRet ";";
|
---|
3629 | }
|
---|
3630 | }
|
---|
3631 | else
|
---|
3632 | sRet = " Failed to open '" sFilename "': " hXml ";";
|
---|
3633 | return sRet;
|
---|
3634 | }
|
---|
3635 |
|
---|
3636 | #endif
|
---|
3637 |
|
---|
3638 | /**
|
---|
3639 | * Loads the standard bird settings.
|
---|
3640 | */
|
---|
3641 | _command void kdev_load_settings(_str sScriptDir = "")
|
---|
3642 | {
|
---|
3643 | typeless nt1;
|
---|
3644 | typeless nt2;
|
---|
3645 | typeless nt3;
|
---|
3646 | typeless nt4;
|
---|
3647 | typeless nt5;
|
---|
3648 | typeless nt6;
|
---|
3649 | typeless i7;
|
---|
3650 | _str sRest;
|
---|
3651 | _str sTmp;
|
---|
3652 | _str sMsg = 'Please restart SlickEdit.';
|
---|
3653 |
|
---|
3654 | /*
|
---|
3655 | * Validate script dir argument.
|
---|
3656 | */
|
---|
3657 | sScriptDir = _maybe_unquote_filename(sScriptDir);
|
---|
3658 | if (sScriptDir == "")
|
---|
3659 | {
|
---|
3660 | message("Need script dir argument!");
|
---|
3661 | return;
|
---|
3662 | }
|
---|
3663 | if (!file_exists(sScriptDir :+ "/lexer-kmk.cfg.xml"))
|
---|
3664 | {
|
---|
3665 | message("Invalid script dir '" sScriptDir "' no lexer-kmk.cfg.xml file found!");
|
---|
3666 | return;
|
---|
3667 | }
|
---|
3668 |
|
---|
3669 | #if __VERSION__ >= 21.0
|
---|
3670 | /*
|
---|
3671 | * Load the color profiles (was lexer).
|
---|
3672 | */
|
---|
3673 | sMsg = sMsg :+ kdev_load_lexer(sScriptDir :+ "/lexer-kmk-v2.cfg.xml");
|
---|
3674 |
|
---|
3675 | /*
|
---|
3676 | * Load project templates for kBuild.
|
---|
3677 | */
|
---|
3678 | int rc = importProjectPacks(sScriptDir :+ "/usrprjtemplates.vpt");
|
---|
3679 | if (rc != 0)
|
---|
3680 | sMsg = sMsg :+ " importProjectPacks(usrprjtemplates.vpt)->" :+ rc :+ ";";
|
---|
3681 |
|
---|
3682 | /*
|
---|
3683 | * Load the beautifier profiles.
|
---|
3684 | */
|
---|
3685 | sMsg = sMsg :+ kdev_load_beautifier_profiles(sScriptDir :+ "/beautifier-profiles.cfg.xml");
|
---|
3686 |
|
---|
3687 | /*
|
---|
3688 | * Load color and select scheme.
|
---|
3689 | */
|
---|
3690 | _str sErr = _color_form_import_settings(sScriptDir :+ "/color_profiles.cfg.xml", 'Solarized Dark');
|
---|
3691 | if (sErr != "")
|
---|
3692 | sMsg = sMsg :+ " _color_form_import_settings(color_profiles.cfg.xml)->" :+ sErr :+ ";";
|
---|
3693 | _app_theme('Dark', true);
|
---|
3694 | #endif
|
---|
3695 |
|
---|
3696 | /*
|
---|
3697 | * General stuff.
|
---|
3698 | */
|
---|
3699 | _default_option('A', '0'); /* ALT menu */
|
---|
3700 | def_alt_menu = 0;
|
---|
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. */
|
---|
3711 | #endif
|
---|
3712 | _config_modify_flags(CFGMODIFY_DEFDATA);
|
---|
3713 |
|
---|
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)'
|
---|
3719 | 'C# Files (*.cs),'
|
---|
3720 | 'Ch Files (*.ch;*.chf;*.chs;*.cpp;*.h),'
|
---|
3721 | 'D Files (*.d),'
|
---|
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),'
|
---|
3747 | 'PV-WAVE (*.pro),'
|
---|
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),'
|
---|
3757 | ;
|
---|
3758 | #endif
|
---|
3759 |
|
---|
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[~"]#}")');
|
---|
3766 |
|
---|
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')
|
---|
3773 | {
|
---|
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,,');
|
---|
3777 | }
|
---|
3778 |
|
---|
3779 | /* Not so important. */
|
---|
3780 | int fSearch = 0x400400; /* VSSEARCHFLAG_WRAP | VSSEARCHFLAG_PROMPT_WRAP */;
|
---|
3781 | _default_option('S', (_str)fSearch);
|
---|
3782 |
|
---|
3783 |
|
---|
3784 | #if __VERSION__ >= 17.0
|
---|
3785 | /*
|
---|
3786 | * Language settings via API.
|
---|
3787 | */
|
---|
3788 | int fNewAff = AFF_BEGIN_END_STYLE \
|
---|
3789 | | AFF_INDENT_WITH_TABS \
|
---|
3790 | | AFF_SYNTAX_INDENT \
|
---|
3791 | /*| AFF_TABS*/ \
|
---|
3792 | | AFF_NO_SPACE_BEFORE_PAREN \
|
---|
3793 | | AFF_PAD_PARENS \
|
---|
3794 | | AFF_INDENT_CASE \
|
---|
3795 | | AFF_KEYWORD_CASING \
|
---|
3796 | | AFF_TAG_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);
|
---|
3802 | _str sLangId;
|
---|
3803 | foreach (sLangId in aMyLangIds)
|
---|
3804 | {
|
---|
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);
|
---|
3813 |
|
---|
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);
|
---|
3820 | # else
|
---|
3821 | sTmp = LanguageSettings.getCommentWrapOptions(sLangId);
|
---|
3822 | if (length(sTmp) > 10)
|
---|
3823 | {
|
---|
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.
|
---|
3831 | }
|
---|
3832 | # endif
|
---|
3833 |
|
---|
3834 | /* set the encoding to UTF-8 without any friggin useless signatures. */
|
---|
3835 | idxExt = name_match('def-lang-for-ext-', 1, MISC_TYPE);
|
---|
3836 | while (idxExt > 0)
|
---|
3837 | {
|
---|
3838 | if (name_info(idxExt) == sLangId)
|
---|
3839 | {
|
---|
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);
|
---|
3845 | }
|
---|
3846 | idxExt = name_match('def-lang-for-ext-', 0, MISC_TYPE);
|
---|
3847 | }
|
---|
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);
|
---|
3852 |
|
---|
3853 | }
|
---|
3854 | replace_def_data('def-encoding', '+futf8 ');
|
---|
3855 |
|
---|
3856 | LanguageSettings.setIndentWithTabs('mak', true);
|
---|
3857 | LanguageSettings.setLexerName('mak', 'kmk');
|
---|
3858 | LanguageSettings.setSyntaxIndent('mak', 8);
|
---|
3859 |
|
---|
3860 | LanguageSettings.setBeautifierProfileName('c', "bird's Style");
|
---|
3861 | LanguageSettings.setBeautifierProfileName('m', "bird's Objective-C Style");
|
---|
3862 |
|
---|
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');
|
---|
3869 |
|
---|
3870 | /*
|
---|
3871 | * Change the codehelp default.
|
---|
3872 | */
|
---|
3873 | # if __VERSION__ >= 22.0
|
---|
3874 | VSCodeHelpFlags fOldCodeHelp, fNewCodeHelp;
|
---|
3875 | # else
|
---|
3876 | int fOldCodeHelp, fNewCodeHelp;
|
---|
3877 | # endif
|
---|
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 \
|
---|
3897 | ;
|
---|
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 \
|
---|
3906 | );
|
---|
3907 | def_codehelp_flags = fNewCodeHelp;
|
---|
3908 | foreach (sLangId in aMyLangIds)
|
---|
3909 | {
|
---|
3910 | _str sVarName = 'def-codehelp-' :+ sLangId;
|
---|
3911 | int idxVar = find_index(sVarName, MISC_TYPE);
|
---|
3912 | if (idxVar != 0)
|
---|
3913 | replace_def_data(sVarName, fNewCodeHelp);
|
---|
3914 | }
|
---|
3915 | #endif
|
---|
3916 |
|
---|
3917 | # if __VERSION__ >= 21.0
|
---|
3918 | /* Old style search dialog, not mini. */
|
---|
3919 | def_gui_find_default = 1;
|
---|
3920 | # endif
|
---|
3921 |
|
---|
3922 | _fso_strip_spaces(STSO_STRIP_MODIFIED);
|
---|
3923 |
|
---|
3924 | /** @todo
|
---|
3925 | * - Auto restore clipboards
|
---|
3926 | * */
|
---|
3927 |
|
---|
3928 | message(sMsg)
|
---|
3929 | }
|
---|
3930 |
|
---|
3931 |
|
---|
3932 | static int kfile_to_array(_str sFile, _str (&asLines)[])
|
---|
3933 | {
|
---|
3934 | asLines._makeempty();
|
---|
3935 |
|
---|
3936 | int idTempView = 0;
|
---|
3937 | int idOrgView = 0;
|
---|
3938 | int rc = _open_temp_view(sFile, idTempView, idOrgView);
|
---|
3939 | if (!rc)
|
---|
3940 | {
|
---|
3941 | _GoToROffset(0); /* top of the file. */
|
---|
3942 |
|
---|
3943 | int i = 0;
|
---|
3944 | do
|
---|
3945 | {
|
---|
3946 | _str sLine = '';
|
---|
3947 | get_line(sLine);
|
---|
3948 | asLines[i] = sLine;
|
---|
3949 | i += 1;
|
---|
3950 | } while (down() == 0);
|
---|
3951 |
|
---|
3952 | _delete_temp_view(idTempView);
|
---|
3953 | activate_window(idOrgView);
|
---|
3954 | }
|
---|
3955 | return rc;
|
---|
3956 | }
|
---|
3957 |
|
---|
3958 |
|
---|
3959 | _command void kload_files(_str sFile = "file-not-specified.lst")
|
---|
3960 | {
|
---|
3961 | _str sFileDir = absolute(_strip_filename(sFile, 'NE'));
|
---|
3962 | _str aFiles[];
|
---|
3963 | int rc = kfile_to_array(sFile, asFiles);
|
---|
3964 | if (rc == 0)
|
---|
3965 | {
|
---|
3966 | _str sFile;
|
---|
3967 | int i;
|
---|
3968 | for (i = 0; i < asFiles._length(); i++)
|
---|
3969 | {
|
---|
3970 | _str sFile = strip(asFiles[i]);
|
---|
3971 | if (length(sFile) > 0)
|
---|
3972 | {
|
---|
3973 | sAbsFile = absolute(sFile, sFileDir);
|
---|
3974 | message("Loading \"" :+ sAbsFile :+ "\"...");
|
---|
3975 | //say("sAbsFile=" :+ sAbsFile);
|
---|
3976 | edit(sAbsFile);
|
---|
3977 | }
|
---|
3978 | }
|
---|
3979 | }
|
---|
3980 | else
|
---|
3981 | message("_GetFileContents failed: " :+ rc);
|
---|
3982 | }
|
---|
3983 |
|
---|
3984 |
|
---|
3985 | /**
|
---|
3986 | * Module initiation.
|
---|
3987 | */
|
---|
3988 | definit()
|
---|
3989 | {
|
---|
3990 | /* do cleanup. */
|
---|
3991 | for (i = 0; i < 999; i++)
|
---|
3992 | {
|
---|
3993 | index = name_match("def-koptions-", 1 /*find_first*/, MISC_TYPE);
|
---|
3994 | if (!index)
|
---|
3995 | break;
|
---|
3996 | delete_name(index);
|
---|
3997 | }
|
---|
3998 |
|
---|
3999 | /* do init */
|
---|
4000 | k_styles_create();
|
---|
4001 | #ifdef KDEV_WITH_MENU
|
---|
4002 | k_menu_create();
|
---|
4003 | # if __VERSION__ < 18.0 /* Something with timers are busted, so excusing my code. */
|
---|
4004 | iTimer = _set_timer(1000, k_menu_create, "timer");
|
---|
4005 | # endif
|
---|
4006 | /* createMyColorSchemeAndUseIt();*/
|
---|
4007 | #endif
|
---|
4008 | }
|
---|
4009 |
|
---|