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