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