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