[1591] | 1 | /* $Id: kdev.e 2588 2012-06-17 14:11:25Z bird $ -*- tab-width: 4 c-indent-level: 4 -*- */
|
---|
[2019] | 2 | /** @file
|
---|
[113] | 3 | * Visual SlickEdit Documentation Macros.
|
---|
[1591] | 4 | */
|
---|
| 5 |
|
---|
| 6 | /*
|
---|
[2413] | 7 | * Copyright (c) 1999-2010 knut st. osmundsen <bird-kBuild-spamx@anduin.net>
|
---|
[113] | 8 | *
|
---|
[2019] | 9 | * This file is part of kBuild.
|
---|
| 10 | *
|
---|
| 11 | * kBuild is free software; you can redistribute it and/or modify
|
---|
[113] | 12 | * it under the terms of the GNU General Public License as published by
|
---|
[2019] | 13 | * the Free Software Foundation; either version 3 of the License, or
|
---|
[113] | 14 | * (at your option) any later version.
|
---|
| 15 | *
|
---|
[2019] | 16 | * kBuild is distributed in the hope that it will be useful,
|
---|
[113] | 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
|
---|
[2019] | 22 | * along with kBuild. If not, see <http://www.gnu.org/licenses/>
|
---|
[113] | 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.
|
---|
[323] | 46 | * Ctrl+Shift+L: Load document variables.
|
---|
[113] | 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-E' = k_box_exported
|
---|
| 63 | def 'C-S-F' = k_javadoc_funcbox
|
---|
| 64 | def 'C-S-G' = k_box_globals
|
---|
| 65 | def 'C-S-H' = k_box_headers
|
---|
| 66 | def 'C-S-I' = k_box_intfuncs
|
---|
| 67 | def 'C-S-K' = k_box_consts
|
---|
| 68 | def 'C-S-M' = k_javadoc_moduleheader
|
---|
| 69 | def 'C-S-O' = k_oneliner
|
---|
| 70 | def 'C-S-P' = k_mark_modified_line
|
---|
| 71 | def 'C-S-S' = k_box_structs
|
---|
[2354] | 72 | def 'C-S-T' = k_rebuild_tagfile
|
---|
[288] | 73 | def 'C-S-L' = k_style_load
|
---|
[113] | 74 |
|
---|
| 75 | //optional stuff
|
---|
[323] | 76 | //def 'C-S-Q' = klib_klog_file_ask
|
---|
| 77 | //def 'C-S-N' = klib_klog_file_no_ask
|
---|
| 78 | //def 'C-S-1' = klib_klogentry
|
---|
| 79 | //def 'C-S-3' = klib_klogexit
|
---|
[113] | 80 |
|
---|
| 81 |
|
---|
| 82 | //MARKER. Editor searches for this line!
|
---|
| 83 | #pragma option(redeclvars, on)
|
---|
| 84 | #include 'slick.sh'
|
---|
[214] | 85 | #ifndef VS_TAGDETAIL_context_args
|
---|
| 86 | /* newer vslick version. */
|
---|
| 87 | #include 'tagsdb.sh'
|
---|
| 88 | //#pragma option(strict,on)
|
---|
| 89 | /*#else: Version 4.0 (OS/2) */
|
---|
| 90 | #endif
|
---|
[113] | 91 |
|
---|
| 92 | /* Remeber to change these! */
|
---|
[1592] | 93 | static _str skUserInitials = "bird";
|
---|
[113] | 94 | static _str skUserName = "knut st. osmundsen";
|
---|
[2399] | 95 | static _str skUserEmail = "bird-kBuild-spamx@anduin.net";
|
---|
[113] | 96 |
|
---|
| 97 |
|
---|
| 98 | /*******************************************************************************
|
---|
| 99 | * Global Variables *
|
---|
| 100 | *******************************************************************************/
|
---|
| 101 | static _str skCodeStyle = 'Opt2Ind4'; /* coding style scheme. */
|
---|
| 102 | static _str skDocStyle = 'javadoc';/* options: javadoc, */
|
---|
[2019] | 103 | static _str skLicense = 'GPLv3'; /* options: GPL, LGPL, Odin32, Confidential, ++ */
|
---|
[113] | 104 | static _str skCompany = ''; /* empty or company name for copyright */
|
---|
| 105 | static _str skProgram = ''; /* Current program name - used by [L]GPL */
|
---|
| 106 | static _str skChange = ''; /* Current change identifier. */
|
---|
| 107 |
|
---|
| 108 | static int ikStyleWidth = 80; /* The page width of the style. */
|
---|
| 109 | static boolean fkStyleFullHeaders = false; /* false: omit some tags. */
|
---|
| 110 | static int ikStyleOneliner = 41; /* The oneline comment column. */
|
---|
| 111 | static int ikStyleModifyMarkColumn = 105;
|
---|
| 112 | static boolean fkStyleBoxTag = false; /* true: Include tag in k_box_start. */
|
---|
| 113 |
|
---|
| 114 | /*******************************************************************************
|
---|
| 115 | * Internal Functions *
|
---|
| 116 | *******************************************************************************/
|
---|
| 117 | /**
|
---|
| 118 | * Gets iso date.
|
---|
| 119 | * @returns ISO formatted date.
|
---|
| 120 | */
|
---|
| 121 | static _str k_date()
|
---|
| 122 | {
|
---|
| 123 | int i,j;
|
---|
| 124 | _str date;
|
---|
| 125 |
|
---|
| 126 | date = _date('U');
|
---|
| 127 | i = pos("/", date);
|
---|
| 128 | j = pos("/", date, i+1);
|
---|
[214] | 129 | _str month = substr(date, 1, i-1);
|
---|
[113] | 130 | if (length(month) == 1) month = '0'month;
|
---|
[214] | 131 | _str day = substr(date, i+1, j-i-1);
|
---|
[113] | 132 | if (length(day) == 1) day = '0'day;
|
---|
[214] | 133 | _str year = substr(date, j+1);
|
---|
[113] | 134 | return year"-"month"-"day;
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 |
|
---|
| 138 | /**
|
---|
| 139 | * Get the current year.
|
---|
| 140 | * @returns Current year string.
|
---|
| 141 | */
|
---|
| 142 | static _str k_year()
|
---|
| 143 | {
|
---|
[214] | 144 | _str date = _date('U');
|
---|
[113] | 145 | return substr(date, pos("/",date, pos("/",date)+1)+1, 4);
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 |
|
---|
| 149 | /**
|
---|
| 150 | * Aligns a value up to a given alignment.
|
---|
| 151 | */
|
---|
| 152 | static int k_alignup(int iValue, iAlign)
|
---|
| 153 | {
|
---|
| 154 | if (iAlign <= 0)
|
---|
| 155 | {
|
---|
| 156 | message('k_alignup: iValue='iValue ' iAlign='iAlign);
|
---|
| 157 | iAlign = 4;
|
---|
| 158 | }
|
---|
| 159 | return ((iValue intdiv iAlign) + 1) * iAlign;
|
---|
| 160 | }
|
---|
| 161 |
|
---|
| 162 |
|
---|
| 163 | /**
|
---|
| 164 | * Reads the comment setup for this lexer/extension .
|
---|
| 165 | *
|
---|
| 166 | * @returns Success indicator.
|
---|
| 167 | * @param sLeft Left comment. (output)
|
---|
| 168 | * @param sRight Right comment. (output)
|
---|
| 169 | * @param iColumn Comment mark column. (1-based) (output)
|
---|
| 170 | * @param sExt The extension to lookup defaults to the current one.
|
---|
| 171 | * @param sLexer The lexer to lookup defaults to the current one.
|
---|
| 172 | * @remark This should be exported from box.e, but unfortunately it isn't.
|
---|
| 173 | */
|
---|
| 174 | static boolean k_commentconfig(_str &sLeft, _str &sRight, int &iColumn, _str sExt = p_extension, _str sLexer = p_lexer_name)
|
---|
| 175 | {
|
---|
| 176 | /* init returns */
|
---|
| 177 | sLeft = sRight = '';
|
---|
| 178 | iColumn = 0;
|
---|
| 179 |
|
---|
| 180 | /*
|
---|
| 181 | * Get comment setup from the lexer.
|
---|
| 182 | */
|
---|
[214] | 183 | _str sLine = '';
|
---|
[113] | 184 | if (sLexer)
|
---|
| 185 | {
|
---|
| 186 | /* multiline */
|
---|
[2349] | 187 | #if __VERSION__>=14.0
|
---|
| 188 | _str aComments[];
|
---|
| 189 | GetComments(aComments, "mlcomment", sLexer)
|
---|
| 190 | for (i = 0; i < aComments._length(); i++)
|
---|
| 191 | if (!pos("documentation", aComments[i]) > 0)
|
---|
| 192 | {
|
---|
| 193 | sLine = aComments[i];
|
---|
| 194 | break;
|
---|
| 195 | }
|
---|
| 196 | if (sLine != '')
|
---|
| 197 | #else
|
---|
[113] | 198 | rc = _ini_get_value(slick_path_search("user.vlx"), sLexer, 'mlcomment', sLine);
|
---|
| 199 | if (rc)
|
---|
| 200 | rc = _ini_get_value(slick_path_search("vslick.vlx"), sLexer, 'mlcomment', sLine);
|
---|
| 201 | if (!rc)
|
---|
[2349] | 202 | #endif
|
---|
[113] | 203 | {
|
---|
| 204 | sLeft = strip(word(sLine, 1));
|
---|
| 205 | sRight = strip(word(sLine, 2));
|
---|
| 206 | if (sLeft != '' && sRight != '')
|
---|
| 207 | return true;
|
---|
| 208 | }
|
---|
| 209 |
|
---|
| 210 | /* failed, try single line. */
|
---|
[2349] | 211 | #if __VERSION__>=14.0
|
---|
| 212 | GetComments(aComments, "linecomment", sLexer)
|
---|
| 213 | for (i = 0; i < aComments._length(); i++)
|
---|
| 214 | if (!pos("documentation", aComments[i]) > 0)
|
---|
| 215 | {
|
---|
| 216 | sLine = aComments[i];
|
---|
| 217 | break;
|
---|
| 218 | }
|
---|
| 219 | if (sLine != '')
|
---|
| 220 | #else
|
---|
[113] | 221 | rc = _ini_get_value(slick_path_search("user.vlx"), sLexer, 'linecomment', sLine);
|
---|
| 222 | if (rc)
|
---|
| 223 | rc = _ini_get_value(slick_path_search("vslick.vlx"), sLexer, 'linecomment', sLine);
|
---|
| 224 | if (!rc)
|
---|
[2349] | 225 | #endif
|
---|
[113] | 226 | {
|
---|
| 227 | sLeft = strip(word(sLine, 1));
|
---|
| 228 | sRight = '';
|
---|
| 229 | iColumn = 0;
|
---|
[214] | 230 | _str sTmp = word(sLine, 2);
|
---|
[113] | 231 | if (isnumber(sTmp))
|
---|
| 232 | iColumn = (int)sTmp;
|
---|
| 233 | if (sLeft != '')
|
---|
| 234 | return true;
|
---|
| 235 | }
|
---|
| 236 | }
|
---|
| 237 |
|
---|
| 238 | /*
|
---|
| 239 | * Read the nonboxchars and determin user or default box.ini.
|
---|
| 240 | */
|
---|
[214] | 241 | _str sFile = slick_path_search("ubox.ini");
|
---|
| 242 | boolean frc = _ini_get_value(sFile, sExt, 'nonboxchars', sLine);
|
---|
[113] | 243 | if (frc)
|
---|
| 244 | {
|
---|
[214] | 245 | sFile = slick_path_search("box.ini");
|
---|
[113] | 246 | frc = _ini_get_value(sFile, sExt, 'nonboxchars', sLine);
|
---|
| 247 | }
|
---|
| 248 |
|
---|
| 249 | if (!frc)
|
---|
| 250 | { /*
|
---|
| 251 | * Found extension.
|
---|
| 252 | */
|
---|
| 253 | sLeft = strip(eq_name2value('left',sLine));
|
---|
| 254 | if (sLeft == '\e') sLeft = '';
|
---|
| 255 | sRight = strip(eq_name2value('right',sLine));
|
---|
| 256 | if (sRight == '\e') sRight = '';
|
---|
| 257 |
|
---|
| 258 | /* Read comment column too */
|
---|
| 259 | frc = _ini_get_value(sFile, sExt, 'comment_col', sLine);
|
---|
| 260 | if (frc)
|
---|
| 261 | {
|
---|
| 262 | iColumn = eq_name2value('comment_col', sLine);
|
---|
| 263 | if (iColumn == '\e') iColumn = 0;
|
---|
| 264 | }
|
---|
| 265 | else
|
---|
| 266 | iColumn = 0;
|
---|
| 267 | return true;
|
---|
| 268 | }
|
---|
| 269 |
|
---|
| 270 | /* failure */
|
---|
| 271 | sLeft = sRight = '';
|
---|
| 272 | iColumn = 0;
|
---|
| 273 |
|
---|
| 274 | return false;
|
---|
| 275 | }
|
---|
| 276 |
|
---|
| 277 |
|
---|
| 278 | /**
|
---|
| 279 | * Checks if current file only support line comments.
|
---|
| 280 | * @returns True / False.
|
---|
| 281 | * @remark Use builtin extension stuff!
|
---|
| 282 | */
|
---|
| 283 | static boolean k_line_comment()
|
---|
| 284 | {
|
---|
| 285 | _str sRight = '';
|
---|
[214] | 286 | _str sLeft = '';
|
---|
| 287 | int iColumn;
|
---|
[113] | 288 | boolean fLineComment = false;
|
---|
| 289 | if (k_commentconfig(sLeft, sRight, iColumn))
|
---|
| 290 | fLineComment = (sRight == '' || iColumn > 0);
|
---|
| 291 | return fLineComment;
|
---|
| 292 | }
|
---|
| 293 |
|
---|
| 294 |
|
---|
| 295 |
|
---|
| 296 | #define KIC_CURSOR_BEFORE 1
|
---|
| 297 | #define KIC_CURSOR_AFTER 2
|
---|
| 298 | #define KIC_CURSOR_AT_END 3
|
---|
| 299 |
|
---|
| 300 | /**
|
---|
| 301 | * Insert a comment at current or best fitting position in the text.
|
---|
| 302 | * @param sStr The comment to insert.
|
---|
| 303 | * @param iCursor Where to put the cursor.
|
---|
| 304 | * @param iPosition Where to start the comment.
|
---|
| 305 | * Doesn't apply to column based source.
|
---|
| 306 | * -1 means at cursor position. (default)
|
---|
| 307 | * >0 means at end of line, but not before this column (1-based).
|
---|
| 308 | * This also implies a min of one space to EOL.
|
---|
| 309 | */
|
---|
| 310 | void k_insert_comment(_str sStr, int iCursor, int iPosition = -1)
|
---|
| 311 | {
|
---|
| 312 | _str sLeft;
|
---|
| 313 | _str sRight;
|
---|
| 314 | int iColumn;
|
---|
| 315 | if (!k_commentconfig(sLeft, sRight, iColumn))
|
---|
| 316 | {
|
---|
| 317 | sLeft = '/*'; sRight = '*/'; iColumn = 0;
|
---|
| 318 | }
|
---|
| 319 |
|
---|
[214] | 320 | int iCol = 0;
|
---|
[113] | 321 | if (iColumn <= 0)
|
---|
| 322 | { /*
|
---|
| 323 | * not column based source
|
---|
| 324 | */
|
---|
| 325 |
|
---|
| 326 | /* position us first */
|
---|
| 327 | if (iPosition > 0)
|
---|
| 328 | {
|
---|
| 329 | end_line();
|
---|
| 330 | do {
|
---|
| 331 | _insert_text(" ");
|
---|
| 332 | } while (p_col < iPosition);
|
---|
| 333 | }
|
---|
| 334 |
|
---|
| 335 | /* insert comment saving the position for _BEFORE. */
|
---|
| 336 | iCol = p_col;
|
---|
| 337 | _insert_text(sLeft:+' ':+sStr);
|
---|
| 338 | if (iCursor == KIC_CURSOR_AT_END)
|
---|
| 339 | iCol = p_col;
|
---|
| 340 | /* right comment delimiter? */
|
---|
| 341 | if (sRight != '')
|
---|
| 342 | _insert_text(' ':+sRight);
|
---|
| 343 | }
|
---|
| 344 | else
|
---|
| 345 | {
|
---|
| 346 | if (p_col >= iColumn)
|
---|
| 347 | _insert_text("\n");
|
---|
| 348 | do { _insert_text(" "); } while (p_col < iColumn);
|
---|
| 349 | if (iCursor == KIC_CURSOR_BEFORE)
|
---|
| 350 | iCol = p_col;
|
---|
| 351 | _insert_text(sLeft:+' ':+sStr);
|
---|
| 352 | if (iCursor == KIC_CURSOR_AT_END)
|
---|
| 353 | iCol = p_col;
|
---|
| 354 | }
|
---|
| 355 |
|
---|
| 356 | /* set cursor. */
|
---|
| 357 | if (iCursor != KIC_CURSOR_AFTER)
|
---|
| 358 | p_col = iCol;
|
---|
| 359 | }
|
---|
| 360 |
|
---|
| 361 |
|
---|
| 362 | /**
|
---|
| 363 | * Gets the comment prefix or postfix.
|
---|
| 364 | * @returns Comment prefix or postfix.
|
---|
| 365 | * @param fRight If clear left comment string - default.
|
---|
| 366 | * If set right comment string.
|
---|
| 367 | */
|
---|
| 368 | static _str k_comment(boolean fRight = false)
|
---|
| 369 | {
|
---|
[214] | 370 | _str sLeft, sRight;
|
---|
| 371 | int iColumn;
|
---|
| 372 | _str sComment = '/*';
|
---|
[113] | 373 | if (k_commentconfig(sLeft, sRight, iColumn))
|
---|
| 374 | sComment = (!fRight || iColumn > 0 ? sLeft : sRight);
|
---|
| 375 |
|
---|
| 376 | return strip(sComment);
|
---|
| 377 | }
|
---|
| 378 |
|
---|
| 379 |
|
---|
| 380 | /*******************************************************************************
|
---|
| 381 | * BOXES *
|
---|
| 382 | *******************************************************************************/
|
---|
| 383 |
|
---|
| 384 | /**
|
---|
| 385 | * Inserts the first line in a box.
|
---|
| 386 | * @param sTag Not used - box tag.
|
---|
| 387 | */
|
---|
| 388 | static void k_box_start(sTag)
|
---|
| 389 | {
|
---|
[214] | 390 | _str sLeft, sRight;
|
---|
| 391 | int iColumn;
|
---|
[113] | 392 | if (!k_commentconfig(sLeft, sRight, iColumn))
|
---|
| 393 | return;
|
---|
| 394 | _begin_line();
|
---|
| 395 | if (iColumn >= 0)
|
---|
| 396 | while (p_col < iColumn)
|
---|
| 397 | _insert_text(" ");
|
---|
| 398 |
|
---|
[214] | 399 | _str sText = sLeft;
|
---|
[113] | 400 | if (sTag != '' && fkStyleBoxTag)
|
---|
| 401 | {
|
---|
| 402 | if (substr(sText, length(sText)) != '*')
|
---|
| 403 | sText = sText:+'*';
|
---|
| 404 | sText = sText:+sTag;
|
---|
| 405 | }
|
---|
| 406 |
|
---|
[214] | 407 | int i;
|
---|
[113] | 408 | for (i = length(sText); i <= ikStyleWidth - p_col; i++)
|
---|
| 409 | sText = sText:+'*';
|
---|
| 410 | sText = sText:+"\n";
|
---|
| 411 |
|
---|
| 412 | _insert_text(sText);
|
---|
| 413 | }
|
---|
| 414 |
|
---|
| 415 |
|
---|
| 416 | /**
|
---|
| 417 | * Places a string, sStr, into a line started and ended by '*'.
|
---|
| 418 | * @param sStr Text to have between the '*'s.
|
---|
| 419 | */
|
---|
| 420 | static void k_box_line(_str sStr)
|
---|
| 421 | {
|
---|
[214] | 422 | _str sLeft, sRight;
|
---|
| 423 | int iColumn;
|
---|
[113] | 424 | if (!k_commentconfig(sLeft, sRight, iColumn))
|
---|
| 425 | return;
|
---|
| 426 | if (iColumn >= 0)
|
---|
| 427 | while (p_col < iColumn)
|
---|
| 428 | _insert_text(" ");
|
---|
| 429 |
|
---|
[214] | 430 | _str sText = '';
|
---|
[113] | 431 | if (k_line_comment())
|
---|
| 432 | sText = sLeft;
|
---|
| 433 | if (sText == '' || substr(sText, length(sText)) != '*')
|
---|
| 434 | sText = sText:+'*';
|
---|
| 435 |
|
---|
| 436 | sText = sText:+' ';
|
---|
[214] | 437 | int i;
|
---|
[113] | 438 | for (i = length(sText); i < p_SyntaxIndent; i++)
|
---|
| 439 | sText = sText:+' ';
|
---|
| 440 |
|
---|
| 441 | sText = sText:+sStr;
|
---|
| 442 |
|
---|
| 443 | for (i = length(sText) + 1; i <= ikStyleWidth - p_col; i++)
|
---|
| 444 | sText = sText:+' ';
|
---|
| 445 | sText = sText:+"*\n";
|
---|
| 446 |
|
---|
| 447 | _insert_text(sText);
|
---|
| 448 | }
|
---|
| 449 |
|
---|
| 450 |
|
---|
| 451 | /**
|
---|
| 452 | * Inserts the last line in a box.
|
---|
| 453 | */
|
---|
| 454 | static void k_box_end()
|
---|
| 455 | {
|
---|
[214] | 456 | _str sLeft, sRight;
|
---|
| 457 | int iColumn, i;
|
---|
[113] | 458 | if (!k_commentconfig(sLeft, sRight, iColumn))
|
---|
| 459 | return;
|
---|
| 460 | if (iColumn >= 0)
|
---|
| 461 | while (p_col < iColumn)
|
---|
| 462 | _insert_text(" ");
|
---|
| 463 |
|
---|
[214] | 464 | _str sText = '';
|
---|
[113] | 465 | if (k_line_comment())
|
---|
| 466 | sText = sLeft;
|
---|
| 467 | for (i = length(sText) + length(sRight); i <= ikStyleWidth - p_col; i++)
|
---|
| 468 | sText = sText:+'*';
|
---|
| 469 | sText = sText:+sRight:+"\n";
|
---|
| 470 |
|
---|
| 471 | _insert_text(sText);
|
---|
| 472 | }
|
---|
| 473 |
|
---|
| 474 |
|
---|
| 475 |
|
---|
| 476 | /*******************************************************************************
|
---|
| 477 | * FUNCTION AND CODE PARSERS *
|
---|
| 478 | *******************************************************************************/
|
---|
| 479 | /**
|
---|
| 480 | * Moves cursor to nearest function start.
|
---|
| 481 | * @returns 0 if ok.
|
---|
| 482 | * -1 on failure.
|
---|
| 483 | */
|
---|
| 484 | static int k_func_goto_nearest_function()
|
---|
| 485 | {
|
---|
| 486 | boolean fFix = false; /* cursor at function fix. (last function) */
|
---|
[214] | 487 | int cur_line = p_line;
|
---|
| 488 | int prev_line = -1;
|
---|
| 489 | int next_line = -1;
|
---|
| 490 | typeless org_pos;
|
---|
[113] | 491 | _save_pos2(org_pos);
|
---|
| 492 |
|
---|
| 493 | if (!next_proc(1))
|
---|
| 494 | {
|
---|
| 495 | next_line = p_line;
|
---|
| 496 | if (!prev_proc(1) && p_line == cur_line)
|
---|
| 497 | {
|
---|
| 498 | _restore_pos2(org_pos);
|
---|
| 499 | return 0;
|
---|
| 500 | }
|
---|
| 501 | _restore_pos2(org_pos);
|
---|
| 502 | _save_pos2(org_pos);
|
---|
| 503 | }
|
---|
| 504 | else
|
---|
| 505 | {
|
---|
| 506 | p_col++; /* fixes problem with single function files. */
|
---|
| 507 | fFix = true;
|
---|
| 508 | }
|
---|
| 509 |
|
---|
| 510 | if (!prev_proc(1))
|
---|
| 511 | {
|
---|
| 512 | prev_line = p_line;
|
---|
| 513 | if (!next_proc(1) && p_line == cur_line)
|
---|
| 514 | {
|
---|
| 515 | _restore_pos2(org_pos);
|
---|
| 516 | return 0;
|
---|
| 517 | }
|
---|
| 518 | _restore_pos2(org_pos);
|
---|
| 519 | _save_pos2(org_pos);
|
---|
| 520 | }
|
---|
| 521 |
|
---|
| 522 |
|
---|
| 523 | if (prev_line != -1 && (next_line == -1 || cur_line - prev_line <= next_line - cur_line))
|
---|
| 524 | {
|
---|
| 525 | if (fFix)
|
---|
| 526 | p_col++;
|
---|
| 527 | prev_proc(1);
|
---|
| 528 | return 0;
|
---|
| 529 | }
|
---|
| 530 |
|
---|
| 531 | if (next_line != -1 && (prev_line == -1 || cur_line - prev_line > next_line - cur_line))
|
---|
| 532 | {
|
---|
| 533 | next_proc();
|
---|
| 534 | return 0;
|
---|
| 535 | }
|
---|
| 536 |
|
---|
| 537 | _restore_pos2(org_pos);
|
---|
| 538 | return -1;
|
---|
| 539 | }
|
---|
| 540 |
|
---|
| 541 |
|
---|
| 542 | /**
|
---|
| 543 | * Check if nearest function is a prototype.
|
---|
| 544 | * @returns True if function prototype.
|
---|
| 545 | * False if not function prototype.
|
---|
| 546 | */
|
---|
| 547 | static boolean k_func_prototype()
|
---|
| 548 | {
|
---|
| 549 | /*
|
---|
| 550 | * Check if this is a real function implementation.
|
---|
| 551 | */
|
---|
[214] | 552 | typeless procpos;
|
---|
[113] | 553 | _save_pos2(procpos);
|
---|
[214] | 554 | if (!k_func_goto_nearest_function())
|
---|
[113] | 555 | {
|
---|
[214] | 556 | int proc_line = p_line;
|
---|
[113] | 557 |
|
---|
| 558 | if (!k_func_searchcode("{"))
|
---|
| 559 | {
|
---|
| 560 | prev_proc();
|
---|
| 561 | if (p_line != proc_line)
|
---|
| 562 | {
|
---|
| 563 | _restore_pos2(procpos);
|
---|
| 564 | return true;
|
---|
| 565 | }
|
---|
| 566 | }
|
---|
| 567 | }
|
---|
| 568 | _restore_pos2(procpos);
|
---|
| 569 |
|
---|
| 570 | return false;
|
---|
| 571 | }
|
---|
| 572 |
|
---|
| 573 |
|
---|
| 574 | /**
|
---|
| 575 | * Gets the name fo the current function.
|
---|
| 576 | * @returns The current function name.
|
---|
| 577 | */
|
---|
| 578 | static _str k_func_getfunction_name()
|
---|
| 579 | {
|
---|
[214] | 580 | _str sFunctionName = current_proc();
|
---|
[113] | 581 | if (!sFunctionName)
|
---|
| 582 | sFunctionName = "";
|
---|
| 583 | //say 'functionanme='sFunctionName;
|
---|
| 584 | return sFunctionName;
|
---|
| 585 | }
|
---|
| 586 |
|
---|
| 587 |
|
---|
| 588 | /**
|
---|
| 589 | * Goes to the neares function and gets its parameters.
|
---|
| 590 | * @remark Should be reimplemented to use tags (if someone can figure out how to query that stuff).
|
---|
| 591 | */
|
---|
| 592 | static _str k_func_getparams()
|
---|
| 593 | {
|
---|
[214] | 594 | typeless org_pos;
|
---|
[113] | 595 | _save_pos2(org_pos);
|
---|
| 596 |
|
---|
| 597 | /*
|
---|
[214] | 598 | * Try use the tags first.
|
---|
| 599 | */
|
---|
| 600 | _UpdateContext(true);
|
---|
| 601 | int context_id = tag_current_context();
|
---|
| 602 | if (context_id <= 0)
|
---|
| 603 | {
|
---|
| 604 | k_func_goto_nearest_function();
|
---|
| 605 | context_id = tag_current_context();
|
---|
| 606 | }
|
---|
| 607 | if (context_id > 0)
|
---|
| 608 | {
|
---|
| 609 | _str args = '';
|
---|
| 610 | _str type = '';
|
---|
| 611 | tag_get_detail2(VS_TAGDETAIL_context_args, context_id, args);
|
---|
| 612 | tag_get_detail2(VS_TAGDETAIL_context_type, context_id, type);
|
---|
| 613 | if (tag_tree_type_is_func(type))
|
---|
| 614 | return args
|
---|
| 615 | //caption = tag_tree_make_caption_fast(VS_TAGMATCH_context,context_id,true,true,false);
|
---|
| 616 | }
|
---|
| 617 |
|
---|
| 618 | /*
|
---|
[113] | 619 | * Go to nearest function.
|
---|
| 620 | */
|
---|
| 621 | if ( !k_func_goto_nearest_function()
|
---|
| 622 | && !k_func_searchcode("(") /* makes some assumptions. */
|
---|
| 623 | )
|
---|
| 624 | {
|
---|
| 625 | /*
|
---|
| 626 | * Get parameters.
|
---|
| 627 | */
|
---|
[214] | 628 | typeless posStart;
|
---|
[113] | 629 | _save_pos2(posStart);
|
---|
[214] | 630 | long offStart = _QROffset();
|
---|
[113] | 631 | if (!find_matching_paren())
|
---|
| 632 | {
|
---|
[214] | 633 | long offEnd = _QROffset();
|
---|
[113] | 634 | _restore_pos2(posStart);
|
---|
| 635 | p_col++;
|
---|
[214] | 636 | _str sParamsRaw = strip(get_text((int)(offEnd - offStart - 1)));
|
---|
[113] | 637 |
|
---|
| 638 |
|
---|
| 639 | /*
|
---|
| 640 | * Remove new lines and double spaces within params.
|
---|
| 641 | */
|
---|
| 642 | _str sParams = "";
|
---|
| 643 |
|
---|
| 644 | int i;
|
---|
[214] | 645 | _str chPrev;
|
---|
[113] | 646 | for (i = 1, chPrev = ' '; i <= length(sParamsRaw); i++)
|
---|
| 647 | {
|
---|
[214] | 648 | _str ch = substr(sParamsRaw, i, 1);
|
---|
[113] | 649 |
|
---|
| 650 | /*
|
---|
| 651 | * Do fixups.
|
---|
| 652 | */
|
---|
| 653 | if (ch == " " && chPrev == " ")
|
---|
| 654 | continue;
|
---|
| 655 |
|
---|
| 656 | if ((ch :== "\n") || (ch :== "\r") || (ch :== "\t"))
|
---|
| 657 | {
|
---|
| 658 | if (chPrev == ' ')
|
---|
| 659 | continue;
|
---|
| 660 | ch = ' ';
|
---|
| 661 | }
|
---|
| 662 |
|
---|
| 663 | if (ch == ',' && chPrev == ' ')
|
---|
| 664 | {
|
---|
| 665 | sParams = substr(sParams, 1, length(sParams) - 1);
|
---|
| 666 | }
|
---|
| 667 |
|
---|
| 668 | if (ch == '*')
|
---|
| 669 | {
|
---|
| 670 | if (chPrev != ' ')
|
---|
| 671 | sParams = sParams :+ ' * ';
|
---|
| 672 | else
|
---|
| 673 | sParams = sParams :+ '* ';
|
---|
| 674 | chPrev = ' ';
|
---|
| 675 | }
|
---|
| 676 | else
|
---|
| 677 | {
|
---|
| 678 | sParams = sParams :+ ch;
|
---|
| 679 | chPrev = ch;
|
---|
| 680 | }
|
---|
| 681 |
|
---|
| 682 | } /* for */
|
---|
| 683 |
|
---|
| 684 | sParams = strip(sParams);
|
---|
| 685 | if (sParams == 'void' || sParams == 'VOID')
|
---|
| 686 | sParams = "";
|
---|
| 687 | _restore_pos2(org_pos);
|
---|
| 688 | return sParams;
|
---|
| 689 | }
|
---|
| 690 | else
|
---|
| 691 | message("find_matchin_paren failed");
|
---|
| 692 | }
|
---|
| 693 |
|
---|
| 694 | _restore_pos2(org_pos);
|
---|
| 695 | return false;
|
---|
| 696 | }
|
---|
| 697 |
|
---|
| 698 |
|
---|
| 699 |
|
---|
| 700 | /**
|
---|
| 701 | * Enumerates the parameters to the function.
|
---|
| 702 | * @param sParams Parameter string from k_func_getparams.
|
---|
| 703 | * @param iParam The index (0-based) of the parameter to get.
|
---|
| 704 | * @param sType Type. (output)
|
---|
| 705 | * @param sName Name. (output)
|
---|
| 706 | * @param sDefault Default value. (output)
|
---|
| 707 | * @remark Doesn't perhaps handle function pointers very well (I think)?
|
---|
| 708 | * @remark Should be reimplemented to use tags (if someone can figure out how to query that stuff).
|
---|
| 709 | */
|
---|
| 710 | static int k_func_enumparams(_str sParams, int iParam, _str &sType, _str &sName, _str &sDefault)
|
---|
| 711 | {
|
---|
| 712 | int i;
|
---|
| 713 | int iParLevel;
|
---|
| 714 | int iCurParam;
|
---|
| 715 | int iStartParam;
|
---|
| 716 |
|
---|
| 717 | sType = sName = sDefault = "";
|
---|
| 718 |
|
---|
| 719 | /* no use working on empty string! */
|
---|
| 720 | if (length(sParams) == 0)
|
---|
| 721 | return -1;
|
---|
| 722 |
|
---|
| 723 | /* find the parameter in question */
|
---|
| 724 | for (iStartParam = i = 1, iParLevel = iCurParam = 0; i <= length(sParams); i++)
|
---|
| 725 | {
|
---|
| 726 | _str ch = substr(sParams, i, 1);
|
---|
| 727 | if (ch == ',' && iParLevel == 0)
|
---|
| 728 | {
|
---|
| 729 | /* is it this parameter ? */
|
---|
| 730 | if (iParam == iCurParam)
|
---|
| 731 | break;
|
---|
| 732 |
|
---|
| 733 | iCurParam++;
|
---|
| 734 | iStartParam = i + 1;
|
---|
| 735 | }
|
---|
| 736 | else if (ch == '(')
|
---|
| 737 | iParLevel++;
|
---|
| 738 | else if (ch == ')')
|
---|
| 739 | iParLevel--;
|
---|
| 740 | }
|
---|
| 741 |
|
---|
| 742 | /* did we find the parameter? */
|
---|
| 743 | if (iParam == iCurParam)
|
---|
| 744 | { /* (yeah, we did!) */
|
---|
[214] | 745 | _str sArg = strip(substr(sParams, iStartParam, i - iStartParam));
|
---|
[113] | 746 | /* remove M$ stuff */
|
---|
| 747 | sArg = stranslate(sArg, "", "IN", "E");
|
---|
| 748 | sArg = stranslate(sArg, "", "OUT", "E");
|
---|
| 749 | sArg = stranslate(sArg, "", "OPTIONAL", "E");
|
---|
| 750 | sArg = strip(sArg);
|
---|
| 751 |
|
---|
| 752 | /* lazy approach, which doens't support function types */
|
---|
| 753 |
|
---|
| 754 | if (pos('=', sParams) > 0) /* default */
|
---|
| 755 | {
|
---|
| 756 | sDefault = strip(substr(sParams, pos('=', sParams) + 1));
|
---|
| 757 | sArg = strip(substr(sArg, 1, pos('=', sParams) - 1));
|
---|
| 758 | }
|
---|
| 759 |
|
---|
| 760 | for (i = length(sArg); i > 1; i--)
|
---|
| 761 | {
|
---|
| 762 | _str ch = substr(sArg, i, 1);
|
---|
| 763 | if ( !(ch >= 'a' && ch <= 'z')
|
---|
| 764 | && !(ch >= 'A' && ch <= 'Z')
|
---|
| 765 | && !(ch >= '0' && ch <= '9')
|
---|
| 766 | && ch != '_' && ch != '$')
|
---|
| 767 | break;
|
---|
| 768 | }
|
---|
| 769 | if (sArg == "...")
|
---|
| 770 | i = 0;
|
---|
| 771 | sName = strip(substr(sArg, i + 1));
|
---|
| 772 | sType = strip(substr(sArg, 1, i));
|
---|
| 773 |
|
---|
| 774 | return 0;
|
---|
| 775 | }
|
---|
| 776 |
|
---|
| 777 | return -1;
|
---|
| 778 | }
|
---|
| 779 |
|
---|
| 780 |
|
---|
| 781 | /**
|
---|
| 782 | * Counts the parameters to the function.
|
---|
| 783 | * @param sParams Parameter string from k_func_getparams.
|
---|
| 784 | * @remark Should be reimplemented to use tags (if someone can figure out how to query that stuff).
|
---|
| 785 | */
|
---|
| 786 | static int k_func_countparams(_str sParams)
|
---|
| 787 | {
|
---|
| 788 | int i;
|
---|
| 789 | int iParLevel;
|
---|
| 790 | int iCurParam;
|
---|
[214] | 791 | _str sType = "", sName = "", sDefault = "";
|
---|
[113] | 792 |
|
---|
| 793 | /* check for 0 parameters */
|
---|
| 794 | if (length(sParams) == 0)
|
---|
| 795 | return 0;
|
---|
| 796 |
|
---|
| 797 | /* find the parameter in question */
|
---|
| 798 | for (i = 1, iParLevel = iCurParam = 0; i <= length(sParams); i++)
|
---|
| 799 | {
|
---|
| 800 | _str ch = substr(sParams, i, 1);
|
---|
| 801 | if (ch == ',' && iParLevel == 0)
|
---|
| 802 | {
|
---|
| 803 | iCurParam++;
|
---|
| 804 | }
|
---|
| 805 | else if (ch == '(')
|
---|
| 806 | iParLevel++;
|
---|
| 807 | else if (ch == ')')
|
---|
| 808 | iParLevel--;
|
---|
| 809 | }
|
---|
| 810 |
|
---|
| 811 | return iCurParam + 1;
|
---|
| 812 | }
|
---|
| 813 |
|
---|
| 814 |
|
---|
| 815 | /**
|
---|
| 816 | * Gets the return type.
|
---|
| 817 | */
|
---|
| 818 | static _str k_func_getreturntype(boolean fPureType = false)
|
---|
| 819 | {
|
---|
[214] | 820 | typeless org_pos;
|
---|
[113] | 821 | _save_pos2(org_pos);
|
---|
| 822 |
|
---|
| 823 | /*
|
---|
| 824 | * Go to nearest function.
|
---|
| 825 | */
|
---|
| 826 | if (!k_func_goto_nearest_function())
|
---|
| 827 | {
|
---|
| 828 | /*
|
---|
| 829 | * Return type is from function start to function name...
|
---|
| 830 | */
|
---|
[214] | 831 | typeless posStart;
|
---|
[113] | 832 | _save_pos2(posStart);
|
---|
[214] | 833 | long offStart = _QROffset();
|
---|
[113] | 834 |
|
---|
| 835 | if (!k_func_searchcode("(")) /* makes some assumptions. */
|
---|
| 836 | {
|
---|
| 837 | prev_word();
|
---|
[214] | 838 | long offEnd = _QROffset();
|
---|
[113] | 839 | _restore_pos2(posStart);
|
---|
[214] | 840 | _str sTypeRaw = strip(get_text((int)(offEnd - offStart)));
|
---|
[113] | 841 |
|
---|
| 842 | //say 'sTypeRaw='sTypeRaw;
|
---|
| 843 | /*
|
---|
| 844 | * Remove static, inline, _Optlink, stdcall, EXPENTRY etc.
|
---|
| 845 | */
|
---|
| 846 | if (fPureType)
|
---|
| 847 | {
|
---|
| 848 | sTypeRaw = stranslate(sTypeRaw, "", "__static__", "I");
|
---|
| 849 | sTypeRaw = stranslate(sTypeRaw, "", "__static", "I");
|
---|
| 850 | sTypeRaw = stranslate(sTypeRaw, "", "static__", "I");
|
---|
| 851 | sTypeRaw = stranslate(sTypeRaw, "", "static", "I");
|
---|
| 852 | sTypeRaw = stranslate(sTypeRaw, "", "__inline__", "I");
|
---|
| 853 | sTypeRaw = stranslate(sTypeRaw, "", "__inline", "I");
|
---|
| 854 | sTypeRaw = stranslate(sTypeRaw, "", "inline__", "I");
|
---|
| 855 | sTypeRaw = stranslate(sTypeRaw, "", "inline", "I");
|
---|
| 856 | sTypeRaw = stranslate(sTypeRaw, "", "EXPENTRY", "I");
|
---|
| 857 | sTypeRaw = stranslate(sTypeRaw, "", "_Optlink", "I");
|
---|
| 858 | sTypeRaw = stranslate(sTypeRaw, "", "__stdcall", "I");
|
---|
| 859 | sTypeRaw = stranslate(sTypeRaw, "", "__cdecl", "I");
|
---|
| 860 | sTypeRaw = stranslate(sTypeRaw, "", "_cdecl", "I");
|
---|
| 861 | sTypeRaw = stranslate(sTypeRaw, "", "cdecl", "I");
|
---|
| 862 | sTypeRaw = stranslate(sTypeRaw, "", "__PASCAL", "I");
|
---|
| 863 | sTypeRaw = stranslate(sTypeRaw, "", "_PASCAL", "I");
|
---|
| 864 | sTypeRaw = stranslate(sTypeRaw, "", "PASCAL", "I");
|
---|
| 865 | sTypeRaw = stranslate(sTypeRaw, "", "__Far32__", "I");
|
---|
| 866 | sTypeRaw = stranslate(sTypeRaw, "", "__Far32", "I");
|
---|
| 867 | sTypeRaw = stranslate(sTypeRaw, "", "Far32__", "I");
|
---|
| 868 | sTypeRaw = stranslate(sTypeRaw, "", "_Far32_", "I");
|
---|
| 869 | sTypeRaw = stranslate(sTypeRaw, "", "_Far32", "I");
|
---|
| 870 | sTypeRaw = stranslate(sTypeRaw, "", "Far32_", "I");
|
---|
| 871 | sTypeRaw = stranslate(sTypeRaw, "", "Far32", "I");
|
---|
| 872 | sTypeRaw = stranslate(sTypeRaw, "", "__far", "I");
|
---|
| 873 | sTypeRaw = stranslate(sTypeRaw, "", "_far", "I");
|
---|
| 874 | sTypeRaw = stranslate(sTypeRaw, "", "far", "I");
|
---|
| 875 | sTypeRaw = stranslate(sTypeRaw, "", "__near", "I");
|
---|
| 876 | sTypeRaw = stranslate(sTypeRaw, "", "_near", "I");
|
---|
| 877 | sTypeRaw = stranslate(sTypeRaw, "", "near", "I");
|
---|
| 878 | sTypeRaw = stranslate(sTypeRaw, "", "__loadds__", "I");
|
---|
| 879 | sTypeRaw = stranslate(sTypeRaw, "", "__loadds", "I");
|
---|
| 880 | sTypeRaw = stranslate(sTypeRaw, "", "loadds__", "I");
|
---|
| 881 | sTypeRaw = stranslate(sTypeRaw, "", "_loadds_", "I");
|
---|
| 882 | sTypeRaw = stranslate(sTypeRaw, "", "_loadds", "I");
|
---|
| 883 | sTypeRaw = stranslate(sTypeRaw, "", "loadds_", "I");
|
---|
| 884 | sTypeRaw = stranslate(sTypeRaw, "", "loadds", "I");
|
---|
| 885 | sTypeRaw = stranslate(sTypeRaw, "", "__loades__", "I");
|
---|
| 886 | sTypeRaw = stranslate(sTypeRaw, "", "__loades", "I");
|
---|
| 887 | sTypeRaw = stranslate(sTypeRaw, "", "loades__", "I");
|
---|
| 888 | sTypeRaw = stranslate(sTypeRaw, "", "_loades_", "I");
|
---|
| 889 | sTypeRaw = stranslate(sTypeRaw, "", "_loades", "I");
|
---|
| 890 | sTypeRaw = stranslate(sTypeRaw, "", "loades_", "I");
|
---|
| 891 | sTypeRaw = stranslate(sTypeRaw, "", "loades", "I");
|
---|
| 892 | sTypeRaw = stranslate(sTypeRaw, "", "WIN32API", "I");
|
---|
| 893 | sTypeRaw = stranslate(sTypeRaw, "", "WINAPI", "I");
|
---|
| 894 | sTypeRaw = stranslate(sTypeRaw, "", "LDRCALL", "I");
|
---|
| 895 | sTypeRaw = stranslate(sTypeRaw, "", "KRNLCALL", "I");
|
---|
| 896 | sTypeRaw = stranslate(sTypeRaw, "", "__operator__", "I"); /* operator fix */
|
---|
| 897 | sTypeRaw = stranslate(sTypeRaw, "", "__operator", "I"); /* operator fix */
|
---|
| 898 | sTypeRaw = stranslate(sTypeRaw, "", "operator__", "I"); /* operator fix */
|
---|
| 899 | sTypeRaw = stranslate(sTypeRaw, "", "operator", "I"); /* operator fix */
|
---|
| 900 | sTypeRaw = stranslate(sTypeRaw, "", "IN", "E");
|
---|
| 901 | sTypeRaw = stranslate(sTypeRaw, "", "OUT", "E");
|
---|
| 902 | sTypeRaw = stranslate(sTypeRaw, "", "OPTIONAL", "E");
|
---|
| 903 | }
|
---|
| 904 |
|
---|
| 905 | /*
|
---|
| 906 | * Remove new lines and double spaces within params.
|
---|
| 907 | */
|
---|
| 908 | _str sType = "";
|
---|
| 909 |
|
---|
| 910 | int i;
|
---|
[214] | 911 | _str chPrev;
|
---|
[113] | 912 | for (i = 1, chPrev = ' '; i <= length(sTypeRaw); i++)
|
---|
| 913 | {
|
---|
[214] | 914 | _str ch = substr(sTypeRaw, i, 1);
|
---|
[113] | 915 |
|
---|
| 916 | /*
|
---|
| 917 | * Do fixups.
|
---|
| 918 | */
|
---|
| 919 | if (ch == " " && chPrev == " ")
|
---|
| 920 | continue;
|
---|
| 921 |
|
---|
| 922 | if ((ch :== "\n") || (ch :== "\r") || (ch :== "\t"))
|
---|
| 923 | {
|
---|
| 924 | if (chPrev == ' ')
|
---|
| 925 | continue;
|
---|
| 926 | ch = ' ';
|
---|
| 927 | }
|
---|
| 928 |
|
---|
| 929 | if (ch == ',' && chPrev == ' ')
|
---|
| 930 | {
|
---|
| 931 | sType = substr(sType, 1, length(sType) - 1);
|
---|
| 932 | }
|
---|
| 933 |
|
---|
| 934 | if (ch == '*')
|
---|
| 935 | {
|
---|
| 936 | if (chPrev != ' ')
|
---|
| 937 | sType = sType :+ ' * ';
|
---|
| 938 | else
|
---|
| 939 | sType = sType :+ '* ';
|
---|
| 940 | chPrev = ' ';
|
---|
| 941 | }
|
---|
| 942 | else
|
---|
| 943 | {
|
---|
| 944 | sType = sType :+ ch;
|
---|
| 945 | chPrev = ch;
|
---|
| 946 | }
|
---|
| 947 |
|
---|
| 948 | } /* for */
|
---|
| 949 |
|
---|
| 950 | sType = strip(sType);
|
---|
| 951 |
|
---|
| 952 | _restore_pos2(org_pos);
|
---|
| 953 | return sType;
|
---|
| 954 | }
|
---|
| 955 | else
|
---|
| 956 | message('k_func_getreturntype: can''t find ''(''.');
|
---|
| 957 | }
|
---|
| 958 |
|
---|
| 959 | _restore_pos2(org_pos);
|
---|
| 960 | return false;
|
---|
| 961 | }
|
---|
| 962 |
|
---|
| 963 |
|
---|
| 964 | /**
|
---|
| 965 | * Search for some piece of code.
|
---|
| 966 | */
|
---|
| 967 | static int k_func_searchcode(_str sSearchString, _str sOptions = "E+")
|
---|
| 968 | {
|
---|
| 969 | int rc;
|
---|
| 970 | rc = search(sSearchString, sOptions);
|
---|
| 971 | while (!rc && !k_func_in_code())
|
---|
| 972 | {
|
---|
| 973 | p_col++;
|
---|
| 974 | rc = search(sSearchString, sOptions);
|
---|
| 975 | }
|
---|
| 976 | return rc;
|
---|
| 977 | }
|
---|
| 978 |
|
---|
| 979 |
|
---|
| 980 | /**
|
---|
| 981 | * Checks if cursor is in code or in comment.
|
---|
| 982 | * @return True if cursor in code.
|
---|
| 983 | */
|
---|
| 984 | static boolean k_func_in_code()
|
---|
| 985 | {
|
---|
[214] | 986 | typeless searchsave;
|
---|
[113] | 987 | _save_pos2(searchsave);
|
---|
| 988 | boolean fRc = !_in_comment();
|
---|
| 989 | _restore_pos2(searchsave);
|
---|
| 990 | return fRc;
|
---|
| 991 | }
|
---|
| 992 |
|
---|
| 993 |
|
---|
| 994 | /*
|
---|
| 995 | * Gets the next piece of code.
|
---|
| 996 | */
|
---|
| 997 | static _str k_func_get_next_code_text()
|
---|
| 998 | {
|
---|
[214] | 999 | typeless searchsave;
|
---|
[113] | 1000 | _save_pos2(searchsave);
|
---|
[214] | 1001 | _str ch = k_func_get_next_code_text2();
|
---|
[113] | 1002 | _restore_pos2(searchsave);
|
---|
| 1003 | return ch;
|
---|
| 1004 | }
|
---|
| 1005 |
|
---|
| 1006 |
|
---|
| 1007 | /**
|
---|
| 1008 | * Checks if there is more code on the line.
|
---|
| 1009 | */
|
---|
| 1010 | static boolean k_func_more_code_on_line()
|
---|
| 1011 | {
|
---|
| 1012 | boolean fRc;
|
---|
| 1013 | int curline = p_line;
|
---|
[214] | 1014 | typeless searchsave;
|
---|
[113] | 1015 | _save_pos2(searchsave);
|
---|
| 1016 | k_func_get_next_code_text2();
|
---|
| 1017 | fRc = curline == p_line;
|
---|
| 1018 | _restore_pos2(searchsave);
|
---|
| 1019 |
|
---|
| 1020 | return fRc;
|
---|
| 1021 | }
|
---|
| 1022 |
|
---|
| 1023 |
|
---|
| 1024 | /**
|
---|
| 1025 | * Gets the next piece of code.
|
---|
| 1026 | * Doesn't preserver cursor position.
|
---|
| 1027 | */
|
---|
| 1028 | static _str k_func_get_next_code_text2()
|
---|
| 1029 | {
|
---|
| 1030 | _str ch;
|
---|
| 1031 | do
|
---|
| 1032 | {
|
---|
[214] | 1033 | int curcol = ++p_col;
|
---|
| 1034 | end_line();
|
---|
[113] | 1035 | if (p_col <= curcol)
|
---|
| 1036 | {
|
---|
| 1037 | p_line++;
|
---|
| 1038 | p_col = 1;
|
---|
| 1039 | }
|
---|
| 1040 | else
|
---|
| 1041 | p_col = curcol;
|
---|
| 1042 |
|
---|
| 1043 | ch = get_text();
|
---|
| 1044 | //say ch ' ('_asc(ch)')';
|
---|
| 1045 | while (ch == "#") /* preprocessor stuff */
|
---|
| 1046 | {
|
---|
| 1047 | p_col = 1;
|
---|
| 1048 | p_line++;
|
---|
| 1049 | ch = get_text();
|
---|
| 1050 | //say ch ' ('_asc(ch)')';
|
---|
| 1051 | continue;
|
---|
| 1052 | }
|
---|
| 1053 | } while (ch :== ' ' || ch :== "\t" || ch :== "\n" || ch :== "\r" || !k_func_in_code());
|
---|
| 1054 |
|
---|
| 1055 | return ch;
|
---|
| 1056 | }
|
---|
| 1057 |
|
---|
| 1058 |
|
---|
| 1059 |
|
---|
| 1060 |
|
---|
| 1061 | /*******************************************************************************
|
---|
| 1062 | * JAVA DOC STYLED WORKERS *
|
---|
| 1063 | *******************************************************************************/
|
---|
| 1064 |
|
---|
| 1065 | /** starts a javadoc documentation box. */
|
---|
| 1066 | static void k_javadoc_box_start(_str sStr = '', boolean fDouble = true)
|
---|
| 1067 | {
|
---|
[214] | 1068 | _str sLeft, sRight;
|
---|
| 1069 | int iColumn;
|
---|
[113] | 1070 | if (!k_commentconfig(sLeft, sRight, iColumn))
|
---|
| 1071 | return;
|
---|
| 1072 | _begin_line();
|
---|
| 1073 | if (iColumn >= 0)
|
---|
| 1074 | while (p_col < iColumn)
|
---|
| 1075 | _insert_text(" ");
|
---|
| 1076 |
|
---|
[214] | 1077 | _str sText = sLeft;
|
---|
[113] | 1078 | if (fDouble)
|
---|
| 1079 | sText = sLeft:+substr(sLeft, length(sLeft), 1);
|
---|
| 1080 | if (sStr != '')
|
---|
| 1081 | sText = sText:+' ':+sStr;
|
---|
| 1082 | sText = sText:+"\n";
|
---|
| 1083 |
|
---|
| 1084 | _insert_text(sText);
|
---|
| 1085 | }
|
---|
| 1086 |
|
---|
| 1087 | /** inserts a new line in a javadoc documentation box. */
|
---|
| 1088 | static void k_javadoc_box_line(_str sStr = '', int iPadd = 0, _str sStr2 = '', int iPadd2 = 0, _str sStr3 = '')
|
---|
| 1089 | {
|
---|
[214] | 1090 | _str sLeft, sRight;
|
---|
| 1091 | int iColumn;
|
---|
[113] | 1092 | if (!k_commentconfig(sLeft, sRight, iColumn))
|
---|
| 1093 | return;
|
---|
| 1094 | if (iColumn >= 0)
|
---|
| 1095 | while (p_col < iColumn)
|
---|
| 1096 | _insert_text(" ");
|
---|
| 1097 |
|
---|
[214] | 1098 | _str sText;
|
---|
[113] | 1099 | if (k_line_comment())
|
---|
| 1100 | sText = sLeft;
|
---|
| 1101 | else
|
---|
| 1102 | {
|
---|
| 1103 | sText = sLeft;
|
---|
| 1104 | sText = ' ':+substr(sLeft, length(sLeft));
|
---|
| 1105 | }
|
---|
| 1106 |
|
---|
| 1107 | if (sStr != '')
|
---|
| 1108 | sText = sText:+' ':+sStr;
|
---|
| 1109 | if (iPadd > 0)
|
---|
| 1110 | {
|
---|
[214] | 1111 | int i;
|
---|
[113] | 1112 | for (i = length(sText); i < iPadd; i++)
|
---|
| 1113 | sText = sText:+' ';
|
---|
| 1114 |
|
---|
| 1115 | if (sStr2 != '')
|
---|
| 1116 | sText = sText:+sStr2;
|
---|
| 1117 |
|
---|
| 1118 | if (iPadd2 > 0)
|
---|
| 1119 | {
|
---|
| 1120 | for (i = length(sText); i < iPadd2; i++)
|
---|
| 1121 | sText = sText:+' ';
|
---|
| 1122 |
|
---|
| 1123 | if (sStr3 != '')
|
---|
| 1124 | sText = sText:+sStr3;
|
---|
| 1125 | }
|
---|
| 1126 | }
|
---|
| 1127 | sText = sText:+"\n";
|
---|
| 1128 |
|
---|
| 1129 | _insert_text(sText);
|
---|
| 1130 | }
|
---|
| 1131 |
|
---|
| 1132 | /** ends a javadoc documentation box. */
|
---|
| 1133 | static void k_javadoc_box_end()
|
---|
| 1134 | {
|
---|
[214] | 1135 | _str sLeft, sRight;
|
---|
| 1136 | int iColumn;
|
---|
[113] | 1137 | if (!k_commentconfig(sLeft, sRight, iColumn))
|
---|
| 1138 | return;
|
---|
| 1139 | if (iColumn >= 0)
|
---|
| 1140 | while (p_col < iColumn)
|
---|
| 1141 | _insert_text(" ");
|
---|
| 1142 |
|
---|
[214] | 1143 | _str sText;
|
---|
[113] | 1144 | if (k_line_comment())
|
---|
| 1145 | sText = sLeft;
|
---|
| 1146 | else
|
---|
| 1147 | {
|
---|
| 1148 | sText = sRight;
|
---|
| 1149 | /*if (substr(sText, 1, 1) != '*')
|
---|
| 1150 | sText = '*':+sText;*/
|
---|
| 1151 | sText = ' ':+sText;
|
---|
| 1152 | }
|
---|
| 1153 | sText = sText:+"\n";
|
---|
| 1154 |
|
---|
| 1155 | _insert_text(sText);
|
---|
| 1156 | }
|
---|
| 1157 |
|
---|
| 1158 |
|
---|
| 1159 | /**
|
---|
| 1160 | * Write a Javadoc styled classbox.
|
---|
| 1161 | */
|
---|
| 1162 | void k_javadoc_classbox()
|
---|
| 1163 | {
|
---|
| 1164 | int iCursorLine;
|
---|
| 1165 | int iPadd = k_alignup(12, p_SyntaxIndent);
|
---|
| 1166 |
|
---|
| 1167 | k_javadoc_box_start();
|
---|
| 1168 | iCursorLine = p_RLine;
|
---|
| 1169 | k_javadoc_box_line(' ');
|
---|
| 1170 |
|
---|
| 1171 | if (fkStyleFullHeaders)
|
---|
| 1172 | {
|
---|
| 1173 | k_javadoc_box_line('@shortdesc', iPadd);
|
---|
| 1174 | k_javadoc_box_line('@dstruct', iPadd);
|
---|
| 1175 | k_javadoc_box_line('@version', iPadd);
|
---|
| 1176 | k_javadoc_box_line('@verdesc', iPadd);
|
---|
| 1177 | }
|
---|
| 1178 | k_javadoc_box_line('@author', iPadd, skUserName ' <' skUserEmail '>');
|
---|
| 1179 | k_javadoc_box_line('@approval', iPadd);
|
---|
| 1180 | k_javadoc_box_end();
|
---|
| 1181 |
|
---|
| 1182 | up(p_RLine - iCursorLine);
|
---|
| 1183 | end_line();
|
---|
| 1184 | keyin(' ');
|
---|
| 1185 | }
|
---|
| 1186 |
|
---|
| 1187 |
|
---|
| 1188 | /**
|
---|
| 1189 | * Javadoc - functionbox(/header).
|
---|
| 1190 | */
|
---|
| 1191 | void k_javadoc_funcbox()
|
---|
| 1192 | {
|
---|
| 1193 | int cArgs = 1;
|
---|
| 1194 | _str sArgs = "";
|
---|
| 1195 | int iCursorLine;
|
---|
| 1196 | int iPadd = k_alignup(11, p_SyntaxIndent);
|
---|
[2349] | 1197 |
|
---|
[113] | 1198 | /* look for parameters */
|
---|
| 1199 | boolean fFoundFn = !k_func_goto_nearest_function();
|
---|
| 1200 | if (fFoundFn)
|
---|
| 1201 | {
|
---|
| 1202 | sArgs = k_func_getparams();
|
---|
| 1203 | cArgs = k_func_countparams(sArgs);
|
---|
| 1204 | }
|
---|
| 1205 |
|
---|
| 1206 | k_javadoc_box_start();
|
---|
| 1207 | iCursorLine = p_RLine;
|
---|
| 1208 | k_javadoc_box_line(' ');
|
---|
| 1209 | if (file_eq(p_extension, 'asm'))
|
---|
| 1210 | k_javadoc_box_line('@cproto', iPadd);
|
---|
| 1211 | k_javadoc_box_line('@returns', iPadd);
|
---|
| 1212 | if (fFoundFn)
|
---|
| 1213 | {
|
---|
| 1214 | /*
|
---|
| 1215 | * Determin parameter description indent.
|
---|
| 1216 | */
|
---|
| 1217 | int iPadd2 = 0;
|
---|
[214] | 1218 | int i;
|
---|
[113] | 1219 | for (i = 0; i < cArgs; i++)
|
---|
| 1220 | {
|
---|
| 1221 | _str sName, sType, sDefault;
|
---|
[2349] | 1222 | if ( !k_func_enumparams(sArgs, i, sType, sName, sDefault)
|
---|
[113] | 1223 | && iPadd2 < length(sName))
|
---|
| 1224 | iPadd2 = length(sName);
|
---|
| 1225 | }
|
---|
| 1226 | iPadd2 = k_alignup((iPadd + iPadd2), p_SyntaxIndent);
|
---|
[2349] | 1227 | if (iPadd2 < 28)
|
---|
| 1228 | iPadd2 = k_alignup(28, p_SyntaxIndent);
|
---|
[113] | 1229 |
|
---|
| 1230 | /*
|
---|
| 1231 | * Insert parameter.
|
---|
| 1232 | */
|
---|
| 1233 | for (i = 0; i < cArgs; i++)
|
---|
| 1234 | {
|
---|
| 1235 | _str sName, sType, sDefault;
|
---|
| 1236 | if (!k_func_enumparams(sArgs, i, sType, sName, sDefault))
|
---|
| 1237 | {
|
---|
[2349] | 1238 | _str sStr3 = '.';
|
---|
[113] | 1239 | if (sDefault != "")
|
---|
| 1240 | sStr3 = '(default='sDefault')';
|
---|
| 1241 | k_javadoc_box_line('@param', iPadd, sName, iPadd2, sStr3);
|
---|
| 1242 | }
|
---|
| 1243 | else
|
---|
| 1244 | k_javadoc_box_line('@param', iPadd);
|
---|
| 1245 | }
|
---|
| 1246 | }
|
---|
| 1247 | else
|
---|
| 1248 | k_javadoc_box_line('@param', iPadd);
|
---|
| 1249 |
|
---|
| 1250 | if (file_eq(p_extension, 'asm'))
|
---|
| 1251 | k_javadoc_box_line('@uses', iPadd);
|
---|
| 1252 | if (fkStyleFullHeaders)
|
---|
| 1253 | {
|
---|
| 1254 | k_javadoc_box_line('@equiv', iPadd);
|
---|
| 1255 | k_javadoc_box_line('@time', iPadd);
|
---|
| 1256 | k_javadoc_box_line('@sketch', iPadd);
|
---|
[214] | 1257 | k_javadoc_box_line('@status', iPadd);
|
---|
| 1258 | k_javadoc_box_line('@author', iPadd, skUserName ' <' skUserEmail '>');
|
---|
| 1259 | k_javadoc_box_line('@remark', iPadd);
|
---|
[113] | 1260 | }
|
---|
| 1261 | k_javadoc_box_end();
|
---|
| 1262 |
|
---|
| 1263 | up(p_RLine - iCursorLine);
|
---|
| 1264 | end_line();
|
---|
| 1265 | keyin(' ');
|
---|
| 1266 | }
|
---|
| 1267 |
|
---|
| 1268 |
|
---|
| 1269 | /**
|
---|
| 1270 | * Javadoc module header.
|
---|
| 1271 | */
|
---|
| 1272 | void k_javadoc_moduleheader()
|
---|
| 1273 | {
|
---|
| 1274 | int iCursorLine;
|
---|
[1085] | 1275 | int fSplit = 0;
|
---|
[113] | 1276 |
|
---|
[2019] | 1277 | _insert_text("\n");
|
---|
| 1278 | up();
|
---|
[113] | 1279 | _begin_line();
|
---|
| 1280 | k_insert_comment('$':+'I':+'d: $', KIC_CURSOR_AT_END, -1);
|
---|
| 1281 | _end_line();
|
---|
| 1282 | _insert_text("\n");
|
---|
| 1283 |
|
---|
| 1284 | k_javadoc_box_start('@file');
|
---|
[2019] | 1285 | fSplit = 1;
|
---|
| 1286 | iCursorLine = p_RLine;
|
---|
| 1287 | k_javadoc_box_line();
|
---|
| 1288 | k_javadoc_box_end();
|
---|
| 1289 | _insert_text("\n");
|
---|
| 1290 | _insert_text(k_comment() "\n");
|
---|
[113] | 1291 |
|
---|
| 1292 | if (skLicense == 'Confidential')
|
---|
| 1293 | {
|
---|
| 1294 | k_javadoc_box_line(skCompany ' confidential');
|
---|
| 1295 | k_javadoc_box_line();
|
---|
| 1296 | }
|
---|
| 1297 |
|
---|
| 1298 | if (skCompany != '')
|
---|
| 1299 | {
|
---|
[1647] | 1300 | if (skLicense != 'Confidential')
|
---|
[1085] | 1301 | k_javadoc_box_line('Copyright (C) ' k_year() ' ' skCompany);
|
---|
[784] | 1302 | else
|
---|
| 1303 | {
|
---|
| 1304 | k_javadoc_box_line('Copyright (c) ' k_year() ' ' skCompany);
|
---|
| 1305 | k_javadoc_box_line();
|
---|
| 1306 | k_javadoc_box_line('Author: ' skUserName' <' skUserEmail '>');
|
---|
| 1307 | }
|
---|
[113] | 1308 | }
|
---|
| 1309 | else
|
---|
| 1310 | k_javadoc_box_line('Copyright (c) ' k_year() ' 'skUserName' <' skUserEmail '>');
|
---|
| 1311 | k_javadoc_box_line();
|
---|
[2019] | 1312 | _str sProg = skProgram;
|
---|
[113] | 1313 | switch (skLicense)
|
---|
| 1314 | {
|
---|
| 1315 | case 'Odin32':
|
---|
| 1316 | k_javadoc_box_line('Project Odin Software License can be found in LICENSE.TXT.');
|
---|
| 1317 | break;
|
---|
| 1318 |
|
---|
| 1319 | case 'GPL':
|
---|
[1085] | 1320 | if (!fSplit)
|
---|
| 1321 | k_javadoc_box_line();
|
---|
[113] | 1322 | if (sProg == '')
|
---|
| 1323 | sProg = 'This program';
|
---|
| 1324 | else
|
---|
| 1325 | {
|
---|
| 1326 | k_javadoc_box_line('This file is part of ' sProg '.');
|
---|
| 1327 | k_javadoc_box_line();
|
---|
| 1328 | }
|
---|
| 1329 | k_javadoc_box_line(sProg ' is free software; you can redistribute it and/or modify');
|
---|
| 1330 | k_javadoc_box_line('it under the terms of the GNU General Public License as published by');
|
---|
| 1331 | k_javadoc_box_line('the Free Software Foundation; either version 2 of the License, or');
|
---|
| 1332 | k_javadoc_box_line('(at your option) any later version.');
|
---|
[214] | 1333 | k_javadoc_box_line();
|
---|
[113] | 1334 | k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful,');
|
---|
| 1335 | k_javadoc_box_line('but WITHOUT ANY WARRANTY; without even the implied warranty of');
|
---|
| 1336 | k_javadoc_box_line('MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the');
|
---|
| 1337 | k_javadoc_box_line('GNU General Public License for more details.');
|
---|
[214] | 1338 | k_javadoc_box_line();
|
---|
[113] | 1339 | k_javadoc_box_line('You should have received a copy of the GNU General Public License');
|
---|
| 1340 | k_javadoc_box_line('along with ' sProg '; if not, write to the Free Software');
|
---|
[1085] | 1341 | k_javadoc_box_line('Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA');
|
---|
[113] | 1342 | break;
|
---|
| 1343 |
|
---|
| 1344 | case 'LGPL':
|
---|
[1085] | 1345 | if (!fSplit)
|
---|
| 1346 | k_javadoc_box_line();
|
---|
[113] | 1347 | if (sProg == '')
|
---|
[1086] | 1348 | sProg = 'This library';
|
---|
[113] | 1349 | else
|
---|
| 1350 | {
|
---|
| 1351 | k_javadoc_box_line('This file is part of ' sProg '.');
|
---|
| 1352 | k_javadoc_box_line();
|
---|
| 1353 | }
|
---|
[1085] | 1354 | k_javadoc_box_line(sProg ' is free software; you can redistribute it and/or');
|
---|
| 1355 | k_javadoc_box_line('modify it under the terms of the GNU Lesser General Public');
|
---|
| 1356 | k_javadoc_box_line('License as published by the Free Software Foundation; either');
|
---|
| 1357 | k_javadoc_box_line('version 2.1 of the License, or (at your option) any later version.');
|
---|
[214] | 1358 | k_javadoc_box_line();
|
---|
[113] | 1359 | k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful,');
|
---|
| 1360 | k_javadoc_box_line('but WITHOUT ANY WARRANTY; without even the implied warranty of');
|
---|
[1085] | 1361 | k_javadoc_box_line('MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU');
|
---|
| 1362 | k_javadoc_box_line('Lesser General Public License for more details.');
|
---|
[214] | 1363 | k_javadoc_box_line();
|
---|
[1085] | 1364 | k_javadoc_box_line('You should have received a copy of the GNU Lesser General Public');
|
---|
| 1365 | k_javadoc_box_line('License along with ' sProg '; if not, write to the Free Software');
|
---|
| 1366 | k_javadoc_box_line('Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA');
|
---|
[113] | 1367 | break;
|
---|
| 1368 |
|
---|
[2019] | 1369 | case 'GPLv3':
|
---|
| 1370 | if (!fSplit)
|
---|
| 1371 | k_javadoc_box_line();
|
---|
| 1372 | if (sProg == '')
|
---|
| 1373 | sProg = 'This program';
|
---|
| 1374 | else
|
---|
| 1375 | {
|
---|
| 1376 | k_javadoc_box_line('This file is part of ' sProg '.');
|
---|
| 1377 | k_javadoc_box_line();
|
---|
| 1378 | }
|
---|
| 1379 | k_javadoc_box_line(sProg ' is free software; you can redistribute it and/or modify');
|
---|
| 1380 | k_javadoc_box_line('it under the terms of the GNU General Public License as published by');
|
---|
| 1381 | k_javadoc_box_line('the Free Software Foundation; either version 3 of the License, or');
|
---|
| 1382 | k_javadoc_box_line('(at your option) any later version.');
|
---|
| 1383 | k_javadoc_box_line();
|
---|
| 1384 | k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful,');
|
---|
| 1385 | k_javadoc_box_line('but WITHOUT ANY WARRANTY; without even the implied warranty of');
|
---|
| 1386 | k_javadoc_box_line('MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the');
|
---|
| 1387 | k_javadoc_box_line('GNU General Public License for more details.');
|
---|
| 1388 | k_javadoc_box_line();
|
---|
| 1389 | k_javadoc_box_line('You should have received a copy of the GNU General Public License');
|
---|
| 1390 | k_javadoc_box_line('along with ' sProg '. If not, see <http://www.gnu.org/licenses/>');
|
---|
| 1391 | break;
|
---|
| 1392 |
|
---|
| 1393 | case 'LGPLv3':
|
---|
| 1394 | if (!fSplit)
|
---|
| 1395 | k_javadoc_box_line();
|
---|
| 1396 | if (sProg == '')
|
---|
| 1397 | sProg = 'This program';
|
---|
| 1398 | else
|
---|
| 1399 | {
|
---|
| 1400 | k_javadoc_box_line('This file is part of ' sProg '.');
|
---|
| 1401 | k_javadoc_box_line();
|
---|
| 1402 | }
|
---|
| 1403 | k_javadoc_box_line(sProg ' is free software; you can redistribute it and/or');
|
---|
| 1404 | k_javadoc_box_line('modify it under the terms of the GNU Lesser General Public');
|
---|
| 1405 | k_javadoc_box_line('License as published by the Free Software Foundation; either');
|
---|
| 1406 | k_javadoc_box_line('version 3 of the License, or (at your option) any later version.');
|
---|
| 1407 | k_javadoc_box_line();
|
---|
| 1408 | k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful,');
|
---|
| 1409 | k_javadoc_box_line('but WITHOUT ANY WARRANTY; without even the implied warranty of');
|
---|
| 1410 | k_javadoc_box_line('MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the');
|
---|
| 1411 | k_javadoc_box_line('GNU Lesser General Public License for more details.');
|
---|
| 1412 | k_javadoc_box_line();
|
---|
| 1413 | k_javadoc_box_line('You should have received a copy of the GNU Lesser General Public License');
|
---|
| 1414 | k_javadoc_box_line('along with ' sProg '. If not, see <http://www.gnu.org/licenses/>');
|
---|
| 1415 | break;
|
---|
| 1416 |
|
---|
[113] | 1417 | case 'Confidential':
|
---|
| 1418 | k_javadoc_box_line('All Rights Reserved');
|
---|
| 1419 | break;
|
---|
| 1420 |
|
---|
[2019] | 1421 | case 'ConfidentialNoAuthor':
|
---|
| 1422 | k_javadoc_box_line(skCompany ' confidential');
|
---|
| 1423 | k_javadoc_box_line('All Rights Reserved');
|
---|
| 1424 | break;
|
---|
| 1425 |
|
---|
[784] | 1426 | case 'VirtualBox':
|
---|
[1100] | 1427 | k_javadoc_box_line('This file is part of VirtualBox Open Source Edition (OSE), as')
|
---|
| 1428 | k_javadoc_box_line('available from http://www.virtualbox.org. This file is free software;')
|
---|
| 1429 | k_javadoc_box_line('you can redistribute it and/or modify it under the terms of the GNU')
|
---|
[1647] | 1430 | k_javadoc_box_line('General Public License (GPL) as published by the Free Software')
|
---|
| 1431 | k_javadoc_box_line('Foundation, in version 2 as it comes in the "COPYING" file of the')
|
---|
| 1432 | k_javadoc_box_line('VirtualBox OSE distribution. VirtualBox OSE is distributed in the')
|
---|
| 1433 | k_javadoc_box_line('hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.')
|
---|
| 1434 | k_javadoc_box_line('')
|
---|
| 1435 | k_javadoc_box_line('Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa')
|
---|
| 1436 | k_javadoc_box_line('Clara, CA 95054 USA or visit http://www.sun.com if you need')
|
---|
| 1437 | k_javadoc_box_line('additional information or have any questions.')
|
---|
[784] | 1438 | break;
|
---|
| 1439 |
|
---|
[1647] | 1440 | case 'VirtualBoxGPLAndCDDL':
|
---|
| 1441 | k_javadoc_box_line('This file is part of VirtualBox Open Source Edition (OSE), as')
|
---|
| 1442 | k_javadoc_box_line('available from http://www.virtualbox.org. This file is free software;')
|
---|
| 1443 | k_javadoc_box_line('you can redistribute it and/or modify it under the terms of the GNU')
|
---|
| 1444 | k_javadoc_box_line('General Public License (GPL) as published by the Free Software')
|
---|
| 1445 | k_javadoc_box_line('Foundation, in version 2 as it comes in the "COPYING" file of the')
|
---|
| 1446 | k_javadoc_box_line('VirtualBox OSE distribution. VirtualBox OSE is distributed in the')
|
---|
| 1447 | k_javadoc_box_line('hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.')
|
---|
| 1448 | k_javadoc_box_line('')
|
---|
| 1449 | k_javadoc_box_line('The contents of this file may alternatively be used under the terms')
|
---|
| 1450 | k_javadoc_box_line('of the Common Development and Distribution License Version 1.0')
|
---|
| 1451 | k_javadoc_box_line('(CDDL) only, as it comes in the "COPYING.CDDL" file of the')
|
---|
| 1452 | k_javadoc_box_line('VirtualBox OSE distribution, in which case the provisions of the')
|
---|
| 1453 | k_javadoc_box_line('CDDL are applicable instead of those of the GPL.')
|
---|
| 1454 | k_javadoc_box_line('')
|
---|
| 1455 | k_javadoc_box_line('You may elect to license modified versions of this file under the')
|
---|
| 1456 | k_javadoc_box_line('terms and conditions of either the GPL or the CDDL or both.')
|
---|
| 1457 | k_javadoc_box_line('')
|
---|
| 1458 | k_javadoc_box_line('Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa')
|
---|
| 1459 | k_javadoc_box_line('Clara, CA 95054 USA or visit http://www.sun.com if you need')
|
---|
| 1460 | k_javadoc_box_line('additional information or have any questions.')
|
---|
| 1461 | break;
|
---|
| 1462 |
|
---|
[113] | 1463 | default:
|
---|
| 1464 |
|
---|
| 1465 | }
|
---|
| 1466 | k_javadoc_box_line();
|
---|
| 1467 | k_javadoc_box_end();
|
---|
| 1468 |
|
---|
| 1469 | up(p_RLine - iCursorLine);
|
---|
| 1470 | end_line();
|
---|
| 1471 | keyin(' ');
|
---|
| 1472 | }
|
---|
| 1473 |
|
---|
| 1474 |
|
---|
| 1475 |
|
---|
| 1476 |
|
---|
| 1477 |
|
---|
| 1478 |
|
---|
| 1479 |
|
---|
| 1480 | /*******************************************************************************
|
---|
| 1481 | * Keyboard Shortcuts *
|
---|
| 1482 | *******************************************************************************/
|
---|
| 1483 | /** Makes global box. */
|
---|
| 1484 | void k_box_globals()
|
---|
| 1485 | {
|
---|
| 1486 | k_box_start('Global');
|
---|
| 1487 | k_box_line('Global Variables');
|
---|
| 1488 | k_box_end();
|
---|
| 1489 | }
|
---|
| 1490 |
|
---|
| 1491 | /** Makes header box. */
|
---|
| 1492 | void k_box_headers()
|
---|
| 1493 | {
|
---|
| 1494 | k_box_start("Header");
|
---|
| 1495 | k_box_line("Header Files");
|
---|
| 1496 | k_box_end();
|
---|
| 1497 | }
|
---|
| 1498 |
|
---|
| 1499 | /** Makes internal function box. */
|
---|
| 1500 | void k_box_intfuncs()
|
---|
| 1501 | {
|
---|
| 1502 | k_box_start("IntFunc");
|
---|
| 1503 | k_box_line("Internal Functions");
|
---|
| 1504 | k_box_end();
|
---|
| 1505 | }
|
---|
| 1506 |
|
---|
| 1507 | /** Makes def/const box. */
|
---|
| 1508 | void k_box_consts()
|
---|
| 1509 | {
|
---|
| 1510 | k_box_start("Const");
|
---|
| 1511 | k_box_line("Defined Constants And Macros");
|
---|
| 1512 | k_box_end();
|
---|
| 1513 | }
|
---|
| 1514 |
|
---|
| 1515 | /** Structure box */
|
---|
| 1516 | void k_box_structs()
|
---|
| 1517 | {
|
---|
| 1518 | k_box_start("Struct");
|
---|
| 1519 | k_box_line("Structures and Typedefs");
|
---|
| 1520 | k_box_end();
|
---|
| 1521 | }
|
---|
| 1522 |
|
---|
| 1523 | /** Makes exported symbols box. */
|
---|
| 1524 | void k_box_exported()
|
---|
| 1525 | {
|
---|
| 1526 | k_box_start('Exported');
|
---|
| 1527 | k_box_line('Exported Symbols');
|
---|
| 1528 | k_box_end();
|
---|
| 1529 | }
|
---|
| 1530 |
|
---|
| 1531 |
|
---|
| 1532 |
|
---|
| 1533 | /** oneliner comment */
|
---|
| 1534 | void k_oneliner()
|
---|
| 1535 | {
|
---|
[214] | 1536 | _str sLeft, sRight;
|
---|
| 1537 | int iColumn;
|
---|
[113] | 1538 | if ( k_commentconfig(sLeft, sRight, iColumn)
|
---|
| 1539 | && iColumn > 0)
|
---|
| 1540 | { /* column based needs some tricky repositioning. */
|
---|
| 1541 | _end_line();
|
---|
| 1542 | if (p_col > iColumn)
|
---|
| 1543 | {
|
---|
| 1544 | _begin_line();
|
---|
| 1545 | _insert_text("\n\r");
|
---|
| 1546 | up();
|
---|
| 1547 | }
|
---|
| 1548 | }
|
---|
| 1549 | k_insert_comment("", KIC_CURSOR_AT_END, ikStyleOneliner);
|
---|
| 1550 | }
|
---|
| 1551 |
|
---|
| 1552 | /** mark line as modified. */
|
---|
| 1553 | void k_mark_modified_line()
|
---|
| 1554 | {
|
---|
| 1555 | /* not supported for column based sources */
|
---|
[214] | 1556 | _str sLeft, sRight;
|
---|
| 1557 | int iColumn;
|
---|
[113] | 1558 | if ( !k_commentconfig(sLeft, sRight, iColumn)
|
---|
| 1559 | || iColumn > 0)
|
---|
| 1560 | return;
|
---|
[214] | 1561 | _str sStr;
|
---|
[113] | 1562 | if (skChange != '')
|
---|
| 1563 | sStr = skChange ' (' skUserInitials ')';
|
---|
| 1564 | else
|
---|
| 1565 | sStr = skUserInitials;
|
---|
| 1566 | k_insert_comment(sStr, KIC_CURSOR_BEFORE, ikStyleModifyMarkColumn);
|
---|
| 1567 | down();
|
---|
| 1568 | }
|
---|
| 1569 |
|
---|
| 1570 |
|
---|
| 1571 | /**
|
---|
| 1572 | * Inserts a signature. Form: "//Initials ISO-date:"
|
---|
| 1573 | * @remark defeventtab
|
---|
| 1574 | */
|
---|
| 1575 | void k_signature()
|
---|
| 1576 | {
|
---|
| 1577 | /* kso I5-10000 2002-09-10: */
|
---|
[214] | 1578 | _str sSig;
|
---|
[113] | 1579 | if (skChange != '')
|
---|
| 1580 | sSig = skUserInitials ' ' skChange ' ' k_date() ': ';
|
---|
| 1581 | else
|
---|
| 1582 | sSig = skUserInitials ' ' k_date() ': ';
|
---|
| 1583 | k_insert_comment(sSig, KIC_CURSOR_AT_END);
|
---|
| 1584 | }
|
---|
| 1585 |
|
---|
| 1586 |
|
---|
| 1587 | /*******************************************************************************
|
---|
| 1588 | * kLIB Logging *
|
---|
| 1589 | *******************************************************************************/
|
---|
| 1590 | /**
|
---|
| 1591 | * Hot-Key: Inserts a KLOGENTRY statement at start of nearest function.
|
---|
| 1592 | */
|
---|
| 1593 | void klib_klogentry()
|
---|
| 1594 | {
|
---|
[214] | 1595 | typeless org_pos;
|
---|
[113] | 1596 | _save_pos2(org_pos);
|
---|
| 1597 |
|
---|
| 1598 | /*
|
---|
| 1599 | * Go to nearest function.
|
---|
| 1600 | */
|
---|
| 1601 | if (!k_func_goto_nearest_function())
|
---|
| 1602 | {
|
---|
| 1603 | /*
|
---|
| 1604 | * Get parameters.
|
---|
| 1605 | */
|
---|
| 1606 | _str sParams = k_func_getparams();
|
---|
| 1607 | if (sParams)
|
---|
| 1608 | {
|
---|
| 1609 | _str sRetType = k_func_getreturntype(true);
|
---|
| 1610 | if (!sRetType || sRetType == "")
|
---|
| 1611 | sRetType = "void"; /* paranoia! */
|
---|
| 1612 |
|
---|
| 1613 | /*
|
---|
| 1614 | * Insert text.
|
---|
| 1615 | */
|
---|
| 1616 | if (!k_func_searchcode("{"))
|
---|
| 1617 | {
|
---|
| 1618 | p_col++;
|
---|
[214] | 1619 | int cArgs = k_func_countparams(sParams);
|
---|
[113] | 1620 | if (cArgs > 0)
|
---|
| 1621 | {
|
---|
[214] | 1622 | _str sArgs = "";
|
---|
| 1623 | int i;
|
---|
[113] | 1624 | for (i = 0; i < cArgs; i++)
|
---|
| 1625 | {
|
---|
[214] | 1626 | _str sType, sName, sDefault;
|
---|
[113] | 1627 | if (!k_func_enumparams(sParams, i, sType, sName, sDefault))
|
---|
| 1628 | sArgs = sArgs', 'sName;
|
---|
| 1629 | }
|
---|
| 1630 |
|
---|
| 1631 | _insert_text("\n KLOGENTRY"cArgs"(\""sRetType"\",\""sParams"\""sArgs");"); /* todo tab size.. or smart indent */
|
---|
| 1632 | }
|
---|
| 1633 | else
|
---|
| 1634 | _insert_text("\n KLOGENTRY0(\""sRetType"\");"); /* todo tab size.. or smart indent */
|
---|
| 1635 |
|
---|
| 1636 | /*
|
---|
| 1637 | * Check if the next word is KLOGENTRY.
|
---|
| 1638 | */
|
---|
| 1639 | next_word();
|
---|
| 1640 | if (def_next_word_style == 'E')
|
---|
| 1641 | prev_word();
|
---|
[214] | 1642 | int iIgnorePos = 0;
|
---|
[113] | 1643 | if (substr(cur_word(iIgnorePos), 1, 9) == "KLOGENTRY")
|
---|
| 1644 | delete_line();
|
---|
| 1645 |
|
---|
| 1646 | }
|
---|
| 1647 | else
|
---|
| 1648 | message("didn't find {");
|
---|
| 1649 | }
|
---|
| 1650 | else
|
---|
| 1651 | message("k_func_getparams failed, sParams=" sParams);
|
---|
| 1652 | return;
|
---|
| 1653 | }
|
---|
| 1654 |
|
---|
| 1655 | _restore_pos2(org_pos);
|
---|
| 1656 | }
|
---|
| 1657 |
|
---|
| 1658 |
|
---|
| 1659 | /**
|
---|
| 1660 | * Hot-Key: Inserts a KLOGEXIT statement at cursor location.
|
---|
| 1661 | */
|
---|
| 1662 | void klib_klogexit()
|
---|
| 1663 | {
|
---|
[214] | 1664 | typeless org_pos;
|
---|
[113] | 1665 | _save_pos2(org_pos);
|
---|
| 1666 |
|
---|
| 1667 | /*
|
---|
| 1668 | * Go to nearest function.
|
---|
| 1669 | */
|
---|
| 1670 | if (!prev_proc())
|
---|
| 1671 | {
|
---|
| 1672 | /*
|
---|
| 1673 | * Get parameters.
|
---|
| 1674 | */
|
---|
| 1675 | _str sType = k_func_getreturntype(true);
|
---|
| 1676 | _restore_pos2(org_pos);
|
---|
| 1677 | if (sType)
|
---|
| 1678 | {
|
---|
| 1679 | boolean fReturn = true; /* true if an return statment is following the KLOGEXIT statement. */
|
---|
| 1680 |
|
---|
| 1681 | /*
|
---|
| 1682 | * Insert text.
|
---|
| 1683 | */
|
---|
[214] | 1684 | int cur_col = p_col;
|
---|
[113] | 1685 | if (sType == 'void' || sType == 'VOID')
|
---|
| 1686 | { /* procedure */
|
---|
[214] | 1687 | int iIgnorePos;
|
---|
[113] | 1688 | fReturn = cur_word(iIgnorePos) == 'return';
|
---|
| 1689 | if (!fReturn)
|
---|
| 1690 | {
|
---|
| 1691 | while (p_col <= p_SyntaxIndent)
|
---|
| 1692 | keyin(" ");
|
---|
| 1693 | }
|
---|
| 1694 |
|
---|
| 1695 | _insert_text("KLOGEXITVOID();\n");
|
---|
| 1696 |
|
---|
| 1697 | if (fReturn)
|
---|
| 1698 | {
|
---|
[214] | 1699 | int i;
|
---|
[113] | 1700 | for (i = 1; i < cur_col; i++)
|
---|
| 1701 | _insert_text(" ");
|
---|
| 1702 | }
|
---|
| 1703 | search(")","E-");
|
---|
| 1704 | }
|
---|
| 1705 | else
|
---|
| 1706 | { /* function */
|
---|
| 1707 | _insert_text("KLOGEXIT();\n");
|
---|
[214] | 1708 | int i;
|
---|
[113] | 1709 | for (i = 1; i < cur_col; i++)
|
---|
| 1710 | _insert_text(" ");
|
---|
| 1711 | search(")","E-");
|
---|
| 1712 |
|
---|
| 1713 | /*
|
---|
| 1714 | * Insert value if possible.
|
---|
| 1715 | */
|
---|
[214] | 1716 | typeless valuepos;
|
---|
[113] | 1717 | _save_pos2(valuepos);
|
---|
| 1718 | next_word();
|
---|
| 1719 | if (def_next_word_style == 'E')
|
---|
| 1720 | prev_word();
|
---|
[214] | 1721 | int iIgnorePos;
|
---|
[113] | 1722 | if (cur_word(iIgnorePos) == 'return')
|
---|
| 1723 | {
|
---|
| 1724 | p_col += length('return');
|
---|
[214] | 1725 | typeless posStart;
|
---|
[113] | 1726 | _save_pos2(posStart);
|
---|
[214] | 1727 | long offStart = _QROffset();
|
---|
[113] | 1728 | if (!k_func_searchcode(";", "E+"))
|
---|
| 1729 | {
|
---|
[214] | 1730 | long offEnd = _QROffset();
|
---|
[113] | 1731 | _restore_pos2(posStart);
|
---|
[214] | 1732 | _str sValue = strip(get_text((int)(offEnd - offStart)));
|
---|
[113] | 1733 | //say 'sValue = 'sValue;
|
---|
| 1734 | _restore_pos2(valuepos);
|
---|
| 1735 | _save_pos2(valuepos);
|
---|
| 1736 | _insert_text(sValue);
|
---|
| 1737 | }
|
---|
| 1738 | }
|
---|
| 1739 | _restore_pos2(valuepos);
|
---|
| 1740 | }
|
---|
| 1741 |
|
---|
| 1742 | /*
|
---|
| 1743 | * Remove old KLOGEXIT statement on previous line if any.
|
---|
| 1744 | */
|
---|
[214] | 1745 | typeless valuepos;
|
---|
[113] | 1746 | _save_pos2(valuepos);
|
---|
[214] | 1747 | int newexitline = p_line;
|
---|
[113] | 1748 | p_line--; p_col = 1;
|
---|
| 1749 | next_word();
|
---|
| 1750 | if (def_next_word_style == 'E')
|
---|
| 1751 | prev_word();
|
---|
[214] | 1752 | int iIgnorePos;
|
---|
[113] | 1753 | if (p_line == newexitline - 1 && substr(cur_word(iIgnorePos), 1, 8) == 'KLOGEXIT')
|
---|
| 1754 | delete_line();
|
---|
| 1755 | _restore_pos2(valuepos);
|
---|
| 1756 |
|
---|
| 1757 | /*
|
---|
| 1758 | * Check for missing '{...}'.
|
---|
| 1759 | */
|
---|
| 1760 | if (fReturn)
|
---|
| 1761 | {
|
---|
| 1762 | boolean fFound = false;
|
---|
| 1763 | _save_pos2(valuepos);
|
---|
| 1764 | p_col--; find_matching_paren(); p_col += 2;
|
---|
| 1765 | k_func_searchcode(';', 'E+'); /* places us at the ';' of the return. (hopefully) */
|
---|
| 1766 |
|
---|
| 1767 | _str ch = k_func_get_next_code_text();
|
---|
| 1768 | if (ch != '}')
|
---|
| 1769 | {
|
---|
| 1770 | _restore_pos2(valuepos);
|
---|
| 1771 | _save_pos2(valuepos);
|
---|
| 1772 | p_col--; find_matching_paren(); p_col += 2;
|
---|
| 1773 | k_func_searchcode(';', 'E+'); /* places us at the ';' of the return. (hopefully) */
|
---|
| 1774 | p_col++;
|
---|
| 1775 | if (k_func_more_code_on_line())
|
---|
| 1776 | _insert_text(' }');
|
---|
| 1777 | else
|
---|
| 1778 | {
|
---|
[214] | 1779 | typeless returnget;
|
---|
[113] | 1780 | _save_pos2(returnget);
|
---|
| 1781 | k_func_searchcode("return", "E-");
|
---|
[214] | 1782 | int return_col = p_col;
|
---|
[113] | 1783 | _restore_pos2(returnget);
|
---|
| 1784 |
|
---|
| 1785 | end_line();
|
---|
| 1786 | _insert_text("\n");
|
---|
| 1787 | while (p_col < return_col - p_SyntaxIndent)
|
---|
| 1788 | _insert_text(' ');
|
---|
| 1789 | _insert_text('}');
|
---|
| 1790 | }
|
---|
| 1791 |
|
---|
| 1792 | _restore_pos2(valuepos);
|
---|
| 1793 | _save_pos2(valuepos);
|
---|
| 1794 | prev_word();
|
---|
| 1795 | p_col -= p_SyntaxIndent;
|
---|
[214] | 1796 | int codecol = p_col;
|
---|
[113] | 1797 | _insert_text("{\n");
|
---|
| 1798 | while (p_col < codecol)
|
---|
| 1799 | _insert_text(' ');
|
---|
| 1800 | }
|
---|
| 1801 |
|
---|
| 1802 | _restore_pos2(valuepos);
|
---|
| 1803 | }
|
---|
| 1804 | }
|
---|
| 1805 | else
|
---|
| 1806 | message("k_func_getreturntype failed, sType=" sType);
|
---|
| 1807 | return;
|
---|
| 1808 | }
|
---|
| 1809 |
|
---|
| 1810 | _restore_pos2(org_pos);
|
---|
| 1811 | }
|
---|
| 1812 |
|
---|
| 1813 |
|
---|
| 1814 | /**
|
---|
| 1815 | * Processes a file - ask user all the time.
|
---|
| 1816 | */
|
---|
| 1817 | void klib_klog_file_ask()
|
---|
| 1818 | {
|
---|
[214] | 1819 | klib_klog_file_int(true);
|
---|
[113] | 1820 | }
|
---|
| 1821 |
|
---|
| 1822 |
|
---|
| 1823 | /**
|
---|
| 1824 | * Processes a file - no questions.
|
---|
| 1825 | */
|
---|
| 1826 | void klib_klog_file_no_ask()
|
---|
| 1827 | {
|
---|
[214] | 1828 | klib_klog_file_int(false);
|
---|
[113] | 1829 | }
|
---|
| 1830 |
|
---|
| 1831 |
|
---|
| 1832 |
|
---|
| 1833 | /**
|
---|
| 1834 | * Processes a file.
|
---|
| 1835 | */
|
---|
| 1836 | static void klib_klog_file_int(boolean fAsk)
|
---|
| 1837 | {
|
---|
| 1838 | show_all();
|
---|
| 1839 | bottom();
|
---|
| 1840 | _refresh_scroll();
|
---|
| 1841 |
|
---|
| 1842 | /* ask question so we can get to the right position somehow.. */
|
---|
| 1843 | if (fAsk && _message_box("kLog process this file?", "Visual SlickEdit", MB_YESNO | MB_ICONQUESTION) != IDYES)
|
---|
| 1844 | return;
|
---|
| 1845 |
|
---|
| 1846 | /*
|
---|
| 1847 | * Entries.
|
---|
| 1848 | */
|
---|
| 1849 | while (!prev_proc())
|
---|
| 1850 | {
|
---|
| 1851 | //say 'entry main loop: ' k_func_getfunction_name();
|
---|
| 1852 |
|
---|
| 1853 | /*
|
---|
| 1854 | * Skip prototypes.
|
---|
| 1855 | */
|
---|
| 1856 | if (k_func_prototype())
|
---|
| 1857 | continue;
|
---|
| 1858 |
|
---|
| 1859 | /*
|
---|
| 1860 | * Ask user.
|
---|
| 1861 | */
|
---|
| 1862 | center_line();
|
---|
| 1863 | _refresh_scroll();
|
---|
[214] | 1864 | _str sFunction = k_func_getfunction_name();
|
---|
[113] | 1865 | rc = fAsk ? _message_box("Process this function ("sFunction")?", "Visual SlickEdit", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
|
---|
| 1866 | if (rc == IDYES)
|
---|
| 1867 | {
|
---|
[214] | 1868 | typeless procpos;
|
---|
[113] | 1869 | _save_pos2(procpos);
|
---|
| 1870 | klib_klogentry();
|
---|
| 1871 | _restore_pos2(procpos);
|
---|
| 1872 | }
|
---|
| 1873 | else if (rc == IDNO)
|
---|
| 1874 | continue;
|
---|
| 1875 | else
|
---|
| 1876 | break;
|
---|
| 1877 | }
|
---|
| 1878 |
|
---|
| 1879 | /*
|
---|
| 1880 | * Exits.
|
---|
| 1881 | */
|
---|
| 1882 | bottom(); _refresh_scroll();
|
---|
| 1883 | boolean fUserCancel = false;
|
---|
| 1884 | while (!prev_proc() && !fUserCancel)
|
---|
| 1885 | {
|
---|
[214] | 1886 | typeless procpos;
|
---|
[113] | 1887 | _save_pos2(procpos);
|
---|
[214] | 1888 | _str sCurFunction = k_func_getfunction_name();
|
---|
[113] | 1889 | //say 'exit main loop: ' sCurFunction
|
---|
| 1890 |
|
---|
| 1891 | /*
|
---|
| 1892 | * Skip prototypes.
|
---|
| 1893 | */
|
---|
| 1894 | if (k_func_prototype())
|
---|
| 1895 | continue;
|
---|
| 1896 |
|
---|
| 1897 | /*
|
---|
| 1898 | * Select procedure.
|
---|
| 1899 | */
|
---|
| 1900 | while ( !k_func_searchcode("return", "WE<+")
|
---|
| 1901 | && k_func_getfunction_name() == sCurFunction)
|
---|
| 1902 | {
|
---|
| 1903 | //say 'exit sub loop: ' p_line
|
---|
| 1904 | /*
|
---|
| 1905 | * Ask User.
|
---|
| 1906 | */
|
---|
| 1907 | center_line();
|
---|
| 1908 | _refresh_scroll();
|
---|
[214] | 1909 | _str sFunction = k_func_getfunction_name();
|
---|
[113] | 1910 | rc = fAsk ? _message_box("Process this exit from "sFunction"?", "Visual SlickEdit", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
|
---|
| 1911 | deselect();
|
---|
| 1912 | if (rc == IDYES)
|
---|
| 1913 | {
|
---|
[214] | 1914 | typeless returnpos;
|
---|
[113] | 1915 | _save_pos2(returnpos);
|
---|
| 1916 | klib_klogexit();
|
---|
| 1917 | _restore_pos2(returnpos);
|
---|
| 1918 | p_line++;
|
---|
| 1919 | }
|
---|
| 1920 | else if (rc != IDNO)
|
---|
| 1921 | {
|
---|
| 1922 | fUserCancel = true;
|
---|
| 1923 | break;
|
---|
| 1924 | }
|
---|
| 1925 | p_line++; /* just so we won't hit it again. */
|
---|
| 1926 | }
|
---|
| 1927 |
|
---|
| 1928 | /*
|
---|
| 1929 | * If void function we'll have to check if there is and return; prior to the ending '}'.
|
---|
| 1930 | */
|
---|
| 1931 | _restore_pos2(procpos);
|
---|
| 1932 | _save_pos2(procpos);
|
---|
[214] | 1933 | _str sType = k_func_getreturntype(true);
|
---|
[113] | 1934 | if (!fUserCancel && sType && (sType == 'void' || sType == 'VOID'))
|
---|
| 1935 | {
|
---|
| 1936 | if ( !k_func_searchcode("{", "E+")
|
---|
| 1937 | && !find_matching_paren())
|
---|
| 1938 | {
|
---|
[214] | 1939 | typeless funcend;
|
---|
[113] | 1940 | _save_pos2(funcend);
|
---|
| 1941 | prev_word();
|
---|
[214] | 1942 | int iIgnorePos;
|
---|
[113] | 1943 | if (cur_word(iIgnorePos) != "return")
|
---|
| 1944 | {
|
---|
| 1945 | /*
|
---|
| 1946 | * Ask User.
|
---|
| 1947 | */
|
---|
| 1948 | _restore_pos2(funcend);
|
---|
| 1949 | center_line();
|
---|
| 1950 | _refresh_scroll();
|
---|
[214] | 1951 | _str sFunction = k_func_getfunction_name();
|
---|
[113] | 1952 | rc = fAsk ? _message_box("Process this exit from "sFunction"?", "Visual SlickEdit", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
|
---|
| 1953 | deselect();
|
---|
| 1954 | if (rc == IDYES)
|
---|
| 1955 | {
|
---|
[214] | 1956 | typeless returnpos;
|
---|
[113] | 1957 | _save_pos2(returnpos);
|
---|
| 1958 | klib_klogexit();
|
---|
| 1959 | _restore_pos2(returnpos);
|
---|
| 1960 | }
|
---|
| 1961 | }
|
---|
| 1962 | }
|
---|
| 1963 | }
|
---|
| 1964 |
|
---|
| 1965 | /*
|
---|
| 1966 | * Next proc.
|
---|
| 1967 | */
|
---|
| 1968 | _restore_pos2(procpos);
|
---|
| 1969 | }
|
---|
| 1970 | }
|
---|
| 1971 |
|
---|
[2354] | 1972 | /** @todo move to kkeys.e */
|
---|
| 1973 | _command void k_rebuild_tagfile()
|
---|
[113] | 1974 | {
|
---|
[2354] | 1975 | #if 1 /*__VERSION__ < 14.0*/
|
---|
[113] | 1976 | if (file_match('-p 'maybe_quote_filename(strip_filename(_project_name,'e'):+TAG_FILE_EXT),1) != "")
|
---|
[2354] | 1977 | _project_update_files_retag(false, false, false, false);
|
---|
[113] | 1978 | else
|
---|
[2354] | 1979 | _project_update_files_retag(true, false, false, true);
|
---|
| 1980 | #else
|
---|
| 1981 | _str sArgs = "-refs=on";
|
---|
| 1982 | if (file_match('-p 'maybe_quote_filename(strip_filename(_project_name,'e'):+TAG_FILE_EXT),1) != "")
|
---|
| 1983 | sArgs = sArgs :+ " -retag";
|
---|
| 1984 | sArgs = sArgs :+ " " :+ _workspace_filename;
|
---|
| 1985 | build_workspace_tagfiles(sArgs);
|
---|
| 1986 | #endif
|
---|
[113] | 1987 | }
|
---|
| 1988 |
|
---|
| 1989 |
|
---|
| 1990 | /*******************************************************************************
|
---|
| 1991 | * Styles *
|
---|
| 1992 | *******************************************************************************/
|
---|
| 1993 | static _str StyleLanguages[] =
|
---|
| 1994 | {
|
---|
| 1995 | "c",
|
---|
| 1996 | "e",
|
---|
| 1997 | "java"
|
---|
| 1998 | };
|
---|
| 1999 |
|
---|
| 2000 | struct StyleScheme
|
---|
| 2001 | {
|
---|
| 2002 | _str name;
|
---|
| 2003 | _str settings[];
|
---|
| 2004 | };
|
---|
| 2005 |
|
---|
| 2006 | static StyleScheme StyleSchemes[] =
|
---|
| 2007 | {
|
---|
| 2008 | {
|
---|
| 2009 | "Opt2Ind4",
|
---|
| 2010 | {
|
---|
| 2011 | "orig_tabsize=4",
|
---|
| 2012 | "syntax_indent=4",
|
---|
| 2013 | "tabsize=4",
|
---|
| 2014 | "align_on_equal=1",
|
---|
| 2015 | "pad_condition_state=1",
|
---|
| 2016 | "indent_with_tabs=0",
|
---|
| 2017 | "nospace_before_paren=0",
|
---|
| 2018 | "indent_comments=1",
|
---|
| 2019 | "indent_case=1",
|
---|
| 2020 | "statement_comment_col=0",
|
---|
| 2021 | "disable_bestyle=0",
|
---|
| 2022 | "decl_comment_col=0",
|
---|
| 2023 | "bestyle_on_functions=0",
|
---|
| 2024 | "use_relative_indent=1",
|
---|
| 2025 | "nospace_before_brace=0",
|
---|
| 2026 | "indent_fl=1",
|
---|
| 2027 | "statement_comment_state=2",
|
---|
| 2028 | "indent_pp=1",
|
---|
| 2029 | "be_style=1",
|
---|
| 2030 | "parens_on_return=0",
|
---|
| 2031 | "eat_blank_lines=0",
|
---|
| 2032 | "brace_indent=0",
|
---|
| 2033 | "eat_pp_space=1",
|
---|
| 2034 | "align_on_parens=1",
|
---|
| 2035 | "continuation_indent=0",
|
---|
| 2036 | "cuddle_else=0",
|
---|
| 2037 | "nopad_condition=1",
|
---|
| 2038 | "pad_condition=0",
|
---|
| 2039 | "indent_col1_comments=0"
|
---|
| 2040 | }
|
---|
| 2041 | }
|
---|
| 2042 | ,
|
---|
| 2043 | {
|
---|
| 2044 | "Opt2Ind3",
|
---|
| 2045 | {
|
---|
| 2046 | "orig_tabsize=3",
|
---|
| 2047 | "syntax_indent=3",
|
---|
| 2048 | "tabsize=3",
|
---|
| 2049 | "align_on_equal=1",
|
---|
| 2050 | "pad_condition_state=1",
|
---|
| 2051 | "indent_with_tabs=0",
|
---|
| 2052 | "nospace_before_paren=0",
|
---|
| 2053 | "indent_comments=1",
|
---|
| 2054 | "indent_case=1",
|
---|
| 2055 | "statement_comment_col=0",
|
---|
| 2056 | "disable_bestyle=0",
|
---|
| 2057 | "decl_comment_col=0",
|
---|
| 2058 | "bestyle_on_functions=0",
|
---|
| 2059 | "use_relative_indent=1",
|
---|
| 2060 | "nospace_before_brace=0",
|
---|
| 2061 | "indent_fl=1",
|
---|
| 2062 | "statement_comment_state=2",
|
---|
| 2063 | "indent_pp=1",
|
---|
| 2064 | "be_style=1",
|
---|
| 2065 | "parens_on_return=0",
|
---|
| 2066 | "eat_blank_lines=0",
|
---|
| 2067 | "brace_indent=0",
|
---|
| 2068 | "eat_pp_space=1",
|
---|
| 2069 | "align_on_parens=1",
|
---|
| 2070 | "continuation_indent=0",
|
---|
| 2071 | "cuddle_else=0",
|
---|
| 2072 | "nopad_condition=1",
|
---|
| 2073 | "pad_condition=0",
|
---|
| 2074 | "indent_col1_comments=0"
|
---|
| 2075 | }
|
---|
| 2076 | }
|
---|
| 2077 | ,
|
---|
| 2078 | {
|
---|
| 2079 | "Opt2Ind8",
|
---|
| 2080 | {
|
---|
| 2081 | "orig_tabsize=8",
|
---|
| 2082 | "syntax_indent=8",
|
---|
| 2083 | "tabsize=8",
|
---|
| 2084 | "align_on_equal=1",
|
---|
| 2085 | "pad_condition_state=1",
|
---|
| 2086 | "indent_with_tabs=0",
|
---|
| 2087 | "nospace_before_paren=0",
|
---|
| 2088 | "indent_comments=1",
|
---|
| 2089 | "indent_case=1",
|
---|
| 2090 | "statement_comment_col=0",
|
---|
| 2091 | "disable_bestyle=0",
|
---|
| 2092 | "decl_comment_col=0",
|
---|
| 2093 | "bestyle_on_functions=0",
|
---|
| 2094 | "use_relative_indent=1",
|
---|
| 2095 | "nospace_before_brace=0",
|
---|
| 2096 | "indent_fl=1",
|
---|
| 2097 | "statement_comment_state=2",
|
---|
| 2098 | "indent_pp=1",
|
---|
| 2099 | "be_style=1",
|
---|
| 2100 | "parens_on_return=0",
|
---|
| 2101 | "eat_blank_lines=0",
|
---|
| 2102 | "brace_indent=0",
|
---|
| 2103 | "eat_pp_space=1",
|
---|
| 2104 | "align_on_parens=1",
|
---|
| 2105 | "continuation_indent=0",
|
---|
| 2106 | "cuddle_else=0",
|
---|
| 2107 | "nopad_condition=1",
|
---|
| 2108 | "pad_condition=0",
|
---|
| 2109 | "indent_col1_comments=0"
|
---|
| 2110 | }
|
---|
| 2111 | }
|
---|
| 2112 | ,
|
---|
| 2113 | {
|
---|
| 2114 | "Opt3Ind4",
|
---|
| 2115 | {
|
---|
| 2116 | "orig_tabsize=4",
|
---|
| 2117 | "syntax_indent=4",
|
---|
| 2118 | "tabsize=4",
|
---|
| 2119 | "align_on_equal=1",
|
---|
| 2120 | "pad_condition_state=1",
|
---|
| 2121 | "indent_with_tabs=0",
|
---|
| 2122 | "nospace_before_paren=0",
|
---|
| 2123 | "indent_comments=1",
|
---|
| 2124 | "indent_case=1",
|
---|
| 2125 | "statement_comment_col=0",
|
---|
| 2126 | "disable_bestyle=0",
|
---|
| 2127 | "decl_comment_col=0",
|
---|
| 2128 | "bestyle_on_functions=0",
|
---|
| 2129 | "use_relative_indent=1",
|
---|
| 2130 | "nospace_before_brace=0",
|
---|
| 2131 | "indent_fl=1",
|
---|
| 2132 | "statement_comment_state=2",
|
---|
| 2133 | "indent_pp=1",
|
---|
| 2134 | "be_style=2",
|
---|
| 2135 | "parens_on_return=0",
|
---|
| 2136 | "eat_blank_lines=0",
|
---|
| 2137 | "brace_indent=0",
|
---|
| 2138 | "eat_pp_space=1",
|
---|
| 2139 | "align_on_parens=1",
|
---|
| 2140 | "continuation_indent=0",
|
---|
| 2141 | "cuddle_else=0",
|
---|
| 2142 | "nopad_condition=1",
|
---|
| 2143 | "pad_condition=0",
|
---|
| 2144 | "indent_col1_comments=0"
|
---|
| 2145 | }
|
---|
| 2146 | }
|
---|
| 2147 | ,
|
---|
| 2148 | {
|
---|
| 2149 | "Opt3Ind3",
|
---|
| 2150 | {
|
---|
| 2151 | "orig_tabsize=3",
|
---|
| 2152 | "syntax_indent=3",
|
---|
| 2153 | "tabsize=3",
|
---|
| 2154 | "align_on_equal=1",
|
---|
| 2155 | "pad_condition_state=1",
|
---|
| 2156 | "indent_with_tabs=0",
|
---|
| 2157 | "nospace_before_paren=0",
|
---|
| 2158 | "indent_comments=1",
|
---|
| 2159 | "indent_case=1",
|
---|
| 2160 | "statement_comment_col=0",
|
---|
| 2161 | "disable_bestyle=0",
|
---|
| 2162 | "decl_comment_col=0",
|
---|
| 2163 | "bestyle_on_functions=0",
|
---|
| 2164 | "use_relative_indent=1",
|
---|
| 2165 | "nospace_before_brace=0",
|
---|
| 2166 | "indent_fl=1",
|
---|
| 2167 | "statement_comment_state=2",
|
---|
| 2168 | "indent_pp=1",
|
---|
| 2169 | "be_style=2",
|
---|
| 2170 | "parens_on_return=0",
|
---|
| 2171 | "eat_blank_lines=0",
|
---|
| 2172 | "brace_indent=0",
|
---|
| 2173 | "eat_pp_space=1",
|
---|
| 2174 | "align_on_parens=1",
|
---|
| 2175 | "continuation_indent=0",
|
---|
| 2176 | "cuddle_else=0",
|
---|
| 2177 | "nopad_condition=1",
|
---|
| 2178 | "pad_condition=0",
|
---|
| 2179 | "indent_col1_comments=0"
|
---|
| 2180 | }
|
---|
| 2181 | }
|
---|
| 2182 | };
|
---|
| 2183 |
|
---|
| 2184 |
|
---|
| 2185 | static void k_styles_create()
|
---|
| 2186 | {
|
---|
| 2187 | /*
|
---|
| 2188 | * Find user format ini file.
|
---|
| 2189 | */
|
---|
[214] | 2190 | _str userini = maybe_quote_filename(_config_path():+'uformat.ini');
|
---|
[113] | 2191 | if (file_match('-p 'userini, 1) == '')
|
---|
| 2192 | {
|
---|
[214] | 2193 | _str ini = maybe_quote_filename(slick_path_search('uformat.ini'));
|
---|
[113] | 2194 | if (ini != '') userini = ini;
|
---|
| 2195 | }
|
---|
| 2196 |
|
---|
| 2197 |
|
---|
| 2198 | /*
|
---|
| 2199 | * Remove any old schemes.
|
---|
| 2200 | */
|
---|
[214] | 2201 | int i,j,tv;
|
---|
[113] | 2202 | for (i = 0; i < StyleSchemes._length(); i++)
|
---|
| 2203 | for (j = 0; j < StyleLanguages._length(); j++)
|
---|
| 2204 | {
|
---|
[214] | 2205 | _str sectionname = StyleLanguages[j]:+'-scheme-':+StyleSchemes[i].name;
|
---|
[113] | 2206 | if (!_ini_get_section(userini, sectionname, tv))
|
---|
| 2207 | {
|
---|
| 2208 | _ini_delete_section(userini, sectionname);
|
---|
| 2209 | _delete_temp_view(tv);
|
---|
| 2210 | //message("delete old scheme");
|
---|
| 2211 | }
|
---|
| 2212 | }
|
---|
| 2213 |
|
---|
| 2214 | /*
|
---|
| 2215 | * Create the new schemes.
|
---|
| 2216 | */
|
---|
| 2217 | for (i = 0; i < StyleSchemes._length(); i++)
|
---|
| 2218 | {
|
---|
| 2219 | for (j = 0; j < StyleLanguages._length(); j++)
|
---|
| 2220 | {
|
---|
[214] | 2221 | _str sectionname = StyleLanguages[j]:+'-scheme-':+StyleSchemes[i].name;
|
---|
| 2222 | int temp_view_id, k;
|
---|
| 2223 | _str orig_view_id = _create_temp_view(temp_view_id);
|
---|
[113] | 2224 | activate_view(temp_view_id);
|
---|
| 2225 | for (k = 0; k < StyleSchemes[i].settings._length(); k++)
|
---|
| 2226 | insert_line(StyleSchemes[i].settings[k]);
|
---|
| 2227 |
|
---|
| 2228 | /* Insert the scheme section. */
|
---|
| 2229 | _ini_replace_section(userini, sectionname, temp_view_id);
|
---|
| 2230 | //message(userini)
|
---|
[214] | 2231 | //bogus id - activate_view(orig_view_id);
|
---|
[113] | 2232 | }
|
---|
| 2233 | }
|
---|
| 2234 |
|
---|
| 2235 | //last_scheme = last scheme name!!!
|
---|
| 2236 | }
|
---|
| 2237 |
|
---|
| 2238 |
|
---|
| 2239 | /*
|
---|
| 2240 | * Sets the last used beutify scheme.
|
---|
| 2241 | */
|
---|
| 2242 | static k_styles_set(_str scheme)
|
---|
| 2243 | {
|
---|
| 2244 |
|
---|
| 2245 | /*
|
---|
| 2246 | * Find user format ini file.
|
---|
| 2247 | */
|
---|
[214] | 2248 | _str userini = maybe_quote_filename(_config_path():+'uformat.ini');
|
---|
[113] | 2249 | if (file_match('-p 'userini, 1) == '')
|
---|
| 2250 | {
|
---|
[214] | 2251 | _str ini = maybe_quote_filename(slick_path_search('uformat.ini'));
|
---|
[113] | 2252 | if (ini != '') userini = ini;
|
---|
| 2253 | }
|
---|
| 2254 |
|
---|
| 2255 | /*
|
---|
| 2256 | * Set the scheme for each language.
|
---|
| 2257 | */
|
---|
[214] | 2258 | int j;
|
---|
[113] | 2259 | for (j = 0; j < StyleLanguages._length(); j++)
|
---|
| 2260 | {
|
---|
| 2261 | _ini_set_value(userini,
|
---|
| 2262 | StyleLanguages[j]:+'-scheme-Default',
|
---|
| 2263 | 'last_scheme',
|
---|
| 2264 | scheme);
|
---|
| 2265 | }
|
---|
| 2266 | }
|
---|
| 2267 |
|
---|
| 2268 |
|
---|
| 2269 | static _str defoptions[] =
|
---|
| 2270 | {
|
---|
| 2271 | "def-options-sas",
|
---|
| 2272 | "def-options-js",
|
---|
| 2273 | "def-options-bat",
|
---|
| 2274 | "def-options-c",
|
---|
| 2275 | "def-options-pas",
|
---|
| 2276 | "def-options-e",
|
---|
| 2277 | "def-options-java",
|
---|
| 2278 | "def-options-bourneshell",
|
---|
| 2279 | "def-options-csh",
|
---|
| 2280 | "def-options-vlx",
|
---|
| 2281 | "def-options-plsql",
|
---|
| 2282 | "def-options-sqlserver",
|
---|
| 2283 | "def-options-cmd"
|
---|
| 2284 | };
|
---|
| 2285 |
|
---|
| 2286 | static _str defsetups[] =
|
---|
| 2287 | {
|
---|
| 2288 | "def-setup-sas",
|
---|
| 2289 | "def-setup-js",
|
---|
| 2290 | "def-setup-bat",
|
---|
| 2291 | "def-setup-fundamental",
|
---|
| 2292 | "def-setup-process",
|
---|
| 2293 | "def-setup-c",
|
---|
| 2294 | "def-setup-pas",
|
---|
| 2295 | "def-setup-e",
|
---|
| 2296 | "def-setup-asm",
|
---|
| 2297 | "def-setup-java",
|
---|
| 2298 | "def-setup-html",
|
---|
| 2299 | "def-setup-bourneshell",
|
---|
| 2300 | "def-setup-csh",
|
---|
| 2301 | "def-setup-vlx",
|
---|
| 2302 | "def-setup-fileman",
|
---|
| 2303 | "def-setup-plsql",
|
---|
| 2304 | "def-setup-sqlserver",
|
---|
| 2305 | "def-setup-s",
|
---|
| 2306 | "def-setup-cmd"
|
---|
| 2307 | };
|
---|
| 2308 |
|
---|
| 2309 | static _str defsetupstab8[] =
|
---|
| 2310 | {
|
---|
| 2311 | "def-setup-c"
|
---|
| 2312 | };
|
---|
| 2313 |
|
---|
| 2314 |
|
---|
| 2315 | static void k_styles_setindent(int indent, int iBraceStyle, boolean iWithTabs = false)
|
---|
| 2316 | {
|
---|
| 2317 | if (iBraceStyle < 1 || iBraceStyle > 3)
|
---|
[214] | 2318 | {
|
---|
| 2319 | message('k_styles_setindent: iBraceStyle is bad (=' :+ iBraceStyle :+ ')');
|
---|
[113] | 2320 | iBraceStyle = 2;
|
---|
[214] | 2321 | }
|
---|
| 2322 |
|
---|
[113] | 2323 | /*
|
---|
| 2324 | * def-options for extentions known to have that info.
|
---|
| 2325 | */
|
---|
[214] | 2326 | int i;
|
---|
[113] | 2327 | for (i = 0; i < defoptions._length(); i++)
|
---|
| 2328 | {
|
---|
[214] | 2329 | int idx = find_index(defoptions[i], MISC_TYPE);
|
---|
[113] | 2330 | if (!idx)
|
---|
| 2331 | continue;
|
---|
| 2332 |
|
---|
| 2333 | parse name_info(idx) with syntax_indent o2 o3 o4 flags indent_fl o7 indent_case rest;
|
---|
| 2334 |
|
---|
| 2335 | /* Begin/end style */
|
---|
| 2336 | flags = flags & ~(1|2);
|
---|
| 2337 | flags = flags | (iBraceStyle - 1); /* Set style (0-based) */
|
---|
| 2338 | flags = flags & ~(16); /* no scape before parent.*/
|
---|
| 2339 | indent_fl = 1; /* Indent first level */
|
---|
| 2340 | indent_case = 1; /* Indent case from switch */
|
---|
| 2341 |
|
---|
| 2342 | sNewOptions = indent' 'o2' 'o3' 'o4' 'flags' 'indent_fl' 'o7' 'indent_case' 'rest;
|
---|
| 2343 | set_name_info(idx, sNewOptions);
|
---|
| 2344 | _config_modify |= CFGMODIFY_DEFDATA;
|
---|
| 2345 | }
|
---|
| 2346 |
|
---|
| 2347 | /*
|
---|
| 2348 | * def-setup for known extentions.
|
---|
| 2349 | */
|
---|
| 2350 | for (i = 0; i < defsetups._length(); i++)
|
---|
| 2351 | {
|
---|
| 2352 | idx = find_index(defsetups[i], MISC_TYPE);
|
---|
| 2353 | if (!idx)
|
---|
| 2354 | continue;
|
---|
| 2355 | sExt = substr(defsetups[i], length('def-setup-') + 1);
|
---|
| 2356 | sSetup = name_info(idx);
|
---|
| 2357 |
|
---|
| 2358 | /*
|
---|
| 2359 | parse sSetup with 'MN=' mode_name ','\
|
---|
| 2360 | 'TABS=' tabs ',' 'MA=' margins ',' 'KEYTAB=' keytab_name ','\
|
---|
| 2361 | 'WW='word_wrap_style ',' 'IWT='indent_with_tabs ','\
|
---|
| 2362 | 'ST='show_tabs ',' 'IN='indent_style ','\
|
---|
| 2363 | 'WC='word_chars',' 'LN='lexer_name',' 'CF='color_flags','\
|
---|
| 2364 | 'LNL='line_numbers_len','rest;
|
---|
| 2365 |
|
---|
| 2366 | indent_with_tabs = 0; /* Indent with tabs */
|
---|
| 2367 |
|
---|
| 2368 | /* Make sure all the values are legal */
|
---|
| 2369 | _ext_init_values(ext, lexer_name, color_flags);
|
---|
| 2370 | if (!isinteger(line_numbers_len)) line_numbers_len = 0;
|
---|
| 2371 | if (word_chars == '') word_chars = 'A-Za-z0-9_$';
|
---|
| 2372 | if (word_wrap_style == '') word_wrap_style = 3;
|
---|
| 2373 | if (show_tabs == '') show_tabs = 0;
|
---|
| 2374 | if (indent_style == '') indent_style = INDENT_SMART;
|
---|
| 2375 |
|
---|
| 2376 | /* Set new indent */
|
---|
| 2377 | tabs = '+'indent;
|
---|
| 2378 | */
|
---|
| 2379 |
|
---|
| 2380 | sNewSetup = sSetup;
|
---|
| 2381 |
|
---|
| 2382 | /* Set new indent */
|
---|
| 2383 | if (pos('TABS=', sNewSetup) > 0)
|
---|
| 2384 | {
|
---|
| 2385 | /*
|
---|
| 2386 | * If either in defoptions or defsetupstab8 use default tab of 8
|
---|
| 2387 | * For those supporting separate syntax indent using the normal tabsize
|
---|
| 2388 | * helps us a lot when reading it...
|
---|
| 2389 | */
|
---|
| 2390 | fTab8 = false;
|
---|
| 2391 | for (j = 0; !fTab8 && j < defsetupstab8._length(); j++)
|
---|
| 2392 | if (substr(defsetupstab8[j], lastpos('-', defsetupstab8[j]) + 1) == sExt)
|
---|
| 2393 | fTab8 = true;
|
---|
| 2394 | for (j = 0; !fTab8 && j < defoptions._length(); j++)
|
---|
| 2395 | if (substr(defoptions[j], lastpos('-', defoptions[j]) + 1) == sExt)
|
---|
| 2396 | fTab8 = true;
|
---|
| 2397 |
|
---|
| 2398 | parse sNewSetup with sPre 'TABS=' sValue ',' sPost;
|
---|
| 2399 | if (fTab8)
|
---|
| 2400 | sNewSetup = sPre 'TABS=+8,' sPost
|
---|
| 2401 | else
|
---|
| 2402 | sNewSetup = sPre 'TABS=+' indent ',' sPost
|
---|
| 2403 | }
|
---|
| 2404 |
|
---|
| 2405 | /* Set indent with tabs flag. */
|
---|
| 2406 | if (pos('IWT=', sNewSetup) > 0)
|
---|
| 2407 | {
|
---|
| 2408 | parse sNewSetup with sPre 'IWT=' sValue ',' sPost;
|
---|
| 2409 | if (iWithTabs)
|
---|
| 2410 | sNewSetup = sPre 'IWT=1,' sPost
|
---|
| 2411 | else
|
---|
| 2412 | sNewSetup = sPre 'IWT=0,' sPost
|
---|
| 2413 | }
|
---|
| 2414 |
|
---|
| 2415 | /* Do the real changes */
|
---|
| 2416 | set_name_info(idx, sNewSetup);
|
---|
| 2417 | _config_modify |= CFGMODIFY_DEFDATA;
|
---|
| 2418 | _update_buffers(sExt);
|
---|
| 2419 | }
|
---|
| 2420 | }
|
---|
| 2421 |
|
---|
| 2422 |
|
---|
[288] | 2423 | /**
|
---|
| 2424 | * Takes necessary steps to convert a string to integer.
|
---|
| 2425 | */
|
---|
| 2426 | static int k_style_emacs_var_integer(_str sVal)
|
---|
| 2427 | {
|
---|
| 2428 | int i = (int)sVal;
|
---|
[289] | 2429 | //say 'k_style_emacs_var_integer('sVal') -> 'i;
|
---|
[288] | 2430 | return (int)sVal;
|
---|
| 2431 | }
|
---|
| 2432 |
|
---|
| 2433 |
|
---|
| 2434 | /**
|
---|
| 2435 | * Sets a Emacs style variable.
|
---|
| 2436 | */
|
---|
| 2437 | static int k_style_emacs_var(_str sVar, _str sVal)
|
---|
| 2438 | {
|
---|
| 2439 | /* check input. */
|
---|
| 2440 | if (sVar == '' || sVal == '')
|
---|
| 2441 | return -1;
|
---|
[291] | 2442 | //say 'k_style_emacs_var: 'sVar'='sVal;
|
---|
[288] | 2443 |
|
---|
[323] | 2444 | /*
|
---|
[290] | 2445 | * Unpack the mode style parameters.
|
---|
| 2446 | */
|
---|
[288] | 2447 | _str sStyle = name_info(_edit_window().p_index);
|
---|
[290] | 2448 | _str sStyleName = p_mode_name;
|
---|
[323] | 2449 | typeless iIndentAmount, fExpansion, iMinAbbrivation, fIndentAfterOpenParen, iBeginEndStyle, fIndent1stLevel, iMainStyle, iSwitchStyle,
|
---|
[290] | 2450 | sRest, sRes0, sRes1;
|
---|
| 2451 | if (sStyleName == 'Slick-C')
|
---|
| 2452 | {
|
---|
| 2453 | parse sStyle with iMinAbbrivation sRes0 iBeginEndStyle fIndent1stLevel sRes1 iSwitchStyle sRest;
|
---|
| 2454 | iIndentAmount = p_SyntaxIndent;
|
---|
| 2455 | }
|
---|
| 2456 | else /* C */
|
---|
| 2457 | parse sStyle with iIndentAmount fExpansion iMinAbbrivation fIndentAfterOpenParen iBeginEndStyle fIndent1stLevel iMainStyle iSwitchStyle sRest;
|
---|
[288] | 2458 |
|
---|
[290] | 2459 |
|
---|
[323] | 2460 | /*
|
---|
| 2461 | * Process the variable.
|
---|
[290] | 2462 | */
|
---|
[288] | 2463 | switch (sVar)
|
---|
| 2464 | {
|
---|
| 2465 | case 'mode':
|
---|
| 2466 | case 'Mode':
|
---|
| 2467 | {
|
---|
| 2468 | switch (sVal)
|
---|
| 2469 | {
|
---|
| 2470 | case 'c':
|
---|
| 2471 | case 'C':
|
---|
| 2472 | case 'c++':
|
---|
| 2473 | case 'C++':
|
---|
| 2474 | case 'cpp':
|
---|
| 2475 | case 'CPP':
|
---|
| 2476 | case 'cxx':
|
---|
| 2477 | case 'CXX':
|
---|
| 2478 | p_extension = 'c';
|
---|
| 2479 | p_mode_name = 'C';
|
---|
| 2480 | break;
|
---|
| 2481 |
|
---|
| 2482 | case 'e':
|
---|
| 2483 | case 'slick-c':
|
---|
| 2484 | case 'Slick-c':
|
---|
| 2485 | case 'Slick-C':
|
---|
| 2486 | p_extension = 'e';
|
---|
| 2487 | p_mode_name = 'Slick-C';
|
---|
| 2488 | break;
|
---|
| 2489 |
|
---|
| 2490 | default:
|
---|
| 2491 | message('emacs mode "'sVal'" is not known to us');
|
---|
| 2492 | return -3;
|
---|
| 2493 | }
|
---|
| 2494 | break;
|
---|
| 2495 | }
|
---|
[323] | 2496 | /* relevant emacs code:
|
---|
| 2497 | (defconst c-style-alist
|
---|
| 2498 | '(("gnu"
|
---|
| 2499 | (c-basic-offset . 2)
|
---|
| 2500 | (c-comment-only-line-offset . (0 . 0))
|
---|
| 2501 | (c-offsets-alist . ((statement-block-intro . +)
|
---|
| 2502 | (knr-argdecl-intro . 5)
|
---|
| 2503 | (substatement-open . +)
|
---|
| 2504 | (label . 0)
|
---|
| 2505 | (statement-case-open . +)
|
---|
| 2506 | (statement-cont . +)
|
---|
| 2507 | (arglist-intro . c-lineup-arglist-intro-after-paren)
|
---|
| 2508 | (arglist-close . c-lineup-arglist)
|
---|
| 2509 | (inline-open . 0)
|
---|
| 2510 | (brace-list-open . +)
|
---|
| 2511 | ))
|
---|
| 2512 | (c-special-indent-hook . c-gnu-impose-minimum)
|
---|
| 2513 | (c-block-comment-prefix . "")
|
---|
| 2514 | )
|
---|
| 2515 | ("k&r"
|
---|
| 2516 | (c-basic-offset . 5)
|
---|
| 2517 | (c-comment-only-line-offset . 0)
|
---|
| 2518 | (c-offsets-alist . ((statement-block-intro . +)
|
---|
| 2519 | (knr-argdecl-intro . 0)
|
---|
| 2520 | (substatement-open . 0)
|
---|
| 2521 | (label . 0)
|
---|
| 2522 | (statement-cont . +)
|
---|
| 2523 | ))
|
---|
| 2524 | )
|
---|
| 2525 | ("bsd"
|
---|
| 2526 | (c-basic-offset . 8)
|
---|
| 2527 | (c-comment-only-line-offset . 0)
|
---|
| 2528 | (c-offsets-alist . ((statement-block-intro . +)
|
---|
| 2529 | (knr-argdecl-intro . +)
|
---|
| 2530 | (substatement-open . 0)
|
---|
| 2531 | (label . 0)
|
---|
| 2532 | (statement-cont . +)
|
---|
| 2533 | (inline-open . 0)
|
---|
| 2534 | (inexpr-class . 0)
|
---|
| 2535 | ))
|
---|
| 2536 | )
|
---|
| 2537 | ("stroustrup"
|
---|
| 2538 | (c-basic-offset . 4)
|
---|
| 2539 | (c-comment-only-line-offset . 0)
|
---|
| 2540 | (c-offsets-alist . ((statement-block-intro . +)
|
---|
| 2541 | (substatement-open . 0)
|
---|
| 2542 | (label . 0)
|
---|
| 2543 | (statement-cont . +)
|
---|
| 2544 | ))
|
---|
| 2545 | )
|
---|
| 2546 | ("whitesmith"
|
---|
| 2547 | (c-basic-offset . 4)
|
---|
| 2548 | (c-comment-only-line-offset . 0)
|
---|
| 2549 | (c-offsets-alist . ((knr-argdecl-intro . +)
|
---|
| 2550 | (label . 0)
|
---|
| 2551 | (statement-cont . +)
|
---|
| 2552 | (substatement-open . +)
|
---|
| 2553 | (block-open . +)
|
---|
| 2554 | (statement-block-intro . c-lineup-whitesmith-in-block)
|
---|
| 2555 | (block-close . c-lineup-whitesmith-in-block)
|
---|
| 2556 | (inline-open . +)
|
---|
| 2557 | (defun-open . +)
|
---|
| 2558 | (defun-block-intro . c-lineup-whitesmith-in-block)
|
---|
| 2559 | (defun-close . c-lineup-whitesmith-in-block)
|
---|
| 2560 | (brace-list-open . +)
|
---|
| 2561 | (brace-list-intro . c-lineup-whitesmith-in-block)
|
---|
| 2562 | (brace-entry-open . c-indent-multi-line-block)
|
---|
| 2563 | (brace-list-close . c-lineup-whitesmith-in-block)
|
---|
| 2564 | (class-open . +)
|
---|
| 2565 | (inclass . c-lineup-whitesmith-in-block)
|
---|
| 2566 | (class-close . +)
|
---|
| 2567 | (inexpr-class . 0)
|
---|
| 2568 | (extern-lang-open . +)
|
---|
| 2569 | (inextern-lang . c-lineup-whitesmith-in-block)
|
---|
| 2570 | (extern-lang-close . +)
|
---|
| 2571 | (namespace-open . +)
|
---|
| 2572 | (innamespace . c-lineup-whitesmith-in-block)
|
---|
| 2573 | (namespace-close . +)
|
---|
| 2574 | ))
|
---|
| 2575 | )
|
---|
| 2576 | ("ellemtel"
|
---|
| 2577 | (c-basic-offset . 3)
|
---|
| 2578 | (c-comment-only-line-offset . 0)
|
---|
| 2579 | (c-hanging-braces-alist . ((substatement-open before after)))
|
---|
| 2580 | (c-offsets-alist . ((topmost-intro . 0)
|
---|
| 2581 | (topmost-intro-cont . 0)
|
---|
| 2582 | (substatement . +)
|
---|
| 2583 | (substatement-open . 0)
|
---|
| 2584 | (case-label . +)
|
---|
| 2585 | (access-label . -)
|
---|
| 2586 | (inclass . ++)
|
---|
| 2587 | (inline-open . 0)
|
---|
| 2588 | ))
|
---|
| 2589 | )
|
---|
| 2590 | ("linux"
|
---|
| 2591 | (c-basic-offset . 8)
|
---|
| 2592 | (c-comment-only-line-offset . 0)
|
---|
| 2593 | (c-hanging-braces-alist . ((brace-list-open)
|
---|
| 2594 | (brace-entry-open)
|
---|
| 2595 | (substatement-open after)
|
---|
| 2596 | (block-close . c-snug-do-while)))
|
---|
| 2597 | (c-cleanup-list . (brace-else-brace))
|
---|
| 2598 | (c-offsets-alist . ((statement-block-intro . +)
|
---|
| 2599 | (knr-argdecl-intro . 0)
|
---|
| 2600 | (substatement-open . 0)
|
---|
| 2601 | (label . 0)
|
---|
| 2602 | (statement-cont . +)
|
---|
| 2603 | ))
|
---|
| 2604 | )
|
---|
| 2605 | ("python"
|
---|
| 2606 | (indent-tabs-mode . t)
|
---|
| 2607 | (fill-column . 78)
|
---|
| 2608 | (c-basic-offset . 8)
|
---|
| 2609 | (c-offsets-alist . ((substatement-open . 0)
|
---|
| 2610 | (inextern-lang . 0)
|
---|
| 2611 | (arglist-intro . +)
|
---|
| 2612 | (knr-argdecl-intro . +)
|
---|
| 2613 | ))
|
---|
| 2614 | (c-hanging-braces-alist . ((brace-list-open)
|
---|
| 2615 | (brace-list-intro)
|
---|
| 2616 | (brace-list-close)
|
---|
| 2617 | (brace-entry-open)
|
---|
| 2618 | (substatement-open after)
|
---|
| 2619 | (block-close . c-snug-do-while)
|
---|
| 2620 | ))
|
---|
| 2621 | (c-block-comment-prefix . "")
|
---|
| 2622 | )
|
---|
| 2623 | ("java"
|
---|
| 2624 | (c-basic-offset . 4)
|
---|
| 2625 | (c-comment-only-line-offset . (0 . 0))
|
---|
| 2626 | ;; the following preserves Javadoc starter lines
|
---|
| 2627 | (c-offsets-alist . ((inline-open . 0)
|
---|
| 2628 | (topmost-intro-cont . +)
|
---|
| 2629 | (statement-block-intro . +)
|
---|
| 2630 | (knr-argdecl-intro . 5)
|
---|
| 2631 | (substatement-open . +)
|
---|
| 2632 | (label . +)
|
---|
| 2633 | (statement-case-open . +)
|
---|
| 2634 | (statement-cont . +)
|
---|
| 2635 | (arglist-intro . c-lineup-arglist-intro-after-paren)
|
---|
| 2636 | (arglist-close . c-lineup-arglist)
|
---|
| 2637 | (access-label . 0)
|
---|
| 2638 | (inher-cont . c-lineup-java-inher)
|
---|
| 2639 | (func-decl-cont . c-lineup-java-throws)
|
---|
| 2640 | ))
|
---|
| 2641 | )
|
---|
| 2642 | )
|
---|
| 2643 | */
|
---|
[288] | 2644 |
|
---|
| 2645 | case 'c-file-style':
|
---|
| 2646 | case 'c-indentation-style':
|
---|
| 2647 | switch (sVal)
|
---|
| 2648 | {
|
---|
[291] | 2649 | case 'bsd':
|
---|
| 2650 | case '"bsd"':
|
---|
[288] | 2651 | case 'BSD':
|
---|
| 2652 | iBeginEndStyle = 1 | (iBeginEndStyle & ~3);
|
---|
| 2653 | p_indent_with_tabs = true;
|
---|
| 2654 | iIndentAmount = 8;
|
---|
| 2655 | p_SyntaxIndent = 8;
|
---|
| 2656 | p_tabs = "+8";
|
---|
[289] | 2657 | //say 'bsd';
|
---|
[288] | 2658 | break;
|
---|
| 2659 |
|
---|
| 2660 | case 'k&r':
|
---|
[291] | 2661 | case '"k&r"':
|
---|
[288] | 2662 | case 'K&R':
|
---|
| 2663 | iBeginEndStyle = 0 | (iBeginEndStyle & ~3);
|
---|
| 2664 | p_indent_with_tabs = false;
|
---|
| 2665 | iIndentAmount = 4;
|
---|
| 2666 | p_SyntaxIndent = 4;
|
---|
| 2667 | p_tabs = "+4";
|
---|
[289] | 2668 | //say 'k&r';
|
---|
[288] | 2669 | break;
|
---|
| 2670 |
|
---|
| 2671 | case 'linux-c':
|
---|
[291] | 2672 | case '"linux-c"':
|
---|
[288] | 2673 | iBeginEndStyle = 0 | (iBeginEndStyle & ~3);
|
---|
| 2674 | p_indent_with_tabs = true;
|
---|
| 2675 | iIndentAmount = 4;
|
---|
| 2676 | p_SyntaxIndent = 4;
|
---|
| 2677 | p_tabs = "+4";
|
---|
[289] | 2678 | //say 'linux-c';
|
---|
[288] | 2679 | break;
|
---|
| 2680 |
|
---|
| 2681 | case 'yet-to-be-found':
|
---|
| 2682 | iBeginEndStyle = 2 | (iBeginEndStyle & ~3);
|
---|
| 2683 | p_indent_with_tabs = false;
|
---|
| 2684 | iIndentAmount = 4;
|
---|
| 2685 | p_SyntaxIndent = 4;
|
---|
| 2686 | p_tabs = "+4";
|
---|
[289] | 2687 | //say 'todo';
|
---|
[288] | 2688 | break;
|
---|
| 2689 |
|
---|
| 2690 | default:
|
---|
| 2691 | message('emacs "'sVar'" value "'sVal'" is not known to us.');
|
---|
| 2692 | return -3;
|
---|
| 2693 | }
|
---|
| 2694 | break;
|
---|
| 2695 |
|
---|
[290] | 2696 | case 'c-label-offset':
|
---|
| 2697 | {
|
---|
| 2698 | int i = k_style_emacs_var_integer(sVal);
|
---|
| 2699 | if (i >= -16 && i <= 16)
|
---|
| 2700 | {
|
---|
| 2701 | if (i == -p_SyntaxIndent)
|
---|
| 2702 | iSwitchStyle = 0;
|
---|
| 2703 | else
|
---|
| 2704 | iSwitchStyle = 1;
|
---|
| 2705 | }
|
---|
| 2706 | break;
|
---|
| 2707 | }
|
---|
| 2708 |
|
---|
| 2709 |
|
---|
[288] | 2710 | case 'indent-tabs-mode':
|
---|
| 2711 | p_indent_with_tabs = sVal == 't';
|
---|
| 2712 | break;
|
---|
| 2713 |
|
---|
| 2714 | case 'c-indent-level':
|
---|
| 2715 | case 'c-basic-offset':
|
---|
| 2716 | {
|
---|
| 2717 | int i = k_style_emacs_var_integer(sVal);
|
---|
| 2718 | if (i > 0 && i <= 16)
|
---|
| 2719 | {
|
---|
| 2720 | iIndentAmount = i;
|
---|
| 2721 | p_SyntaxIndent = i;
|
---|
| 2722 | }
|
---|
| 2723 | else
|
---|
| 2724 | {
|
---|
| 2725 | message('emacs "'sVar'" value "'sVal'" is out of range.');
|
---|
| 2726 | return -4;
|
---|
| 2727 | }
|
---|
| 2728 | break;
|
---|
| 2729 | }
|
---|
| 2730 |
|
---|
| 2731 | case 'tab-width':
|
---|
| 2732 | {
|
---|
| 2733 | int i = k_style_emacs_var_integer(sVal);
|
---|
| 2734 | if (i > 0 && i <= 16)
|
---|
| 2735 | p_tabs = '+'i;
|
---|
| 2736 | else
|
---|
| 2737 | {
|
---|
| 2738 | message('emacs "'sVar'" value "'sVal'" is out of range.');
|
---|
| 2739 | return -4;
|
---|
| 2740 | }
|
---|
| 2741 | break;
|
---|
| 2742 | }
|
---|
| 2743 |
|
---|
[323] | 2744 | case 'nuke-trailing-whitespace-p':
|
---|
| 2745 | {
|
---|
[2350] | 2746 | #if 0
|
---|
[323] | 2747 | _str sName = 'def-koptions-'p_buf_id;
|
---|
| 2748 | int idx = insert_name(sName, MISC_TYPE, "kstyledoc");
|
---|
| 2749 | if (!idx)
|
---|
| 2750 | idx = find_index(sName, MISC_TYPE);
|
---|
| 2751 | if (idx)
|
---|
| 2752 | {
|
---|
| 2753 | if (sVal == 't')
|
---|
| 2754 | set_name_info(idx, "saveoptions: +S");
|
---|
| 2755 | else
|
---|
| 2756 | set_name_info(idx, "saveoptions: -S");
|
---|
| 2757 | say 'sVal=' sVal;
|
---|
| 2758 | }
|
---|
[2350] | 2759 | #endif
|
---|
[323] | 2760 | break;
|
---|
| 2761 | }
|
---|
| 2762 |
|
---|
[288] | 2763 | default:
|
---|
| 2764 | message('emacs variable "'sVar'" (value "'sVal'") is unknown to us.');
|
---|
| 2765 | return -5;
|
---|
| 2766 | }
|
---|
| 2767 |
|
---|
[323] | 2768 | /*
|
---|
| 2769 | * Update the style?
|
---|
[290] | 2770 | */
|
---|
| 2771 | _str sNewStyle = "";
|
---|
| 2772 | if (sStyleName == 'Slick-C')
|
---|
| 2773 | sNewStyle = iMinAbbrivation' 'sRes0' 'iBeginEndStyle' 'fIndent1stLevel' 'sRes1' 'iSwitchStyle' 'sRest;
|
---|
| 2774 | else
|
---|
| 2775 | sNewStyle = iIndentAmount' 'fExpansion' 'iMinAbbrivation' 'fIndentAfterOpenParen' 'iBeginEndStyle' 'fIndent1stLevel' 'iMainStyle' 'iSwitchStyle' 'sRest;
|
---|
| 2776 | if ( sNewStyle != ""
|
---|
| 2777 | && sNewStyle != sStyle
|
---|
| 2778 | && sStyleName == p_mode_name)
|
---|
[288] | 2779 | {
|
---|
[291] | 2780 | _str sName = name_name(_edit_window().p_index)
|
---|
[290] | 2781 | //say ' sStyle='sStyle' p_mode_name='p_mode_name;
|
---|
[291] | 2782 | //say 'sNewStyle='sNewStyle' sName='sName;
|
---|
[323] | 2783 | if (pos('kstyledoc-', sName) <= 0)
|
---|
[291] | 2784 | {
|
---|
| 2785 | sName = 'def-kstyledoc-'p_buf_id;
|
---|
| 2786 | int idx = insert_name(sName, MISC_TYPE, "kstyledoc");
|
---|
| 2787 | if (!idx)
|
---|
| 2788 | idx = find_index(sName, MISC_TYPE);
|
---|
| 2789 | if (idx)
|
---|
| 2790 | {
|
---|
| 2791 | if (!set_name_info(idx, sNewStyle))
|
---|
| 2792 | _edit_window().p_index = idx;
|
---|
| 2793 | }
|
---|
| 2794 | //say sName'='idx;
|
---|
[323] | 2795 | }
|
---|
[291] | 2796 | else
|
---|
| 2797 | set_name_info(_edit_window().p_index, sNewStyle);
|
---|
[288] | 2798 | }
|
---|
| 2799 |
|
---|
| 2800 | return 0;
|
---|
| 2801 | }
|
---|
| 2802 |
|
---|
| 2803 |
|
---|
| 2804 | /**
|
---|
| 2805 | * Parses a string with emacs variables.
|
---|
[323] | 2806 | *
|
---|
| 2807 | * The variables are separated by new line. Junk at
|
---|
[288] | 2808 | * the start and end of the line is ignored.
|
---|
| 2809 | */
|
---|
| 2810 | static int k_style_emac_vars(_str sVars)
|
---|
| 2811 | {
|
---|
| 2812 | /* process them line by line */
|
---|
| 2813 | int iLine = 0;
|
---|
| 2814 | while (sVars != '' && iLine++ < 20)
|
---|
| 2815 | {
|
---|
| 2816 | int iNext, iEnd;
|
---|
| 2817 | iEnd = iNext = pos("\n", sVars);
|
---|
| 2818 | if (iEnd <= 0)
|
---|
| 2819 | iEnd = iNext = length(sVars);
|
---|
| 2820 | else
|
---|
| 2821 | iEnd--;
|
---|
[323] | 2822 | iNext++;
|
---|
[288] | 2823 |
|
---|
| 2824 | sLine = strip(substr(sVars, 1, iEnd), 'B', " \t\n\r");
|
---|
| 2825 | sVars = strip(substr(sVars, iNext), 'L', " \t\n\r");
|
---|
| 2826 | //say 'iLine='iLine' sVars='sVars'<eol>';
|
---|
| 2827 | //say 'iLine='iLine' sLine='sLine'<eol>';
|
---|
| 2828 | if (sLine != '')
|
---|
| 2829 | {
|
---|
| 2830 | rc = pos('[^a-zA-Z0-9-_]*([a-zA-Z0-9-_]+)[ \t]*:[ \t]*([^ \t]*)', sLine, 1, 'U');
|
---|
| 2831 | //say '0={'pos('S0')','pos('0')',"'substr(sLine,pos('S0'),pos('0'))'"'
|
---|
| 2832 | //say '1={'pos('S1')','pos('1')',"'substr(sLine,pos('S1'),pos('1'))'"'
|
---|
| 2833 | //say '2={'pos('S2')','pos('2')',"'substr(sLine,pos('S2'),pos('2'))'"'
|
---|
| 2834 | //say '3={'pos('S3')','pos('3')',"'substr(sLine,pos('S3'),pos('3'))'"'
|
---|
| 2835 | //say '4={'pos('S4')','pos('4')',"'substr(sLine,pos('S4'),pos('4'))'"'
|
---|
| 2836 | if (rc > 0)
|
---|
[323] | 2837 | k_style_emacs_var(substr(sLine,pos('S1'),pos('1')),
|
---|
[288] | 2838 | substr(sLine,pos('S2'),pos('2')));
|
---|
| 2839 | }
|
---|
| 2840 | }
|
---|
| 2841 | return 0;
|
---|
| 2842 | }
|
---|
| 2843 |
|
---|
| 2844 | /**
|
---|
| 2845 | * Searches for Emacs style specification for the current document.
|
---|
| 2846 | */
|
---|
| 2847 | void k_style_load()
|
---|
| 2848 | {
|
---|
| 2849 | /* save the position before we start looking around the file. */
|
---|
| 2850 | typeless saved_pos;
|
---|
| 2851 | _save_pos2(saved_pos);
|
---|
[323] | 2852 |
|
---|
[288] | 2853 | int rc;
|
---|
| 2854 |
|
---|
| 2855 | /* Check first line. */
|
---|
| 2856 | top_of_buffer();
|
---|
| 2857 | _str sLine;
|
---|
| 2858 | get_line(sLine);
|
---|
| 2859 | strip(sLine);
|
---|
| 2860 | if (pos('-*-[ \t]+(.*:.*)[ \t]+-*-', sLine, 1, 'U'))
|
---|
| 2861 | {
|
---|
| 2862 | _str sVars;
|
---|
| 2863 | sVars = substr(sLine, pos('S1'), pos('1'));
|
---|
| 2864 | sVars = translate(sVars, "\n", ";");
|
---|
| 2865 | k_style_emac_vars(sVars);
|
---|
| 2866 | }
|
---|
| 2867 |
|
---|
| 2868 | /* Look for the "Local Variables:" stuff from the end of the file. */
|
---|
| 2869 | bottom_of_buffer();
|
---|
| 2870 | rc = search('Local Variables:[ \t]*\n\om(.*)\ol\n.*End:.*\n', '-EU');
|
---|
| 2871 | if (!rc)
|
---|
| 2872 | {
|
---|
| 2873 | /* copy the variables out to a buffer. */
|
---|
| 2874 | _str sVars;
|
---|
| 2875 | sVars = get_text(match_length("1"), match_length("S1"));
|
---|
| 2876 | k_style_emac_vars(sVars);
|
---|
| 2877 | }
|
---|
| 2878 |
|
---|
| 2879 | _restore_pos2(saved_pos);
|
---|
| 2880 | }
|
---|
| 2881 |
|
---|
| 2882 |
|
---|
[323] | 2883 | /**
|
---|
| 2884 | * Callback function for the event of a new buffer.
|
---|
| 2885 | *
|
---|
| 2886 | * This is used to make sure there are no left over per buffer options
|
---|
| 2887 | * hanging around.
|
---|
| 2888 | */
|
---|
| 2889 | void _buffer_add_kdev(int buf_id)
|
---|
| 2890 | {
|
---|
| 2891 | _str sName = 'def-koptions-'buf_id;
|
---|
[2350] | 2892 | int idx = find_index(sName, MISC_TYPE);
|
---|
[323] | 2893 | if (idx)
|
---|
[2350] | 2894 | delete_name(idx);
|
---|
| 2895 | //message("_buffer_add_kdev: " idx " name=" sName);
|
---|
| 2896 |
|
---|
| 2897 | sName = 'def-kstyledoc-'buf_id;
|
---|
| 2898 | idx = find_index(sName, MISC_TYPE);
|
---|
| 2899 | if (idx)
|
---|
| 2900 | delete_name(idx);
|
---|
| 2901 |
|
---|
| 2902 | //k_style_load();
|
---|
[323] | 2903 | }
|
---|
[288] | 2904 |
|
---|
[323] | 2905 |
|
---|
| 2906 | /**
|
---|
| 2907 | * Callback function for the event of quitting a buffer.
|
---|
| 2908 | *
|
---|
| 2909 | * This is used to make sure there are no left over per buffer options
|
---|
| 2910 | * hanging around.
|
---|
| 2911 | */
|
---|
| 2912 | void _cbquit2_kdev(int buf_id)
|
---|
| 2913 | {
|
---|
| 2914 | _str sName = 'def-koptions-'buf_id;
|
---|
| 2915 | int idx = find_index(sName, MISC_TYPE);
|
---|
| 2916 | if (idx)
|
---|
| 2917 | delete_name(idx);
|
---|
| 2918 | //message("_cbquit2_kdev: " idx " " sName);
|
---|
| 2919 |
|
---|
| 2920 | sName = 'def-kstyledoc-'buf_id;
|
---|
| 2921 | idx = find_index(sName, MISC_TYPE);
|
---|
| 2922 | if (idx)
|
---|
| 2923 | delete_name(idx);
|
---|
| 2924 | }
|
---|
| 2925 |
|
---|
| 2926 |
|
---|
| 2927 | /**
|
---|
| 2928 | * Called to get save options for the current buffer.
|
---|
| 2929 | *
|
---|
| 2930 | * This requires a modified loadsave.e!
|
---|
| 2931 | */
|
---|
| 2932 | _str _buffer_save_kdev(int buf_id)
|
---|
| 2933 | {
|
---|
| 2934 | _str sRet = ""
|
---|
| 2935 | _str sName = 'def-koptions-'buf_id;
|
---|
| 2936 | int idx = find_index(sName, MISC_TYPE);
|
---|
| 2937 | if (idx)
|
---|
| 2938 | {
|
---|
| 2939 | _str sOptions = strip(name_info(idx));
|
---|
| 2940 | if (sOptions != "")
|
---|
| 2941 | parse sOptions with . "saveoptions:" sRet .
|
---|
| 2942 | message("_buffer_save_kdev: " idx " " sName " " sOptions);
|
---|
| 2943 | }
|
---|
| 2944 | return sRet;
|
---|
| 2945 | }
|
---|
| 2946 |
|
---|
| 2947 |
|
---|
| 2948 |
|
---|
[113] | 2949 | /*******************************************************************************
|
---|
| 2950 | * Menu and Menu commands *
|
---|
| 2951 | *******************************************************************************/
|
---|
| 2952 | static int iTimer = 0;
|
---|
| 2953 | static int mhkDev = 0;
|
---|
| 2954 | static int mhCode = 0;
|
---|
| 2955 | static int mhDoc = 0;
|
---|
| 2956 | static int mhLic = 0;
|
---|
| 2957 | static int mhPre = 0;
|
---|
| 2958 |
|
---|
| 2959 | /*
|
---|
| 2960 | * Creates the kDev menu.
|
---|
| 2961 | */
|
---|
| 2962 | static k_menu_create()
|
---|
| 2963 | {
|
---|
| 2964 | if (arg(1) == 'timer')
|
---|
| 2965 | _kill_timer(iTimer);
|
---|
| 2966 | menu_handle = _mdi.p_menu_handle;
|
---|
| 2967 | menu_index = find_index(_cur_mdi_menu,oi2type(OI_MENU));
|
---|
| 2968 |
|
---|
| 2969 | /*
|
---|
| 2970 | * Remove any old menu.
|
---|
| 2971 | */
|
---|
| 2972 | mhDelete = iPos = 0;
|
---|
| 2973 | index = _menu_find(menu_handle, "kDev", mhDelete, iPos, 'C');
|
---|
| 2974 | //message("index="index " mhDelete="mhDelete " iPos="iPos);
|
---|
| 2975 | if (index == 0)
|
---|
| 2976 | _menu_delete(mhDelete, iPos);
|
---|
| 2977 |
|
---|
| 2978 |
|
---|
| 2979 | /*
|
---|
| 2980 | * Insert the "kDev" menu.
|
---|
| 2981 | */
|
---|
| 2982 | mhkDev = _menu_insert(menu_handle, 9, MF_SUBMENU, "&kDev", "", "kDev");
|
---|
| 2983 | mhCode=_menu_insert(mhkDev, -1, MF_ENABLED | MF_SUBMENU, "Coding &Style", "", "coding");
|
---|
| 2984 | rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 2, Syntax Indent 4 (knut)", "k_menu_style Opt2Ind4", "Opt2Ind4");
|
---|
| 2985 | rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 2, Syntax Indent 3", "k_menu_style Opt2Ind3", "Opt2Ind3");
|
---|
| 2986 | rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 2, Syntax Indent 8", "k_menu_style Opt2Ind8", "Opt2Ind8");
|
---|
| 2987 | rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 3, Syntax Indent 4 (giws)", "k_menu_style Opt3Ind4", "Opt3Ind4");
|
---|
| 2988 | rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 3, Syntax Indent 3 (giws)", "k_menu_style Opt3Ind3", "Opt3Ind3");
|
---|
| 2989 |
|
---|
| 2990 | mhDoc= _menu_insert(mhkDev, -1, MF_ENABLED | MF_SUBMENU, "&Documentation", "", "doc");
|
---|
| 2991 | mhDSJ= _menu_insert(mhDoc, -1, MF_ENABLED | MF_UNCHECKED, "&Javadoc Style", "k_menu_doc_style javadoc", "javadoc");
|
---|
| 2992 | mhDSL= _menu_insert(mhDoc, -1, MF_GRAYED | MF_UNCHECKED, "&Linux Kernel Style", "k_menu_doc_style linux", "linux");
|
---|
| 2993 |
|
---|
| 2994 | mhLic= _menu_insert(mhkDev, -1, MF_ENABLED | MF_SUBMENU, "&License", "", "License");
|
---|
| 2995 | rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&Odin32", "k_menu_license Odin32", "Odin32");
|
---|
| 2996 | rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&GPL", "k_menu_license GPL", "GPL");
|
---|
| 2997 | rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&LGPL", "k_menu_license LGPL", "LGPL");
|
---|
[2019] | 2998 | rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&GPLv3", "k_menu_license GPLv3", "GPLv3");
|
---|
| 2999 | rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&LGPLv3", "k_menu_license LGPLv3", "LGPLv3");
|
---|
[784] | 3000 | rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&VirtualBox", "k_menu_license VirtualBox", "VirtualBox");
|
---|
[1647] | 3001 | rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&VirtualBox GPL And CDDL","k_menu_license VirtualBoxGPLAndCDDL", "VirtualBoxGPLAndCDDL");
|
---|
[113] | 3002 | rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&Confidential", "k_menu_license Confidential", "Confidential");
|
---|
[2019] | 3003 | rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&Confidential No Author", "k_menu_license ConfidentialNoAuthor", "ConfidentialNoAuthor");
|
---|
[113] | 3004 |
|
---|
| 3005 | rc = _menu_insert(mhkDev, -1, MF_ENABLED, "-", "", "dash vars");
|
---|
| 3006 | rc = _menu_insert(mhkDev, -1, MF_ENABLED, skChange == '' ? '&Change...' : '&Change (' skChange ')...', "k_menu_change", "");
|
---|
| 3007 | rc = _menu_insert(mhkDev, -1, MF_ENABLED, skProgram == '' ? '&Program...' : '&Program (' skProgram ')...', "k_menu_program", "");
|
---|
| 3008 | rc = _menu_insert(mhkDev, -1, MF_ENABLED, skCompany == '' ? 'Co&mpany...' : 'Co&mpany (' skCompany ')...', "k_menu_company", "");
|
---|
| 3009 | rc = _menu_insert(mhkDev, -1, MF_ENABLED, '&User Name (' skUserName ')...', "k_menu_user_name", "username");
|
---|
| 3010 | rc = _menu_insert(mhkDev, -1, MF_ENABLED, 'User &e-mail (' skUserEmail ')...', "k_menu_user_email", "useremail");
|
---|
| 3011 | rc = _menu_insert(mhkDev, -1, MF_ENABLED, 'User &Initials (' skUserInitials ')...', "k_menu_user_initials", "userinitials");
|
---|
| 3012 | rc = _menu_insert(mhkDev, -1, MF_ENABLED, "-", "", "dash preset");
|
---|
| 3013 | mhPre= _menu_insert(mhkDev, -1, MF_SUBMENU, "P&resets", "", "");
|
---|
[2019] | 3014 | rc = _menu_insert(mhPre, -1, MF_ENABLED, "The Bird", "k_menu_preset javadoc, GPL, Opt2Ind4", "bird");
|
---|
| 3015 | rc = _menu_insert(mhPre, -1, MF_ENABLED, "kLIBC", "k_menu_preset javadoc, GPL, Opt2Ind4,, kLIBC", "kLIBC");
|
---|
| 3016 | rc = _menu_insert(mhPre, -1, MF_ENABLED, "kBuild", "k_menu_preset javadoc, GPLv3, Opt2Ind4,, kBuild", "kBuild");
|
---|
| 3017 | rc = _menu_insert(mhPre, -1, MF_ENABLED, "kStuff", "k_menu_preset javadoc, GPL, Opt2Ind4,, kStuff", "kStuff");
|
---|
| 3018 | rc = _menu_insert(mhPre, -1, MF_ENABLED, "sun", "k_menu_preset javadoc, ConfidentialNoAuthor, Opt2Ind4, sun", "sun");
|
---|
| 3019 | rc = _menu_insert(mhPre, -1, MF_ENABLED, "VirtualBox", "k_menu_preset javadoc, VirtualBox, Opt2Ind4, sun", "VirtualBox");
|
---|
[113] | 3020 |
|
---|
| 3021 | k_menu_doc_style();
|
---|
| 3022 | k_menu_license();
|
---|
| 3023 | k_menu_style();
|
---|
| 3024 | }
|
---|
| 3025 |
|
---|
| 3026 |
|
---|
| 3027 | /**
|
---|
| 3028 | * Change change Id.
|
---|
| 3029 | */
|
---|
| 3030 | _command k_menu_change()
|
---|
| 3031 | {
|
---|
| 3032 | sRc = show("-modal k_form_simple_input", "Change ID", skChange);
|
---|
| 3033 | if (sRc != "\r")
|
---|
| 3034 | {
|
---|
| 3035 | skChange = sRc;
|
---|
| 3036 | k_menu_create();
|
---|
| 3037 | }
|
---|
| 3038 | }
|
---|
| 3039 |
|
---|
| 3040 |
|
---|
| 3041 | /**
|
---|
| 3042 | * Change program name.
|
---|
| 3043 | */
|
---|
| 3044 | _command k_menu_program()
|
---|
| 3045 | {
|
---|
| 3046 | sRc = show("-modal k_form_simple_input", "Program", skProgram);
|
---|
| 3047 | if (sRc != "\r")
|
---|
| 3048 | {
|
---|
| 3049 | skProgram = sRc;
|
---|
| 3050 | k_menu_create();
|
---|
| 3051 | }
|
---|
| 3052 | }
|
---|
| 3053 |
|
---|
| 3054 |
|
---|
| 3055 | /**
|
---|
| 3056 | * Change company.
|
---|
| 3057 | */
|
---|
| 3058 | _command k_menu_company()
|
---|
| 3059 | {
|
---|
| 3060 | if (skCompany == '')
|
---|
[1367] | 3061 | sRc = show("-modal k_form_simple_input", "Company", 'innotek GmbH');
|
---|
[113] | 3062 | else
|
---|
| 3063 | sRc = show("-modal k_form_simple_input", "Company", skCompany);
|
---|
| 3064 | if (sRc != "\r")
|
---|
| 3065 | {
|
---|
| 3066 | skCompany = sRc;
|
---|
| 3067 | k_menu_create();
|
---|
| 3068 | }
|
---|
| 3069 | }
|
---|
| 3070 |
|
---|
| 3071 |
|
---|
| 3072 | /**
|
---|
| 3073 | * Change user name.
|
---|
| 3074 | */
|
---|
| 3075 | _command k_menu_user_name()
|
---|
| 3076 | {
|
---|
| 3077 | sRc = show("-modal k_form_simple_input", "User Name", skUserName);
|
---|
| 3078 | if (sRc != "\r" && sRc != '')
|
---|
| 3079 | {
|
---|
| 3080 | skUserName = sRc;
|
---|
| 3081 | k_menu_create();
|
---|
| 3082 | }
|
---|
| 3083 | }
|
---|
| 3084 |
|
---|
| 3085 |
|
---|
| 3086 | /**
|
---|
| 3087 | * Change user email.
|
---|
| 3088 | */
|
---|
| 3089 | _command k_menu_user_email()
|
---|
| 3090 | {
|
---|
| 3091 | sRc = show("-modal k_form_simple_input", "User e-mail", skUserEmail);
|
---|
| 3092 | if (sRc != "\r" && sRc != '')
|
---|
| 3093 | {
|
---|
| 3094 | skUserEmail = sRc;
|
---|
| 3095 | k_menu_create();
|
---|
| 3096 | }
|
---|
| 3097 | }
|
---|
| 3098 |
|
---|
| 3099 |
|
---|
| 3100 | /**
|
---|
| 3101 | * Change user initials.
|
---|
| 3102 | */
|
---|
| 3103 | _command k_menu_user_initials()
|
---|
| 3104 | {
|
---|
| 3105 | sRc = show("-modal k_form_simple_input", "User e-mail", skUserInitials);
|
---|
| 3106 | if (sRc != "\r" && sRc != '')
|
---|
| 3107 | {
|
---|
| 3108 | skUserInitials = sRc;
|
---|
| 3109 | k_menu_create();
|
---|
| 3110 | }
|
---|
| 3111 | }
|
---|
| 3112 |
|
---|
| 3113 |
|
---|
| 3114 |
|
---|
| 3115 | /**
|
---|
| 3116 | * Checks the correct menu item.
|
---|
| 3117 | */
|
---|
| 3118 | _command void k_menu_doc_style(_str sNewDocStyle = '')
|
---|
| 3119 | {
|
---|
| 3120 | //say 'sNewDocStyle='sNewDocStyle;
|
---|
| 3121 | if (sNewDocStyle != '')
|
---|
| 3122 | skDocStyle = sNewDocStyle
|
---|
| 3123 | _menu_set_state(mhDoc, "javadoc", MF_UNCHECKED);
|
---|
| 3124 | _menu_set_state(mhDoc, "linux", MF_UNCHECKED | MF_GRAYED);
|
---|
[2019] | 3125 |
|
---|
[113] | 3126 | _menu_set_state(mhDoc, skDocStyle, MF_CHECKED);
|
---|
| 3127 | }
|
---|
| 3128 |
|
---|
| 3129 |
|
---|
| 3130 | /**
|
---|
| 3131 | * Checks the correct menu item.
|
---|
| 3132 | */
|
---|
| 3133 | _command void k_menu_license(_str sNewLicense = '')
|
---|
| 3134 | {
|
---|
| 3135 | //say 'sNewLicense='sNewLicense;
|
---|
| 3136 | if (sNewLicense != '')
|
---|
| 3137 | skLicense = sNewLicense
|
---|
| 3138 | _menu_set_state(mhLic, "Odin32", MF_UNCHECKED);
|
---|
| 3139 | _menu_set_state(mhLic, "GPL", MF_UNCHECKED);
|
---|
| 3140 | _menu_set_state(mhLic, "LGPL", MF_UNCHECKED);
|
---|
[2019] | 3141 | _menu_set_state(mhLic, "GPLv3", MF_UNCHECKED);
|
---|
| 3142 | _menu_set_state(mhLic, "LGPLv3", MF_UNCHECKED);
|
---|
| 3143 | _menu_set_state(mhLic, "VirtualBox", MF_UNCHECKED);
|
---|
| 3144 | _menu_set_state(mhLic, "VirtualBoxGPLAndCDDL", MF_UNCHECKED);
|
---|
[113] | 3145 | _menu_set_state(mhLic, "Confidential", MF_UNCHECKED);
|
---|
[2019] | 3146 | _menu_set_state(mhLic, "ConfidentialNoAuthor", MF_UNCHECKED);
|
---|
| 3147 |
|
---|
[113] | 3148 | _menu_set_state(mhLic, skLicense, MF_CHECKED);
|
---|
| 3149 | }
|
---|
| 3150 |
|
---|
| 3151 |
|
---|
| 3152 | /**
|
---|
| 3153 | * Check the correct style menu item.
|
---|
| 3154 | */
|
---|
| 3155 | _command void k_menu_style(_str sNewStyle = '')
|
---|
| 3156 | {
|
---|
| 3157 | //say 'sNewStyle='sNewStyle;
|
---|
| 3158 | _menu_set_state(mhCode, "Opt1Ind4", MF_UNCHECKED);
|
---|
| 3159 | _menu_set_state(mhCode, "Opt1Ind3", MF_UNCHECKED);
|
---|
| 3160 | _menu_set_state(mhCode, "Opt1Ind8", MF_UNCHECKED);
|
---|
| 3161 | _menu_set_state(mhCode, "Opt2Ind4", MF_UNCHECKED);
|
---|
| 3162 | _menu_set_state(mhCode, "Opt2Ind3", MF_UNCHECKED);
|
---|
| 3163 | _menu_set_state(mhCode, "Opt2Ind8", MF_UNCHECKED);
|
---|
| 3164 | _menu_set_state(mhCode, "Opt3Ind4", MF_UNCHECKED);
|
---|
| 3165 | _menu_set_state(mhCode, "Opt3Ind3", MF_UNCHECKED);
|
---|
| 3166 | _menu_set_state(mhCode, "Opt3Ind8", MF_UNCHECKED);
|
---|
| 3167 |
|
---|
| 3168 | if (sNewStyle != '')
|
---|
| 3169 | {
|
---|
| 3170 | int iIndent = (int)substr(sNewStyle, 8, 1);
|
---|
| 3171 | int iBraceStyle = (int)substr(sNewStyle, 4, 1);
|
---|
| 3172 | skCodeStyle = sNewStyle;
|
---|
| 3173 | k_styles_setindent(iIndent, iBraceStyle);
|
---|
| 3174 | k_styles_set(sNewStyle);
|
---|
| 3175 | }
|
---|
| 3176 |
|
---|
| 3177 | _menu_set_state(mhCode, skCodeStyle, MF_CHECKED);
|
---|
| 3178 | }
|
---|
| 3179 |
|
---|
| 3180 |
|
---|
| 3181 | /**
|
---|
| 3182 | * Load a 'preset'.
|
---|
| 3183 | */
|
---|
| 3184 | _command void k_menu_preset(_str sArgs = '')
|
---|
| 3185 | {
|
---|
| 3186 | parse sArgs with sNewDocStyle ',' sNewLicense ',' sNewStyle ',' sNewCompany ',' sNewProgram ',' sNewChange
|
---|
| 3187 | sNewDocStyle= strip(sNewDocStyle);
|
---|
| 3188 | sNewLicense = strip(sNewLicense);
|
---|
| 3189 | sNewStyle = strip(sNewStyle);
|
---|
| 3190 | sNewCompany = strip(sNewCompany);
|
---|
[1592] | 3191 | if (sNewCompany == 'sun')
|
---|
| 3192 | sNewCompany = 'Sun Microsystems, Inc.'
|
---|
[113] | 3193 | sNewProgram = strip(sNewProgram);
|
---|
| 3194 | sNewChange = strip(sNewChange);
|
---|
| 3195 |
|
---|
| 3196 | //say 'k_menu_preset('sNewDocStyle',' sNewLicense',' sNewStyle',' sNewCompany',' sNewProgram')';
|
---|
| 3197 | k_menu_doc_style(sNewDocStyle);
|
---|
| 3198 | k_menu_license(sNewLicense);
|
---|
| 3199 | k_menu_style(sNewStyle);
|
---|
| 3200 | skCompany = sNewCompany;
|
---|
| 3201 | skProgram = sNewProgram;
|
---|
| 3202 | skChange = sNewChange;
|
---|
| 3203 | k_menu_create();
|
---|
| 3204 | }
|
---|
| 3205 |
|
---|
| 3206 |
|
---|
| 3207 |
|
---|
| 3208 | /* future ones..
|
---|
| 3209 | _command k_menu_setcolor()
|
---|
| 3210 | {
|
---|
| 3211 | createMyColorSchemeAndUseIt();
|
---|
| 3212 | }
|
---|
| 3213 |
|
---|
| 3214 |
|
---|
| 3215 | _command k_menu_setkeys()
|
---|
| 3216 | {
|
---|
| 3217 | rc = load("d:/knut/VSlickMacros/BoxerDef.e");
|
---|
| 3218 | }
|
---|
| 3219 |
|
---|
| 3220 | _command k_menu_settings()
|
---|
| 3221 | {
|
---|
| 3222 | mySettings();
|
---|
| 3223 | }
|
---|
| 3224 | */
|
---|
| 3225 |
|
---|
| 3226 |
|
---|
| 3227 | /*******************************************************************************
|
---|
| 3228 | * Dialogs *
|
---|
| 3229 | *******************************************************************************/
|
---|
| 3230 | _form k_form_simple_input {
|
---|
| 3231 | p_backcolor=0x80000005
|
---|
| 3232 | p_border_style=BDS_DIALOG_BOX
|
---|
| 3233 | p_caption='Simple Input'
|
---|
| 3234 | p_clip_controls=FALSE
|
---|
| 3235 | p_forecolor=0x80000008
|
---|
| 3236 | p_height=1120
|
---|
| 3237 | p_width=5020
|
---|
| 3238 | p_x=6660
|
---|
| 3239 | p_y=6680
|
---|
| 3240 | _text_box entText {
|
---|
| 3241 | p_auto_size=TRUE
|
---|
| 3242 | p_backcolor=0x80000005
|
---|
| 3243 | p_border_style=BDS_FIXED_SINGLE
|
---|
| 3244 | p_completion=NONE_ARG
|
---|
| 3245 | p_font_bold=FALSE
|
---|
| 3246 | p_font_italic=FALSE
|
---|
| 3247 | p_font_name='MS Sans Serif'
|
---|
| 3248 | p_font_size=8
|
---|
| 3249 | p_font_underline=FALSE
|
---|
| 3250 | p_forecolor=0x80000008
|
---|
| 3251 | p_height=270
|
---|
| 3252 | p_tab_index=1
|
---|
| 3253 | p_tab_stop=TRUE
|
---|
| 3254 | p_text='text'
|
---|
| 3255 | p_width=3180
|
---|
| 3256 | p_x=1680
|
---|
| 3257 | p_y=240
|
---|
| 3258 | p_eventtab2=_ul2_textbox
|
---|
| 3259 | }
|
---|
| 3260 | _label lblLabel {
|
---|
| 3261 | p_alignment=AL_VCENTERRIGHT
|
---|
| 3262 | p_auto_size=FALSE
|
---|
| 3263 | p_backcolor=0x80000005
|
---|
| 3264 | p_border_style=BDS_NONE
|
---|
| 3265 | p_caption='Label'
|
---|
| 3266 | p_font_bold=FALSE
|
---|
| 3267 | p_font_italic=FALSE
|
---|
| 3268 | p_font_name='MS Sans Serif'
|
---|
| 3269 | p_font_size=8
|
---|
| 3270 | p_font_underline=FALSE
|
---|
| 3271 | p_forecolor=0x80000008
|
---|
| 3272 | p_height=240
|
---|
| 3273 | p_tab_index=2
|
---|
| 3274 | p_width=1380
|
---|
| 3275 | p_word_wrap=FALSE
|
---|
| 3276 | p_x=180
|
---|
| 3277 | p_y=240
|
---|
| 3278 | }
|
---|
| 3279 | _command_button btnOK {
|
---|
| 3280 | p_cancel=FALSE
|
---|
| 3281 | p_caption='&OK'
|
---|
| 3282 | p_default=TRUE
|
---|
| 3283 | p_font_bold=FALSE
|
---|
| 3284 | p_font_italic=FALSE
|
---|
| 3285 | p_font_name='MS Sans Serif'
|
---|
| 3286 | p_font_size=8
|
---|
| 3287 | p_font_underline=FALSE
|
---|
| 3288 | p_height=360
|
---|
| 3289 | p_tab_index=3
|
---|
| 3290 | p_tab_stop=TRUE
|
---|
| 3291 | p_width=1020
|
---|
| 3292 | p_x=180
|
---|
| 3293 | p_y=660
|
---|
| 3294 | }
|
---|
| 3295 | _command_button btnCancel {
|
---|
| 3296 | p_cancel=TRUE
|
---|
| 3297 | p_caption='Cancel'
|
---|
| 3298 | p_default=FALSE
|
---|
| 3299 | p_font_bold=FALSE
|
---|
| 3300 | p_font_italic=FALSE
|
---|
| 3301 | p_font_name='MS Sans Serif'
|
---|
| 3302 | p_font_size=8
|
---|
| 3303 | p_font_underline=FALSE
|
---|
| 3304 | p_height=360
|
---|
| 3305 | p_tab_index=4
|
---|
| 3306 | p_tab_stop=TRUE
|
---|
| 3307 | p_width=840
|
---|
| 3308 | p_x=1380
|
---|
| 3309 | p_y=660
|
---|
| 3310 | }
|
---|
| 3311 | }
|
---|
| 3312 |
|
---|
| 3313 | defeventtab k_form_simple_input
|
---|
| 3314 | btnOK.on_create(_str sLabel = '', _str sText = '')
|
---|
| 3315 | {
|
---|
| 3316 | p_active_form.p_caption = sLabel;
|
---|
| 3317 | lblLabel.p_caption = sLabel;
|
---|
| 3318 | entText.p_text = sText;
|
---|
| 3319 | }
|
---|
| 3320 |
|
---|
| 3321 | btnOK.lbutton_up()
|
---|
| 3322 | {
|
---|
| 3323 | sText = entText.p_text;
|
---|
| 3324 | p_active_form._delete_window(sText);
|
---|
| 3325 | }
|
---|
| 3326 | btnCancel.lbutton_up()
|
---|
| 3327 | {
|
---|
| 3328 | sText = entText.p_text;
|
---|
| 3329 | p_active_form._delete_window("\r");
|
---|
| 3330 | }
|
---|
| 3331 |
|
---|
[2588] | 3332 | static _str aCLikeIncs[] =
|
---|
| 3333 | {
|
---|
[2583] | 3334 | "c", "ansic", "java", "rul", "vera", "ch", "as", "idl", "asm", "s", "imakefile", "rc", "lex", "yacc", "antlr"
|
---|
| 3335 | };
|
---|
[113] | 3336 |
|
---|
[2583] | 3337 | static _str aMyLangIds[] =
|
---|
| 3338 | {
|
---|
[2588] | 3339 | "ansic",
|
---|
| 3340 | "antlr",
|
---|
| 3341 | "as",
|
---|
| 3342 | "asm",
|
---|
| 3343 | "c",
|
---|
| 3344 | "csh",
|
---|
| 3345 | "css",
|
---|
| 3346 | "ch",
|
---|
| 3347 | "conf",
|
---|
| 3348 | "d",
|
---|
| 3349 | "docbook",
|
---|
| 3350 | "dtd",
|
---|
| 3351 | "html",
|
---|
| 3352 | "idl",
|
---|
| 3353 | "imakefile",
|
---|
| 3354 | "ini",
|
---|
| 3355 | "java",
|
---|
| 3356 | "js",
|
---|
| 3357 | "lex",
|
---|
| 3358 | "mak",
|
---|
| 3359 | "masm",
|
---|
| 3360 | "phpscript",
|
---|
| 3361 | "powershell",
|
---|
[2583] | 3362 | "py",
|
---|
| 3363 | "rexx",
|
---|
[2588] | 3364 | "rc",
|
---|
| 3365 | "rul",
|
---|
| 3366 | "tcl",
|
---|
| 3367 | "s",
|
---|
| 3368 | "unixasm",
|
---|
| 3369 | "vbs",
|
---|
| 3370 | "xhtml",
|
---|
| 3371 | "xml",
|
---|
| 3372 | "xmldoc",
|
---|
| 3373 | "xsd",
|
---|
[2583] | 3374 | "yacc"
|
---|
| 3375 | };
|
---|
[113] | 3376 |
|
---|
[2583] | 3377 | #if __VERSION__ >= 17.0
|
---|
| 3378 | # require "se/lang/api/LanguageSettings.e"
|
---|
| 3379 | using se.lang.api.LanguageSettings;
|
---|
| 3380 | #endif
|
---|
| 3381 |
|
---|
[113] | 3382 | /**
|
---|
[2583] | 3383 | * Loads the standard bird settings.
|
---|
| 3384 | */
|
---|
| 3385 | _command void kdev_load_settings()
|
---|
| 3386 | {
|
---|
[2588] | 3387 | typeless nt1;
|
---|
[2583] | 3388 | typeless nt2;
|
---|
| 3389 | typeless nt3;
|
---|
| 3390 | typeless nt4;
|
---|
| 3391 | typeless nt5;
|
---|
| 3392 | typeless nt6;
|
---|
| 3393 | typeless i7;
|
---|
| 3394 | _str sRest;
|
---|
| 3395 | _str sTmp;
|
---|
| 3396 |
|
---|
| 3397 | /*
|
---|
| 3398 | * Generl stuff.
|
---|
| 3399 | */
|
---|
| 3400 | _default_option('A', '0'); /* ALT menu */
|
---|
| 3401 | def_alt_menu = 0;
|
---|
| 3402 | _default_option('R', '130'); /* Vertical line in column 130. */
|
---|
| 3403 | def_mfsearch_init_flags = 2 | 4; /* MFSEARCH_INIT_CURWORD | MFSEARCH_INIT_SELECTION */
|
---|
| 3404 | def_line_insert = 'B'; /* insert before */
|
---|
| 3405 | def_file_types='All Files (*),' /** @todo make this prettier */
|
---|
| 3406 | 'C/C++ Files (*.c;*.cc;*.cpp;*.cp;*.cxx;*.c++;*.h;*.hh;*.hpp;*.hxx;*.inl;*.xpm),'
|
---|
| 3407 | 'Assembler (*.s;*.asm;*.mac;*.S),'
|
---|
| 3408 | 'Makefiles (*;*.mak;*.kmk)'
|
---|
| 3409 | 'C# Files (*.cs),'
|
---|
| 3410 | 'Ch Files (*.ch;*.chf;*.chs;*.cpp;*.h),'
|
---|
| 3411 | 'D Files (*.d),'
|
---|
| 3412 | 'Java Files (*.java),'
|
---|
| 3413 | 'HTML Files (*.htm;*.html;*.shtml;*.asp;*.jsp;*.php;*.php3;*.rhtml;*.css),'
|
---|
| 3414 | 'CFML Files (*.cfm;*.cfml;*.cfc),'
|
---|
| 3415 | 'XML Files (*.xml;*.dtd;*.xsd;*.xmldoc;*.xsl;*.xslt;*.ent;*.tld;*.xhtml;*.build;*.plist),'
|
---|
| 3416 | 'XML/SGML DTD Files (*.xsd;*.dtd),'
|
---|
| 3417 | 'XML/JSP TagLib Files (*.tld;*.xml),'
|
---|
| 3418 | 'Objective-C (*.m;*.mm;*.h),'
|
---|
| 3419 | 'IDL Files (*.idl),'
|
---|
| 3420 | 'Ada Files (*.ada;*.adb;*.ads),'
|
---|
| 3421 | 'Applescript Files (*.applescript),'
|
---|
| 3422 | 'Basic Files (*.vb;*.vbs;*.bas;*.frm),'
|
---|
| 3423 | 'Cobol Files (*.cob;*.cbl;*.ocb),'
|
---|
| 3424 | 'JCL Files (*.jcl),'
|
---|
| 3425 | 'JavaScript (*.js;*.ds),'
|
---|
| 3426 | 'ActionScript (*.as),'
|
---|
| 3427 | 'Pascal Files (*.pas;*.dpr),'
|
---|
| 3428 | 'Fortran Files (*.for;*.f),'
|
---|
| 3429 | 'PL/I Files (*.pl1),'
|
---|
| 3430 | 'InstallScript (*.rul),'
|
---|
| 3431 | 'Perl Files (*.pl;*.pm;*.perl;*.plx),'
|
---|
| 3432 | 'Python Files (*.py),'
|
---|
| 3433 | 'Ruby Files (*.rb;*.rby),'
|
---|
| 3434 | 'Java Properties (*.properties),'
|
---|
| 3435 | 'Lua Files (*.lua),'
|
---|
| 3436 | 'Tcl Files (*.tcl;*.tlib;*.itk;*.itcl;*.exp),'
|
---|
| 3437 | 'PV-WAVE (*.pro),'
|
---|
| 3438 | 'Slick-C (*.e;*.sh),'
|
---|
| 3439 | 'SQL Files (*.sql),'
|
---|
| 3440 | 'SAS Files (*.sas),'
|
---|
| 3441 | 'Text Files (*.txt),'
|
---|
| 3442 | 'Verilog Files (*.v),'
|
---|
| 3443 | 'VHDL Files (*.vhd),'
|
---|
| 3444 | 'SystemVerilog Files (*.sv;*.svh;*.svi),'
|
---|
| 3445 | 'Vera Files (*.vr;*.vrh),'
|
---|
| 3446 | 'Erlang Files (*.erl;*.hrl),'
|
---|
| 3447 | ;
|
---|
| 3448 |
|
---|
| 3449 | def_updown_col=0; /* cursor movement */
|
---|
| 3450 | def_cursorwrap=0; /* ditto. */
|
---|
| 3451 | def_click_past_end=1; /* ditto */
|
---|
| 3452 | def_start_on_first=1; /* vs A B C; view A. */
|
---|
| 3453 | def_vc_system='Subversion' /* svn is default version control */
|
---|
| 3454 | #if __VERSION__ >= 16.0
|
---|
| 3455 | def_auto_unsurround_block=0; /* Delete line, not block. */
|
---|
| 3456 | #endif
|
---|
| 3457 |
|
---|
| 3458 | /* Make it grok: # include <stuff.h> */
|
---|
| 3459 | for (i = 0; i < aCLikeIncs._length(); i++)
|
---|
| 3460 | replace_def_data("def-":+aCLikeIncs[i]:+"-include",
|
---|
| 3461 | '^[ \t]*(\#[ \t]*include|include|\#[ \t]*line)[ \t]#({#1:i}[ \t]#|)(<{#0[~>]#}>|"{#0[~"]#}")');
|
---|
| 3462 | replace_def_data("def-m-include", '^[ \t]*(\#[ \t]*include|\#[ \t]*import|include|\#[ \t]*line)[ \t]#({#1:i}[ \t]#|)(<{#0[~>]#}>|"{#0[~"]#}")');
|
---|
| 3463 | replace_def_data("def-e-include", '^[ \t]*(\#[ \t]*include|\#[ \t]*import|\#[ \t]*require|include)[ \t]#(''{#0[~'']#}''|"{#0[~"]#}")');
|
---|
| 3464 |
|
---|
| 3465 | /* Replace the default unicode proportional font with the fixed oned. */
|
---|
| 3466 | _str sCodeFont = _default_font(CFG_SBCS_DBCS_SOURCE_WINDOW);
|
---|
| 3467 | _str sUnicodeFont = _default_font(CFG_UNICODE_SOURCE_WINDOW);
|
---|
| 3468 | if (pos("Default Unicode", sUnicodeFont) > 0 && length(sCodeFont) > 5)
|
---|
| 3469 | _default_font(CFG_UNICODE_SOURCE_WINDOW,sCodeFont);
|
---|
| 3470 | if (machine()=='INTELSOLARIS' || machine()=='SPARCSOLARIS')
|
---|
| 3471 | {
|
---|
| 3472 | _default_font(CFG_MENU,'DejaVu Sans,10,0,0,');
|
---|
[2584] | 3473 | _default_font(CFG_DIALOG,'DejaVu Sans,10,0,,');
|
---|
| 3474 | _ConfigEnvVar('VSLICKDIALOGFONT','DejaVu Sans,10,0,,');
|
---|
[2583] | 3475 | }
|
---|
| 3476 |
|
---|
| 3477 | /* Not so important. */
|
---|
| 3478 | int fSearch = 0x400400; /* VSSEARCHFLAG_WRAP | VSSEARCHFLAG_PROMPT_WRAP */;
|
---|
| 3479 | _default_option('S', (_str)fSearch);
|
---|
| 3480 |
|
---|
| 3481 |
|
---|
| 3482 | #if __VERSION__ >= 17.0
|
---|
| 3483 | /*
|
---|
| 3484 | * Language settings via API.
|
---|
| 3485 | */
|
---|
| 3486 | _str sLangId;
|
---|
| 3487 | foreach (sLangId in aMyLangIds)
|
---|
| 3488 | {
|
---|
[2587] | 3489 | LanguageSettings.setIndentCaseFromSwitch(sLangId, true);
|
---|
| 3490 | LanguageSettings.setBeginEndStyle(sLangId, BES_BEGIN_END_STYLE_2);
|
---|
| 3491 | LanguageSettings.setIndentWithTabs(sLangId, false);
|
---|
| 3492 | LanguageSettings.setUseAdaptiveFormatting(sLangId, true);
|
---|
| 3493 | LanguageSettings.setSaveStripTrailingSpaces(sLangId, STSO_STRIP_MODIFIED);
|
---|
[2588] | 3494 | LanguageSettings.setTabs(sLangId, "8+");
|
---|
| 3495 | LanguageSettings.setSyntaxIndent(sLangId, 4);
|
---|
[2583] | 3496 |
|
---|
| 3497 | /* C/C++ setup, wrap at column 80 not 64. */
|
---|
| 3498 | sTmp = LanguageSettings.getCommentWrapOptions(sLangId);
|
---|
| 3499 | if (length(sTmp) > 10)
|
---|
| 3500 | {
|
---|
| 3501 | typeless ntBlockCommentWrap, ntDocCommentWrap, ntFixedWidth;
|
---|
| 3502 | parse sTmp with ntBlockCommentWrap ntDocCommentWrap nt3 nt4 nt5 ntFixedWidth sRest;
|
---|
| 3503 | if ((int)ntFixedWidth < 80)
|
---|
| 3504 | LanguageSettings.setCommentWrapOptions('c', ntBlockCommentWrap:+' ':+ntDocCommentWrap:+' ':+nt3:+' ':+nt4:+' ':+nt5:+' 80 ':+sRest);
|
---|
| 3505 | //replace_def_data("def-comment-wrap-c",'0 1 0 1 1 64 0 0 80 0 80 0 80 0 0 1 '); - default
|
---|
| 3506 | //replace_def_data("def-comment-wrap-c",'0 1 0 1 1 80 0 0 80 0 80 0 80 0 0 0 '); - disabled
|
---|
| 3507 | //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.
|
---|
| 3508 | }
|
---|
| 3509 | }
|
---|
| 3510 | LanguageSettings.setIndentWithTabs('mak', true);
|
---|
[2586] | 3511 | LanguageSettings.setLexerName('mak', 'kmk');
|
---|
[2588] | 3512 | LanguageSettings.setSyntaxIndent('mak', 8);
|
---|
[2583] | 3513 |
|
---|
[2586] | 3514 | /* Fix .asm and add .mac and .kmk. */
|
---|
| 3515 | replace_def_data("def-lang-for-ext-asm",'masm');
|
---|
| 3516 | replace_def_data("def-lang-for-ext-mac",'masm');
|
---|
| 3517 | replace_def_data("def-lang-for-ext-kmk",'mak');
|
---|
[2583] | 3518 | #endif
|
---|
| 3519 |
|
---|
| 3520 | /** @todo
|
---|
| 3521 | * def_save_options
|
---|
| 3522 | * */
|
---|
| 3523 |
|
---|
| 3524 | message("Please restart SlickEdit.")
|
---|
| 3525 | }
|
---|
| 3526 |
|
---|
| 3527 | /**
|
---|
[113] | 3528 | * Module initiation.
|
---|
| 3529 | */
|
---|
| 3530 | definit()
|
---|
| 3531 | {
|
---|
[1081] | 3532 | /* do cleanup. */
|
---|
[2350] | 3533 | for (i = 0; i < 999; i++)
|
---|
[1081] | 3534 | {
|
---|
[2350] | 3535 | index = name_match("def-koptions-", 1 /*find_first*/, MISC_TYPE);
|
---|
[1081] | 3536 | if (!index)
|
---|
| 3537 | break;
|
---|
| 3538 | delete_name(index);
|
---|
| 3539 | }
|
---|
| 3540 |
|
---|
| 3541 | /* do init */
|
---|
| 3542 | k_styles_create();
|
---|
| 3543 | k_menu_create();
|
---|
| 3544 | iTimer = _set_timer(1000, k_menu_create, "timer");
|
---|
| 3545 | /* createMyColorSchemeAndUseIt();*/
|
---|
[113] | 3546 | }
|
---|