| 1 | // |
|---|
| 2 | // TxWin, Textmode Windowing Library |
|---|
| 3 | // |
|---|
| 4 | // Original code Copyright (c) 1995-2005 Fsys Software and Jan van Wijk |
|---|
| 5 | // |
|---|
| 6 | // ========================================================================== |
|---|
| 7 | // |
|---|
| 8 | // This file contains Original Code and/or Modifications of Original Code as |
|---|
| 9 | // defined in and that are subject to the GNU Lesser General Public License. |
|---|
| 10 | // You may not use this file except in compliance with the License. |
|---|
| 11 | // BY USING THIS FILE YOU AGREE TO ALL TERMS AND CONDITIONS OF THE LICENSE. |
|---|
| 12 | // A copy of the License is provided with the Original Code and Modifications, |
|---|
| 13 | // and is also available at http://www.dfsee.com/txwin/lgpl.htm |
|---|
| 14 | // |
|---|
| 15 | // This library is free software; you can redistribute it and/or modify |
|---|
| 16 | // it under the terms of the GNU Lesser General Public License as published |
|---|
| 17 | // by the Free Software Foundation; either version 2.1 of the License, |
|---|
| 18 | // or (at your option) any later version. |
|---|
| 19 | // |
|---|
| 20 | // This library is distributed in the hope that it will be useful, |
|---|
| 21 | // but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 22 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|---|
| 23 | // See the GNU Lesser General Public License for more details. |
|---|
| 24 | // |
|---|
| 25 | // You should have received a copy of the GNU Lesser General Public License |
|---|
| 26 | // along with this library; (lgpl.htm) if not, write to the Free Software |
|---|
| 27 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 28 | // |
|---|
| 29 | // Questions on TxWin licensing can be directed to: txwin@fsys.nl |
|---|
| 30 | // |
|---|
| 31 | // ========================================================================== |
|---|
| 32 | // |
|---|
| 33 | // TX standard command execution |
|---|
| 34 | // |
|---|
| 35 | // Author: J. van Wijk |
|---|
| 36 | // |
|---|
| 37 | // Developed for LPT/DFSEE utilities |
|---|
| 38 | // |
|---|
| 39 | // 20-11-2001 // Use TXA command parser only |
|---|
| 40 | // 11-10-2001 // Reduced memory usage for SMALLMEM by removing commands |
|---|
| 41 | // 15-02-2000 // Fixed 'set ansi on/off' bug |
|---|
| 42 | |
|---|
| 43 | #include <txlib.h> // TX library interface |
|---|
| 44 | #include <txtpriv.h> // TX library privates |
|---|
| 45 | #include <txwpriv.h> // TX windows privates |
|---|
| 46 | |
|---|
| 47 | #if defined (__WATCOMC__) |
|---|
| 48 | #ifndef LINUX |
|---|
| 49 | #include <dos.h> |
|---|
| 50 | #endif |
|---|
| 51 | #endif |
|---|
| 52 | |
|---|
| 53 | static char txsetPrio = 'S'; // default Std priority |
|---|
| 54 | |
|---|
| 55 | /*****************************************************************************/ |
|---|
| 56 | // Execute standard commands |
|---|
| 57 | /*****************************************************************************/ |
|---|
| 58 | ULONG TxStdCommand |
|---|
| 59 | ( |
|---|
| 60 | void // parameters through TXA |
|---|
| 61 | ) |
|---|
| 62 | { |
|---|
| 63 | ULONG rc = NO_ERROR; |
|---|
| 64 | LONG nr = 0; |
|---|
| 65 | TXLN dc; // local command string |
|---|
| 66 | int cc = 0; // command string count |
|---|
| 67 | char *c0, *c1, *c2, *c3; // parsed command parts |
|---|
| 68 | char *c4, *c5, *c6, *c7; // parsed command parts |
|---|
| 69 | TXLN s1; // temporary string space |
|---|
| 70 | char *pp; // parameter pointers |
|---|
| 71 | |
|---|
| 72 | ENTER(); |
|---|
| 73 | |
|---|
| 74 | #if defined (USEWINDOWING) |
|---|
| 75 | if (txwa->sbview) |
|---|
| 76 | { |
|---|
| 77 | TxaGetArgString( TXA_CUR, 0, TXA_OPT, TXMAXLN, dc); |
|---|
| 78 | sprintf( s1, "TxWin executing: %s", dc); |
|---|
| 79 | txwSendMsg( (TXWHANDLE) txwa->sbview, TXWM_STATUS, (ULONG) s1, cSchemeColor); |
|---|
| 80 | } |
|---|
| 81 | #endif // USEWINDOWING |
|---|
| 82 | |
|---|
| 83 | pp = TxaGetArgString( TXA_CUR, 1, 0, TXMAXLN, dc); // dc => cmd from arg 1 |
|---|
| 84 | cc = TxaArgCount( ); // number of parameters |
|---|
| 85 | c0 = TxaArgValue(0); |
|---|
| 86 | c1 = TxaArgValue(1); |
|---|
| 87 | c2 = TxaArgValue(2); |
|---|
| 88 | c3 = TxaArgValue(3); |
|---|
| 89 | c4 = TxaArgValue(4); |
|---|
| 90 | c5 = TxaArgValue(5); |
|---|
| 91 | c6 = TxaArgValue(6); |
|---|
| 92 | c7 = TxaArgValue(7); |
|---|
| 93 | |
|---|
| 94 | TRACES(("cc: %u c0:'%s' c1:'%s' c2:'%s' c3:'%s' c4:'%s' c5:'%s' c6:'%s' c7:'%s' pp:'%s'\n", |
|---|
| 95 | cc, c0, c1, c2, c3, c4, c5, c6, c7, pp)); |
|---|
| 96 | |
|---|
| 97 | if (stricmp(c0, "log" ) == 0) |
|---|
| 98 | { |
|---|
| 99 | if (TxaOption('?')) |
|---|
| 100 | { |
|---|
| 101 | TxPrint( "\nStart or stop logging to a file\n\n" |
|---|
| 102 | "Usage: log [filename] [-r] [-f:ff] [-m:mm]\n\n" |
|---|
| 103 | " -f[:ff] retain ff numbered logfiles when cycling\n" |
|---|
| 104 | " -m[:mm] cycle to next logfile after size mm Kb\n" |
|---|
| 105 | " -r close and reopen log on each line (slow)\n" |
|---|
| 106 | " filename filename with optional path for logfile\n" |
|---|
| 107 | " When not specified, logging is STOPPED\n\n"); |
|---|
| 108 | } |
|---|
| 109 | else |
|---|
| 110 | { |
|---|
| 111 | if (TxaOptSet('r')) |
|---|
| 112 | { |
|---|
| 113 | TxSetLogReOpen( TxaOption('r')); |
|---|
| 114 | } |
|---|
| 115 | if (TxaOptSet('m')) |
|---|
| 116 | { |
|---|
| 117 | TxSetLogMaxSize( TxaOptBkmg( 'm', 2047, 'k')); |
|---|
| 118 | } |
|---|
| 119 | if (TxaOptSet('f')) |
|---|
| 120 | { |
|---|
| 121 | TxSetLogRetain( TxaOptNum('f', NULL, 1)); |
|---|
| 122 | } |
|---|
| 123 | TxAppendToLogFile( c1, TRUE); |
|---|
| 124 | } |
|---|
| 125 | } |
|---|
| 126 | else if (stricmp(c0, "trace" ) == 0) |
|---|
| 127 | { |
|---|
| 128 | if (TxaOption('?')) |
|---|
| 129 | { |
|---|
| 130 | TxPrint( "\nSet and check TRACE level, format and destinations\n\n" |
|---|
| 131 | "Usage: trace [level | filename] [-r] [-s] [-t] [-d] [-f] [-m]\n\n" |
|---|
| 132 | " -d[:xx] add xx ms delay for each trace line, slowdown\n" |
|---|
| 133 | " -f[:ff] retain ff numbered logfiles when cycling\n" |
|---|
| 134 | " -m[:mm] cycle to next logfile after size mm Kb\n" |
|---|
| 135 | " -r close and reopen log on each line (slow)\n" |
|---|
| 136 | " -r- open log just once (this is the default)\n" |
|---|
| 137 | " -s trace to the scoll-buffer (screen) too\n" |
|---|
| 138 | " -s- switch off trace to screen\n" |
|---|
| 139 | " -t add timestamps and force thread-id display\n" |
|---|
| 140 | " -t- switch off timestamp and thread-id\n" |
|---|
| 141 | " level 0 = off, 1 = window-title, 10..999 = detail\n" |
|---|
| 142 | " filename filename with optional path for tracefile\n" |
|---|
| 143 | " (this is the same file used as normal LOG)\n\n" |
|---|
| 144 | " The (left) <Alt>+/ key cycles levels 0 -> 1 -> 100 -> 0\n\n"); |
|---|
| 145 | } |
|---|
| 146 | else |
|---|
| 147 | { |
|---|
| 148 | if (TxaOptSet('d')) // delay xx ms per traceline |
|---|
| 149 | { |
|---|
| 150 | TxTrSlowDown = TxaOptNum( 'd', NULL, 100); |
|---|
| 151 | } |
|---|
| 152 | if (TxaOptSet('r')) |
|---|
| 153 | { |
|---|
| 154 | TxSetLogReOpen( TxaOption('r')); |
|---|
| 155 | } |
|---|
| 156 | if (TxaOptSet('t')) // timestamping specified |
|---|
| 157 | { |
|---|
| 158 | TxTraceSetStamp( TxaOption('t')); |
|---|
| 159 | } |
|---|
| 160 | if (TxaOptSet('s')) |
|---|
| 161 | { |
|---|
| 162 | TxTrLogOnly = !TxaOption('s'); // to screen with -s |
|---|
| 163 | } |
|---|
| 164 | if (TxaOptSet('m')) |
|---|
| 165 | { |
|---|
| 166 | TxSetLogMaxSize( TxaOptBkmg( 'm', 2047, 'k')); |
|---|
| 167 | } |
|---|
| 168 | if (TxaOptSet('f')) |
|---|
| 169 | { |
|---|
| 170 | TxSetLogRetain( TxaOptNum('f', NULL, 1)); |
|---|
| 171 | } |
|---|
| 172 | if (isdigit( c1[0])) // setting a level |
|---|
| 173 | { |
|---|
| 174 | TxTrLevel = atol(c1); |
|---|
| 175 | } |
|---|
| 176 | else |
|---|
| 177 | { |
|---|
| 178 | if (strlen( c1)) |
|---|
| 179 | { |
|---|
| 180 | TxAppendToLogFile( c1, TRUE); |
|---|
| 181 | TxTrLevel = 100; |
|---|
| 182 | } |
|---|
| 183 | } |
|---|
| 184 | } |
|---|
| 185 | TxPrint("Funct trace level : %lu trace to %s\n", TxTrLevel, |
|---|
| 186 | (TxTrLevel == 1) ? "Window title-bar" : |
|---|
| 187 | (TxTrLogOnly) ? (TxQueryLogFile( NULL, NULL)) ? "logfile only" |
|---|
| 188 | : "nowhere!" |
|---|
| 189 | : (TxQueryLogFile( NULL, NULL)) ? "log and screen" |
|---|
| 190 | : "screen only"); |
|---|
| 191 | } |
|---|
| 192 | else if (stricmp(c0, "cmd" ) == 0) |
|---|
| 193 | { |
|---|
| 194 | if (cc > 1) |
|---|
| 195 | { |
|---|
| 196 | rc = TxExternalCommand( pp); // execute parameter as cmd |
|---|
| 197 | } |
|---|
| 198 | else |
|---|
| 199 | { |
|---|
| 200 | if ((pp = getenv( "COMSPEC")) != NULL) // when defined |
|---|
| 201 | { |
|---|
| 202 | TxaOptSetItem( "-B"); // no trusted command check |
|---|
| 203 | TxExternalCommand( pp); // run command interpreter |
|---|
| 204 | } |
|---|
| 205 | else |
|---|
| 206 | { |
|---|
| 207 | TxPrint( "No command processor defined in 'COMSPEC' environment variable\n"); |
|---|
| 208 | } |
|---|
| 209 | } |
|---|
| 210 | } |
|---|
| 211 | #ifndef TXMIN |
|---|
| 212 | else if (stricmp(c0, "cboxes" ) == 0) |
|---|
| 213 | { |
|---|
| 214 | TxPrint("\n%s", ansi[NORMAL]); |
|---|
| 215 | TxPrint(" ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄ¿ \n"); |
|---|
| 216 | TxPrint(" ³ Single line ³default ³ \n"); |
|---|
| 217 | TxPrint(" ³ box character ÃÄÄÄÄÄÄÄÄŽ \n"); |
|---|
| 218 | TxPrint(" ³ with joints ³colors ³ \n"); |
|---|
| 219 | TxPrint(" ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÙ \n"); |
|---|
| 220 | TxPrint("\n"); |
|---|
| 221 | TxPrint(" %s ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍËÍÍÍÍÍÍÍÍ» %s\n", ansi[TXaBYnC], ansi[NORMAL]); |
|---|
| 222 | TxPrint(" %s º Double line ºYellow º %s\n", ansi[TXaBYnC], ansi[NORMAL]); |
|---|
| 223 | TxPrint(" %s º box character ÌÍÍÍÍÍÍÍ͹ %s\n", ansi[TXaBYnC], ansi[NORMAL]); |
|---|
| 224 | TxPrint(" %s º with joints ºon Cyan º %s\n", ansi[TXaBYnC], ansi[NORMAL]); |
|---|
| 225 | TxPrint(" %s ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÊÍÍÍÍÍÍÍÍŒ %s\n", ansi[TXaBYnC], ansi[NORMAL]); |
|---|
| 226 | TxPrint("\n"); |
|---|
| 227 | TxPrint(" %s ÕÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÑÍÍÍÍÍÍÍÍž %s ÖÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÒÄÄÄÄÄÄÄÄ· %s\n", ansi[TXaNMnW], ansi[TXaNWnM], ansi[NORMAL]); |
|---|
| 228 | TxPrint(" %s ³ Mixed lines ³Magenta ³ %s º Mixed lines ºWhite onº %s\n", ansi[TXaNMnW], ansi[TXaNWnM], ansi[NORMAL]); |
|---|
| 229 | TxPrint(" %s ³ box character ÆÍÍÍÍÍÍÍ͵ %s º box character ÇÄÄÄÄÄÄÄĶ %s\n", ansi[TXaNMnW], ansi[TXaNWnM], ansi[NORMAL]); |
|---|
| 230 | TxPrint(" %s ³ with joints ³on Grey ³ %s º with joints ºMagenta º %s\n", ansi[TXaNMnW], ansi[TXaNWnM], ansi[NORMAL]); |
|---|
| 231 | TxPrint(" %s ÔÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÏÍÍÍÍÍÍÍÍŸ %s ÓÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÐÄÄÄÄÄÄÄÄœ %s\n", ansi[TXaNMnW], ansi[TXaNWnM], ansi[NORMAL]); |
|---|
| 232 | TxPrint("%s\n", ansi[NORMAL]); |
|---|
| 233 | } |
|---|
| 234 | else if (stricmp(c0, "charset" ) == 0) |
|---|
| 235 | { |
|---|
| 236 | TxPrint( " %s\n", "ÚÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿" ); |
|---|
| 237 | TxPrint( " %s\n", "³\\³0123456789ABCDEF³" ); |
|---|
| 238 | TxPrint( " %s\n", "³0³ ³" ); |
|---|
| 239 | TxPrint( " %s\n", "³1³ |
|---|
| 240 | |
|---|
| 241 | |
|---|
| 242 | ³" ); |
|---|
| 243 | TxPrint( " %s\n", "³2³ ! #$%&'()*+,-./³" ); |
|---|
| 244 | TxPrint( " %s\n", "³3³0123456789:;<=>?³" ); |
|---|
| 245 | TxPrint( " %s\n", "³4³@ABCDEFGHIJKLMNO³" ); |
|---|
| 246 | TxPrint( " %s\n", "³5³PQRSTUVWXYZ[ ]^_³" ); |
|---|
| 247 | TxPrint( " %s\n", "³6³`abcdefghijklmno³" ); |
|---|
| 248 | TxPrint( " %s\n", "³7³pqrstuvwxyz{|}~³" ); |
|---|
| 249 | TxPrint( " %s\n", "³8³ |
|---|
| 250 | ³" ); |
|---|
| 251 | TxPrint( " %s\n", "³9³³" ); |
|---|
| 252 | TxPrint( " %s\n", "³A³ ¡¢£€¥Š§š©ª«¬®¯³" ); |
|---|
| 253 | TxPrint( " %s\n", "³B³°±²³Žµ¶·ž¹º»ŒœŸ¿³" ); |
|---|
| 254 | TxPrint( " %s\n", "³C³ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎϳ" ); |
|---|
| 255 | TxPrint( " %s\n", "³D³ÐÑÒÓÔÕÖרÙÚÛÜÝÞß³" ); |
|---|
| 256 | TxPrint( " %s\n", "³E³àáâãäåæçèéêëìíîï³" ); |
|---|
| 257 | TxPrint( " %s\n", "³F³ðñòóôõö÷øùúûüýþÿ³" ); |
|---|
| 258 | TxPrint( " %s\n", "³/³0123456789ABCDEF³" ); |
|---|
| 259 | TxPrint( " %s\n", "ÀÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ" ); |
|---|
| 260 | } |
|---|
| 261 | else if (stricmp(c0, "colors" ) == 0) |
|---|
| 262 | { |
|---|
| 263 | int bg,fg; |
|---|
| 264 | |
|---|
| 265 | TxPrint("%s", ansi[NORMAL]); |
|---|
| 266 | for (bg = 0; bg < 16; bg++) |
|---|
| 267 | { |
|---|
| 268 | TxPrint("\n "); |
|---|
| 269 | for (fg = 0; fg < 16; fg++) |
|---|
| 270 | { |
|---|
| 271 | TxPrint( "%s %1X%1X %s", ansi[fg + (bg * 16)], |
|---|
| 272 | bg, fg, ansi[NORMAL]); |
|---|
| 273 | } |
|---|
| 274 | } |
|---|
| 275 | TxPrint("\n\n"); |
|---|
| 276 | } |
|---|
| 277 | else if (strnicmp(c0, "txd", 3) == 0) |
|---|
| 278 | { |
|---|
| 279 | char *filter[5] = {NULL,NULL,NULL,NULL,NULL}; |
|---|
| 280 | |
|---|
| 281 | if (TxaOption('?')) // explicit help request |
|---|
| 282 | { |
|---|
| 283 | TxPrint("\nShow files and/or directories in selectable format\n"); |
|---|
| 284 | TxPrint("\n Usage: %s fspec select 'attrs' [includes] [-b]\n\n" |
|---|
| 285 | " fspec = File or directory spec, including wildcards\n" |
|---|
| 286 | " search = display selection criteria: SFDP\n" |
|---|
| 287 | " S=subdirs, F=Files, D=Dirs, P=Parent ..\n" |
|---|
| 288 | " attrs = file-attributes to match : '+A+R+S+H-A-R-S-H'\n" |
|---|
| 289 | " +A archive-bit -A NO archive bit\n" |
|---|
| 290 | " +R read-only -R NOT read-only\n" |
|---|
| 291 | " +S system-bit -S NO system bit\n" |
|---|
| 292 | " +H hidden -H NOT hidden\n" |
|---|
| 293 | " inexcl = include/exclude wildcards\n", c0); |
|---|
| 294 | TxPrint("\n -b = show basename only\n\n"); |
|---|
| 295 | } |
|---|
| 296 | else |
|---|
| 297 | { |
|---|
| 298 | if (cc > 4) |
|---|
| 299 | { |
|---|
| 300 | filter[0] = c4; |
|---|
| 301 | } |
|---|
| 302 | if (cc > 5) |
|---|
| 303 | { |
|---|
| 304 | filter[1] = c5; |
|---|
| 305 | } |
|---|
| 306 | if (cc > 6) |
|---|
| 307 | { |
|---|
| 308 | filter[2] = c6; |
|---|
| 309 | } |
|---|
| 310 | if (cc > 7) |
|---|
| 311 | { |
|---|
| 312 | filter[3] = c7; |
|---|
| 313 | } |
|---|
| 314 | TxPrint( "\nTxDir for: %s, options: %s, attributes: %s\n\n", |
|---|
| 315 | (cc > 1) ? c1 : "current dir", |
|---|
| 316 | (cc > 2) ? c2 : "file+dirs", |
|---|
| 317 | (cc > 3) ? c3 : "all files"); |
|---|
| 318 | if (TxaOption('b')) // basename only |
|---|
| 319 | { |
|---|
| 320 | rc = TxFileTree( c1, c2, c3, "", filter, txFileTreeNoPath, NULL); |
|---|
| 321 | } |
|---|
| 322 | else |
|---|
| 323 | { |
|---|
| 324 | rc = TxFileTree( c1, c2, c3, "", filter, txFileTreeOneFile, NULL); |
|---|
| 325 | } |
|---|
| 326 | } |
|---|
| 327 | } |
|---|
| 328 | else if (stricmp(c0, "keys" ) == 0) |
|---|
| 329 | { |
|---|
| 330 | ULONG input; |
|---|
| 331 | TXW_INPUT_EVENT mouse; |
|---|
| 332 | |
|---|
| 333 | while ((input = txwGetInputEvent( &mouse)) != TXK_ESCAPE) |
|---|
| 334 | { |
|---|
| 335 | if (input == TXW_INPUT_MOUSE) // mouse |
|---|
| 336 | { |
|---|
| 337 | TxPrint("Mouse @ : % 3hu % 3hu button:%4.4hx Kstate: %4.4hx\n", |
|---|
| 338 | mouse.row, mouse.col, mouse.value, mouse.state); |
|---|
| 339 | } |
|---|
| 340 | else |
|---|
| 341 | { |
|---|
| 342 | TxPrint("Keyvalue: %3.3lX\n", input); |
|---|
| 343 | } |
|---|
| 344 | } |
|---|
| 345 | } |
|---|
| 346 | #if defined (USEWINDOWING) |
|---|
| 347 | else if (stricmp(c0, "mode" ) == 0) // change display mode |
|---|
| 348 | { |
|---|
| 349 | if ((cc > 1) && // resize screen using OS cmd |
|---|
| 350 | (!TxaExeSwitch('S'))) // when not in shell-mode |
|---|
| 351 | { |
|---|
| 352 | USHORT cols; |
|---|
| 353 | USHORT rows; |
|---|
| 354 | |
|---|
| 355 | if ((cc > 2) && (isdigit(c2[0]))) |
|---|
| 356 | { |
|---|
| 357 | rows = (USHORT) atoi( c2); // nr of rows |
|---|
| 358 | } |
|---|
| 359 | else if ((pp = strchr( c1, ',')) != NULL) |
|---|
| 360 | { |
|---|
| 361 | rows = (USHORT) atoi( pp+1); |
|---|
| 362 | } |
|---|
| 363 | else // single param, keep rows |
|---|
| 364 | { |
|---|
| 365 | rows = TxScreenRows(); |
|---|
| 366 | } |
|---|
| 367 | cols = (USHORT) atoi( c1); // nr of columns |
|---|
| 368 | if (cols < 10) |
|---|
| 369 | { |
|---|
| 370 | cols = TxScreenCols(); |
|---|
| 371 | } |
|---|
| 372 | sprintf( s1, "mode %hu,%hu", cols, rows); |
|---|
| 373 | |
|---|
| 374 | TxExternalCommand( s1); // set mode, will cls too |
|---|
| 375 | } |
|---|
| 376 | TxSetBrightBgMode( TRUE); // no blinking, use bright BG |
|---|
| 377 | rc = TX_DISPLAY_CHANGE; // signal display change |
|---|
| 378 | } |
|---|
| 379 | #endif // windowing |
|---|
| 380 | #endif // not TXMIN |
|---|
| 381 | else if (stricmp(c0, "confirm" ) == 0) |
|---|
| 382 | { |
|---|
| 383 | if (cc > 1) |
|---|
| 384 | { |
|---|
| 385 | strcpy( s1, pp); |
|---|
| 386 | TxRepl( s1, '~', '\n'); |
|---|
| 387 | } |
|---|
| 388 | else // no text specified |
|---|
| 389 | { |
|---|
| 390 | strcpy( s1, "Continue"); |
|---|
| 391 | } |
|---|
| 392 | if (TxaOption('y')) // confirm Yes/No |
|---|
| 393 | { |
|---|
| 394 | strcat( s1, " ? [Y/N] : "); |
|---|
| 395 | if (!TxConfirm( 0, s1)) |
|---|
| 396 | { |
|---|
| 397 | rc = TX_ABORTED; // Will result in 'better' |
|---|
| 398 | } // message to user :-) |
|---|
| 399 | } |
|---|
| 400 | else |
|---|
| 401 | { |
|---|
| 402 | if (cc == 1) // no ? after custom text |
|---|
| 403 | { |
|---|
| 404 | strcat( s1, " ?"); |
|---|
| 405 | } |
|---|
| 406 | if (!TxMessage( !TxaOption('n'), 0, s1)) // -n needs no key pressed |
|---|
| 407 | { |
|---|
| 408 | rc = TX_ABORTED; // Will result in 'better' |
|---|
| 409 | } // message to user :-) |
|---|
| 410 | } |
|---|
| 411 | } |
|---|
| 412 | #if defined (DOS32) |
|---|
| 413 | else if (stricmp(c0, "keyb" ) == 0) // change keyboard mapping |
|---|
| 414 | { |
|---|
| 415 | if ((cc > 1) && (!TxaOption('?'))) |
|---|
| 416 | { |
|---|
| 417 | if ((rc = TxSetNlsKeyboard( c1, c2)) != NO_ERROR) |
|---|
| 418 | { |
|---|
| 419 | TxPrint( "\nError %lu setting keyboard mapping '%s'\n\n", rc, c1); |
|---|
| 420 | } |
|---|
| 421 | } |
|---|
| 422 | else // give help |
|---|
| 423 | { |
|---|
| 424 | TxPrint("\nSet country or codepage-specific keyboard mapping\n"); |
|---|
| 425 | TxPrint("\n Usage: %s def [cp]\n\n" |
|---|
| 426 | " def = Keyboard definition file (.kl) basename\n" |
|---|
| 427 | " cp = Codepage value valid for that language\n\n" |
|---|
| 428 | " Example: keyb nl 850\n\n", c0); |
|---|
| 429 | |
|---|
| 430 | TxExternalCommand( "keyb"); // show current keyb, if any |
|---|
| 431 | } |
|---|
| 432 | } |
|---|
| 433 | #endif |
|---|
| 434 | else if (stricmp(c0, "start" ) == 0) |
|---|
| 435 | { |
|---|
| 436 | sprintf( s1, "start /b /c %s", pp); |
|---|
| 437 | rc = system( s1); // execute parameter as cmd |
|---|
| 438 | } |
|---|
| 439 | else if ((stricmp(c0, "cd") == 0) || |
|---|
| 440 | ((strlen(c0) == 2) && (c0[1] == ':') )) |
|---|
| 441 | { |
|---|
| 442 | if (stricmp(c0, "cd") == 0) |
|---|
| 443 | { |
|---|
| 444 | strcpy( s1, pp); |
|---|
| 445 | } |
|---|
| 446 | else |
|---|
| 447 | { |
|---|
| 448 | strcpy( s1, c0); |
|---|
| 449 | } |
|---|
| 450 | #if defined (LINUX) |
|---|
| 451 | rc = (ULONG) chdir( s1); |
|---|
| 452 | #else |
|---|
| 453 | if (s1[1] == ':') // set drive too, if specified |
|---|
| 454 | { |
|---|
| 455 | #if defined (__WATCOMC__) |
|---|
| 456 | #ifndef LINUX |
|---|
| 457 | unsigned drives; |
|---|
| 458 | |
|---|
| 459 | _dos_setdrive(toupper( s1[0]) - 'A' +1, &drives); |
|---|
| 460 | #endif |
|---|
| 461 | #else |
|---|
| 462 | _chdrive(toupper( s1[0]) - 'A' +1); |
|---|
| 463 | #endif |
|---|
| 464 | } |
|---|
| 465 | if ((strlen( s1) > 2) || (s1[1] != ':')) |
|---|
| 466 | { |
|---|
| 467 | rc = (ULONG) chdir( s1); |
|---|
| 468 | } |
|---|
| 469 | #endif |
|---|
| 470 | getcwd(s1, TXMAXLN); |
|---|
| 471 | TxPrint("\nWorking directory : %s%s%s%s\n", |
|---|
| 472 | CBC, s1, (strlen(s1) > 3) ? FS_PATH_STR : "", CNN); |
|---|
| 473 | } |
|---|
| 474 | else if (stricmp(c0, "exist" ) == 0) |
|---|
| 475 | { |
|---|
| 476 | if (cc > 1) |
|---|
| 477 | { |
|---|
| 478 | TxPrint("File '%s' does%s exist\n", s1, (TxFileExists(c1)) ? "": " NOT"); |
|---|
| 479 | } |
|---|
| 480 | } |
|---|
| 481 | #if defined (USEWINDOWING) |
|---|
| 482 | else if ((stricmp(c0, "scrfile") == 0)) // screen to file |
|---|
| 483 | { |
|---|
| 484 | ULONG lines = -1; // default all lines |
|---|
| 485 | |
|---|
| 486 | if (cc <= 1) |
|---|
| 487 | { |
|---|
| 488 | strcpy( s1, "screen"); |
|---|
| 489 | } |
|---|
| 490 | else |
|---|
| 491 | { |
|---|
| 492 | strcpy( s1, c1); |
|---|
| 493 | } |
|---|
| 494 | TxFnameExtension( s1, "log"); // append default extension |
|---|
| 495 | if (cc > 2) |
|---|
| 496 | { |
|---|
| 497 | lines = (ULONG) atol( c2); |
|---|
| 498 | } |
|---|
| 499 | lines = txwSavePrintfSB( s1, lines, (cc <= 3)); |
|---|
| 500 | TxPrint( "Saved %lu lines from screen-buffer to %s\n", lines, s1); |
|---|
| 501 | } |
|---|
| 502 | #endif // USEWINDOWING |
|---|
| 503 | else if ((stricmp(c0, "screen" ) == 0)) // backward compatibility! |
|---|
| 504 | { |
|---|
| 505 | if ((cc > 1) && (!TxaOption('?'))) |
|---|
| 506 | { |
|---|
| 507 | if ((strcmpi(c1, "on") == 0) || (c1[0] == '1')) |
|---|
| 508 | { |
|---|
| 509 | TxScreenState(DEVICE_ON); |
|---|
| 510 | } |
|---|
| 511 | else |
|---|
| 512 | { |
|---|
| 513 | TxScreenState(DEVICE_OFF); |
|---|
| 514 | } |
|---|
| 515 | } |
|---|
| 516 | else |
|---|
| 517 | { |
|---|
| 518 | rc = (ULONG) TxScreenState( DEVICE_TEST); |
|---|
| 519 | TxPrint("Screen output is switched %s.\n", |
|---|
| 520 | (rc == (ULONG) DEVICE_ON) ? "on" : "off"); |
|---|
| 521 | } |
|---|
| 522 | } |
|---|
| 523 | else if ((stricmp(c0, "set" ) == 0)) |
|---|
| 524 | { |
|---|
| 525 | if ((cc > 1) && (!TxaOption('?'))) |
|---|
| 526 | { |
|---|
| 527 | if ((stricmp(c1, "screen" ) == 0)) |
|---|
| 528 | { |
|---|
| 529 | if (cc > 2) |
|---|
| 530 | { |
|---|
| 531 | #if defined (USEWINDOWING) |
|---|
| 532 | if (strnicmp(c2, "i", 1) == 0) |
|---|
| 533 | { |
|---|
| 534 | if (txwa->sbview) |
|---|
| 535 | { |
|---|
| 536 | txwa->sbview->window->sb.altcol ^= TXSB_COLOR_INVERT; |
|---|
| 537 | } |
|---|
| 538 | } |
|---|
| 539 | else if (strnicmp(c2, "b", 1) == 0) |
|---|
| 540 | { |
|---|
| 541 | if (txwa->sbview) |
|---|
| 542 | { |
|---|
| 543 | txwa->sbview->window->sb.altcol ^= TXSB_COLOR_BRIGHT; |
|---|
| 544 | } |
|---|
| 545 | } |
|---|
| 546 | else if (strnicmp(c2, "s", 1) == 0) |
|---|
| 547 | { |
|---|
| 548 | if (txwa->sbview) |
|---|
| 549 | { |
|---|
| 550 | txwa->sbview->window->sb.altcol ^= TXSB_COLOR_B2BLUE; |
|---|
| 551 | } |
|---|
| 552 | } |
|---|
| 553 | else |
|---|
| 554 | #endif // USEWINDOWING |
|---|
| 555 | if ((strcmpi(c2, "on") == 0) || (c2[0] == '1')) |
|---|
| 556 | { |
|---|
| 557 | TxScreenState(DEVICE_ON); |
|---|
| 558 | } |
|---|
| 559 | else |
|---|
| 560 | { |
|---|
| 561 | TxScreenState(DEVICE_OFF); |
|---|
| 562 | } |
|---|
| 563 | } |
|---|
| 564 | else |
|---|
| 565 | { |
|---|
| 566 | rc = TxScreenState( DEVICE_TEST); |
|---|
| 567 | TxPrint("\nSet screen text-output properties\n\n" |
|---|
| 568 | " Usage: %s %s on | off" |
|---|
| 569 | #if defined (USEWINDOWING) |
|---|
| 570 | " | invert | bright | swapblue" |
|---|
| 571 | #endif // USEWINDOWING |
|---|
| 572 | " Usage: %s %s on | off | invert | bright | swapblue\n\n" |
|---|
| 573 | "\n\nScreen output is switched %s.\n\n", c0, c1, |
|---|
| 574 | (rc == DEVICE_ON) ? "on" : "off"); |
|---|
| 575 | } |
|---|
| 576 | } |
|---|
| 577 | else if ((strnicmp(c1, "logfile", 7 ) == 0)) |
|---|
| 578 | { |
|---|
| 579 | if (cc > 2) |
|---|
| 580 | { |
|---|
| 581 | if ((strcmpi(c2, "on") == 0) || (c2[0] == '1')) |
|---|
| 582 | { |
|---|
| 583 | TxLogfileState(DEVICE_ON); |
|---|
| 584 | } |
|---|
| 585 | else |
|---|
| 586 | { |
|---|
| 587 | TxLogfileState(DEVICE_OFF); |
|---|
| 588 | } |
|---|
| 589 | } |
|---|
| 590 | else |
|---|
| 591 | { |
|---|
| 592 | rc = TxLogfileState( DEVICE_TEST); |
|---|
| 593 | TxPrint("\nSet logfile output status\n\n" |
|---|
| 594 | " Usage: %s %s on | off\n\n" |
|---|
| 595 | "ANSI is currently %s\n\n", c0, c1, |
|---|
| 596 | (rc == DEVICE_ON) ? "on" : "off"); |
|---|
| 597 | } |
|---|
| 598 | } |
|---|
| 599 | else if ((strnicmp(c1, "ansi", 4 ) == 0)) |
|---|
| 600 | { |
|---|
| 601 | if (cc > 2) |
|---|
| 602 | { |
|---|
| 603 | if ((strcmpi(c2, "on") == 0) || (c2[0] == '1')) |
|---|
| 604 | { |
|---|
| 605 | TxSetAnsiMode( A_ON); |
|---|
| 606 | } |
|---|
| 607 | else |
|---|
| 608 | { |
|---|
| 609 | TxSetAnsiMode( A_OFF); |
|---|
| 610 | } |
|---|
| 611 | } |
|---|
| 612 | else |
|---|
| 613 | { |
|---|
| 614 | TxPrint("\nSet usage of ANSI color for text output\n\n" |
|---|
| 615 | " Usage: %s %s on | off\n\n" |
|---|
| 616 | "ANSI is currently %s\n\n", c0, c1, |
|---|
| 617 | (TxGetAnsiMode() == A_ON) ? "ON" : "OFF"); |
|---|
| 618 | } |
|---|
| 619 | } |
|---|
| 620 | #if defined (USEWINDOWING) |
|---|
| 621 | else if ((strnicmp(c1, "scheme", 6 ) == 0)) |
|---|
| 622 | { |
|---|
| 623 | if (cc > 2) |
|---|
| 624 | { |
|---|
| 625 | txwColorScheme( c2[0], NULL); |
|---|
| 626 | } |
|---|
| 627 | else |
|---|
| 628 | { |
|---|
| 629 | TxPrint("\nSet color-scheme used for Windowing\n\n" |
|---|
| 630 | " Usage: %s %s grey|m3d|nobl|cmdr|half|full|white|black|dfsee\n\n" |
|---|
| 631 | "SCHEME is currently: '%s'\n\n", c0, c1, txwcs->name); |
|---|
| 632 | } |
|---|
| 633 | if (txwa->desktop != NULL) |
|---|
| 634 | { |
|---|
| 635 | txwInvalidateAll(); |
|---|
| 636 | } |
|---|
| 637 | } |
|---|
| 638 | else if ((strnicmp(c1, "style", 5 ) == 0)) |
|---|
| 639 | { |
|---|
| 640 | if (cc > 2) |
|---|
| 641 | { |
|---|
| 642 | txwcs->linestyle = (atol(c2) % TXW_CS_LAST); |
|---|
| 643 | } |
|---|
| 644 | else |
|---|
| 645 | { |
|---|
| 646 | TxPrint("\nSet linestyle used for Windowing\n\n" |
|---|
| 647 | " Usage: %s %s 0..3\n\n" |
|---|
| 648 | " 0=double 1=3d 2=halfblock 3=fullblock\n\n" |
|---|
| 649 | "STYLE is currently: %lu\n\n", c0, c1, txwcs->linestyle); |
|---|
| 650 | } |
|---|
| 651 | if (txwa->desktop != NULL) |
|---|
| 652 | { |
|---|
| 653 | txwInvalidateAll(); |
|---|
| 654 | } |
|---|
| 655 | } |
|---|
| 656 | else if ((strnicmp(c1, "color", 5 ) == 0)) |
|---|
| 657 | { |
|---|
| 658 | if (txwa->sbview) |
|---|
| 659 | { |
|---|
| 660 | TXWINDOW *sbwin = txwa->sbview->window; |
|---|
| 661 | |
|---|
| 662 | if (cc > 2) |
|---|
| 663 | { |
|---|
| 664 | sbwin->sb.altcol = atol(c2) & TXSB_COLOR_MASK; |
|---|
| 665 | txwInvalidateWindow((TXWHANDLE) txwa->sbview, FALSE, FALSE); |
|---|
| 666 | } |
|---|
| 667 | else |
|---|
| 668 | { |
|---|
| 669 | TxPrint("\nSet color-scheme used for Output\n\n" |
|---|
| 670 |
|---|