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