| 1 | /* $Id: kdev.e,v 1.3 2002-09-11 22:31:01 bird Exp $
|
|---|
| 2 | *
|
|---|
| 3 | * Visual SlickEdit Documentation Macros.
|
|---|
| 4 | *
|
|---|
| 5 | * Copyright (c) 1999-2002 knut st. osmundsen (bird@anduin.net)
|
|---|
| 6 | *
|
|---|
| 7 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 8 | *
|
|---|
| 9 | ****
|
|---|
| 10 | *
|
|---|
| 11 | * This define the following keys:
|
|---|
| 12 | *---------------------------------
|
|---|
| 13 | * Ctrl+Shift+C: Class description box.
|
|---|
| 14 | * Ctrl+Shift+F: Function/method description box.
|
|---|
| 15 | * Ctrl+Shift+M: Module(file) description box
|
|---|
| 16 | * Ctrl+Shift+O: One-liner (comment)
|
|---|
| 17 | *
|
|---|
| 18 | * Ctrl+Shift+G: Global box
|
|---|
| 19 | * Ctrl+Shift+H: Header box
|
|---|
| 20 | * Ctrl+Shift+I: Internal function box
|
|---|
| 21 | * Ctrl+Shift+K: Const/macro box
|
|---|
| 22 | * Ctrl+Shift+S: Struct/Typedef box
|
|---|
| 23 | *
|
|---|
| 24 | * Ctrl+Shift+P: Mark line as change by me
|
|---|
| 25 | *
|
|---|
| 26 | * Ctrl+Shift+T:
|
|---|
| 27 | *
|
|---|
| 28 | * Ctrl+Shift+B: KLOGENTRYX(..)
|
|---|
| 29 | * Ctrl+Shift+E: KLOGEXIT(..)
|
|---|
| 30 | * Ctrl+Shift+N: Do kLog stuff for the current file. No questions.
|
|---|
| 31 | * Ctrl+Shift+Q: Do kLog stuff for the current file. Ask a lot of questions.
|
|---|
| 32 | *
|
|---|
| 33 | * Remember to set the correct sOdin32UserName, sOdin32UserEmail and sOdin32UserInitials
|
|---|
| 34 | * before compiling and loading the macros into Visual SlickEdit.
|
|---|
| 35 | *
|
|---|
| 36 | * These macros are compatible with both 3.0(c) and 4.0(b).
|
|---|
| 37 | *
|
|---|
| 38 | */
|
|---|
| 39 | defeventtab default_keys
|
|---|
| 40 | def 'C-S-A' = k_signature
|
|---|
| 41 | //def 'C-S-B' = odin32_klogentry
|
|---|
| 42 | def 'C-S-C' = k_javadoc_classbox
|
|---|
| 43 | //def 'C-S-E' = odin32_klogexit
|
|---|
| 44 | def 'C-S-F' = k_javadoc_funcbox
|
|---|
| 45 | def 'C-S-G' = k_box_globals
|
|---|
| 46 | def 'C-S-H' = k_box_headers
|
|---|
| 47 | def 'C-S-I' = k_box_intfuncs
|
|---|
| 48 | def 'C-S-K' = k_box_consts
|
|---|
| 49 | def 'C-S-M' = k_javadoc_moduleheader
|
|---|
| 50 | //def 'C-S-N' = odin32_klog_file_no_ask
|
|---|
| 51 | def 'C-S-O' = k_oneliner
|
|---|
| 52 | //def 'C-S-Q' = odin32_klog_file_ask
|
|---|
| 53 | def 'C-S-P' = k_mark_modified_line
|
|---|
| 54 | def 'C-S-S' = k_box_structs
|
|---|
| 55 | def 'C-S-T' = odin32_maketagfile
|
|---|
| 56 |
|
|---|
| 57 |
|
|---|
| 58 | //MARKER. Editor searches for this line!
|
|---|
| 59 | #pragma option(redeclvars, on)
|
|---|
| 60 | #include 'slick.sh'
|
|---|
| 61 |
|
|---|
| 62 | /* Remeber to change these! */
|
|---|
| 63 | static _str skUserInitials = "kso";
|
|---|
| 64 | static _str skUserName = "knut st. osmundsen";
|
|---|
| 65 | static _str skUserEmail = "bird@anduin.net";
|
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 | /*******************************************************************************
|
|---|
| 69 | * Global Variables *
|
|---|
| 70 | *******************************************************************************/
|
|---|
| 71 | static _str skCodeStyle = 'Opt2Ind4'; /* coding style scheme. */
|
|---|
| 72 | static _str skDocStyle = 'javadoc';/* options: javadoc, */
|
|---|
| 73 | static _str skLicense = 'GPL'; /* options: GPL, LGPL, Odin32, Confidential */
|
|---|
| 74 | static _str skCompany = ''; /* empty or company name for copyright */
|
|---|
| 75 | static _str skProgram = ''; /* Current program name - used by [L]GPL */
|
|---|
| 76 | static _str skChange = ''; /* Current change identifier. */
|
|---|
| 77 |
|
|---|
| 78 | static int ikStyleWidth = 80; /* The page width of the style. */
|
|---|
| 79 | static boolean fkStyleFullHeaders = false; /* false: omit some tags. */
|
|---|
| 80 | static int ikStyleOneliner = 41; /* The online comment column. */
|
|---|
| 81 | static int ikStyleModifyMarkColumn = 105;
|
|---|
| 82 | static boolean fkStyleBoxTag = false; /* true: Include tag in k_box_start. */
|
|---|
| 83 |
|
|---|
| 84 |
|
|---|
| 85 | /*******************************************************************************
|
|---|
| 86 | * Internal Functions *
|
|---|
| 87 | *******************************************************************************/
|
|---|
| 88 | /**
|
|---|
| 89 | * Gets iso date.
|
|---|
| 90 | * @returns ISO formatted date.
|
|---|
| 91 | */
|
|---|
| 92 | static _str k_date()
|
|---|
| 93 | {
|
|---|
| 94 | int i,j;
|
|---|
| 95 | _str date;
|
|---|
| 96 |
|
|---|
| 97 | date = _date('U');
|
|---|
| 98 | i = pos("/", date);
|
|---|
| 99 | j = pos("/", date, i+1);
|
|---|
| 100 | month = substr(date, 1, i-1);
|
|---|
| 101 | if (length(month) == 1) month = '0'month;
|
|---|
| 102 | day = substr(date, i+1, j-i-1);
|
|---|
| 103 | if (length(day) == 1) day = '0'day;
|
|---|
| 104 | year = substr(date, j+1);
|
|---|
| 105 | return year"-"month"-"day;
|
|---|
| 106 | }
|
|---|
| 107 |
|
|---|
| 108 |
|
|---|
| 109 | /**
|
|---|
| 110 | * Get the current year.
|
|---|
| 111 | * @returns Current year string.
|
|---|
| 112 | */
|
|---|
| 113 | static _str k_year()
|
|---|
| 114 | {
|
|---|
| 115 | date = _date('U');
|
|---|
| 116 | return substr(date, pos("/",date, pos("/",date)+1)+1, 4);
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 |
|
|---|
| 120 | /**
|
|---|
| 121 | * Aligns a value up to a given alignment.
|
|---|
| 122 | */
|
|---|
| 123 | static int k_alignup(int iValue, iAlign)
|
|---|
| 124 | {
|
|---|
| 125 | if (iAlign <= 0)
|
|---|
| 126 | {
|
|---|
| 127 | message('k_alignup: iValue='iValue ' iAlign='iAlign);
|
|---|
| 128 | iAlign = 4;
|
|---|
| 129 | }
|
|---|
| 130 | return ((iValue intdiv iAlign) + 1) * iAlign;
|
|---|
| 131 | }
|
|---|
| 132 |
|
|---|
| 133 |
|
|---|
| 134 | /**
|
|---|
| 135 | * Reads the comment setup for this extension.
|
|---|
| 136 | * @returns Success indicator.
|
|---|
| 137 | * @param sLeft Left comment. (output)
|
|---|
| 138 | * @param sRight Right comment. (output)
|
|---|
| 139 | * @param iColumn Comment mark column. (1-based) (output)
|
|---|
| 140 | * @param sExt The extension to lookup defaults to the current one.
|
|---|
| 141 | * @author knut st. osmundsen (bird@anduin.net)
|
|---|
| 142 | * @remark This should be exported from box.e, but unfortunately it isn't.
|
|---|
| 143 | */
|
|---|
| 144 | static boolean k_readboxconfig(_str &sLeft, _str &sRight, int &iColumn, _str sExt = p_extension)
|
|---|
| 145 | {
|
|---|
| 146 | /*
|
|---|
| 147 | * Read the nonboxchars and determin user or default box.ini.
|
|---|
| 148 | */
|
|---|
| 149 | sFile = slick_path_search("ubox.ini");
|
|---|
| 150 | frc = _ini_get_value(sFile, sExt, 'nonboxchars', sLine);
|
|---|
| 151 | if (frc)
|
|---|
| 152 | {
|
|---|
| 153 | sFile = slick_path_search("box.ini")
|
|---|
| 154 | frc = _ini_get_value(sFile, sExt, 'nonboxchars', sLine);
|
|---|
| 155 | }
|
|---|
| 156 |
|
|---|
| 157 | if (!frc)
|
|---|
| 158 | { /*
|
|---|
| 159 | * Found extension.
|
|---|
| 160 | */
|
|---|
| 161 | sLeft = strip(eq_name2value('left',sLine));
|
|---|
| 162 | sRight = strip(eq_name2value('right',sLine));
|
|---|
| 163 |
|
|---|
| 164 | /* Read comment column too */
|
|---|
| 165 | frc = _ini_get_value(sFile, sExt, 'comment_col', sLine);
|
|---|
| 166 | if (frc)
|
|---|
| 167 | iColumn = eq_name2value('comment_col', sLine);
|
|---|
| 168 | else
|
|---|
| 169 | iColumn = 0;
|
|---|
| 170 | return true;
|
|---|
| 171 | }
|
|---|
| 172 |
|
|---|
| 173 | /* failure */
|
|---|
| 174 | sLeft = sRight = '';
|
|---|
| 175 | iColumn = 0;
|
|---|
| 176 |
|
|---|
| 177 | return false;
|
|---|
| 178 | }
|
|---|
| 179 |
|
|---|
| 180 |
|
|---|
| 181 | /**
|
|---|
| 182 | * Checks if current file only support line comments.
|
|---|
| 183 | * @returns True / False.
|
|---|
| 184 | * @remark Use builtin extension stuff!
|
|---|
| 185 | */
|
|---|
| 186 | static boolean k_line_comment()
|
|---|
| 187 | {
|
|---|
| 188 | _str sRight = '';
|
|---|
| 189 | boolean fLineComment = false;
|
|---|
| 190 | if (k_readboxconfig(sLeft, sRight, iColumn))
|
|---|
| 191 | fLineComment = (sRight == '' || iColumn > 0);
|
|---|
| 192 | return fLineComment;
|
|---|
| 193 | }
|
|---|
| 194 |
|
|---|
| 195 |
|
|---|
| 196 | /**
|
|---|
| 197 | * Gets the comment prefix or postfix.
|
|---|
| 198 | * @returns Comment prefix or postfix.
|
|---|
| 199 | * @param fRight If clear left comment string - default.
|
|---|
| 200 | * If set right comment string.
|
|---|
| 201 | * @author knut st. osmundsen (bird@anduin.net)
|
|---|
| 202 | */
|
|---|
| 203 | static _str k_comment(boolean fRight = false)
|
|---|
| 204 | {
|
|---|
| 205 | sComment = '/*';
|
|---|
| 206 | if (k_readboxconfig(sLeft, sRight, iColumn))
|
|---|
| 207 | sComment = (!fRight || iColumn > 0 ? sLeft : sRight);
|
|---|
| 208 |
|
|---|
| 209 | return strip(sComment);
|
|---|
| 210 | }
|
|---|
| 211 |
|
|---|
| 212 |
|
|---|
| 213 | /*******************************************************************************
|
|---|
| 214 | * BOXES *
|
|---|
| 215 | *******************************************************************************/
|
|---|
| 216 |
|
|---|
| 217 | /**
|
|---|
| 218 | * Inserts the first line in a box.
|
|---|
| 219 | * @param sTag Not used - box tag.
|
|---|
| 220 | */
|
|---|
| 221 | static void k_box_start(sTag)
|
|---|
| 222 | {
|
|---|
| 223 | begin_line();
|
|---|
| 224 |
|
|---|
| 225 | sText = k_comment();
|
|---|
| 226 | if (sTag != '' && fkStyleBoxTag)
|
|---|
| 227 | {
|
|---|
| 228 | if (substr(sText, length(sText)) != '*')
|
|---|
| 229 | sText = sText:+'*';
|
|---|
| 230 | sText = sText:+sTag;
|
|---|
| 231 | }
|
|---|
| 232 |
|
|---|
| 233 | for (i = length(sText); i < ikStyleWidth; i++)
|
|---|
| 234 | sText = sText:+'*';
|
|---|
| 235 | sText = sText:+"\n";
|
|---|
| 236 |
|
|---|
| 237 | _insert_text(sText);
|
|---|
| 238 | }
|
|---|
| 239 |
|
|---|
| 240 |
|
|---|
| 241 | /**
|
|---|
| 242 | * Places a string, sStr, into a line started and ended by '*'.
|
|---|
| 243 | * @param sStr Text to have between the '*'s.
|
|---|
| 244 | */
|
|---|
| 245 | static void k_box_line(_str sStr)
|
|---|
| 246 | {
|
|---|
| 247 | sText = '';
|
|---|
| 248 | if (k_line_comment())
|
|---|
| 249 | sText = k_comment();
|
|---|
| 250 | if (sText == '' || substr(sText, length(sText)) != '*')
|
|---|
| 251 | sText = sText:+'*';
|
|---|
| 252 |
|
|---|
| 253 | sText = sText:+' ';
|
|---|
| 254 | for (i = length(sText); i < p_SyntaxIndent; i++)
|
|---|
| 255 | sText = sText:+' ';
|
|---|
| 256 |
|
|---|
| 257 | sText = sText:+sStr;
|
|---|
| 258 |
|
|---|
| 259 | for (i = length(sText) + 1; i < ikStyleWidth; i++)
|
|---|
| 260 | sText = sText:+' ';
|
|---|
| 261 | sText = sText:+"*\n";
|
|---|
| 262 |
|
|---|
| 263 | _insert_text(sText);
|
|---|
| 264 | }
|
|---|
| 265 |
|
|---|
| 266 |
|
|---|
| 267 | /**
|
|---|
| 268 | * Inserts the last line in a box.
|
|---|
| 269 | */
|
|---|
| 270 | static void k_box_end()
|
|---|
| 271 | {
|
|---|
| 272 | _str sRight = '';
|
|---|
| 273 | _str sText = '';
|
|---|
| 274 | if (k_line_comment())
|
|---|
| 275 | sText = k_comment();
|
|---|
| 276 | else
|
|---|
| 277 | sRight = k_comment(true);
|
|---|
| 278 |
|
|---|
| 279 | for (i = length(sText) + length(sRight); i < ikStyleWidth; i++)
|
|---|
| 280 | sText = sText:+'*';
|
|---|
| 281 |
|
|---|
| 282 | sText = sText:+sRight:+"\n";
|
|---|
| 283 |
|
|---|
| 284 | _insert_text(sText);
|
|---|
| 285 | }
|
|---|
| 286 |
|
|---|
| 287 |
|
|---|
| 288 |
|
|---|
| 289 | /*******************************************************************************
|
|---|
| 290 | * FUNCTION AND CODE PARSERS *
|
|---|
| 291 | *******************************************************************************/
|
|---|
| 292 | /**
|
|---|
| 293 | * Moves cursor to nearest function start.
|
|---|
| 294 | * @returns 0 if ok.
|
|---|
| 295 | * -1 on failure.
|
|---|
| 296 | */
|
|---|
| 297 | static int k_func_goto_nearest_function()
|
|---|
| 298 | {
|
|---|
| 299 | boolean fFix = false; /* cursor at function fix. (last function) */
|
|---|
| 300 | cur_line = p_line;
|
|---|
| 301 | prev_line = -1;
|
|---|
| 302 | next_line = -1;
|
|---|
| 303 | _save_pos2(org_pos);
|
|---|
| 304 |
|
|---|
| 305 | if (!next_proc(1))
|
|---|
| 306 | {
|
|---|
| 307 | next_line = p_line;
|
|---|
| 308 | if (!prev_proc(1) && p_line == cur_line)
|
|---|
| 309 | {
|
|---|
| 310 | _restore_pos2(org_pos);
|
|---|
| 311 | return 0;
|
|---|
| 312 | }
|
|---|
| 313 | _restore_pos2(org_pos);
|
|---|
| 314 | _save_pos2(org_pos);
|
|---|
| 315 | }
|
|---|
| 316 | else
|
|---|
| 317 | {
|
|---|
| 318 | p_col++; /* fixes problem with single function files. */
|
|---|
| 319 | fFix = true;
|
|---|
| 320 | }
|
|---|
| 321 |
|
|---|
| 322 | if (!prev_proc(1))
|
|---|
| 323 | {
|
|---|
| 324 | prev_line = p_line;
|
|---|
| 325 | if (!next_proc(1) && p_line == cur_line)
|
|---|
| 326 | {
|
|---|
| 327 | _restore_pos2(org_pos);
|
|---|
| 328 | return 0;
|
|---|
| 329 | }
|
|---|
| 330 | _restore_pos2(org_pos);
|
|---|
| 331 | _save_pos2(org_pos);
|
|---|
| 332 | }
|
|---|
| 333 |
|
|---|
| 334 |
|
|---|
| 335 | if (prev_line != -1 && (next_line == -1 || cur_line - prev_line <= next_line - cur_line))
|
|---|
| 336 | {
|
|---|
| 337 | if (fFix)
|
|---|
| 338 | p_col++;
|
|---|
| 339 | prev_proc(1);
|
|---|
| 340 | return 0;
|
|---|
| 341 | }
|
|---|
| 342 |
|
|---|
| 343 | if (next_line != -1 && (prev_line == -1 || cur_line - prev_line > next_line - cur_line))
|
|---|
| 344 | {
|
|---|
| 345 | next_proc();
|
|---|
| 346 | return 0;
|
|---|
| 347 | }
|
|---|
| 348 |
|
|---|
| 349 | _restore_pos2(org_pos);
|
|---|
| 350 | return -1;
|
|---|
| 351 | }
|
|---|
| 352 |
|
|---|
| 353 |
|
|---|
| 354 | /**
|
|---|
| 355 | * Check if nearest function is a prototype.
|
|---|
| 356 | * @returns True if function prototype.
|
|---|
| 357 | * False if not function prototype.
|
|---|
| 358 | */
|
|---|
| 359 | static boolean k_func_prototype()
|
|---|
| 360 | {
|
|---|
| 361 | /*
|
|---|
| 362 | * Check if this is a real function implementation.
|
|---|
| 363 | */
|
|---|
| 364 | _save_pos2(procpos);
|
|---|
| 365 | if (!k_func_goto_nearest_functions())
|
|---|
| 366 | {
|
|---|
| 367 | proc_line = p_line;
|
|---|
| 368 |
|
|---|
| 369 | if (!k_func_searchcode("{"))
|
|---|
| 370 | {
|
|---|
| 371 | prev_proc();
|
|---|
| 372 | if (p_line != proc_line)
|
|---|
| 373 | {
|
|---|
| 374 | _restore_pos2(procpos);
|
|---|
| 375 | return true;
|
|---|
| 376 | }
|
|---|
| 377 | }
|
|---|
| 378 | }
|
|---|
| 379 | _restore_pos2(procpos);
|
|---|
| 380 |
|
|---|
| 381 | return false;
|
|---|
| 382 | }
|
|---|
| 383 |
|
|---|
| 384 |
|
|---|
| 385 | /**
|
|---|
| 386 | * Gets the name fo the current function.
|
|---|
| 387 | * @returns The current function name.
|
|---|
| 388 | */
|
|---|
| 389 | static _str k_func_getfunction_name()
|
|---|
| 390 | {
|
|---|
| 391 | sFunctionName = current_proc();
|
|---|
| 392 | if (!sFunctionName)
|
|---|
| 393 | sFunctionName = "";
|
|---|
| 394 | //say 'functionanme='sFunctionName;
|
|---|
| 395 | return sFunctionName;
|
|---|
| 396 | }
|
|---|
| 397 |
|
|---|
| 398 |
|
|---|
| 399 | /**
|
|---|
| 400 | * Goes to the neares function and gets its parameters.
|
|---|
| 401 | * @remark Should be reimplemented to use tags (if someone can figure out how to query that stuff).
|
|---|
| 402 | */
|
|---|
| 403 | static _str k_func_getparams()
|
|---|
| 404 | {
|
|---|
| 405 | _save_pos2(org_pos);
|
|---|
| 406 |
|
|---|
| 407 | /*
|
|---|
| 408 | * Go to nearest function.
|
|---|
| 409 | */
|
|---|
| 410 | if ( !k_func_goto_nearest_function()
|
|---|
| 411 | && !k_func_searchcode("(") /* makes some assumptions. */
|
|---|
| 412 | )
|
|---|
| 413 | {
|
|---|
| 414 | /*
|
|---|
| 415 | * Get parameters.
|
|---|
| 416 | */
|
|---|
| 417 | _save_pos2(posStart);
|
|---|
| 418 | offStart = _QROffset();
|
|---|
| 419 | if (!find_matching_paren())
|
|---|
| 420 | {
|
|---|
| 421 | offEnd = _QROffset();
|
|---|
| 422 | _restore_pos2(posStart);
|
|---|
| 423 | p_col++;
|
|---|
| 424 | _str sParamsRaw = strip(get_text(offEnd - offStart - 1));
|
|---|
| 425 |
|
|---|
| 426 |
|
|---|
| 427 | /*
|
|---|
| 428 | * Remove new lines and double spaces within params.
|
|---|
| 429 | */
|
|---|
| 430 | _str sParams = "";
|
|---|
| 431 |
|
|---|
| 432 | int i;
|
|---|
| 433 | for (i = 1, chPrev = ' '; i <= length(sParamsRaw); i++)
|
|---|
| 434 | {
|
|---|
| 435 | ch = substr(sParamsRaw, i, 1);
|
|---|
| 436 |
|
|---|
| 437 | /*
|
|---|
| 438 | * Do fixups.
|
|---|
| 439 | */
|
|---|
| 440 | if (ch == " " && chPrev == " ")
|
|---|
| 441 | continue;
|
|---|
| 442 |
|
|---|
| 443 | if ((ch :== "\n") || (ch :== "\r") || (ch :== "\t"))
|
|---|
| 444 | {
|
|---|
| 445 | if (chPrev == ' ')
|
|---|
| 446 | continue;
|
|---|
| 447 | ch = ' ';
|
|---|
| 448 | }
|
|---|
| 449 |
|
|---|
| 450 | if (ch == ',' && chPrev == ' ')
|
|---|
| 451 | {
|
|---|
| 452 | sParams = substr(sParams, 1, length(sParams) - 1);
|
|---|
| 453 | }
|
|---|
| 454 |
|
|---|
| 455 | if (ch == '*')
|
|---|
| 456 | {
|
|---|
| 457 | if (chPrev != ' ')
|
|---|
| 458 | sParams = sParams :+ ' * ';
|
|---|
| 459 | else
|
|---|
| 460 | sParams = sParams :+ '* ';
|
|---|
| 461 | chPrev = ' ';
|
|---|
| 462 | }
|
|---|
| 463 | else
|
|---|
| 464 | {
|
|---|
| 465 | sParams = sParams :+ ch;
|
|---|
| 466 | chPrev = ch;
|
|---|
| 467 | }
|
|---|
| 468 |
|
|---|
| 469 | } /* for */
|
|---|
| 470 |
|
|---|
| 471 | sParams = strip(sParams);
|
|---|
| 472 | if (sParams == 'void' || sParams == 'VOID')
|
|---|
| 473 | sParams = "";
|
|---|
| 474 | _restore_pos2(org_pos);
|
|---|
| 475 | return sParams;
|
|---|
| 476 | }
|
|---|
| 477 | else
|
|---|
| 478 | message("find_matchin_paren failed");
|
|---|
| 479 | }
|
|---|
| 480 |
|
|---|
| 481 | _restore_pos2(org_pos);
|
|---|
| 482 | return false;
|
|---|
| 483 | }
|
|---|
| 484 |
|
|---|
| 485 |
|
|---|
| 486 |
|
|---|
| 487 | /**
|
|---|
| 488 | * Enumerates the parameters to the function.
|
|---|
| 489 | * @param sParams Parameter string from k_func_getparams.
|
|---|
| 490 | * @param iParam The index (0-based) of the parameter to get.
|
|---|
| 491 | * @param sType Type. (output)
|
|---|
| 492 | * @param sName Name. (output)
|
|---|
| 493 | * @param sDefault Default value. (output)
|
|---|
| 494 | * @remark Doesn't perhaps handle function pointers very well (I think)?
|
|---|
| 495 | * @remark Should be reimplemented to use tags (if someone can figure out how to query that stuff).
|
|---|
| 496 | */
|
|---|
| 497 | static int k_func_enumparams(_str sParams, int iParam, _str &sType, _str &sName, _str &sDefault)
|
|---|
| 498 | {
|
|---|
| 499 | int i;
|
|---|
| 500 | int iParLevel;
|
|---|
| 501 | int iCurParam;
|
|---|
| 502 | int iStartParam;
|
|---|
| 503 |
|
|---|
| 504 | sType = sName = sDefault = "";
|
|---|
| 505 |
|
|---|
| 506 | /* no use working on empty string! */
|
|---|
| 507 | if (length(sParams) == 0)
|
|---|
| 508 | return -1;
|
|---|
| 509 |
|
|---|
| 510 | /* find the parameter in question */
|
|---|
| 511 | for (iStartParam = i = 1, iParLevel = iCurParam = 0; i <= length(sParams); i++)
|
|---|
| 512 | {
|
|---|
| 513 | _str ch = substr(sParams, i, 1);
|
|---|
| 514 | if (ch == ',' && iParLevel == 0)
|
|---|
| 515 | {
|
|---|
| 516 | /* is it this parameter ? */
|
|---|
| 517 | if (iParam == iCurParam)
|
|---|
| 518 | break;
|
|---|
| 519 |
|
|---|
| 520 | iCurParam++;
|
|---|
| 521 | iStartParam = i + 1;
|
|---|
| 522 | }
|
|---|
| 523 | else if (ch == '(')
|
|---|
| 524 | iParLevel++;
|
|---|
| 525 | else if (ch == ')')
|
|---|
| 526 | iParLevel--;
|
|---|
| 527 | }
|
|---|
| 528 |
|
|---|
| 529 | /* did we find the parameter? */
|
|---|
| 530 | if (iParam == iCurParam)
|
|---|
| 531 | { /* (yeah, we did!) */
|
|---|
| 532 | sArg = strip(substr(sParams, iStartParam, i - iStartParam));
|
|---|
| 533 |
|
|---|
| 534 | /* lazy approach, which doens't support function types */
|
|---|
| 535 |
|
|---|
| 536 | if (pos('=', sParams) > 0) /* default */
|
|---|
| 537 | {
|
|---|
| 538 | sDefault = strip(substr(sParams, pos('=', sParams) + 1));
|
|---|
| 539 | sArg = strip(substr(sArg, 1, pos('=', sParams) - 1));
|
|---|
| 540 | }
|
|---|
| 541 |
|
|---|
| 542 | for (i = length(sArg); i > 1; i--)
|
|---|
| 543 | {
|
|---|
| 544 | _str ch = substr(sArg, i, 1);
|
|---|
| 545 | if ( !(ch >= 'a' && ch <= 'z')
|
|---|
| 546 | && !(ch >= 'A' && ch <= 'Z')
|
|---|
| 547 | && !(ch >= '0' && ch <= '9')
|
|---|
| 548 | && ch != '_' && ch != '$')
|
|---|
| 549 | break;
|
|---|
| 550 | }
|
|---|
| 551 | if (sArg == "...")
|
|---|
| 552 | i = 0;
|
|---|
| 553 | sName = strip(substr(sArg, i + 1));
|
|---|
| 554 | sType = strip(substr(sArg, 1, i));
|
|---|
| 555 |
|
|---|
| 556 | return 0;
|
|---|
| 557 | }
|
|---|
| 558 |
|
|---|
| 559 | return -1;
|
|---|
| 560 | }
|
|---|
| 561 |
|
|---|
| 562 |
|
|---|
| 563 | /**
|
|---|
| 564 | * Counts the parameters to the function.
|
|---|
| 565 | * @param sParams Parameter string from k_func_getparams.
|
|---|
| 566 | * @remark Should be reimplemented to use tags (if someone can figure out how to query that stuff).
|
|---|
| 567 | */
|
|---|
| 568 | static int k_func_countparams(_str sParams)
|
|---|
| 569 | {
|
|---|
| 570 | int i;
|
|---|
| 571 | int iParLevel;
|
|---|
| 572 | int iCurParam;
|
|---|
| 573 |
|
|---|
| 574 | sType = sName = sDefault = "";
|
|---|
| 575 |
|
|---|
| 576 | /* check for 0 parameters */
|
|---|
| 577 | if (length(sParams) == 0)
|
|---|
| 578 | return 0;
|
|---|
| 579 |
|
|---|
| 580 | /* find the parameter in question */
|
|---|
| 581 | for (i = 1, iParLevel = iCurParam = 0; i <= length(sParams); i++)
|
|---|
| 582 | {
|
|---|
| 583 | _str ch = substr(sParams, i, 1);
|
|---|
| 584 | if (ch == ',' && iParLevel == 0)
|
|---|
| 585 | {
|
|---|
| 586 | iCurParam++;
|
|---|
| 587 | }
|
|---|
| 588 | else if (ch == '(')
|
|---|
| 589 | iParLevel++;
|
|---|
| 590 | else if (ch == ')')
|
|---|
| 591 | iParLevel--;
|
|---|
| 592 | }
|
|---|
| 593 |
|
|---|
| 594 | return iCurParam + 1;
|
|---|
| 595 | }
|
|---|
| 596 |
|
|---|
| 597 |
|
|---|
| 598 | /**
|
|---|
| 599 | * Gets the return type.
|
|---|
| 600 | */
|
|---|
| 601 | static _str k_func_getreturntype(boolean fPureType = false)
|
|---|
| 602 | {
|
|---|
| 603 | _save_pos2(org_pos);
|
|---|
| 604 |
|
|---|
| 605 | /*
|
|---|
| 606 | * Go to nearest function.
|
|---|
| 607 | */
|
|---|
| 608 | if (!k_func_goto_nearest_function())
|
|---|
| 609 | {
|
|---|
| 610 | /*
|
|---|
| 611 | * Return type is from function start to function name...
|
|---|
| 612 | */
|
|---|
| 613 | _save_pos2(posStart);
|
|---|
| 614 | offStart = _QROffset();
|
|---|
| 615 |
|
|---|
| 616 | if (!k_func_searchcode("(")) /* makes some assumptions. */
|
|---|
| 617 | {
|
|---|
| 618 | prev_word();
|
|---|
| 619 | offEnd = _QROffset();
|
|---|
| 620 | _restore_pos2(posStart);
|
|---|
| 621 | _str sTypeRaw = strip(get_text(offEnd - offStart));
|
|---|
| 622 |
|
|---|
| 623 | //say 'sTypeRaw='sTypeRaw;
|
|---|
| 624 | /*
|
|---|
| 625 | * Remove static, inline, _Optlink, stdcall, EXPENTRY etc.
|
|---|
| 626 | */
|
|---|
| 627 | if (fPureType)
|
|---|
| 628 | {
|
|---|
| 629 | sTypeRaw = stranslate(sTypeRaw, "", "__static__", "I");
|
|---|
| 630 | sTypeRaw = stranslate(sTypeRaw, "", "__static", "I");
|
|---|
| 631 | sTypeRaw = stranslate(sTypeRaw, "", "static__", "I");
|
|---|
| 632 | sTypeRaw = stranslate(sTypeRaw, "", "static", "I");
|
|---|
| 633 | sTypeRaw = stranslate(sTypeRaw, "", "__inline__", "I");
|
|---|
| 634 | sTypeRaw = stranslate(sTypeRaw, "", "__inline", "I");
|
|---|
| 635 | sTypeRaw = stranslate(sTypeRaw, "", "inline__", "I");
|
|---|
| 636 | sTypeRaw = stranslate(sTypeRaw, "", "inline", "I");
|
|---|
| 637 | sTypeRaw = stranslate(sTypeRaw, "", "EXPENTRY", "I");
|
|---|
| 638 | sTypeRaw = stranslate(sTypeRaw, "", "_Optlink", "I");
|
|---|
| 639 | sTypeRaw = stranslate(sTypeRaw, "", "__stdcall", "I");
|
|---|
| 640 | sTypeRaw = stranslate(sTypeRaw, "", "__cdecl", "I");
|
|---|
| 641 | sTypeRaw = stranslate(sTypeRaw, "", "_cdecl", "I");
|
|---|
| 642 | sTypeRaw = stranslate(sTypeRaw, "", "cdecl", "I");
|
|---|
| 643 | sTypeRaw = stranslate(sTypeRaw, "", "__PASCAL", "I");
|
|---|
| 644 | sTypeRaw = stranslate(sTypeRaw, "", "_PASCAL", "I");
|
|---|
| 645 | sTypeRaw = stranslate(sTypeRaw, "", "PASCAL", "I");
|
|---|
| 646 | sTypeRaw = stranslate(sTypeRaw, "", "__Far32__", "I");
|
|---|
| 647 | sTypeRaw = stranslate(sTypeRaw, "", "__Far32", "I");
|
|---|
| 648 | sTypeRaw = stranslate(sTypeRaw, "", "Far32__", "I");
|
|---|
| 649 | sTypeRaw = stranslate(sTypeRaw, "", "_Far32_", "I");
|
|---|
| 650 | sTypeRaw = stranslate(sTypeRaw, "", "_Far32", "I");
|
|---|
| 651 | sTypeRaw = stranslate(sTypeRaw, "", "Far32_", "I");
|
|---|
| 652 | sTypeRaw = stranslate(sTypeRaw, "", "Far32", "I");
|
|---|
| 653 | sTypeRaw = stranslate(sTypeRaw, "", "__far", "I");
|
|---|
| 654 | sTypeRaw = stranslate(sTypeRaw, "", "_far", "I");
|
|---|
| 655 | sTypeRaw = stranslate(sTypeRaw, "", "far", "I");
|
|---|
| 656 | sTypeRaw = stranslate(sTypeRaw, "", "__near", "I");
|
|---|
| 657 | sTypeRaw = stranslate(sTypeRaw, "", "_near", "I");
|
|---|
| 658 | sTypeRaw = stranslate(sTypeRaw, "", "near", "I");
|
|---|
| 659 | sTypeRaw = stranslate(sTypeRaw, "", "__loadds__", "I");
|
|---|
| 660 | sTypeRaw = stranslate(sTypeRaw, "", "__loadds", "I");
|
|---|
| 661 | sTypeRaw = stranslate(sTypeRaw, "", "loadds__", "I");
|
|---|
| 662 | sTypeRaw = stranslate(sTypeRaw, "", "_loadds_", "I");
|
|---|
| 663 | sTypeRaw = stranslate(sTypeRaw, "", "_loadds", "I");
|
|---|
| 664 | sTypeRaw = stranslate(sTypeRaw, "", "loadds_", "I");
|
|---|
| 665 | sTypeRaw = stranslate(sTypeRaw, "", "loadds", "I");
|
|---|
| 666 | sTypeRaw = stranslate(sTypeRaw, "", "__loades__", "I");
|
|---|
| 667 | sTypeRaw = stranslate(sTypeRaw, "", "__loades", "I");
|
|---|
| 668 | sTypeRaw = stranslate(sTypeRaw, "", "loades__", "I");
|
|---|
| 669 | sTypeRaw = stranslate(sTypeRaw, "", "_loades_", "I");
|
|---|
| 670 | sTypeRaw = stranslate(sTypeRaw, "", "_loades", "I");
|
|---|
| 671 | sTypeRaw = stranslate(sTypeRaw, "", "loades_", "I");
|
|---|
| 672 | sTypeRaw = stranslate(sTypeRaw, "", "loades", "I");
|
|---|
| 673 | sTypeRaw = stranslate(sTypeRaw, "", "WIN32API", "I");
|
|---|
| 674 | sTypeRaw = stranslate(sTypeRaw, "", "WINAPI", "I");
|
|---|
| 675 | sTypeRaw = stranslate(sTypeRaw, "", "LDRCALL", "I");
|
|---|
| 676 | sTypeRaw = stranslate(sTypeRaw, "", "KRNLCALL", "I");
|
|---|
| 677 | sTypeRaw = stranslate(sTypeRaw, "", "__operator__", "I"); /* operator fix */
|
|---|
| 678 | sTypeRaw = stranslate(sTypeRaw, "", "__operator", "I"); /* operator fix */
|
|---|
| 679 | sTypeRaw = stranslate(sTypeRaw, "", "operator__", "I"); /* operator fix */
|
|---|
| 680 | sTypeRaw = stranslate(sTypeRaw, "", "operator", "I"); /* operator fix */
|
|---|
| 681 | }
|
|---|
| 682 |
|
|---|
| 683 | /*
|
|---|
| 684 | * Remove new lines and double spaces within params.
|
|---|
| 685 | */
|
|---|
| 686 | _str sType = "";
|
|---|
| 687 |
|
|---|
| 688 | int i;
|
|---|
| 689 | for (i = 1, chPrev = ' '; i <= length(sTypeRaw); i++)
|
|---|
| 690 | {
|
|---|
| 691 | ch = substr(sTypeRaw, i, 1);
|
|---|
| 692 |
|
|---|
| 693 | /*
|
|---|
| 694 | * Do fixups.
|
|---|
| 695 | */
|
|---|
| 696 | if (ch == " " && chPrev == " ")
|
|---|
| 697 | continue;
|
|---|
| 698 |
|
|---|
| 699 | if ((ch :== "\n") || (ch :== "\r") || (ch :== "\t"))
|
|---|
| 700 | {
|
|---|
| 701 | if (chPrev == ' ')
|
|---|
| 702 | continue;
|
|---|
| 703 | ch = ' ';
|
|---|
| 704 | }
|
|---|
| 705 |
|
|---|
| 706 | if (ch == ',' && chPrev == ' ')
|
|---|
| 707 | {
|
|---|
| 708 | sType = substr(sType, 1, length(sType) - 1);
|
|---|
| 709 | }
|
|---|
| 710 |
|
|---|
| 711 | if (ch == '*')
|
|---|
| 712 | {
|
|---|
| 713 | if (chPrev != ' ')
|
|---|
| 714 | sType = sType :+ ' * ';
|
|---|
| 715 | else
|
|---|
| 716 | sType = sType :+ '* ';
|
|---|
| 717 | chPrev = ' ';
|
|---|
| 718 | }
|
|---|
| 719 | else
|
|---|
| 720 | {
|
|---|
| 721 | sType = sType :+ ch;
|
|---|
| 722 | chPrev = ch;
|
|---|
| 723 | }
|
|---|
| 724 |
|
|---|
| 725 | } /* for */
|
|---|
| 726 |
|
|---|
| 727 | sType = strip(sType);
|
|---|
| 728 |
|
|---|
| 729 | _restore_pos2(org_pos);
|
|---|
| 730 | return sType;
|
|---|
| 731 | }
|
|---|
| 732 | else
|
|---|
| 733 | message('k_func_getreturntype: can''t find ''(''.');
|
|---|
| 734 | }
|
|---|
| 735 |
|
|---|
| 736 | _restore_pos2(org_pos);
|
|---|
| 737 | return false;
|
|---|
| 738 | }
|
|---|
| 739 |
|
|---|
| 740 |
|
|---|
| 741 | /**
|
|---|
| 742 | * Search for some piece of code.
|
|---|
| 743 | */
|
|---|
| 744 | static int k_func_searchcode(_str sSearchString, _str sOptions = "E+")
|
|---|
| 745 | {
|
|---|
| 746 | int rc;
|
|---|
| 747 | rc = search(sSearchString, sOptions);
|
|---|
| 748 | while (!rc && !k_func_in_code())
|
|---|
| 749 | {
|
|---|
| 750 | p_col++;
|
|---|
| 751 | rc = search(sSearchString, sOptions);
|
|---|
| 752 | }
|
|---|
| 753 | return rc;
|
|---|
| 754 | }
|
|---|
| 755 |
|
|---|
| 756 |
|
|---|
| 757 | /**
|
|---|
| 758 | * Checks if cursor is in code or in comment.
|
|---|
| 759 | * @return True if cursor in code.
|
|---|
| 760 | */
|
|---|
| 761 | static boolean k_func_in_code()
|
|---|
| 762 | {
|
|---|
| 763 | _save_pos2(searchsave);
|
|---|
| 764 | boolean fRc = !_in_comment();
|
|---|
| 765 | _restore_pos2(searchsave);
|
|---|
| 766 | return fRc;
|
|---|
| 767 | }
|
|---|
| 768 |
|
|---|
| 769 |
|
|---|
| 770 | /*
|
|---|
| 771 | * Gets the next piece of code.
|
|---|
| 772 | */
|
|---|
| 773 | static _str k_func_get_next_code_text()
|
|---|
| 774 | {
|
|---|
| 775 | _str ch;
|
|---|
| 776 | _save_pos2(searchsave);
|
|---|
| 777 | ch = k_func_get_next_code_text2();
|
|---|
| 778 | _restore_pos2(searchsave);
|
|---|
| 779 | return ch;
|
|---|
| 780 | }
|
|---|
| 781 |
|
|---|
| 782 |
|
|---|
| 783 | /**
|
|---|
| 784 | * Checks if there is more code on the line.
|
|---|
| 785 | */
|
|---|
| 786 | static boolean k_func_more_code_on_line()
|
|---|
| 787 | {
|
|---|
| 788 | boolean fRc;
|
|---|
| 789 | int curline = p_line;
|
|---|
| 790 |
|
|---|
| 791 | _save_pos2(searchsave);
|
|---|
| 792 | k_func_get_next_code_text2();
|
|---|
| 793 | fRc = curline == p_line;
|
|---|
| 794 | _restore_pos2(searchsave);
|
|---|
| 795 |
|
|---|
| 796 | return fRc;
|
|---|
| 797 | }
|
|---|
| 798 |
|
|---|
| 799 |
|
|---|
| 800 | /**
|
|---|
| 801 | * Gets the next piece of code.
|
|---|
| 802 | * Doesn't preserver cursor position.
|
|---|
| 803 | */
|
|---|
| 804 | static _str k_func_get_next_code_text2()
|
|---|
| 805 | {
|
|---|
| 806 | _str ch;
|
|---|
| 807 | do
|
|---|
| 808 | {
|
|---|
| 809 | curcol = ++p_col;
|
|---|
| 810 | end_line()
|
|---|
| 811 | if (p_col <= curcol)
|
|---|
| 812 | {
|
|---|
| 813 | p_line++;
|
|---|
| 814 | p_col = 1;
|
|---|
| 815 | }
|
|---|
| 816 | else
|
|---|
| 817 | p_col = curcol;
|
|---|
| 818 |
|
|---|
| 819 | ch = get_text();
|
|---|
| 820 | //say ch ' ('_asc(ch)')';
|
|---|
| 821 | while (ch == "#") /* preprocessor stuff */
|
|---|
| 822 | {
|
|---|
| 823 | p_col = 1;
|
|---|
| 824 | p_line++;
|
|---|
| 825 | ch = get_text();
|
|---|
| 826 | //say ch ' ('_asc(ch)')';
|
|---|
| 827 | continue;
|
|---|
| 828 | }
|
|---|
| 829 | } while (ch :== ' ' || ch :== "\t" || ch :== "\n" || ch :== "\r" || !k_func_in_code());
|
|---|
| 830 |
|
|---|
| 831 | return ch;
|
|---|
| 832 | }
|
|---|
| 833 |
|
|---|
| 834 |
|
|---|
| 835 |
|
|---|
| 836 |
|
|---|
| 837 | /*******************************************************************************
|
|---|
| 838 | * JAVA DOC STYLED WORKERS *
|
|---|
| 839 | *******************************************************************************/
|
|---|
| 840 |
|
|---|
| 841 | /** starts a javadoc documentation box. */
|
|---|
| 842 | static void k_javadoc_box_start(_str sStr = '', boolean fDouble = true)
|
|---|
| 843 | {
|
|---|
| 844 | _begin_line();
|
|---|
| 845 | sText = k_comment();
|
|---|
| 846 | if (fDouble)
|
|---|
| 847 | sText = sText:+substr(sText, length(sText), 1);
|
|---|
| 848 | if (sStr != '')
|
|---|
| 849 | sText = sText:+' ':+sStr;
|
|---|
| 850 | sText = sText:+"\n";
|
|---|
| 851 |
|
|---|
| 852 | _insert_text(sText);
|
|---|
| 853 | }
|
|---|
| 854 |
|
|---|
| 855 | /** inserts a new line in a javadoc documentation box. */
|
|---|
| 856 | static void k_javadoc_box_line(_str sStr = '', int iPadd = 0, _str sStr2 = '', int iPadd2 = 0, _str sStr3 = '')
|
|---|
| 857 | {
|
|---|
| 858 | if (k_line_comment())
|
|---|
| 859 | sText = k_comment();
|
|---|
| 860 | else
|
|---|
| 861 | {
|
|---|
| 862 | sText = k_comment();
|
|---|
| 863 | sText = ' ':+substr(sText, length(sText));
|
|---|
| 864 | }
|
|---|
| 865 |
|
|---|
| 866 | if (sStr != '')
|
|---|
| 867 | sText = sText:+' ':+sStr;
|
|---|
| 868 | if (iPadd > 0)
|
|---|
| 869 | {
|
|---|
| 870 | for (i = length(sText); i < iPadd; i++)
|
|---|
| 871 | sText = sText:+' ';
|
|---|
| 872 |
|
|---|
| 873 | if (sStr2 != '')
|
|---|
| 874 | sText = sText:+sStr2;
|
|---|
| 875 |
|
|---|
| 876 | if (iPadd2 > 0)
|
|---|
| 877 | {
|
|---|
| 878 | for (i = length(sText); i < iPadd2; i++)
|
|---|
| 879 | sText = sText:+' ';
|
|---|
| 880 |
|
|---|
| 881 | if (sStr3 != '')
|
|---|
| 882 | sText = sText:+sStr3;
|
|---|
| 883 | }
|
|---|
| 884 | }
|
|---|
| 885 |
|
|---|
| 886 | sText = sText:+"\n";
|
|---|
| 887 |
|
|---|
| 888 | _insert_text(sText);
|
|---|
| 889 | }
|
|---|
| 890 |
|
|---|
| 891 | /** starts a javadoc documentation box. */
|
|---|
| 892 | static void k_javadoc_box_end()
|
|---|
| 893 | {
|
|---|
| 894 | if (k_line_comment())
|
|---|
| 895 | sText = k_comment();
|
|---|
| 896 | else
|
|---|
| 897 | {
|
|---|
| 898 | sText = k_comment(true);
|
|---|
| 899 | if (substr(sText, 1, 1) != '*')
|
|---|
| 900 | sText = '*':+sText;
|
|---|
| 901 | sText = ' ':+sText;
|
|---|
| 902 | }
|
|---|
| 903 | sText = sText:+"\n";
|
|---|
| 904 |
|
|---|
| 905 | _insert_text(sText);
|
|---|
| 906 | }
|
|---|
| 907 |
|
|---|
| 908 |
|
|---|
| 909 | /**
|
|---|
| 910 | * Write a Javadoc styled classbox.
|
|---|
| 911 | */
|
|---|
| 912 | void k_javadoc_classbox()
|
|---|
| 913 | {
|
|---|
| 914 | int iCursorLine;
|
|---|
| 915 | int iPadd = k_alignup(12, p_SyntaxIndent);
|
|---|
| 916 |
|
|---|
| 917 | k_javadoc_box_start();
|
|---|
| 918 | iCursorLine = p_RLine;
|
|---|
| 919 | k_javadoc_box_line(' ');
|
|---|
| 920 |
|
|---|
| 921 | if (fkStyleFullHeaders)
|
|---|
| 922 | {
|
|---|
| 923 | k_javadoc_box_line('@shortdesc', iPadd);
|
|---|
| 924 | k_javadoc_box_line('@dstruct', iPadd);
|
|---|
| 925 | k_javadoc_box_line('@version', iPadd);
|
|---|
| 926 | k_javadoc_box_line('@verdesc', iPadd);
|
|---|
| 927 | }
|
|---|
| 928 | k_javadoc_box_line('@author', iPadd, skUserName " <" skUserEmail ">");
|
|---|
| 929 | k_javadoc_box_line('@approval', iPadd);
|
|---|
| 930 | k_javadoc_box_end();
|
|---|
| 931 |
|
|---|
| 932 | up(p_RLine - iCursorLine);
|
|---|
| 933 | end_line();
|
|---|
| 934 | keyin(' ');
|
|---|
| 935 | }
|
|---|
| 936 |
|
|---|
| 937 |
|
|---|
| 938 | /**
|
|---|
| 939 | * Javadoc - functionbox(/header).
|
|---|
| 940 | */
|
|---|
| 941 | void k_javadoc_funcbox()
|
|---|
| 942 | {
|
|---|
| 943 | int cArgs = 1;
|
|---|
| 944 | _str sArgs = "";
|
|---|
| 945 | int iCursorLine;
|
|---|
| 946 | int iPadd = k_alignup(11, p_SyntaxIndent);
|
|---|
| 947 | /* look for parameters */
|
|---|
| 948 | boolean fFoundFn = !k_func_goto_nearest_function();
|
|---|
| 949 | if (fFoundFn)
|
|---|
| 950 | {
|
|---|
| 951 | sArgs = k_func_getparams();
|
|---|
| 952 | cArgs = k_func_countparams(sArgs);
|
|---|
| 953 | }
|
|---|
| 954 |
|
|---|
| 955 | k_javadoc_box_start();
|
|---|
| 956 | iCursorLine = p_RLine;
|
|---|
| 957 | k_javadoc_box_line(' ');
|
|---|
| 958 | if (file_eq(p_extension, 'asm'))
|
|---|
| 959 | k_javadoc_box_line('@cproto', iPadd);
|
|---|
| 960 | k_javadoc_box_line('@returns', iPadd);
|
|---|
| 961 | if (fFoundFn)
|
|---|
| 962 | {
|
|---|
| 963 | /*
|
|---|
| 964 | * Determin parameter description indent.
|
|---|
| 965 | */
|
|---|
| 966 | int iPadd2 = 0;
|
|---|
| 967 | for (i = 0; i < cArgs; i++)
|
|---|
| 968 | {
|
|---|
| 969 | _str sName, sType, sDefault;
|
|---|
| 970 | if (!k_func_enumparams(sArgs, i, sType, sName, sDefault)
|
|---|
| 971 | && iPadd2 < length(sName))
|
|---|
| 972 | iPadd2 = length(sName);
|
|---|
| 973 | }
|
|---|
| 974 | iPadd2 = k_alignup((iPadd + iPadd2), p_SyntaxIndent);
|
|---|
| 975 |
|
|---|
| 976 | /*
|
|---|
| 977 | * Insert parameter.
|
|---|
| 978 | */
|
|---|
| 979 | for (i = 0; i < cArgs; i++)
|
|---|
| 980 | {
|
|---|
| 981 | _str sName, sType, sDefault;
|
|---|
| 982 | if (!k_func_enumparams(sArgs, i, sType, sName, sDefault))
|
|---|
| 983 | {
|
|---|
| 984 | sStr3 = '';
|
|---|
| 985 | if (sDefault != "")
|
|---|
| 986 | sStr3 = '(default='sDefault')';
|
|---|
| 987 | k_javadoc_box_line('@param', iPadd, sName, iPadd2, sStr3);
|
|---|
| 988 | }
|
|---|
| 989 | else
|
|---|
| 990 | k_javadoc_box_line('@param', iPadd);
|
|---|
| 991 | }
|
|---|
| 992 | }
|
|---|
| 993 | else
|
|---|
| 994 | k_javadoc_box_line('@param', iPadd);
|
|---|
| 995 |
|
|---|
| 996 | if (file_eq(p_extension, 'asm'))
|
|---|
| 997 | k_javadoc_box_line('@uses', iPadd);
|
|---|
| 998 | if (fkStyleFullHeaders)
|
|---|
| 999 | {
|
|---|
| 1000 | k_javadoc_box_line('@equiv', iPadd);
|
|---|
| 1001 | k_javadoc_box_line('@time', iPadd);
|
|---|
| 1002 | }
|
|---|
| 1003 | k_javadoc_box_line('@sketch', iPadd);
|
|---|
| 1004 | k_javadoc_box_line('@status', iPadd);
|
|---|
| 1005 | k_javadoc_box_line('@author', iPadd, skUserName '<' skUserEmail '>');
|
|---|
| 1006 | k_javadoc_box_line('@remark', iPadd);
|
|---|
| 1007 | k_javadoc_box_end();
|
|---|
| 1008 |
|
|---|
| 1009 | up(p_RLine - iCursorLine);
|
|---|
| 1010 | end_line();
|
|---|
| 1011 | keyin(' ');
|
|---|
| 1012 | }
|
|---|
| 1013 |
|
|---|
| 1014 |
|
|---|
| 1015 | /**
|
|---|
| 1016 | * Javadoc module header.
|
|---|
| 1017 | */
|
|---|
| 1018 | void k_javadoc_moduleheader()
|
|---|
| 1019 | {
|
|---|
| 1020 | int iCursorLine;
|
|---|
| 1021 |
|
|---|
| 1022 | _begin_line();
|
|---|
| 1023 | k_javadoc_box_start('$':+'I':+'d: $', false);
|
|---|
| 1024 | k_javadoc_box_line();
|
|---|
| 1025 | iCursorLine = p_RLine;
|
|---|
| 1026 | k_javadoc_box_line();
|
|---|
| 1027 | k_javadoc_box_line();
|
|---|
| 1028 |
|
|---|
| 1029 | if (skLicense == 'Confidential')
|
|---|
| 1030 | {
|
|---|
| 1031 | k_javadoc_box_line(skCompany 'confidential');
|
|---|
| 1032 | k_javadoc_box_line();
|
|---|
| 1033 | }
|
|---|
| 1034 |
|
|---|
| 1035 | if (skCompany != '')
|
|---|
| 1036 | {
|
|---|
| 1037 | k_javadoc_box_line('Copyright (c) ' k_year() ' ' skCompany);
|
|---|
| 1038 | k_javadoc_box_line('Author: ' skUserName' <' skUserEmail '>');
|
|---|
| 1039 | }
|
|---|
| 1040 | else
|
|---|
| 1041 | k_javadoc_box_line('Copyright (c) ' k_year() ' 'skUserName' <' skUserEmail '>');
|
|---|
| 1042 | k_javadoc_box_line();
|
|---|
| 1043 | switch (skLicense)
|
|---|
| 1044 | {
|
|---|
| 1045 | case 'Odin32':
|
|---|
| 1046 | k_javadoc_box_line('Project Odin Software License can be found in LICENSE.TXT.');
|
|---|
| 1047 | break;
|
|---|
| 1048 |
|
|---|
| 1049 | case 'GPL':
|
|---|
| 1050 | sProg = skProgram;
|
|---|
| 1051 | k_javadoc_box_line()
|
|---|
| 1052 | if (sProg == '')
|
|---|
| 1053 | sProg = 'This program';
|
|---|
| 1054 | else
|
|---|
| 1055 | {
|
|---|
| 1056 | k_javadoc_box_line('This file is part of ' sProg '.');
|
|---|
| 1057 | k_javadoc_box_line();
|
|---|
| 1058 | }
|
|---|
| 1059 | k_javadoc_box_line(sProg ' is free software; you can redistribute it and/or modify');
|
|---|
| 1060 | k_javadoc_box_line('it under the terms of the GNU General Public License as published by');
|
|---|
| 1061 | k_javadoc_box_line('the Free Software Foundation; either version 2 of the License, or');
|
|---|
| 1062 | k_javadoc_box_line('(at your option) any later version.');
|
|---|
| 1063 | k_javadoc_box_line()
|
|---|
| 1064 | k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful,');
|
|---|
| 1065 | k_javadoc_box_line('but WITHOUT ANY WARRANTY; without even the implied warranty of');
|
|---|
| 1066 | k_javadoc_box_line('MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the');
|
|---|
| 1067 | k_javadoc_box_line('GNU General Public License for more details.');
|
|---|
| 1068 | k_javadoc_box_line()
|
|---|
| 1069 | k_javadoc_box_line('You should have received a copy of the GNU General Public License');
|
|---|
| 1070 | k_javadoc_box_line('along with ' sProg '; if not, write to the Free Software');
|
|---|
| 1071 | k_javadoc_box_line('Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA');
|
|---|
| 1072 | break;
|
|---|
| 1073 |
|
|---|
| 1074 | case 'LGPL':
|
|---|
| 1075 | sProg = skProgram;
|
|---|
| 1076 | k_javadoc_box_line()
|
|---|
| 1077 | if (sProg == '')
|
|---|
| 1078 | sProg = 'This program';
|
|---|
| 1079 | else
|
|---|
| 1080 | {
|
|---|
| 1081 | k_javadoc_box_line('This file is part of ' sProg '.');
|
|---|
| 1082 | k_javadoc_box_line();
|
|---|
| 1083 | }
|
|---|
| 1084 | k_javadoc_box_line(sProg ' is free software; you can redistribute it and/or modify');
|
|---|
| 1085 | k_javadoc_box_line('it under the terms of the GNU Lesser General Public License as published');
|
|---|
| 1086 | k_javadoc_box_line('by the Free Software Foundation; either version 2 of the License, or');
|
|---|
| 1087 | k_javadoc_box_line('(at your option) any later version.');
|
|---|
| 1088 | k_javadoc_box_line()
|
|---|
| 1089 | k_javadoc_box_line(sProg ' is distributed in the hope that it will be useful,');
|
|---|
| 1090 | k_javadoc_box_line('but WITHOUT ANY WARRANTY; without even the implied warranty of');
|
|---|
| 1091 | k_javadoc_box_line('MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the');
|
|---|
| 1092 | k_javadoc_box_line('GNU Lesser General Public License for more details.');
|
|---|
| 1093 | k_javadoc_box_line()
|
|---|
| 1094 | k_javadoc_box_line('You should have received a copy of the GNU Lesser General Public License');
|
|---|
| 1095 | k_javadoc_box_line('along with ' sProg '; if not, write to the Free Software');
|
|---|
| 1096 | k_javadoc_box_line('Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA');
|
|---|
| 1097 | break;
|
|---|
| 1098 |
|
|---|
| 1099 | case 'Confidential':
|
|---|
| 1100 | k_javadoc_box_line('All Rights Reserved');
|
|---|
| 1101 | break;
|
|---|
| 1102 |
|
|---|
| 1103 | default:
|
|---|
| 1104 |
|
|---|
| 1105 | }
|
|---|
| 1106 | k_javadoc_box_line();
|
|---|
| 1107 | k_javadoc_box_end();
|
|---|
| 1108 |
|
|---|
| 1109 | up(p_RLine - iCursorLine);
|
|---|
| 1110 | p_col = length(k_comment()) + 2;
|
|---|
| 1111 | }
|
|---|
| 1112 |
|
|---|
| 1113 |
|
|---|
| 1114 |
|
|---|
| 1115 |
|
|---|
| 1116 |
|
|---|
| 1117 |
|
|---|
| 1118 |
|
|---|
| 1119 | /*******************************************************************************
|
|---|
| 1120 | * Keyboard Shortcuts *
|
|---|
| 1121 | *******************************************************************************/
|
|---|
| 1122 | /** Makes global box. */
|
|---|
| 1123 | void k_box_globals()
|
|---|
| 1124 | {
|
|---|
| 1125 | k_box_start('Global');
|
|---|
| 1126 | k_box_line('Global Variables');
|
|---|
| 1127 | k_box_end();
|
|---|
| 1128 | }
|
|---|
| 1129 |
|
|---|
| 1130 | /** Makes header box. */
|
|---|
| 1131 | void k_box_headers()
|
|---|
| 1132 | {
|
|---|
| 1133 | k_box_start("Header");
|
|---|
| 1134 | k_box_line("Header Files");
|
|---|
| 1135 | k_box_end();
|
|---|
| 1136 | }
|
|---|
| 1137 |
|
|---|
| 1138 | /** Makes internal function box. */
|
|---|
| 1139 | void k_box_intfuncs()
|
|---|
| 1140 | {
|
|---|
| 1141 | k_box_start("IntFunc");
|
|---|
| 1142 | k_box_line("Internal Functions");
|
|---|
| 1143 | k_box_end();
|
|---|
| 1144 | }
|
|---|
| 1145 |
|
|---|
| 1146 | /** Makes def/const box. */
|
|---|
| 1147 | void k_box_consts()
|
|---|
| 1148 | {
|
|---|
| 1149 | k_box_start("Const");
|
|---|
| 1150 | k_box_line("Defined Constants And Macros");
|
|---|
| 1151 | k_box_end();
|
|---|
| 1152 | }
|
|---|
| 1153 |
|
|---|
| 1154 | /** Structure box */
|
|---|
| 1155 | void k_box_structs()
|
|---|
| 1156 | {
|
|---|
| 1157 | k_box_start("Struct");
|
|---|
| 1158 | k_box_line("Structures and Typedefs");
|
|---|
| 1159 | k_box_end();
|
|---|
| 1160 | }
|
|---|
| 1161 |
|
|---|
| 1162 |
|
|---|
| 1163 | /** oneliner comment */
|
|---|
| 1164 | void k_oneliner()
|
|---|
| 1165 | {
|
|---|
| 1166 | int iColumn = 0;
|
|---|
| 1167 | _str sLeft = '';
|
|---|
| 1168 | _str sRight = '';
|
|---|
| 1169 |
|
|---|
| 1170 | if (!k_readboxconfig(sLeft, sRight, iColumn))
|
|---|
| 1171 | {
|
|---|
| 1172 | sLeft = '/*';
|
|---|
| 1173 | sRight = '*/';
|
|---|
| 1174 | }
|
|---|
| 1175 |
|
|---|
| 1176 | end_line();
|
|---|
| 1177 | do
|
|---|
| 1178 | {
|
|---|
| 1179 | _insert_text(" ");
|
|---|
| 1180 | } while (p_col < ikStyleOneliner);
|
|---|
| 1181 |
|
|---|
| 1182 | if (sRight == '')
|
|---|
| 1183 | _insert_text(sLeft:+' ');
|
|---|
| 1184 | else
|
|---|
| 1185 | {
|
|---|
| 1186 | _insert_text(sLeft:+' ':+sRight);
|
|---|
| 1187 | p_col -= length(sRight) + 1;
|
|---|
| 1188 | }
|
|---|
| 1189 | }
|
|---|
| 1190 |
|
|---|
| 1191 | /** mark line as modified. */
|
|---|
| 1192 | void k_mark_modified_line()
|
|---|
| 1193 | {
|
|---|
| 1194 | end_line();
|
|---|
| 1195 | do
|
|---|
| 1196 | {
|
|---|
| 1197 | _insert_text(" ");
|
|---|
| 1198 | } while (p_col < ikStyleModifyMarkColumn);
|
|---|
| 1199 |
|
|---|
| 1200 |
|
|---|
| 1201 | if (skChange != '')
|
|---|
| 1202 | _insert_text(k_comment() ' ' skChange ' (' skUserInitials ')');
|
|---|
| 1203 | else
|
|---|
| 1204 | _insert_text(k_comment() ' ' skUserInitials);
|
|---|
| 1205 |
|
|---|
| 1206 | if (!k_line_comment())
|
|---|
| 1207 | _insert_text(' ' k_comment(true));
|
|---|
| 1208 | down();
|
|---|
| 1209 | }
|
|---|
| 1210 |
|
|---|
| 1211 |
|
|---|
| 1212 | /**
|
|---|
| 1213 | * Inserts a signature. Form: "//Initials ISO-date:"
|
|---|
| 1214 | * @remark defeventtab
|
|---|
| 1215 | */
|
|---|
| 1216 | void k_signature()
|
|---|
| 1217 | {
|
|---|
| 1218 | /* kso I5-10000 2002-09-10: */
|
|---|
| 1219 | if (skChange != '')
|
|---|
| 1220 | _insert_text(k_comment() ' ' skUserInitials ' ' skChange ' ' k_date() ': ');
|
|---|
| 1221 | else
|
|---|
| 1222 | _insert_text(k_comment() ' ' skUserInitials ' ' k_date() ': ');
|
|---|
| 1223 |
|
|---|
| 1224 | if (!k_line_comment())
|
|---|
| 1225 | {
|
|---|
| 1226 | _str sRight = k_comment(true);
|
|---|
| 1227 | _insert_text(' ' sRight);
|
|---|
| 1228 | p_col -= length(sRight) + 1;
|
|---|
| 1229 | }
|
|---|
| 1230 | }
|
|---|
| 1231 |
|
|---|
| 1232 |
|
|---|
| 1233 | /*******************************************************************************
|
|---|
| 1234 | * kLIB Logging *
|
|---|
| 1235 | *******************************************************************************/
|
|---|
| 1236 | /**
|
|---|
| 1237 | * Hot-Key: Inserts a KLOGENTRY statement at start of nearest function.
|
|---|
| 1238 | */
|
|---|
| 1239 | void klib_klogentry()
|
|---|
| 1240 | {
|
|---|
| 1241 | _save_pos2(org_pos);
|
|---|
| 1242 |
|
|---|
| 1243 | /*
|
|---|
| 1244 | * Go to nearest function.
|
|---|
| 1245 | */
|
|---|
| 1246 | if (!k_func_goto_nearest_function())
|
|---|
| 1247 | {
|
|---|
| 1248 | /*
|
|---|
| 1249 | * Get parameters.
|
|---|
| 1250 | */
|
|---|
| 1251 | _str sParams = k_func_getparams();
|
|---|
| 1252 | if (sParams)
|
|---|
| 1253 | {
|
|---|
| 1254 | _str sRetType = k_func_getreturntype(true);
|
|---|
| 1255 | if (!sRetType || sRetType == "")
|
|---|
| 1256 | sRetType = "void"; /* paranoia! */
|
|---|
| 1257 |
|
|---|
| 1258 | /*
|
|---|
| 1259 | * Insert text.
|
|---|
| 1260 | */
|
|---|
| 1261 | if (!k_func_searchcode("{"))
|
|---|
| 1262 | {
|
|---|
| 1263 | p_col++;
|
|---|
| 1264 | cArgs = k_func_countparams(sParams);
|
|---|
| 1265 | if (cArgs > 0)
|
|---|
| 1266 | {
|
|---|
| 1267 | sArgs = "";
|
|---|
| 1268 | for (i = 0; i < cArgs; i++)
|
|---|
| 1269 | {
|
|---|
| 1270 | _str sType, sName, sDefault
|
|---|
| 1271 | if (!k_func_enumparams(sParams, i, sType, sName, sDefault))
|
|---|
| 1272 | sArgs = sArgs', 'sName;
|
|---|
| 1273 | }
|
|---|
| 1274 |
|
|---|
| 1275 | _insert_text("\n KLOGENTRY"cArgs"(\""sRetType"\",\""sParams"\""sArgs");"); /* todo tab size.. or smart indent */
|
|---|
| 1276 | }
|
|---|
| 1277 | else
|
|---|
| 1278 | _insert_text("\n KLOGENTRY0(\""sRetType"\");"); /* todo tab size.. or smart indent */
|
|---|
| 1279 |
|
|---|
| 1280 | /*
|
|---|
| 1281 | * Check if the next word is KLOGENTRY.
|
|---|
| 1282 | */
|
|---|
| 1283 | next_word();
|
|---|
| 1284 | if (def_next_word_style == 'E')
|
|---|
| 1285 | prev_word();
|
|---|
| 1286 | if (substr(cur_word(iIgnorePos), 1, 9) == "KLOGENTRY")
|
|---|
| 1287 | delete_line();
|
|---|
| 1288 |
|
|---|
| 1289 | }
|
|---|
| 1290 | else
|
|---|
| 1291 | message("didn't find {");
|
|---|
| 1292 | }
|
|---|
| 1293 | else
|
|---|
| 1294 | message("k_func_getparams failed, sParams=" sParams);
|
|---|
| 1295 | return;
|
|---|
| 1296 | }
|
|---|
| 1297 |
|
|---|
| 1298 | _restore_pos2(org_pos);
|
|---|
| 1299 | }
|
|---|
| 1300 |
|
|---|
| 1301 |
|
|---|
| 1302 | /**
|
|---|
| 1303 | * Hot-Key: Inserts a KLOGEXIT statement at cursor location.
|
|---|
| 1304 | */
|
|---|
| 1305 | void klib_klogexit()
|
|---|
| 1306 | {
|
|---|
| 1307 | _save_pos2(org_pos);
|
|---|
| 1308 |
|
|---|
| 1309 | /*
|
|---|
| 1310 | * Go to nearest function.
|
|---|
| 1311 | */
|
|---|
| 1312 | if (!prev_proc())
|
|---|
| 1313 | {
|
|---|
| 1314 | /*
|
|---|
| 1315 | * Get parameters.
|
|---|
| 1316 | */
|
|---|
| 1317 | _str sType = k_func_getreturntype(true);
|
|---|
| 1318 | _restore_pos2(org_pos);
|
|---|
| 1319 | if (sType)
|
|---|
| 1320 | {
|
|---|
| 1321 | boolean fReturn = true; /* true if an return statment is following the KLOGEXIT statement. */
|
|---|
| 1322 |
|
|---|
| 1323 | /*
|
|---|
| 1324 | * Insert text.
|
|---|
| 1325 | */
|
|---|
| 1326 | cur_col = p_col;
|
|---|
| 1327 | if (sType == 'void' || sType == 'VOID')
|
|---|
| 1328 | { /* procedure */
|
|---|
| 1329 | fReturn = cur_word(iIgnorePos) == 'return';
|
|---|
| 1330 | if (!fReturn)
|
|---|
| 1331 | {
|
|---|
| 1332 | while (p_col <= p_SyntaxIndent)
|
|---|
| 1333 | keyin(" ");
|
|---|
| 1334 | }
|
|---|
| 1335 |
|
|---|
| 1336 | _insert_text("KLOGEXITVOID();\n");
|
|---|
| 1337 |
|
|---|
| 1338 | if (fReturn)
|
|---|
| 1339 | {
|
|---|
| 1340 | for (i = 1; i < cur_col; i++)
|
|---|
| 1341 | _insert_text(" ");
|
|---|
| 1342 | }
|
|---|
| 1343 | search(")","E-");
|
|---|
| 1344 | }
|
|---|
| 1345 | else
|
|---|
| 1346 | { /* function */
|
|---|
| 1347 | _insert_text("KLOGEXIT();\n");
|
|---|
| 1348 | for (i = 1; i < cur_col; i++)
|
|---|
| 1349 | _insert_text(" ");
|
|---|
| 1350 | search(")","E-");
|
|---|
| 1351 |
|
|---|
| 1352 | /*
|
|---|
| 1353 | * Insert value if possible.
|
|---|
| 1354 | */
|
|---|
| 1355 | _save_pos2(valuepos);
|
|---|
| 1356 | next_word();
|
|---|
| 1357 | if (def_next_word_style == 'E')
|
|---|
| 1358 | prev_word();
|
|---|
| 1359 | if (cur_word(iIgnorePos) == 'return')
|
|---|
| 1360 | {
|
|---|
| 1361 | p_col += length('return');
|
|---|
| 1362 | _save_pos2(posStart);
|
|---|
| 1363 | offStart = _QROffset();
|
|---|
| 1364 | if (!k_func_searchcode(";", "E+"))
|
|---|
| 1365 | {
|
|---|
| 1366 | offEnd = _QROffset();
|
|---|
| 1367 | _restore_pos2(posStart);
|
|---|
| 1368 | _str sValue = strip(get_text(offEnd - offStart));
|
|---|
| 1369 | //say 'sValue = 'sValue;
|
|---|
| 1370 | _restore_pos2(valuepos);
|
|---|
| 1371 | _save_pos2(valuepos);
|
|---|
| 1372 | _insert_text(sValue);
|
|---|
| 1373 | }
|
|---|
| 1374 | }
|
|---|
| 1375 | _restore_pos2(valuepos);
|
|---|
| 1376 | }
|
|---|
| 1377 |
|
|---|
| 1378 | /*
|
|---|
| 1379 | * Remove old KLOGEXIT statement on previous line if any.
|
|---|
| 1380 | */
|
|---|
| 1381 | _save_pos2(valuepos);
|
|---|
| 1382 | newexitline = p_line;
|
|---|
| 1383 | p_line--; p_col = 1;
|
|---|
| 1384 | next_word();
|
|---|
| 1385 | if (def_next_word_style == 'E')
|
|---|
| 1386 | prev_word();
|
|---|
| 1387 | if (p_line == newexitline - 1 && substr(cur_word(iIgnorePos), 1, 8) == 'KLOGEXIT')
|
|---|
| 1388 | delete_line();
|
|---|
| 1389 | _restore_pos2(valuepos);
|
|---|
| 1390 |
|
|---|
| 1391 | /*
|
|---|
| 1392 | * Check for missing '{...}'.
|
|---|
| 1393 | */
|
|---|
| 1394 | if (fReturn)
|
|---|
| 1395 | {
|
|---|
| 1396 | boolean fFound = false;
|
|---|
| 1397 | _save_pos2(valuepos);
|
|---|
| 1398 | p_col--; find_matching_paren(); p_col += 2;
|
|---|
| 1399 | k_func_searchcode(';', 'E+'); /* places us at the ';' of the return. (hopefully) */
|
|---|
| 1400 |
|
|---|
| 1401 | _str ch = k_func_get_next_code_text();
|
|---|
| 1402 | if (ch != '}')
|
|---|
| 1403 | {
|
|---|
| 1404 | _restore_pos2(valuepos);
|
|---|
| 1405 | _save_pos2(valuepos);
|
|---|
| 1406 | p_col--; find_matching_paren(); p_col += 2;
|
|---|
| 1407 | k_func_searchcode(';', 'E+'); /* places us at the ';' of the return. (hopefully) */
|
|---|
| 1408 | p_col++;
|
|---|
| 1409 | if (k_func_more_code_on_line())
|
|---|
| 1410 | _insert_text(' }');
|
|---|
| 1411 | else
|
|---|
| 1412 | {
|
|---|
| 1413 | _save_pos2(returnget);
|
|---|
| 1414 | k_func_searchcode("return", "E-");
|
|---|
| 1415 | return_col = p_col;
|
|---|
| 1416 | _restore_pos2(returnget);
|
|---|
| 1417 |
|
|---|
| 1418 | end_line();
|
|---|
| 1419 | _insert_text("\n");
|
|---|
| 1420 | while (p_col < return_col - p_SyntaxIndent)
|
|---|
| 1421 | _insert_text(' ');
|
|---|
| 1422 | _insert_text('}');
|
|---|
| 1423 | }
|
|---|
| 1424 |
|
|---|
| 1425 | _restore_pos2(valuepos);
|
|---|
| 1426 | _save_pos2(valuepos);
|
|---|
| 1427 | prev_word();
|
|---|
| 1428 | p_col -= p_SyntaxIndent;
|
|---|
| 1429 | codecol = p_col;
|
|---|
| 1430 | _insert_text("{\n");
|
|---|
| 1431 | while (p_col < codecol)
|
|---|
| 1432 | _insert_text(' ');
|
|---|
| 1433 | }
|
|---|
| 1434 |
|
|---|
| 1435 | _restore_pos2(valuepos);
|
|---|
| 1436 | }
|
|---|
| 1437 | }
|
|---|
| 1438 | else
|
|---|
| 1439 | message("k_func_getreturntype failed, sType=" sType);
|
|---|
| 1440 | return;
|
|---|
| 1441 | }
|
|---|
| 1442 |
|
|---|
| 1443 | _restore_pos2(org_pos);
|
|---|
| 1444 | }
|
|---|
| 1445 |
|
|---|
| 1446 |
|
|---|
| 1447 | /**
|
|---|
| 1448 | * Processes a file - ask user all the time.
|
|---|
| 1449 | */
|
|---|
| 1450 | void klib_klog_file_ask()
|
|---|
| 1451 | {
|
|---|
| 1452 | klib_klog_file_int(true)
|
|---|
| 1453 | }
|
|---|
| 1454 |
|
|---|
| 1455 |
|
|---|
| 1456 | /**
|
|---|
| 1457 | * Processes a file - no questions.
|
|---|
| 1458 | */
|
|---|
| 1459 | void klib_klog_file_no_ask()
|
|---|
| 1460 | {
|
|---|
| 1461 | klib_klog_file_int(false)
|
|---|
| 1462 | }
|
|---|
| 1463 |
|
|---|
| 1464 |
|
|---|
| 1465 |
|
|---|
| 1466 | /**
|
|---|
| 1467 | * Processes a file.
|
|---|
| 1468 | */
|
|---|
| 1469 | static void klib_klog_file_int(boolean fAsk)
|
|---|
| 1470 | {
|
|---|
| 1471 | show_all();
|
|---|
| 1472 | bottom();
|
|---|
| 1473 | _refresh_scroll();
|
|---|
| 1474 |
|
|---|
| 1475 | /* ask question so we can get to the right position somehow.. */
|
|---|
| 1476 | if (fAsk && _message_box("kLog process this file?", "Visual SlickEdit", MB_YESNO | MB_ICONQUESTION) != IDYES)
|
|---|
| 1477 | return;
|
|---|
| 1478 |
|
|---|
| 1479 | /*
|
|---|
| 1480 | * Entries.
|
|---|
| 1481 | */
|
|---|
| 1482 | while (!prev_proc())
|
|---|
| 1483 | {
|
|---|
| 1484 | //say 'entry main loop: ' k_func_getfunction_name();
|
|---|
| 1485 |
|
|---|
| 1486 | /*
|
|---|
| 1487 | * Skip prototypes.
|
|---|
| 1488 | */
|
|---|
| 1489 | if (k_func_prototype())
|
|---|
| 1490 | continue;
|
|---|
| 1491 |
|
|---|
| 1492 | /*
|
|---|
| 1493 | * Ask user.
|
|---|
| 1494 | */
|
|---|
| 1495 | center_line();
|
|---|
| 1496 | _refresh_scroll();
|
|---|
| 1497 | sFunction = k_func_getfunction_name();
|
|---|
| 1498 | rc = fAsk ? _message_box("Process this function ("sFunction")?", "Visual SlickEdit", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
|
|---|
| 1499 | if (rc == IDYES)
|
|---|
| 1500 | {
|
|---|
| 1501 | _save_pos2(procpos);
|
|---|
| 1502 | klib_klogentry();
|
|---|
| 1503 | _restore_pos2(procpos);
|
|---|
| 1504 | }
|
|---|
| 1505 | else if (rc == IDNO)
|
|---|
| 1506 | continue;
|
|---|
| 1507 | else
|
|---|
| 1508 | break;
|
|---|
| 1509 | }
|
|---|
| 1510 |
|
|---|
| 1511 | /*
|
|---|
| 1512 | * Exits.
|
|---|
| 1513 | */
|
|---|
| 1514 | bottom(); _refresh_scroll();
|
|---|
| 1515 | boolean fUserCancel = false;
|
|---|
| 1516 | while (!prev_proc() && !fUserCancel)
|
|---|
| 1517 | {
|
|---|
| 1518 | _save_pos2(procpos);
|
|---|
| 1519 | sCurFunction = k_func_getfunction_name();
|
|---|
| 1520 | //say 'exit main loop: ' sCurFunction
|
|---|
| 1521 |
|
|---|
| 1522 | /*
|
|---|
| 1523 | * Skip prototypes.
|
|---|
| 1524 | */
|
|---|
| 1525 | if (k_func_prototype())
|
|---|
| 1526 | continue;
|
|---|
| 1527 |
|
|---|
| 1528 | /*
|
|---|
| 1529 | * Select procedure.
|
|---|
| 1530 | */
|
|---|
| 1531 | while ( !k_func_searchcode("return", "WE<+")
|
|---|
| 1532 | && k_func_getfunction_name() == sCurFunction)
|
|---|
| 1533 | {
|
|---|
| 1534 | //say 'exit sub loop: ' p_line
|
|---|
| 1535 | /*
|
|---|
| 1536 | * Ask User.
|
|---|
| 1537 | */
|
|---|
| 1538 | center_line();
|
|---|
| 1539 | _refresh_scroll();
|
|---|
| 1540 | sFunction = k_func_getfunction_name();
|
|---|
| 1541 | rc = fAsk ? _message_box("Process this exit from "sFunction"?", "Visual SlickEdit", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
|
|---|
| 1542 | deselect();
|
|---|
| 1543 | if (rc == IDYES)
|
|---|
| 1544 | {
|
|---|
| 1545 | _save_pos2(returnpos);
|
|---|
| 1546 | klib_klogexit();
|
|---|
| 1547 | _restore_pos2(returnpos);
|
|---|
| 1548 | p_line++;
|
|---|
| 1549 | }
|
|---|
| 1550 | else if (rc != IDNO)
|
|---|
| 1551 | {
|
|---|
| 1552 | fUserCancel = true;
|
|---|
| 1553 | break;
|
|---|
| 1554 | }
|
|---|
| 1555 | p_line++; /* just so we won't hit it again. */
|
|---|
| 1556 | }
|
|---|
| 1557 |
|
|---|
| 1558 | /*
|
|---|
| 1559 | * If void function we'll have to check if there is and return; prior to the ending '}'.
|
|---|
| 1560 | */
|
|---|
| 1561 | _restore_pos2(procpos);
|
|---|
| 1562 | _save_pos2(procpos);
|
|---|
| 1563 | sType = k_func_getreturntype(true);
|
|---|
| 1564 | if (!fUserCancel && sType && (sType == 'void' || sType == 'VOID'))
|
|---|
| 1565 | {
|
|---|
| 1566 | if ( !k_func_searchcode("{", "E+")
|
|---|
| 1567 | && !find_matching_paren())
|
|---|
| 1568 | {
|
|---|
| 1569 | _save_pos2(funcend);
|
|---|
| 1570 | prev_word();
|
|---|
| 1571 | if (cur_word(iIgnorePos) != "return")
|
|---|
| 1572 | {
|
|---|
| 1573 | /*
|
|---|
| 1574 | * Ask User.
|
|---|
| 1575 | */
|
|---|
| 1576 | _restore_pos2(funcend);
|
|---|
| 1577 | center_line();
|
|---|
| 1578 | _refresh_scroll();
|
|---|
| 1579 | sFunction = k_func_getfunction_name();
|
|---|
| 1580 | rc = fAsk ? _message_box("Process this exit from "sFunction"?", "Visual SlickEdit", MB_YESNOCANCEL | MB_ICONQUESTION) : IDYES;
|
|---|
| 1581 | deselect();
|
|---|
| 1582 | if (rc == IDYES)
|
|---|
| 1583 | {
|
|---|
| 1584 | _save_pos2(returnpos);
|
|---|
| 1585 | klib_klogexit();
|
|---|
| 1586 | _restore_pos2(returnpos);
|
|---|
| 1587 | }
|
|---|
| 1588 | }
|
|---|
| 1589 | }
|
|---|
| 1590 | }
|
|---|
| 1591 |
|
|---|
| 1592 | /*
|
|---|
| 1593 | * Next proc.
|
|---|
| 1594 | */
|
|---|
| 1595 | _restore_pos2(procpos);
|
|---|
| 1596 | }
|
|---|
| 1597 | }
|
|---|
| 1598 |
|
|---|
| 1599 |
|
|---|
| 1600 | /*******************************************************************************
|
|---|
| 1601 | * Odin32 backward compatibility *
|
|---|
| 1602 | *******************************************************************************/
|
|---|
| 1603 | _command void odin32_maketagfile()
|
|---|
| 1604 | {
|
|---|
| 1605 | /* We'll */
|
|---|
| 1606 | if (file_match('-p 'maybe_quote_filename(strip_filename(_project_name,'e'):+TAG_FILE_EXT),1) != "")
|
|---|
| 1607 | {
|
|---|
| 1608 | _project_update_files_retag(false,false,false,false);
|
|---|
| 1609 | /*
|
|---|
| 1610 | RetagFilesInTagFile2(project_tag_file, orig_view_id, temp_view_id, rebuild_all, false,
|
|---|
| 1611 | doRemove,false,true,true);*/7
|
|---|
| 1612 | }
|
|---|
| 1613 | else
|
|---|
| 1614 | _project_update_files_retag(true,false,false,true);
|
|---|
| 1615 | }
|
|---|
| 1616 |
|
|---|
| 1617 | _command void odin32_setcurrentdir()
|
|---|
| 1618 | {
|
|---|
| 1619 | //_ini_get_value(_project_name,"COMPILER","WORKINGDIR", workingdir);
|
|---|
| 1620 | //cd(workingdir);
|
|---|
| 1621 | /* Go the the directory containing the project filename */
|
|---|
| 1622 | cd(strip_filename(_project_name, 'NE'));
|
|---|
| 1623 | }
|
|---|
| 1624 |
|
|---|
| 1625 |
|
|---|
| 1626 |
|
|---|
| 1627 |
|
|---|
| 1628 | /*******************************************************************************
|
|---|
| 1629 | * Styles *
|
|---|
| 1630 | *******************************************************************************/
|
|---|
| 1631 | static _str StyleLanguages[] =
|
|---|
| 1632 | {
|
|---|
| 1633 | "c",
|
|---|
| 1634 | "e",
|
|---|
| 1635 | "java"
|
|---|
| 1636 | };
|
|---|
| 1637 |
|
|---|
| 1638 | struct StyleScheme
|
|---|
| 1639 | {
|
|---|
| 1640 | _str name;
|
|---|
| 1641 | _str settings[];
|
|---|
| 1642 | };
|
|---|
| 1643 |
|
|---|
| 1644 | static StyleScheme StyleSchemes[] =
|
|---|
| 1645 | {
|
|---|
| 1646 | {
|
|---|
| 1647 | "Opt2Ind4",
|
|---|
| 1648 | {
|
|---|
| 1649 | "orig_tabsize=4",
|
|---|
| 1650 | "syntax_indent=4",
|
|---|
| 1651 | "tabsize=4",
|
|---|
| 1652 | "align_on_equal=1",
|
|---|
| 1653 | "pad_condition_state=1",
|
|---|
| 1654 | "indent_with_tabs=0",
|
|---|
| 1655 | "nospace_before_paren=0",
|
|---|
| 1656 | "indent_comments=1",
|
|---|
| 1657 | "indent_case=1",
|
|---|
| 1658 | "statement_comment_col=0",
|
|---|
| 1659 | "disable_bestyle=0",
|
|---|
| 1660 | "decl_comment_col=0",
|
|---|
| 1661 | "bestyle_on_functions=0",
|
|---|
| 1662 | "use_relative_indent=1",
|
|---|
| 1663 | "nospace_before_brace=0",
|
|---|
| 1664 | "indent_fl=1",
|
|---|
| 1665 | "statement_comment_state=2",
|
|---|
| 1666 | "indent_pp=1",
|
|---|
| 1667 | "be_style=1",
|
|---|
| 1668 | "parens_on_return=0",
|
|---|
| 1669 | "eat_blank_lines=0",
|
|---|
| 1670 | "brace_indent=0",
|
|---|
| 1671 | "eat_pp_space=1",
|
|---|
| 1672 | "align_on_parens=1",
|
|---|
| 1673 | "continuation_indent=0",
|
|---|
| 1674 | "cuddle_else=0",
|
|---|
| 1675 | "nopad_condition=1",
|
|---|
| 1676 | "pad_condition=0",
|
|---|
| 1677 | "indent_col1_comments=0"
|
|---|
| 1678 | }
|
|---|
| 1679 | }
|
|---|
| 1680 | ,
|
|---|
| 1681 | {
|
|---|
| 1682 | "Opt2Ind3",
|
|---|
| 1683 | {
|
|---|
| 1684 | "orig_tabsize=3",
|
|---|
| 1685 | "syntax_indent=3",
|
|---|
| 1686 | "tabsize=3",
|
|---|
| 1687 | "align_on_equal=1",
|
|---|
| 1688 | "pad_condition_state=1",
|
|---|
| 1689 | "indent_with_tabs=0",
|
|---|
| 1690 | "nospace_before_paren=0",
|
|---|
| 1691 | "indent_comments=1",
|
|---|
| 1692 | "indent_case=1",
|
|---|
| 1693 | "statement_comment_col=0",
|
|---|
| 1694 | "disable_bestyle=0",
|
|---|
| 1695 | "decl_comment_col=0",
|
|---|
| 1696 | "bestyle_on_functions=0",
|
|---|
| 1697 | "use_relative_indent=1",
|
|---|
| 1698 | "nospace_before_brace=0",
|
|---|
| 1699 | "indent_fl=1",
|
|---|
| 1700 | "statement_comment_state=2",
|
|---|
| 1701 | "indent_pp=1",
|
|---|
| 1702 | "be_style=1",
|
|---|
| 1703 | "parens_on_return=0",
|
|---|
| 1704 | "eat_blank_lines=0",
|
|---|
| 1705 | "brace_indent=0",
|
|---|
| 1706 | "eat_pp_space=1",
|
|---|
| 1707 | "align_on_parens=1",
|
|---|
| 1708 | "continuation_indent=0",
|
|---|
| 1709 | "cuddle_else=0",
|
|---|
| 1710 | "nopad_condition=1",
|
|---|
| 1711 | "pad_condition=0",
|
|---|
| 1712 | "indent_col1_comments=0"
|
|---|
| 1713 | }
|
|---|
| 1714 | }
|
|---|
| 1715 | ,
|
|---|
| 1716 | {
|
|---|
| 1717 | "Opt2Ind8",
|
|---|
| 1718 | {
|
|---|
| 1719 | "orig_tabsize=8",
|
|---|
| 1720 | "syntax_indent=8",
|
|---|
| 1721 | "tabsize=8",
|
|---|
| 1722 | "align_on_equal=1",
|
|---|
| 1723 | "pad_condition_state=1",
|
|---|
| 1724 | "indent_with_tabs=0",
|
|---|
| 1725 | "nospace_before_paren=0",
|
|---|
| 1726 | "indent_comments=1",
|
|---|
| 1727 | "indent_case=1",
|
|---|
| 1728 | "statement_comment_col=0",
|
|---|
| 1729 | "disable_bestyle=0",
|
|---|
| 1730 | "decl_comment_col=0",
|
|---|
| 1731 | "bestyle_on_functions=0",
|
|---|
| 1732 | "use_relative_indent=1",
|
|---|
| 1733 | "nospace_before_brace=0",
|
|---|
| 1734 | "indent_fl=1",
|
|---|
| 1735 | "statement_comment_state=2",
|
|---|
| 1736 | "indent_pp=1",
|
|---|
| 1737 | "be_style=1",
|
|---|
| 1738 | "parens_on_return=0",
|
|---|
| 1739 | "eat_blank_lines=0",
|
|---|
| 1740 | "brace_indent=0",
|
|---|
| 1741 | "eat_pp_space=1",
|
|---|
| 1742 | "align_on_parens=1",
|
|---|
| 1743 | "continuation_indent=0",
|
|---|
| 1744 | "cuddle_else=0",
|
|---|
| 1745 | "nopad_condition=1",
|
|---|
| 1746 | "pad_condition=0",
|
|---|
| 1747 | "indent_col1_comments=0"
|
|---|
| 1748 | }
|
|---|
| 1749 | }
|
|---|
| 1750 | ,
|
|---|
| 1751 | {
|
|---|
| 1752 | "Opt3Ind4",
|
|---|
| 1753 | {
|
|---|
| 1754 | "orig_tabsize=4",
|
|---|
| 1755 | "syntax_indent=4",
|
|---|
| 1756 | "tabsize=4",
|
|---|
| 1757 | "align_on_equal=1",
|
|---|
| 1758 | "pad_condition_state=1",
|
|---|
| 1759 | "indent_with_tabs=0",
|
|---|
| 1760 | "nospace_before_paren=0",
|
|---|
| 1761 | "indent_comments=1",
|
|---|
| 1762 | "indent_case=1",
|
|---|
| 1763 | "statement_comment_col=0",
|
|---|
| 1764 | "disable_bestyle=0",
|
|---|
| 1765 | "decl_comment_col=0",
|
|---|
| 1766 | "bestyle_on_functions=0",
|
|---|
| 1767 | "use_relative_indent=1",
|
|---|
| 1768 | "nospace_before_brace=0",
|
|---|
| 1769 | "indent_fl=1",
|
|---|
| 1770 | "statement_comment_state=2",
|
|---|
| 1771 | "indent_pp=1",
|
|---|
| 1772 | "be_style=2",
|
|---|
| 1773 | "parens_on_return=0",
|
|---|
| 1774 | "eat_blank_lines=0",
|
|---|
| 1775 | "brace_indent=0",
|
|---|
| 1776 | "eat_pp_space=1",
|
|---|
| 1777 | "align_on_parens=1",
|
|---|
| 1778 | "continuation_indent=0",
|
|---|
| 1779 | "cuddle_else=0",
|
|---|
| 1780 | "nopad_condition=1",
|
|---|
| 1781 | "pad_condition=0",
|
|---|
| 1782 | "indent_col1_comments=0"
|
|---|
| 1783 | }
|
|---|
| 1784 | }
|
|---|
| 1785 | ,
|
|---|
| 1786 | {
|
|---|
| 1787 | "Opt3Ind3",
|
|---|
| 1788 | {
|
|---|
| 1789 | "orig_tabsize=3",
|
|---|
| 1790 | "syntax_indent=3",
|
|---|
| 1791 | "tabsize=3",
|
|---|
| 1792 | "align_on_equal=1",
|
|---|
| 1793 | "pad_condition_state=1",
|
|---|
| 1794 | "indent_with_tabs=0",
|
|---|
| 1795 | "nospace_before_paren=0",
|
|---|
| 1796 | "indent_comments=1",
|
|---|
| 1797 | "indent_case=1",
|
|---|
| 1798 | "statement_comment_col=0",
|
|---|
| 1799 | "disable_bestyle=0",
|
|---|
| 1800 | "decl_comment_col=0",
|
|---|
| 1801 | "bestyle_on_functions=0",
|
|---|
| 1802 | "use_relative_indent=1",
|
|---|
| 1803 | "nospace_before_brace=0",
|
|---|
| 1804 | "indent_fl=1",
|
|---|
| 1805 | "statement_comment_state=2",
|
|---|
| 1806 | "indent_pp=1",
|
|---|
| 1807 | "be_style=2",
|
|---|
| 1808 | "parens_on_return=0",
|
|---|
| 1809 | "eat_blank_lines=0",
|
|---|
| 1810 | "brace_indent=0",
|
|---|
| 1811 | "eat_pp_space=1",
|
|---|
| 1812 | "align_on_parens=1",
|
|---|
| 1813 | "continuation_indent=0",
|
|---|
| 1814 | "cuddle_else=0",
|
|---|
| 1815 | "nopad_condition=1",
|
|---|
| 1816 | "pad_condition=0",
|
|---|
| 1817 | "indent_col1_comments=0"
|
|---|
| 1818 | }
|
|---|
| 1819 | }
|
|---|
| 1820 | };
|
|---|
| 1821 |
|
|---|
| 1822 |
|
|---|
| 1823 | static void k_styles_create()
|
|---|
| 1824 | {
|
|---|
| 1825 | /*
|
|---|
| 1826 | * Find user format ini file.
|
|---|
| 1827 | */
|
|---|
| 1828 | userini = maybe_quote_filename(_config_path():+'uformat.ini');
|
|---|
| 1829 | if (file_match('-p 'userini, 1) == '')
|
|---|
| 1830 | {
|
|---|
| 1831 | ini = maybe_quote_filename(slick_path_search('uformat.ini'));
|
|---|
| 1832 | if (ini != '') userini = ini;
|
|---|
| 1833 | }
|
|---|
| 1834 |
|
|---|
| 1835 |
|
|---|
| 1836 | /*
|
|---|
| 1837 | * Remove any old schemes.
|
|---|
| 1838 | */
|
|---|
| 1839 | for (i = 0; i < StyleSchemes._length(); i++)
|
|---|
| 1840 | for (j = 0; j < StyleLanguages._length(); j++)
|
|---|
| 1841 | {
|
|---|
| 1842 | sectionname = StyleLanguages[j]:+'-scheme-':+StyleSchemes[i].name;
|
|---|
| 1843 | if (!_ini_get_section(userini, sectionname, tv))
|
|---|
| 1844 | {
|
|---|
| 1845 | _ini_delete_section(userini, sectionname);
|
|---|
| 1846 | _delete_temp_view(tv);
|
|---|
| 1847 | //message("delete old scheme");
|
|---|
| 1848 | }
|
|---|
| 1849 | }
|
|---|
| 1850 |
|
|---|
| 1851 | /*
|
|---|
| 1852 | * Create the new schemes.
|
|---|
| 1853 | */
|
|---|
| 1854 | for (i = 0; i < StyleSchemes._length(); i++)
|
|---|
| 1855 | {
|
|---|
| 1856 | for (j = 0; j < StyleLanguages._length(); j++)
|
|---|
| 1857 | {
|
|---|
| 1858 | sectionname = StyleLanguages[j]:+'-scheme-':+StyleSchemes[i].name;
|
|---|
| 1859 | orig_view_id = _create_temp_view(temp_view_id);
|
|---|
| 1860 | activate_view(temp_view_id);
|
|---|
| 1861 | for (k = 0; k < StyleSchemes[i].settings._length(); k++)
|
|---|
| 1862 | insert_line(StyleSchemes[i].settings[k]);
|
|---|
| 1863 |
|
|---|
| 1864 | /* Insert the scheme section. */
|
|---|
| 1865 | _ini_replace_section(userini, sectionname, temp_view_id);
|
|---|
| 1866 | //message(userini)
|
|---|
| 1867 | activate_view(orig_view_id);
|
|---|
| 1868 | }
|
|---|
| 1869 | }
|
|---|
| 1870 |
|
|---|
| 1871 | //last_scheme = last scheme name!!!
|
|---|
| 1872 | }
|
|---|
| 1873 |
|
|---|
| 1874 |
|
|---|
| 1875 | /*
|
|---|
| 1876 | * Sets the last used beutify scheme.
|
|---|
| 1877 | */
|
|---|
| 1878 | static k_styles_set(_str scheme)
|
|---|
| 1879 | {
|
|---|
| 1880 |
|
|---|
| 1881 | /*
|
|---|
| 1882 | * Find user format ini file.
|
|---|
| 1883 | */
|
|---|
| 1884 | userini = maybe_quote_filename(_config_path():+'uformat.ini');
|
|---|
| 1885 | if (file_match('-p 'userini, 1) == '')
|
|---|
| 1886 | {
|
|---|
| 1887 | ini = maybe_quote_filename(slick_path_search('uformat.ini'));
|
|---|
| 1888 | if (ini != '') userini = ini;
|
|---|
| 1889 | }
|
|---|
| 1890 |
|
|---|
| 1891 | /*
|
|---|
| 1892 | * Set the scheme for each language.
|
|---|
| 1893 | */
|
|---|
| 1894 | for (j = 0; j < StyleLanguages._length(); j++)
|
|---|
| 1895 | {
|
|---|
| 1896 | _ini_set_value(userini,
|
|---|
| 1897 | StyleLanguages[j]:+'-scheme-Default',
|
|---|
| 1898 | 'last_scheme',
|
|---|
| 1899 | scheme);
|
|---|
| 1900 | }
|
|---|
| 1901 | }
|
|---|
| 1902 |
|
|---|
| 1903 |
|
|---|
| 1904 | static _str defoptions[] =
|
|---|
| 1905 | {
|
|---|
| 1906 | "def-options-sas",
|
|---|
| 1907 | "def-options-js",
|
|---|
| 1908 | "def-options-bat",
|
|---|
| 1909 | "def-options-c",
|
|---|
| 1910 | "def-options-pas",
|
|---|
| 1911 | "def-options-e",
|
|---|
| 1912 | "def-options-java",
|
|---|
| 1913 | "def-options-bourneshell",
|
|---|
| 1914 | "def-options-csh",
|
|---|
| 1915 | "def-options-vlx",
|
|---|
| 1916 | "def-options-plsql",
|
|---|
| 1917 | "def-options-sqlserver",
|
|---|
| 1918 | "def-options-cmd"
|
|---|
| 1919 | };
|
|---|
| 1920 |
|
|---|
| 1921 | static _str defsetups[] =
|
|---|
| 1922 | {
|
|---|
| 1923 | "def-setup-sas",
|
|---|
| 1924 | "def-setup-js",
|
|---|
| 1925 | "def-setup-bat",
|
|---|
| 1926 | "def-setup-fundamental",
|
|---|
| 1927 | "def-setup-process",
|
|---|
| 1928 | "def-setup-c",
|
|---|
| 1929 | "def-setup-pas",
|
|---|
| 1930 | "def-setup-e",
|
|---|
| 1931 | "def-setup-asm",
|
|---|
| 1932 | "def-setup-java",
|
|---|
| 1933 | "def-setup-html",
|
|---|
| 1934 | "def-setup-bourneshell",
|
|---|
| 1935 | "def-setup-csh",
|
|---|
| 1936 | "def-setup-vlx",
|
|---|
| 1937 | "def-setup-fileman",
|
|---|
| 1938 | "def-setup-plsql",
|
|---|
| 1939 | "def-setup-sqlserver",
|
|---|
| 1940 | "def-setup-s",
|
|---|
| 1941 | "def-setup-cmd"
|
|---|
| 1942 | };
|
|---|
| 1943 |
|
|---|
| 1944 | static _str defsetupstab8[] =
|
|---|
| 1945 | {
|
|---|
| 1946 | "def-setup-c"
|
|---|
| 1947 | };
|
|---|
| 1948 |
|
|---|
| 1949 |
|
|---|
| 1950 | static void k_styles_setindent(int indent, int iBraceStyle, boolean iWithTabs = false)
|
|---|
| 1951 | {
|
|---|
| 1952 | if (iBraceStyle < 1 || iBraceStyle > 3)
|
|---|
| 1953 | {
|
|---|
| 1954 | say 'k_styles_setindent: iBraceStyle is bad (='iBraceStyle')';
|
|---|
| 1955 | iBraceStyle = 2;
|
|---|
| 1956 | }
|
|---|
| 1957 | /*
|
|---|
| 1958 | * def-options for extentions known to have that info.
|
|---|
| 1959 | */
|
|---|
| 1960 | for (i = 0; i < defoptions._length(); i++)
|
|---|
| 1961 | {
|
|---|
| 1962 | idx = find_index(defoptions[i], MISC_TYPE);
|
|---|
| 1963 | if (!idx)
|
|---|
| 1964 | continue;
|
|---|
| 1965 |
|
|---|
| 1966 | parse name_info(idx) with syntax_indent o2 o3 o4 flags indent_fl o7 indent_case rest;
|
|---|
| 1967 |
|
|---|
| 1968 | /* Begin/end style */
|
|---|
| 1969 | flags = flags & ~(1|2);
|
|---|
| 1970 | flags = flags | (iBraceStyle - 1); /* Set style (0-based) */
|
|---|
| 1971 | flags = flags & ~(16); /* no scape before parent.*/
|
|---|
| 1972 | indent_fl = 1; /* Indent first level */
|
|---|
| 1973 | indent_case = 1; /* Indent case from switch */
|
|---|
| 1974 |
|
|---|
| 1975 | sNewOptions = indent' 'o2' 'o3' 'o4' 'flags' 'indent_fl' 'o7' 'indent_case' 'rest;
|
|---|
| 1976 | set_name_info(idx, sNewOptions);
|
|---|
| 1977 | _config_modify |= CFGMODIFY_DEFDATA;
|
|---|
| 1978 | }
|
|---|
| 1979 |
|
|---|
| 1980 | /*
|
|---|
| 1981 | * def-setup for known extentions.
|
|---|
| 1982 | */
|
|---|
| 1983 | for (i = 0; i < defsetups._length(); i++)
|
|---|
| 1984 | {
|
|---|
| 1985 | idx = find_index(defsetups[i], MISC_TYPE);
|
|---|
| 1986 | if (!idx)
|
|---|
| 1987 | continue;
|
|---|
| 1988 | sExt = substr(defsetups[i], length('def-setup-') + 1);
|
|---|
| 1989 | sSetup = name_info(idx);
|
|---|
| 1990 |
|
|---|
| 1991 | /*
|
|---|
| 1992 | parse sSetup with 'MN=' mode_name ','\
|
|---|
| 1993 | 'TABS=' tabs ',' 'MA=' margins ',' 'KEYTAB=' keytab_name ','\
|
|---|
| 1994 | 'WW='word_wrap_style ',' 'IWT='indent_with_tabs ','\
|
|---|
| 1995 | 'ST='show_tabs ',' 'IN='indent_style ','\
|
|---|
| 1996 | 'WC='word_chars',' 'LN='lexer_name',' 'CF='color_flags','\
|
|---|
| 1997 | 'LNL='line_numbers_len','rest;
|
|---|
| 1998 |
|
|---|
| 1999 | indent_with_tabs = 0; /* Indent with tabs */
|
|---|
| 2000 |
|
|---|
| 2001 | /* Make sure all the values are legal */
|
|---|
| 2002 | _ext_init_values(ext, lexer_name, color_flags);
|
|---|
| 2003 | if (!isinteger(line_numbers_len)) line_numbers_len = 0;
|
|---|
| 2004 | if (word_chars == '') word_chars = 'A-Za-z0-9_$';
|
|---|
| 2005 | if (word_wrap_style == '') word_wrap_style = 3;
|
|---|
| 2006 | if (show_tabs == '') show_tabs = 0;
|
|---|
| 2007 | if (indent_style == '') indent_style = INDENT_SMART;
|
|---|
| 2008 |
|
|---|
| 2009 | /* Set new indent */
|
|---|
| 2010 | tabs = '+'indent;
|
|---|
| 2011 | */
|
|---|
| 2012 |
|
|---|
| 2013 | sNewSetup = sSetup;
|
|---|
| 2014 |
|
|---|
| 2015 | /* Set new indent */
|
|---|
| 2016 | if (pos('TABS=', sNewSetup) > 0)
|
|---|
| 2017 | {
|
|---|
| 2018 | /*
|
|---|
| 2019 | * If either in defoptions or defsetupstab8 use default tab of 8
|
|---|
| 2020 | * For those supporting separate syntax indent using the normal tabsize
|
|---|
| 2021 | * helps us a lot when reading it...
|
|---|
| 2022 | */
|
|---|
| 2023 | fTab8 = false;
|
|---|
| 2024 | for (j = 0; !fTab8 && j < defsetupstab8._length(); j++)
|
|---|
| 2025 | if (substr(defsetupstab8[j], lastpos('-', defsetupstab8[j]) + 1) == sExt)
|
|---|
| 2026 | fTab8 = true;
|
|---|
| 2027 | for (j = 0; !fTab8 && j < defoptions._length(); j++)
|
|---|
| 2028 | if (substr(defoptions[j], lastpos('-', defoptions[j]) + 1) == sExt)
|
|---|
| 2029 | fTab8 = true;
|
|---|
| 2030 |
|
|---|
| 2031 | parse sNewSetup with sPre 'TABS=' sValue ',' sPost;
|
|---|
| 2032 | if (fTab8)
|
|---|
| 2033 | sNewSetup = sPre 'TABS=+8,' sPost
|
|---|
| 2034 | else
|
|---|
| 2035 | sNewSetup = sPre 'TABS=+' indent ',' sPost
|
|---|
| 2036 | }
|
|---|
| 2037 |
|
|---|
| 2038 | /* Set indent with tabs flag. */
|
|---|
| 2039 | if (pos('IWT=', sNewSetup) > 0)
|
|---|
| 2040 | {
|
|---|
| 2041 | parse sNewSetup with sPre 'IWT=' sValue ',' sPost;
|
|---|
| 2042 | if (iWithTabs)
|
|---|
| 2043 | sNewSetup = sPre 'IWT=1,' sPost
|
|---|
| 2044 | else
|
|---|
| 2045 | sNewSetup = sPre 'IWT=0,' sPost
|
|---|
| 2046 | }
|
|---|
| 2047 |
|
|---|
| 2048 | /* Do the real changes */
|
|---|
| 2049 | set_name_info(idx, sNewSetup);
|
|---|
| 2050 | _config_modify |= CFGMODIFY_DEFDATA;
|
|---|
| 2051 | _update_buffers(sExt);
|
|---|
| 2052 | }
|
|---|
| 2053 | }
|
|---|
| 2054 |
|
|---|
| 2055 |
|
|---|
| 2056 | /*******************************************************************************
|
|---|
| 2057 | * Menu and Menu commands *
|
|---|
| 2058 | *******************************************************************************/
|
|---|
| 2059 | static int iTimer = 0;
|
|---|
| 2060 | static int mhExtra = 0;
|
|---|
| 2061 | static int mhCode = 0;
|
|---|
| 2062 | static int mhDoc = 0;
|
|---|
| 2063 | static int mhLic = 0;
|
|---|
| 2064 | static int mhPre = 0;
|
|---|
| 2065 |
|
|---|
| 2066 | /*
|
|---|
| 2067 | * Creates the Extra menu.
|
|---|
| 2068 | */
|
|---|
| 2069 | static k_menu_create()
|
|---|
| 2070 | {
|
|---|
| 2071 | if (arg(1) == 'timer')
|
|---|
| 2072 | _kill_timer(iTimer);
|
|---|
| 2073 | menu_handle = _mdi.p_menu_handle;
|
|---|
| 2074 | menu_index = find_index(_cur_mdi_menu,oi2type(OI_MENU));
|
|---|
| 2075 |
|
|---|
| 2076 | /*
|
|---|
| 2077 | * Remove any old menu.
|
|---|
| 2078 | */
|
|---|
| 2079 | mhDelete = iPos = 0;
|
|---|
| 2080 | index = _menu_find(menu_handle, "Extra", mhDelete, iPos, 'C');
|
|---|
| 2081 | //message("index="index " mhDelete="mhDelete " iPos="iPos);
|
|---|
| 2082 | if (index == 0)
|
|---|
| 2083 | _menu_delete(mhDelete, iPos);
|
|---|
| 2084 |
|
|---|
| 2085 |
|
|---|
| 2086 | /*
|
|---|
| 2087 | * Insert the "Extra" menu.
|
|---|
| 2088 | */
|
|---|
| 2089 | mhExtra = _menu_insert(menu_handle, 9, MF_SUBMENU, "E&xtra", "", "Extra");
|
|---|
| 2090 | mhCode=_menu_insert(mhExtra, -1, MF_ENABLED | MF_SUBMENU, "Coding &Style", "", "coding");
|
|---|
| 2091 | rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 2, Syntax Indent 4 (knut)", "k_menu_style Opt2Ind4", "Opt2Ind4");
|
|---|
| 2092 | rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 2, Syntax Indent 3", "k_menu_style Opt2Ind3", "Opt2Ind3");
|
|---|
| 2093 | rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 2, Syntax Indent 8", "k_menu_style Opt2Ind8", "Opt2Ind8");
|
|---|
| 2094 | rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 3, Syntax Indent 4 (giws)", "k_menu_style Opt3Ind4", "Opt3Ind4");
|
|---|
| 2095 | rc = _menu_insert(mhCode, -1, MF_ENABLED | MF_UNCHECKED, "Braces 3, Syntax Indent 3 (giws)", "k_menu_style Opt3Ind3", "Opt3Ind3");
|
|---|
| 2096 |
|
|---|
| 2097 | mhDoc= _menu_insert(mhExtra, -1, MF_ENABLED | MF_SUBMENU, "&Documentation", "", "doc");
|
|---|
| 2098 | mhDSJ= _menu_insert(mhDoc, -1, MF_ENABLED | MF_UNCHECKED, "&Javadoc Style", "k_menu_doc_style javadoc", "javadoc");
|
|---|
| 2099 | mhDSL= _menu_insert(mhDoc, -1, MF_GRAYED | MF_UNCHECKED, "&Linux Kernel Style", "k_menu_doc_style linux", "linux");
|
|---|
| 2100 |
|
|---|
| 2101 | mhLic= _menu_insert(mhExtra, -1, MF_ENABLED | MF_SUBMENU, "&License", "", "License");
|
|---|
| 2102 | rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&Odin32", "k_menu_license Odin32", "Odin32");
|
|---|
| 2103 | rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&GPL", "k_menu_license GPL", "GPL");
|
|---|
| 2104 | rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&LGPL", "k_menu_license LGPL", "LGPL");
|
|---|
| 2105 | rc = _menu_insert(mhLic, -1, MF_ENABLED | MF_UNCHECKED, "&Confidential", "k_menu_license Confidential", "Confidential");
|
|---|
| 2106 |
|
|---|
| 2107 | rc = _menu_insert(mhExtra, -1, MF_ENABLED, "-", "", "dash vars");
|
|---|
| 2108 | rc = _menu_insert(mhExtra, -1, MF_ENABLED, skChange == '' ? '&Change...' : '&Change (' skChange ')...', "k_menu_change", "");
|
|---|
| 2109 | rc = _menu_insert(mhExtra, -1, MF_ENABLED, skProgram == '' ? '&Program...' : '&Program (' skProgram ')...', "k_menu_program", "");
|
|---|
| 2110 | rc = _menu_insert(mhExtra, -1, MF_ENABLED, skCompany == '' ? 'Co&mpany...' : 'Co&mpany (' skCompany ')...', "k_menu_company", "");
|
|---|
| 2111 | rc = _menu_insert(mhExtra, -1, MF_ENABLED, '&User Name (' skUserName ')...', "k_menu_user_name", "username");
|
|---|
| 2112 | rc = _menu_insert(mhExtra, -1, MF_ENABLED, 'User &e-mail (' skUserEmail ')...', "k_menu_user_email", "useremail");
|
|---|
| 2113 | rc = _menu_insert(mhExtra, -1, MF_ENABLED, 'User &Initials (' skUserInitials ')...', "k_menu_user_initials", "userinitials");
|
|---|
| 2114 | rc = _menu_insert(mhExtra, -1, MF_ENABLED, "-", "", "dash preset");
|
|---|
| 2115 | mhPre= _menu_insert(mhExtra, -1, MF_SUBMENU, "P&resets", "", "");
|
|---|
| 2116 | rc = _menu_insert(mhPre, -1, MF_ENABLED, "Odin32", "k_menu_preset javadoc, Odin32, Opt2Ind4,,Odin32", "odin32");
|
|---|
| 2117 | rc = _menu_insert(mhPre, -1, MF_ENABLED, "Linux Kernel","k_menu_preset linux, GPL, Opt1Ind4,,Linux", "linux");
|
|---|
| 2118 | rc = _menu_insert(mhPre, -1, MF_ENABLED, "The Bird", "k_menu_preset javadoc, GPL, Opt2Ind4", "bird");
|
|---|
| 2119 | rc = _menu_insert(mhPre, -1, MF_ENABLED, "Win32k", "k_menu_preset javadoc, GPL, Opt2Ind4,, Win32k", "Win32k");
|
|---|
| 2120 | rc = _menu_insert(mhPre, -1, MF_ENABLED, "kKrnlLib", "k_menu_preset javadoc, GPL, Opt2Ind4,, kKrnlLib", "kKrnlLib");
|
|---|
| 2121 | rc = _menu_insert(mhPre, -1, MF_ENABLED, "kLib", "k_menu_preset javadoc, GPL, Opt2Ind4,, kLib", "kLib");
|
|---|
| 2122 | rc = _menu_insert(mhPre, -1, MF_ENABLED, "Innotek", "k_menu_preset javadoc, Confidential, Opt2Ind4, InnoTek Systemberatung GmbH", "Innotek");
|
|---|
| 2123 |
|
|---|
| 2124 | k_menu_doc_style();
|
|---|
| 2125 | k_menu_license();
|
|---|
| 2126 | k_menu_style();
|
|---|
| 2127 | }
|
|---|
| 2128 |
|
|---|
| 2129 |
|
|---|
| 2130 | /**
|
|---|
| 2131 | * Change change Id.
|
|---|
| 2132 | */
|
|---|
| 2133 | _command k_menu_change()
|
|---|
| 2134 | {
|
|---|
| 2135 | sRc = show("-modal k_form_simple_input", "Change ID", skChange);
|
|---|
| 2136 | if (sRc != "\r")
|
|---|
| 2137 | {
|
|---|
| 2138 | skChange = sRc;
|
|---|
| 2139 | k_menu_create();
|
|---|
| 2140 | }
|
|---|
| 2141 | }
|
|---|
| 2142 |
|
|---|
| 2143 |
|
|---|
| 2144 | /**
|
|---|
| 2145 | * Change program name.
|
|---|
| 2146 | */
|
|---|
| 2147 | _command k_menu_program()
|
|---|
| 2148 | {
|
|---|
| 2149 | sRc = show("-modal k_form_simple_input", "Program", skProgram);
|
|---|
| 2150 | if (sRc != "\r")
|
|---|
| 2151 | {
|
|---|
| 2152 | skProgram = sRc;
|
|---|
| 2153 | k_menu_create();
|
|---|
| 2154 | }
|
|---|
| 2155 | }
|
|---|
| 2156 |
|
|---|
| 2157 |
|
|---|
| 2158 | /**
|
|---|
| 2159 | * Change company.
|
|---|
| 2160 | */
|
|---|
| 2161 | _command k_menu_company()
|
|---|
| 2162 | {
|
|---|
| 2163 | if (skCompany == '')
|
|---|
| 2164 | sRc = show("-modal k_form_simple_input", "Company", 'InnoTek Systemberatung GmbH');
|
|---|
| 2165 | else
|
|---|
| 2166 | sRc = show("-modal k_form_simple_input", "Company", skCompany);
|
|---|
| 2167 | if (sRc != "\r")
|
|---|
| 2168 | {
|
|---|
| 2169 | skCompany = sRc;
|
|---|
| 2170 | k_menu_create();
|
|---|
| 2171 | }
|
|---|
| 2172 | }
|
|---|
| 2173 |
|
|---|
| 2174 |
|
|---|
| 2175 | /**
|
|---|
| 2176 | * Change user name.
|
|---|
| 2177 | */
|
|---|
| 2178 | _command k_menu_user_name()
|
|---|
| 2179 | {
|
|---|
| 2180 | sRc = show("-modal k_form_simple_input", "User Name", skUserName);
|
|---|
| 2181 | if (sRc != "\r" && sRc != '')
|
|---|
| 2182 | {
|
|---|
| 2183 | skUserName = sRc;
|
|---|
| 2184 | k_menu_create();
|
|---|
| 2185 | }
|
|---|
| 2186 | }
|
|---|
| 2187 |
|
|---|
| 2188 |
|
|---|
| 2189 | /**
|
|---|
| 2190 | * Change user email.
|
|---|
| 2191 | */
|
|---|
| 2192 | _command k_menu_user_email()
|
|---|
| 2193 | {
|
|---|
| 2194 | sRc = show("-modal k_form_simple_input", "User e-mail", skUserEmail);
|
|---|
| 2195 | if (sRc != "\r" && sRc != '')
|
|---|
| 2196 | {
|
|---|
| 2197 | skUserEmail = sRc;
|
|---|
| 2198 | k_menu_create();
|
|---|
| 2199 | }
|
|---|
| 2200 | }
|
|---|
| 2201 |
|
|---|
| 2202 |
|
|---|
| 2203 | /**
|
|---|
| 2204 | * Change user initials.
|
|---|
| 2205 | */
|
|---|
| 2206 | _command k_menu_user_initials()
|
|---|
| 2207 | {
|
|---|
| 2208 | sRc = show("-modal k_form_simple_input", "User e-mail", skUserInitials);
|
|---|
| 2209 | if (sRc != "\r" && sRc != '')
|
|---|
| 2210 | {
|
|---|
| 2211 | skUserInitials = sRc;
|
|---|
| 2212 | k_menu_create();
|
|---|
| 2213 | }
|
|---|
| 2214 | }
|
|---|
| 2215 |
|
|---|
| 2216 |
|
|---|
| 2217 |
|
|---|
| 2218 | /**
|
|---|
| 2219 | * Checks the correct menu item.
|
|---|
| 2220 | */
|
|---|
| 2221 | _command void k_menu_doc_style(_str sNewDocStyle = '')
|
|---|
| 2222 | {
|
|---|
| 2223 | //say 'sNewDocStyle='sNewDocStyle;
|
|---|
| 2224 | if (sNewDocStyle != '')
|
|---|
| 2225 | skDocStyle = sNewDocStyle
|
|---|
| 2226 | _menu_set_state(mhDoc, "javadoc", MF_UNCHECKED);
|
|---|
| 2227 | _menu_set_state(mhDoc, "linux", MF_UNCHECKED | MF_GRAYED);
|
|---|
| 2228 | _menu_set_state(mhDoc, skDocStyle, MF_CHECKED);
|
|---|
| 2229 | }
|
|---|
| 2230 |
|
|---|
| 2231 |
|
|---|
| 2232 | /**
|
|---|
| 2233 | * Checks the correct menu item.
|
|---|
| 2234 | */
|
|---|
| 2235 | _command void k_menu_license(_str sNewLicense = '')
|
|---|
| 2236 | {
|
|---|
| 2237 | //say 'sNewLicense='sNewLicense;
|
|---|
| 2238 | if (sNewLicense != '')
|
|---|
| 2239 | skLicense = sNewLicense
|
|---|
| 2240 | _menu_set_state(mhLic, "Odin32", MF_UNCHECKED);
|
|---|
| 2241 | _menu_set_state(mhLic, "GPL", MF_UNCHECKED);
|
|---|
| 2242 | _menu_set_state(mhLic, "LGPL", MF_UNCHECKED);
|
|---|
| 2243 | _menu_set_state(mhLic, "Confidential", MF_UNCHECKED);
|
|---|
| 2244 | _menu_set_state(mhLic, skLicense, MF_CHECKED);
|
|---|
| 2245 | }
|
|---|
| 2246 |
|
|---|
| 2247 |
|
|---|
| 2248 | /**
|
|---|
| 2249 | * Check the correct style menu item.
|
|---|
| 2250 | */
|
|---|
| 2251 | _command void k_menu_style(_str sNewStyle = '')
|
|---|
| 2252 | {
|
|---|
| 2253 | //say 'sNewStyle='sNewStyle;
|
|---|
| 2254 | _menu_set_state(mhCode, "Opt1Ind4", MF_UNCHECKED);
|
|---|
| 2255 | _menu_set_state(mhCode, "Opt1Ind3", MF_UNCHECKED);
|
|---|
| 2256 | _menu_set_state(mhCode, "Opt1Ind8", MF_UNCHECKED);
|
|---|
| 2257 | _menu_set_state(mhCode, "Opt2Ind4", MF_UNCHECKED);
|
|---|
| 2258 | _menu_set_state(mhCode, "Opt2Ind3", MF_UNCHECKED);
|
|---|
| 2259 | _menu_set_state(mhCode, "Opt2Ind8", MF_UNCHECKED);
|
|---|
| 2260 | _menu_set_state(mhCode, "Opt3Ind4", MF_UNCHECKED);
|
|---|
| 2261 | _menu_set_state(mhCode, "Opt3Ind3", MF_UNCHECKED);
|
|---|
| 2262 | _menu_set_state(mhCode, "Opt3Ind8", MF_UNCHECKED);
|
|---|
| 2263 |
|
|---|
| 2264 | if (sNewStyle != '')
|
|---|
| 2265 | {
|
|---|
| 2266 | int iIndent = (int)substr(sNewStyle, 8, 1);
|
|---|
| 2267 | int iBraceStyle = (int)substr(sNewStyle, 4, 1);
|
|---|
| 2268 | skCodeStyle = sNewStyle;
|
|---|
| 2269 | k_styles_setindent(iIndent, iBraceStyle);
|
|---|
| 2270 | k_styles_set(sNewStyle);
|
|---|
| 2271 | }
|
|---|
| 2272 |
|
|---|
| 2273 | _menu_set_state(mhCode, skCodeStyle, MF_CHECKED);
|
|---|
| 2274 | }
|
|---|
| 2275 |
|
|---|
| 2276 |
|
|---|
| 2277 | /**
|
|---|
| 2278 | * Load a 'preset'.
|
|---|
| 2279 | */
|
|---|
| 2280 | _command void k_menu_preset(_str sArgs = '')
|
|---|
| 2281 | {
|
|---|
| 2282 | parse sArgs with sNewDocStyle ',' sNewLicense ',' sNewStyle ',' sNewCompany ',' sNewProgram
|
|---|
| 2283 | sNewDocStyle= strip(sNewDocStyle);
|
|---|
| 2284 | sNewLicense = strip(sNewLicense);
|
|---|
| 2285 | sNewStyle = strip(sNewStyle);
|
|---|
| 2286 | sNewCompany = strip(sNewCompany);
|
|---|
| 2287 | sNewProgram = strip(sNewProgram);
|
|---|
| 2288 |
|
|---|
| 2289 | //say 'k_menu_preset('sNewDocStyle',' sNewLicense',' sNewStyle',' sNewCompany',' sNewProgram')';
|
|---|
| 2290 | k_menu_doc_style(sNewDocStyle);
|
|---|
| 2291 | k_menu_license(sNewLicense);
|
|---|
| 2292 | k_menu_style(sNewStyle);
|
|---|
| 2293 | skCompany = sNewCompany;
|
|---|
| 2294 | skProgram = sNewProgram;
|
|---|
| 2295 | skChange = '';
|
|---|
| 2296 | k_menu_create();
|
|---|
| 2297 | }
|
|---|
| 2298 |
|
|---|
| 2299 |
|
|---|
| 2300 |
|
|---|
| 2301 | /* future ones..
|
|---|
| 2302 | _command k_menu_setcolor()
|
|---|
| 2303 | {
|
|---|
| 2304 | createMyColorSchemeAndUseIt();
|
|---|
| 2305 | }
|
|---|
| 2306 |
|
|---|
| 2307 |
|
|---|
| 2308 | _command k_menu_setkeys()
|
|---|
| 2309 | {
|
|---|
| 2310 | rc = load("d:/knut/VSlickMacros/BoxerDef.e");
|
|---|
| 2311 | }
|
|---|
| 2312 |
|
|---|
| 2313 | _command k_menu_settings()
|
|---|
| 2314 | {
|
|---|
| 2315 | mySettings();
|
|---|
| 2316 | }
|
|---|
| 2317 | */
|
|---|
| 2318 |
|
|---|
| 2319 |
|
|---|
| 2320 | /*******************************************************************************
|
|---|
| 2321 | * Dialogs *
|
|---|
| 2322 | *******************************************************************************/
|
|---|
| 2323 | _form k_form_simple_input {
|
|---|
| 2324 | p_backcolor=0x80000005
|
|---|
| 2325 | p_border_style=BDS_DIALOG_BOX
|
|---|
| 2326 | p_caption='Simple Input'
|
|---|
| 2327 | p_clip_controls=FALSE
|
|---|
| 2328 | p_forecolor=0x80000008
|
|---|
| 2329 | p_height=1120
|
|---|
| 2330 | p_width=5020
|
|---|
| 2331 | p_x=6660
|
|---|
| 2332 | p_y=6680
|
|---|
| 2333 | _text_box entText {
|
|---|
| 2334 | p_auto_size=TRUE
|
|---|
| 2335 | p_backcolor=0x80000005
|
|---|
| 2336 | p_border_style=BDS_FIXED_SINGLE
|
|---|
| 2337 | p_completion=NONE_ARG
|
|---|
| 2338 | p_font_bold=FALSE
|
|---|
| 2339 | p_font_italic=FALSE
|
|---|
| 2340 | p_font_name='MS Sans Serif'
|
|---|
| 2341 | p_font_size=8
|
|---|
| 2342 | p_font_underline=FALSE
|
|---|
| 2343 | p_forecolor=0x80000008
|
|---|
| 2344 | p_height=270
|
|---|
| 2345 | p_tab_index=1
|
|---|
| 2346 | p_tab_stop=TRUE
|
|---|
| 2347 | p_text='text'
|
|---|
| 2348 | p_width=3180
|
|---|
| 2349 | p_x=1680
|
|---|
| 2350 | p_y=240
|
|---|
| 2351 | p_eventtab2=_ul2_textbox
|
|---|
| 2352 | }
|
|---|
| 2353 | _label lblLabel {
|
|---|
| 2354 | p_alignment=AL_VCENTERRIGHT
|
|---|
| 2355 | p_auto_size=FALSE
|
|---|
| 2356 | p_backcolor=0x80000005
|
|---|
| 2357 | p_border_style=BDS_NONE
|
|---|
| 2358 | p_caption='Label'
|
|---|
| 2359 | p_font_bold=FALSE
|
|---|
| 2360 | p_font_italic=FALSE
|
|---|
| 2361 | p_font_name='MS Sans Serif'
|
|---|
| 2362 | p_font_size=8
|
|---|
| 2363 | p_font_underline=FALSE
|
|---|
| 2364 | p_forecolor=0x80000008
|
|---|
| 2365 | p_height=240
|
|---|
| 2366 | p_tab_index=2
|
|---|
| 2367 | p_width=1380
|
|---|
| 2368 | p_word_wrap=FALSE
|
|---|
| 2369 | p_x=180
|
|---|
| 2370 | p_y=240
|
|---|
| 2371 | }
|
|---|
| 2372 | _command_button btnOK {
|
|---|
| 2373 | p_cancel=FALSE
|
|---|
| 2374 | p_caption='&OK'
|
|---|
| 2375 | p_default=TRUE
|
|---|
| 2376 | p_font_bold=FALSE
|
|---|
| 2377 | p_font_italic=FALSE
|
|---|
| 2378 | p_font_name='MS Sans Serif'
|
|---|
| 2379 | p_font_size=8
|
|---|
| 2380 | p_font_underline=FALSE
|
|---|
| 2381 | p_height=360
|
|---|
| 2382 | p_tab_index=3
|
|---|
| 2383 | p_tab_stop=TRUE
|
|---|
| 2384 | p_width=1020
|
|---|
| 2385 | p_x=180
|
|---|
| 2386 | p_y=660
|
|---|
| 2387 | }
|
|---|
| 2388 | _command_button btnCancel {
|
|---|
| 2389 | p_cancel=TRUE
|
|---|
| 2390 | p_caption='Cancel'
|
|---|
| 2391 | p_default=FALSE
|
|---|
| 2392 | p_font_bold=FALSE
|
|---|
| 2393 | p_font_italic=FALSE
|
|---|
| 2394 | p_font_name='MS Sans Serif'
|
|---|
| 2395 | p_font_size=8
|
|---|
| 2396 | p_font_underline=FALSE
|
|---|
| 2397 | p_height=360
|
|---|
| 2398 | p_tab_index=4
|
|---|
| 2399 | p_tab_stop=TRUE
|
|---|
| 2400 | p_width=840
|
|---|
| 2401 | p_x=1380
|
|---|
| 2402 | p_y=660
|
|---|
| 2403 | }
|
|---|
| 2404 | }
|
|---|
| 2405 |
|
|---|
| 2406 | defeventtab k_form_simple_input
|
|---|
| 2407 | btnOK.on_create(_str sLabel = '', _str sText = '')
|
|---|
| 2408 | {
|
|---|
| 2409 | p_active_form.p_caption = sLabel;
|
|---|
| 2410 | lblLabel.p_caption = sLabel;
|
|---|
| 2411 | entText.p_text = sText;
|
|---|
| 2412 | }
|
|---|
| 2413 |
|
|---|
| 2414 | btnOK.lbutton_up()
|
|---|
| 2415 | {
|
|---|
| 2416 | sText = entText.p_text;
|
|---|
| 2417 | p_active_form._delete_window(sText);
|
|---|
| 2418 | }
|
|---|
| 2419 | btnCancel.lbutton_up()
|
|---|
| 2420 | {
|
|---|
| 2421 | sText = entText.p_text;
|
|---|
| 2422 | p_active_form._delete_window("\r");
|
|---|
| 2423 | }
|
|---|
| 2424 |
|
|---|
| 2425 |
|
|---|
| 2426 |
|
|---|
| 2427 | /**
|
|---|
| 2428 | * Module initiation.
|
|---|
| 2429 | */
|
|---|
| 2430 | definit()
|
|---|
| 2431 | {
|
|---|
| 2432 | k_styles_create();
|
|---|
| 2433 | k_menu_create();
|
|---|
| 2434 | iTimer = _set_timer(1000, k_menu_create, "timer");
|
|---|
| 2435 | /* createMyColorSchemeAndUseIt();*/
|
|---|
| 2436 | }
|
|---|
| 2437 |
|
|---|
| 2438 |
|
|---|