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