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