Changeset 10129 for trunk/tools/vslick/kdev.e
- Timestamp:
- May 31, 2003, 10:10:11 PM (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/vslick/kdev.e
r9352 r10129 1 /* $Id: kdev.e,v 1. 4 2002-10-22 13:53:00bird Exp $1 /* $Id: kdev.e,v 1.5 2003-05-31 20:10:11 bird Exp $ 2 2 * 3 3 * Visual SlickEdit Documentation Macros. 4 4 * 5 * Copyright (c) 1999-200 2 knut st. osmundsen (bird@anduin.net)5 * Copyright (c) 1999-2003 knut st. osmundsen <bird@anduin.net> 6 6 * 7 * Project Odin Software License can be found in LICENSE.TXT8 7 * 9 **** 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 /*** 10 25 * 11 26 * This define the following keys: … … 18 33 * Ctrl+Shift+G: Global box 19 34 * Ctrl+Shift+H: Header box 35 * Ctrl+Shift+E: Exported Symbols 20 36 * Ctrl+Shift+I: Internal function box 21 37 * Ctrl+Shift+K: Const/macro box 22 38 * Ctrl+Shift+S: Struct/Typedef box 23 39 * 40 * Ctrl+Shift+A: Signature+Date marker 24 41 * Ctrl+Shift+P: Mark line as change by me 25 42 * 26 * Ctrl+Shift+T: 43 * Ctrl+Shift+T: Update project tagfile. 27 44 * 28 45 * Ctrl+Shift+B: KLOGENTRYX(..) … … 39 56 defeventtab default_keys 40 57 def 'C-S-A' = k_signature 41 //def 'C-S-B' = odin32_klogentry42 58 def 'C-S-C' = k_javadoc_classbox 43 //def 'C-S-E' = odin32_klogexit 59 def 'C-S-E' = k_box_exported 44 60 def 'C-S-F' = k_javadoc_funcbox 45 61 def 'C-S-G' = k_box_globals … … 48 64 def 'C-S-K' = k_box_consts 49 65 def 'C-S-M' = k_javadoc_moduleheader 50 //def 'C-S-N' = odin32_klog_file_no_ask51 66 def 'C-S-O' = k_oneliner 52 //def 'C-S-Q' = odin32_klog_file_ask53 67 def 'C-S-P' = k_mark_modified_line 54 68 def 'C-S-S' = k_box_structs 55 69 def 'C-S-T' = odin32_maketagfile 56 70 71 //optional stuff 72 //def 'C-S-Q' = odin32_klog_file_ask 73 //def 'C-S-N' = odin32_klog_file_no_ask 74 //def 'C-S-1' = odin32_klogentry 75 //def 'C-S-3' = odin32_klogexit 76 57 77 58 78 //MARKER. Editor searches for this line! … … 63 83 static _str skUserInitials = "kso"; 64 84 static _str skUserName = "knut st. osmundsen"; 65 static _str skUserEmail = "bird @anduin.net";85 static _str skUserEmail = "bird-srcspam@anduin.net"; 66 86 67 87 … … 82 102 static boolean fkStyleBoxTag = false; /* true: Include tag in k_box_start. */ 83 103 84 85 104 /******************************************************************************* 86 105 * Internal Functions * … … 133 152 134 153 /** 135 * Reads the comment setup for this extension. 154 * Reads the comment setup for this lexer/extension . 155 * 136 156 * @returns Success indicator. 137 157 * @param sLeft Left comment. (output) … … 139 159 * @param iColumn Comment mark column. (1-based) (output) 140 160 * @param sExt The extension to lookup defaults to the current one. 161 * @param sLexer The lexer to lookup defaults to the current one. 141 162 * @author knut st. osmundsen (bird@anduin.net) 142 163 * @remark This should be exported from box.e, but unfortunately it isn't. 143 164 */ 144 static boolean k_readboxconfig(_str &sLeft, _str &sRight, int &iColumn, _str sExt = p_extension) 145 { 165 static boolean k_commentconfig(_str &sLeft, _str &sRight, int &iColumn, _str sExt = p_extension, _str sLexer = p_lexer_name) 166 { 167 /* init returns */ 168 sLeft = sRight = ''; 169 iColumn = 0; 170 171 /* 172 * Get comment setup from the lexer. 173 */ 174 if (sLexer) 175 { 176 sLine = ''; 177 /* multiline */ 178 rc = _ini_get_value(slick_path_search("user.vlx"), sLexer, 'mlcomment', sLine); 179 if (rc) 180 rc = _ini_get_value(slick_path_search("vslick.vlx"), sLexer, 'mlcomment', sLine); 181 if (!rc) 182 { 183 sLeft = strip(word(sLine, 1)); 184 sRight = strip(word(sLine, 2)); 185 if (sLeft != '' && sRight != '') 186 return true; 187 } 188 189 /* failed, try single line. */ 190 rc = _ini_get_value(slick_path_search("user.vlx"), sLexer, 'linecomment', sLine); 191 if (rc) 192 rc = _ini_get_value(slick_path_search("vslick.vlx"), sLexer, 'linecomment', sLine); 193 if (!rc) 194 { 195 sLeft = strip(word(sLine, 1)); 196 sRight = ''; 197 iColumn = 0; 198 sTmp = word(sLine, 2); 199 if (isnumber(sTmp)) 200 iColumn = (int)sTmp; 201 if (sLeft != '') 202 return true; 203 } 204 } 205 146 206 /* 147 207 * Read the nonboxchars and determin user or default box.ini. … … 193 253 _str sRight = ''; 194 254 boolean fLineComment = false; 195 if (k_ readboxconfig(sLeft, sRight, iColumn))255 if (k_commentconfig(sLeft, sRight, iColumn)) 196 256 fLineComment = (sRight == '' || iColumn > 0); 197 257 return fLineComment; 258 } 259 260 261 262 #define KIC_CURSOR_BEFORE 1 263 #define KIC_CURSOR_AFTER 2 264 #define KIC_CURSOR_AT_END 3 265 266 /** 267 * Insert a comment at current or best fitting position in the text. 268 * @param sStr The comment to insert. 269 * @param iCursor Where to put the cursor. 270 * @param iPosition Where to start the comment. 271 * Doesn't apply to column based source. 272 * -1 means at cursor position. (default) 273 * >0 means at end of line, but not before this column (1-based). 274 * This also implies a min of one space to EOL. 275 */ 276 void k_insert_comment(_str sStr, int iCursor, int iPosition = -1) 277 { 278 _str sLeft; 279 _str sRight; 280 int iColumn; 281 if (!k_commentconfig(sLeft, sRight, iColumn)) 282 { 283 sLeft = '/*'; sRight = '*/'; iColumn = 0; 284 } 285 286 if (iColumn <= 0) 287 { /* 288 * not column based source 289 */ 290 291 /* position us first */ 292 if (iPosition > 0) 293 { 294 end_line(); 295 do { 296 _insert_text(" "); 297 } while (p_col < iPosition); 298 } 299 300 /* insert comment saving the position for _BEFORE. */ 301 iCol = p_col; 302 _insert_text(sLeft:+' ':+sStr); 303 if (iCursor == KIC_CURSOR_AT_END) 304 iCol = p_col; 305 /* right comment delimiter? */ 306 if (sRight != '') 307 _insert_text(' ':+sRight); 308 } 309 else 310 { 311 if (p_col >= iColumn) 312 _insert_text("\n"); 313 do { _insert_text(" "); } while (p_col < iColumn); 314 if (iCursor == KIC_CURSOR_BEFORE) 315 iCol = p_col; 316 _insert_text(sLeft:+' ':+sStr); 317 if (iCursor == KIC_CURSOR_AT_END) 318 iCol = p_col; 319 } 320 321 /* set cursor. */ 322 if (iCursor != KIC_CURSOR_AFTER) 323 p_col = iCol; 198 324 } 199 325 … … 209 335 { 210 336 sComment = '/*'; 211 if (k_ readboxconfig(sLeft, sRight, iColumn))337 if (k_commentconfig(sLeft, sRight, iColumn)) 212 338 sComment = (!fRight || iColumn > 0 ? sLeft : sRight); 213 339 … … 226 352 static void k_box_start(sTag) 227 353 { 228 begin_line(); 229 230 sText = k_comment(); 354 if (!k_commentconfig(sLeft, sRight, iColumn)) 355 return; 356 _begin_line(); 357 if (iColumn >= 0) 358 while (p_col < iColumn) 359 _insert_text(" "); 360 361 sText = sLeft; 231 362 if (sTag != '' && fkStyleBoxTag) 232 363 { … … 236 367 } 237 368 238 for (i = length(sText); i < ikStyleWidth; i++)369 for (i = length(sText); i <= ikStyleWidth - p_col; i++) 239 370 sText = sText:+'*'; 240 371 sText = sText:+"\n"; … … 250 381 static void k_box_line(_str sStr) 251 382 { 383 if (!k_commentconfig(sLeft, sRight, iColumn)) 384 return; 385 if (iColumn >= 0) 386 while (p_col < iColumn) 387 _insert_text(" "); 388 252 389 sText = ''; 253 390 if (k_line_comment()) 254 sText = k_comment();391 sText = sLeft; 255 392 if (sText == '' || substr(sText, length(sText)) != '*') 256 393 sText = sText:+'*'; … … 262 399 sText = sText:+sStr; 263 400 264 for (i = length(sText) + 1; i < ikStyleWidth; i++)401 for (i = length(sText) + 1; i <= ikStyleWidth - p_col; i++) 265 402 sText = sText:+' '; 266 403 sText = sText:+"*\n"; … … 275 412 static void k_box_end() 276 413 { 277 _str sRight = ''; 278 _str sText = ''; 414 if (!k_commentconfig(sLeft, sRight, iColumn)) 415 return; 416 if (iColumn >= 0) 417 while (p_col < iColumn) 418 _insert_text(" "); 419 420 sText = ''; 279 421 if (k_line_comment()) 280 sText = k_comment(); 281 else 282 sRight = k_comment(true); 283 284 for (i = length(sText) + length(sRight); i < ikStyleWidth; i++) 422 sText = sLeft; 423 for (i = length(sText) + length(sRight); i <= ikStyleWidth - p_col; i++) 285 424 sText = sText:+'*'; 286 287 425 sText = sText:+sRight:+"\n"; 288 426 … … 847 985 static void k_javadoc_box_start(_str sStr = '', boolean fDouble = true) 848 986 { 987 if (!k_commentconfig(sLeft, sRight, iColumn)) 988 return; 849 989 _begin_line(); 850 sText = k_comment(); 990 if (iColumn >= 0) 991 while (p_col < iColumn) 992 _insert_text(" "); 993 994 sText = sLeft; 851 995 if (fDouble) 852 sText = s Text:+substr(sText, length(sText), 1);996 sText = sLeft:+substr(sLeft, length(sLeft), 1); 853 997 if (sStr != '') 854 998 sText = sText:+' ':+sStr; … … 861 1005 static void k_javadoc_box_line(_str sStr = '', int iPadd = 0, _str sStr2 = '', int iPadd2 = 0, _str sStr3 = '') 862 1006 { 1007 if (!k_commentconfig(sLeft, sRight, iColumn)) 1008 return; 1009 if (iColumn >= 0) 1010 while (p_col < iColumn) 1011 _insert_text(" "); 1012 863 1013 if (k_line_comment()) 864 sText = k_comment();1014 sText = sLeft; 865 1015 else 866 1016 { 867 sText = k_comment();868 sText = ' ':+substr(s Text, length(sText));1017 sText = sLeft; 1018 sText = ' ':+substr(sLeft, length(sLeft)); 869 1019 } 870 1020 … … 888 1038 } 889 1039 } 890 891 1040 sText = sText:+"\n"; 892 1041 … … 894 1043 } 895 1044 896 /** starts a javadoc documentation box. */1045 /** ends a javadoc documentation box. */ 897 1046 static void k_javadoc_box_end() 898 1047 { 1048 if (!k_commentconfig(sLeft, sRight, iColumn)) 1049 return; 1050 if (iColumn >= 0) 1051 while (p_col < iColumn) 1052 _insert_text(" "); 1053 899 1054 if (k_line_comment()) 900 sText = k_comment();1055 sText = sLeft; 901 1056 else 902 1057 { 903 sText = k_comment(true);1058 sText = sRight; 904 1059 if (substr(sText, 1, 1) != '*') 905 1060 sText = '*':+sText; … … 1008 1163 k_javadoc_box_line('@sketch', iPadd); 1009 1164 k_javadoc_box_line('@status', iPadd); 1010 k_javadoc_box_line('@author', iPadd, skUserName ' 1165 k_javadoc_box_line('@author', iPadd, skUserName '<' skUserEmail '>'); 1011 1166 k_javadoc_box_line('@remark', iPadd); 1012 1167 k_javadoc_box_end(); … … 1034 1189 if (skLicense == 'Confidential') 1035 1190 { 1036 k_javadoc_box_line(skCompany ' 1191 k_javadoc_box_line(skCompany 'confidential'); 1037 1192 k_javadoc_box_line(); 1038 1193 } … … 1113 1268 1114 1269 up(p_RLine - iCursorLine); 1115 p_col = length(k_comment()) + 2; 1270 end_line(); 1271 keyin(' '); 1116 1272 } 1117 1273 … … 1165 1321 } 1166 1322 1323 /** Makes exported symbols box. */ 1324 void k_box_exported() 1325 { 1326 k_box_start('Exported'); 1327 k_box_line('Exported Symbols'); 1328 k_box_end(); 1329 } 1330 1331 1167 1332 1168 1333 /** oneliner comment */ 1169 1334 void k_oneliner() 1170 1335 { 1171 int iColumn = 0; 1172 _str sLeft = ''; 1173 _str sRight = ''; 1174 1175 if (!k_readboxconfig(sLeft, sRight, iColumn)) 1176 { 1177 sLeft = '/*'; 1178 sRight = '*/'; 1179 } 1180 1181 end_line(); 1182 do 1183 { 1184 _insert_text(" "); 1185 } while (p_col < ikStyleOneliner); 1186 1187 if (sRight == '') 1188 _insert_text(sLeft:+' '); 1189 else 1190 { 1191 _insert_text(sLeft:+' ':+sRight); 1192 p_col -= length(sRight) + 1; 1193 } 1336 if ( k_commentconfig(sLeft, sRight, iColumn) 1337 && iColumn > 0) 1338 { /* column based needs some tricy repositioning. */ 1339 _end_line(); 1340 if (p_col > iColumn) 1341 { 1342 _begin_line(); 1343 _insert_text("\n\r"); 1344 up(); 1345 } 1346 } 1347 k_insert_comment("", KIC_CURSOR_AT_END, ikStyleOneliner); 1194 1348 } 1195 1349 … … 1197 1351 void k_mark_modified_line() 1198 1352 { 1199 end_line(); 1200 do 1201 { 1202 _insert_text(" "); 1203 } while (p_col < ikStyleModifyMarkColumn); 1204 1353 /* not supported for column based sources */ 1354 if ( !k_commentconfig(sLeft, sRight, iColumn) 1355 || iColumn > 0) 1356 return; 1205 1357 1206 1358 if (skChange != '') 1207 _insert_text(k_comment() ' ' skChange ' (' skUserInitials ')');1359 sStr = skChange ' (' skUserInitials ')'; 1208 1360 else 1209 _insert_text(k_comment() ' ' skUserInitials); 1210 1211 if (!k_line_comment()) 1212 _insert_text(' ' k_comment(true)); 1361 sStr = skUserInitials; 1362 k_insert_comment(sStr, KIC_CURSOR_BEFORE, ikStyleModifyMarkColumn); 1213 1363 down(); 1214 1364 } … … 1223 1373 /* kso I5-10000 2002-09-10: */ 1224 1374 if (skChange != '') 1225 _insert_text(k_comment() ' ' skUserInitials ' ' skChange ' ' k_date() ': ');1375 sSig = skUserInitials ' ' skChange ' ' k_date() ': '; 1226 1376 else 1227 _insert_text(k_comment() ' ' skUserInitials ' ' k_date() ': '); 1228 1229 if (!k_line_comment()) 1230 { 1231 _str sRight = k_comment(true); 1232 _insert_text(' ' sRight); 1233 p_col -= length(sRight) + 1; 1234 } 1377 sSig = skUserInitials ' ' k_date() ': '; 1378 k_insert_comment(sSig, KIC_CURSOR_AT_END); 1235 1379 } 1236 1380 … … 2125 2269 rc = _menu_insert(mhPre, -1, MF_ENABLED, "kKrnlLib", "k_menu_preset javadoc, GPL, Opt2Ind4,, kKrnlLib", "kKrnlLib"); 2126 2270 rc = _menu_insert(mhPre, -1, MF_ENABLED, "kLib", "k_menu_preset javadoc, GPL, Opt2Ind4,, kLib", "kLib"); 2271 rc = _menu_insert(mhPre, -1, MF_ENABLED, "kBuild", "k_menu_preset javadoc, GPL, Opt2Ind4,, kBuild", "kBuild"); 2127 2272 rc = _menu_insert(mhPre, -1, MF_ENABLED, "Innotek", "k_menu_preset javadoc, Confidential, Opt2Ind4, InnoTek Systemberatung GmbH", "Innotek"); 2273 rc = _menu_insert(mhPre, -1, MF_ENABLED, "VPC/2", "k_menu_preset javadoc, Confidential, Opt2Ind4, InnoTek Systemberatung GmbH, VPC/2", "VPC2"); 2128 2274 2129 2275 k_menu_doc_style();
Note:
See TracChangeset
for help on using the changeset viewer.