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