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