1: /***************************************************************************
   2:  * This program is Copyright (C) 1986, 1987, 1988 by Jonathan Payne.  JOVE *
   3:  * is provided to you without charge, and with no warranty.  You may give  *
   4:  * away copies of JOVE, including sources, provided that this notice is    *
   5:  * included in all the files.                                              *
   6:  ***************************************************************************/
   7: 
   8: #include "jove.h"
   9: #include "ctype.h"
  10: 
  11: #if !defined(TXT_TO_C)
  12: extern void
  13:     EscPrefix(),
  14:     CtlxPrefix(),
  15:     MiscPrefix(),
  16:     UnbindC(),
  17:     ShowVersion(),
  18:     WVisSpace(),
  19: #ifdef ANSICODES
  20:     AnsiCodes(),
  21: #endif
  22:     AppReg(),
  23:     Apropos(),
  24:     BackChar(),
  25:     BList(),
  26:     FList(),
  27:     BUpList(),
  28:     FDownList(),
  29:     BSexpr(),
  30:     BackWord(),
  31:     Bof(),
  32:     Bol(),
  33:     Bos(),
  34:     Bow(),
  35:     BindAKey(),
  36:     BindMac(),
  37:     BufPos(),
  38: #ifdef MSDOS
  39:     Buf1Select(),
  40:     Buf2Select(),
  41:     Buf3Select(),
  42:     Buf4Select(),
  43:     Buf5Select(),
  44:     Buf6Select(),
  45:     Buf7Select(),
  46:     Buf8Select(),
  47:     Buf9Select(),
  48:     Buf10Select(),
  49: #endif /* MSDOS */
  50:     CasRegLower(),
  51:     CasRegUpper(),
  52:     CapChar(),
  53:     CapWord(),
  54:     LowWord(),
  55:     UppWord(),
  56: #ifdef CHDIR
  57:     Chdir(),
  58:     prCWD(),
  59:     prDIRS(),
  60:     Pushd(),
  61:     Popd(),
  62: #endif
  63:     prCTIME(),
  64:     ChrToOct(),
  65:     ClAndRedraw(),
  66: #ifndef MAC
  67:     MakeErrors(),
  68: #endif
  69:     CopyRegion(),
  70:     BufSelect(),
  71:     DelBlnkLines(),
  72:     DelNChar(),
  73:     DelNWord(),
  74:     OneWindow(),
  75:     DelPChar(),
  76:     DelPWord(),
  77:     DelReg(),
  78:     KillSome(),
  79:     DelWtSpace(),
  80:     DelCurWindow(),
  81:     KeyDesc(),
  82:     Digit(),
  83:     Digit0(),
  84:     Digit1(),
  85:     Digit2(),
  86:     Digit3(),
  87:     Digit4(),
  88:     Digit5(),
  89:     Digit6(),
  90:     Digit7(),
  91:     Digit8(),
  92:     Digit9(),
  93:     DescBindings(),
  94:     DescCom(),
  95:     Eof(),
  96:     Eol(),
  97:     Eos(),
  98:     Eow(),
  99:     ForPara(),
 100:     BackPara(),
 101:     BufErase(),
 102:     PtToMark(),
 103:     Extend(),
 104:     ExecMacro(),
 105:     RunMacro(),
 106:     Leave(),
 107:     FindFile(),
 108:     WindFind(),
 109:     FindTag(),
 110:     FDotTag(),
 111:     ToIndent(),
 112:     ForChar(),
 113:     FSexpr(),
 114:     ForWord(),
 115:     TimesFour(),
 116:     GoLine(),
 117:     GrowWindow(),
 118:     IncFSearch(),
 119:     IncRSearch(),
 120:     InsFile(),
 121:     Justify(),
 122:     RegJustify(),
 123:     SetLMargin(),
 124:     SetRMargin(),
 125:     BufKill(),
 126:     KillBos(),
 127:     KillEos(),
 128:     KillEOL(),
 129:     KillExpr(),
 130:     BufList(),
 131:     NotModified(),
 132:     NameMac(),
 133:     DelMacro(),
 134:     Newline(),
 135:     OpenLine(),
 136:     LineAI(),
 137: #ifndef MAC
 138:     ShowErr(),
 139:     NextError(),
 140: #endif /* MAC */
 141: #ifdef MSDOS
 142:     PageScrollUp(),
 143:     PageScrollDown(),
 144: #endif /* MSDOS */
 145: #ifndef MAC
 146:     PrevError(),
 147: #endif /* MAC */
 148:     NextLine(),
 149:     NextPage(),
 150:     NextWindow(),
 151:     Recur(),
 152:     PopMark(),
 153:     PageNWind(),
 154:     Tab(),
 155:     DoParen(),
 156: #ifndef MAC
 157:     ParseAll(),
 158: #endif
 159: #ifdef SPELL
 160:     SpelWords(),
 161: #endif
 162: #ifdef JOB_CONTROL
 163:     PauseJove(),
 164: #endif
 165:     PrevLine(),
 166:     PrevPage(),
 167:     PrevWindow(),
 168: #ifndef MAC
 169:     Push(),
 170: #endif
 171:     RegReplace(),
 172:     QRepSearch(),
 173:     QuotChar(),
 174:     ReadFile(),
 175:     DefKBDMac(),
 176:     RedrawDisplay(),
 177:     ReNamBuf(),
 178:     RepSearch(),
 179:     DownScroll(),
 180:     UpScroll(),
 181:     ForSearch(),
 182:     FSrchND(),
 183:     RevSearch(),
 184:     RSrchND(),
 185:     SelfInsert(),
 186:     SetVar(),
 187:     SetMark(),
 188: #ifndef MAC
 189:     ShellCom(),
 190:     ShNoBuf(),
 191:     Shtypeout(),
 192:     ShToBuf(),
 193: #endif
 194:     ShrWindow(),
 195:     Source(),
 196: #ifdef SPELL
 197:     SpelBuffer(),
 198: #endif
 199:     SplitWind(),
 200:     GotoWind(),
 201:     Remember(),
 202:     Forget(),
 203:     StrLength(),
 204:     TransChar(),
 205:     TransLines(),
 206:     SaveFile(),
 207:     WtModBuf(),
 208:     WriteFile(),
 209:     WriteMacs(),
 210:     WrtReg(),
 211:     Yank(),
 212:     YankPop(),  PrVar(),
 213: #ifndef MAC
 214:     FilterRegion(),
 215: #endif
 216:     WNumLines(),
 217: #ifdef IPROCS
 218:     ShellProc(),
 219:     ProcInt(),
 220:     ProcQuit(),
 221:     ProcKill(),
 222: #  ifndef PIPEPROCS
 223:     ProcEof(),
 224:     ProcStop(),
 225:     ProcCont(),
 226:     ProcDStop(),
 227: #  endif
 228:     ProcSendData(),
 229:     ProcNewline(),
 230:     ProcList(),
 231:     ProcBind(),
 232:     Iprocess(),
 233: #endif
 234: 
 235: #ifdef LISP
 236:     GSexpr(),   /* Grind S Expression. */
 237:     AddSpecial(),   /* add lisp special form */
 238: #endif
 239:     CAutoExec(),
 240:     MAutoExec(),
 241: 
 242:     DefMAbbrev(),
 243:     DefGAbbrev(),
 244:     SaveAbbrevs(),
 245:     RestAbbrevs(),
 246:     EditAbbrevs(),
 247:     BindMtoW(),
 248: 
 249: #ifdef CMT_FMT
 250:     Comment(),
 251: #endif
 252: 
 253:     ScrollLeft(),
 254:     ScrollRight(),
 255:     MacInter();     /* This is the last one. */
 256: 
 257: 
 258: #ifdef MAC
 259: #	define WIRED_CMD(c) c,'\0','\0'   /* for About Jove... */
 260: #else
 261: #	define WIRED_CMD(c)   c
 262: #endif /* MAC */
 263: 
 264: #else /* TXT_TO_C */
 265: 
 266: #ifdef MAC
 267: #	define WIRED_CMD(c) 0,'\0','\0'
 268: #else
 269: #	define WIRED_CMD(c)   0
 270: #endif
 271: #endif /* TXT_TO_C */
 272: 
 273: struct cmd  commands[] = {
 274: #ifdef LISP
 275:     FUNCTION, "add-lisp-special", WIRED_CMD(AddSpecial),
 276: #endif
 277: #ifdef ANSICODES
 278:     FUNCTION, "ansi-codes", WIRED_CMD(AnsiCodes),
 279: #endif
 280:     FUNCTION, "append-region", WIRED_CMD(AppReg),
 281:     FUNCTION, "apropos", WIRED_CMD(Apropos),
 282:     FUNCTION, "auto-execute-command", WIRED_CMD(CAutoExec),
 283:     FUNCTION, "auto-execute-macro", WIRED_CMD(MAutoExec),
 284:     DefMinor(Fill), "auto-fill-mode", WIRED_CMD(0),
 285:     DefMinor(Indent), "auto-indent-mode", WIRED_CMD(0),
 286:     FUNCTION, "backward-character", WIRED_CMD(BackChar),
 287:     FUNCTION, "backward-list", WIRED_CMD(BList),
 288:     FUNCTION, "backward-paragraph", WIRED_CMD(BackPara),
 289:     FUNCTION, "backward-s-expression", WIRED_CMD(BSexpr),
 290:     FUNCTION, "backward-sentence", WIRED_CMD(Bos),
 291:     FUNCTION, "backward-up-list", WIRED_CMD(BUpList),
 292:     FUNCTION, "backward-word", WIRED_CMD(BackWord),
 293:     FUNCTION, "begin-kbd-macro", WIRED_CMD(Remember),
 294:     FUNCTION, "beginning-of-file", WIRED_CMD(Bof),
 295:     FUNCTION, "beginning-of-line", WIRED_CMD(Bol),
 296:     FUNCTION, "beginning-of-window", WIRED_CMD(Bow),
 297:     FUNCTION, "bind-to-key", WIRED_CMD(BindAKey),
 298:     FUNCTION, "bind-macro-to-key", WIRED_CMD(BindMac),
 299: #ifdef ABBREV
 300:     FUNCTION, "bind-macro-to-word-abbrev", WIRED_CMD(BindMtoW),
 301: #endif
 302:     FUNCTION, "buffer-position", WIRED_CMD(BufPos),
 303:     DefMajor(CMODE), "c-mode", WIRED_CMD(0),
 304:     FUNCTION, "case-character-capitalize", WIRED_CMD(CapChar),
 305:     FUNCTION, "case-region-lower", WIRED_CMD(CasRegLower),
 306:     FUNCTION, "case-region-upper", WIRED_CMD(CasRegUpper),
 307:     FUNCTION, "case-word-capitalize", WIRED_CMD(CapWord),
 308:     FUNCTION, "case-word-lower", WIRED_CMD(LowWord),
 309:     FUNCTION, "case-word-upper", WIRED_CMD(UppWord),
 310:     FUNCTION, "character-to-octal-insert", WIRED_CMD(ChrToOct),
 311: #ifdef CHDIR
 312:     FUNCTION, "cd", WIRED_CMD(Chdir),
 313: #endif
 314:     FUNCTION, "clear-and-redraw", WIRED_CMD(ClAndRedraw),
 315: #ifndef MAC
 316:     FUNCTION, "compile-it", WIRED_CMD(MakeErrors),
 317: #endif
 318: #ifdef IPROCS
 319: #  ifndef PIPEPROCS
 320: #    ifdef TIOCSLTC
 321:     FUNCTION, "continue-process", WIRED_CMD(ProcCont),
 322: #    endif
 323: #  endif
 324: #endif
 325:     FUNCTION, "copy-region", WIRED_CMD(CopyRegion),
 326: #ifndef MAC
 327:     FUNCTION, "current-error", WIRED_CMD(ShowErr),
 328: #endif
 329:     FUNCTION, "date", WIRED_CMD(prCTIME),
 330: #ifdef ABBREV
 331:     FUNCTION, "define-global-word-abbrev", WIRED_CMD(DefGAbbrev),
 332:     FUNCTION, "define-mode-word-abbrev", WIRED_CMD(DefMAbbrev),
 333: #endif
 334:     FUNCTION, "define-macro", WIRED_CMD(DefKBDMac),
 335:     FUNCTION, "delete-blank-lines", WIRED_CMD(DelBlnkLines),
 336:     FUNCTION, "delete-buffer", WIRED_CMD(BufKill),
 337:     FUNCTION, "delete-macro", WIRED_CMD(DelMacro),
 338:     FUNCTION, "delete-next-character", WIRED_CMD(DelNChar),
 339:     FUNCTION, "delete-other-windows", WIRED_CMD(OneWindow),
 340:     FUNCTION, "delete-previous-character", WIRED_CMD(DelPChar),
 341:     FUNCTION, "delete-white-space", WIRED_CMD(DelWtSpace),
 342:     FUNCTION, "delete-current-window", WIRED_CMD(DelCurWindow),
 343:     FUNCTION, "describe-bindings", WIRED_CMD(DescBindings),
 344:     FUNCTION, "describe-command", WIRED_CMD(DescCom),
 345:     FUNCTION, "describe-key", WIRED_CMD(KeyDesc),
 346:     FUNCTION, "describe-variable", WIRED_CMD(DescCom),
 347:     FUNCTION, "digit", WIRED_CMD(Digit),
 348:     FUNCTION, "digit-1", WIRED_CMD(Digit1),
 349:     FUNCTION, "digit-2", WIRED_CMD(Digit2),
 350:     FUNCTION, "digit-3", WIRED_CMD(Digit3),
 351:     FUNCTION, "digit-4", WIRED_CMD(Digit4),
 352:     FUNCTION, "digit-5", WIRED_CMD(Digit5),
 353:     FUNCTION, "digit-6", WIRED_CMD(Digit6),
 354:     FUNCTION, "digit-7", WIRED_CMD(Digit7),
 355:     FUNCTION, "digit-8", WIRED_CMD(Digit8),
 356:     FUNCTION, "digit-9", WIRED_CMD(Digit9),
 357:     FUNCTION, "digit-0", WIRED_CMD(Digit0),
 358: #ifdef CHDIR
 359:     FUNCTION, "dirs", WIRED_CMD(prDIRS),
 360: #endif
 361:     FUNCTION, "down-list", WIRED_CMD(FDownList),
 362: #ifdef IPROCS
 363: #  ifndef PIPEPROCS
 364: #    ifdef TIOCSLTC
 365:     FUNCTION, "dstop-process", WIRED_CMD(ProcDStop),
 366: #    endif
 367: #  endif
 368: #endif
 369: #ifdef ABBREV
 370:     FUNCTION, "edit-word-abbrevs", WIRED_CMD(EditAbbrevs),
 371: #endif
 372:     FUNCTION, "end-kbd-macro", WIRED_CMD(Forget),
 373:     FUNCTION, "end-of-file", WIRED_CMD(Eof),
 374:     FUNCTION, "end-of-line", WIRED_CMD(Eol),
 375:     FUNCTION, "end-of-window", WIRED_CMD(Eow),
 376: #ifdef IPROCS
 377: #  ifndef PIPEPROCS
 378:     FUNCTION, "eof-process", WIRED_CMD(ProcEof),
 379: #  endif
 380: #endif
 381:     FUNCTION, "erase-buffer", WIRED_CMD(BufErase),
 382:     FUNCTION, "exchange-point-and-mark", WIRED_CMD(PtToMark),
 383:     FUNCTION, "execute-named-command", WIRED_CMD(Extend),
 384:     FUNCTION, "execute-kbd-macro", WIRED_CMD(ExecMacro),
 385:     FUNCTION, "execute-macro", WIRED_CMD(RunMacro),
 386:     FUNCTION, "exit-jove", WIRED_CMD(Leave),
 387: #ifdef CMT_FMT
 388:     FUNCTION, "fill-comment", WIRED_CMD(Comment),
 389: #endif /* CMT_FMT */
 390:     FUNCTION, "fill-paragraph", WIRED_CMD(Justify),
 391:     FUNCTION, "fill-region", WIRED_CMD(RegJustify),
 392: #ifndef MAC
 393:     FUNCTION, "filter-region", WIRED_CMD(FilterRegion),
 394: #endif
 395:     FUNCTION, "find-file", WIRED_CMD(FindFile),
 396:     FUNCTION, "find-tag", WIRED_CMD(FindTag),
 397:     FUNCTION, "find-tag-at-point", WIRED_CMD(FDotTag),
 398:     FUNCTION, "first-non-blank", WIRED_CMD(ToIndent),
 399:     FUNCTION, "forward-character", WIRED_CMD(ForChar),
 400:     FUNCTION, "forward-list", WIRED_CMD(FList),
 401:     FUNCTION, "forward-paragraph", WIRED_CMD(ForPara),
 402:     FUNCTION, "forward-s-expression", WIRED_CMD(FSexpr),
 403:     FUNCTION, "forward-sentence", WIRED_CMD(Eos),
 404:     FUNCTION, "forward-word", WIRED_CMD(ForWord),
 405:     DefMajor(FUNDAMENTAL), "fundamental-mode", WIRED_CMD(0),
 406:     FUNCTION, "gather-numeric-argument", WIRED_CMD(TimesFour),
 407: #ifdef LISP
 408:     FUNCTION, "grind-s-expr", WIRED_CMD(GSexpr),
 409: #endif
 410:     FUNCTION, "goto-line", WIRED_CMD(GoLine),
 411:     FUNCTION, "goto-window-with-buffer", WIRED_CMD(GotoWind),
 412:     FUNCTION, "grow-window", WIRED_CMD(GrowWindow),
 413:     FUNCTION, "handle-tab", WIRED_CMD(Tab),
 414:     FUNCTION, "i-search-forward", WIRED_CMD(IncFSearch),
 415:     FUNCTION, "i-search-reverse", WIRED_CMD(IncRSearch),
 416:     FUNCTION, "insert-file", WIRED_CMD(InsFile),
 417: #ifdef IPROCS
 418:     FUNCTION, "interrupt-process", WIRED_CMD(ProcInt),
 419:     FUNCTION, "i-shell-command", WIRED_CMD(Iprocess),
 420: #endif
 421:     FUNCTION, "kill-next-word", WIRED_CMD(DelNWord),
 422:     FUNCTION, "kill-previous-word", WIRED_CMD(DelPWord),
 423: #ifdef IPROCS
 424:     FUNCTION, "kill-process", WIRED_CMD(ProcKill),
 425: #endif
 426:     FUNCTION, "kill-region", WIRED_CMD(DelReg),
 427:     FUNCTION, "kill-s-expression", WIRED_CMD(KillExpr),
 428:     FUNCTION, "kill-some-buffers", WIRED_CMD(KillSome),
 429:     FUNCTION, "kill-to-beginning-of-sentence", WIRED_CMD(KillBos),
 430:     FUNCTION, "kill-to-end-of-line", WIRED_CMD(KillEOL),
 431:     FUNCTION, "kill-to-end-of-sentence", WIRED_CMD(KillEos),
 432:     FUNCTION, "left-margin-here", WIRED_CMD(SetLMargin),
 433: #ifdef LISP
 434:     DefMajor(LISPMODE), "lisp-mode", WIRED_CMD(0),
 435: #endif
 436:     FUNCTION, "list-buffers", WIRED_CMD(BufList),
 437: #ifdef IPROCS
 438:     FUNCTION, "list-processes", WIRED_CMD(ProcList),
 439: #endif
 440:     FUNCTION, "make-buffer-unmodified", WIRED_CMD(NotModified),
 441:     FUNCTION, "make-macro-interactive", WIRED_CMD(MacInter),
 442:     FUNCTION, "name-kbd-macro", WIRED_CMD(NameMac),
 443:     FUNCTION, "newline", WIRED_CMD(Newline),
 444:     FUNCTION, "newline-and-backup", WIRED_CMD(OpenLine),
 445:     FUNCTION, "newline-and-indent", WIRED_CMD(LineAI),
 446: #ifndef MAC
 447:     FUNCTION, "next-error", WIRED_CMD(NextError),
 448: #endif
 449:     FUNCTION, "next-line", WIRED_CMD(NextLine),
 450:     FUNCTION, "next-page", WIRED_CMD(NextPage),
 451:     FUNCTION, "next-window", WIRED_CMD(NextWindow),
 452:     FUNCTION, "number-lines-in-window", WIRED_CMD(WNumLines),
 453:     DefMinor(OverWrite), "over-write-mode", WIRED_CMD(0),
 454:     FUNCTION, "page-next-window", WIRED_CMD(PageNWind),
 455:     FUNCTION, "paren-flash", WIRED_CMD(DoParen),
 456: #ifndef MAC
 457:     FUNCTION, "parse-errors", WIRED_CMD(ErrParse),
 458: #endif
 459: #ifdef SPELL
 460:     FUNCTION, "parse-spelling-errors-in-buffer", WIRED_CMD(SpelWords),
 461: #endif
 462: #ifdef JOB_CONTROL
 463:     FUNCTION, "pause-jove", WIRED_CMD(PauseJove),
 464: #else
 465: #	ifndef MAC
 466:     FUNCTION, "pause-jove", WIRED_CMD(Push),
 467: #	endif
 468: #endif
 469:     FUNCTION, "pop-mark", WIRED_CMD(PopMark),
 470: #ifdef CHDIR
 471:     FUNCTION, "popd", WIRED_CMD(Popd),
 472: #endif
 473:     FUNCTION, "prefix-1", WIRED_CMD(EscPrefix),
 474:     FUNCTION, "prefix-2", WIRED_CMD(CtlxPrefix),
 475:     FUNCTION, "prefix-3", WIRED_CMD(MiscPrefix),
 476: #ifndef MAC
 477:     FUNCTION, "previous-error", WIRED_CMD(PrevError),
 478: #endif
 479:     FUNCTION, "previous-line", WIRED_CMD(PrevLine),
 480:     FUNCTION, "previous-page", WIRED_CMD(PrevPage),
 481:     FUNCTION, "previous-window", WIRED_CMD(PrevWindow),
 482:     FUNCTION, "print", WIRED_CMD(PrVar),
 483: #ifdef IPROCS
 484:     FUNCTION, "process-bind-to-key", WIRED_CMD(ProcBind),
 485:     FUNCTION, "process-newline", WIRED_CMD(ProcNewline),
 486:     FUNCTION, "process-send-data-no-return", WIRED_CMD(ProcSendData),
 487: #endif
 488: #ifndef MAC
 489:     FUNCTION, "push-shell", WIRED_CMD(Push),
 490: #endif
 491: #ifdef CHDIR
 492:     FUNCTION, "pushd", WIRED_CMD(Pushd),
 493:     FUNCTION, "pwd", WIRED_CMD(prCWD),
 494: #endif
 495:     FUNCTION, "query-replace-string", WIRED_CMD(QRepSearch),
 496: #ifdef IPROCS
 497:     FUNCTION, "quit-process", WIRED_CMD(ProcQuit),
 498: #endif
 499:     FUNCTION, "quoted-insert", WIRED_CMD(QuotChar),
 500: #ifdef ABBREV
 501:     FUNCTION, "read-word-abbrev-file", WIRED_CMD(RestAbbrevs),
 502: #endif
 503:     FUNCTION, "redraw-display", WIRED_CMD(RedrawDisplay),
 504:     FUNCTION, "recursive-edit", WIRED_CMD(Recur),
 505:     FUNCTION, "rename-buffer", WIRED_CMD(ReNamBuf),
 506:     FUNCTION, "replace-in-region", WIRED_CMD(RegReplace),
 507:     FUNCTION, "replace-string", WIRED_CMD(RepSearch),
 508:     FUNCTION, "right-margin-here", WIRED_CMD(SetRMargin),
 509:     FUNCTION, "save-file", WIRED_CMD(SaveFile),
 510:     FUNCTION, "scroll-down", WIRED_CMD(DownScroll),
 511:     FUNCTION, "scroll-left", WIRED_CMD(ScrollLeft),
 512: #ifdef MSDOS
 513:     FUNCTION, "scroll-next-page", WIRED_CMD(PageScrollUp),
 514:     FUNCTION, "scroll-previous-page", WIRED_CMD(PageScrollDown),
 515: #endif /* MSDOS */
 516:     FUNCTION, "scroll-right", WIRED_CMD(ScrollRight),
 517:     FUNCTION, "scroll-up", WIRED_CMD(UpScroll),
 518:     FUNCTION, "search-forward", WIRED_CMD(ForSearch),
 519:     FUNCTION, "search-forward-nd", WIRED_CMD(FSrchND),
 520:     FUNCTION, "search-reverse", WIRED_CMD(RevSearch),
 521:     FUNCTION, "search-reverse-nd", WIRED_CMD(RSrchND),
 522:     FUNCTION, "select-buffer", WIRED_CMD(BufSelect),
 523: #ifdef MSDOS
 524:     FUNCTION, "select-buffer-1", WIRED_CMD(Buf1Select),
 525:     FUNCTION, "select-buffer-2", WIRED_CMD(Buf2Select),
 526:     FUNCTION, "select-buffer-3", WIRED_CMD(Buf3Select),
 527:     FUNCTION, "select-buffer-4", WIRED_CMD(Buf4Select),
 528:     FUNCTION, "select-buffer-5", WIRED_CMD(Buf5Select),
 529:     FUNCTION, "select-buffer-6", WIRED_CMD(Buf6Select),
 530:     FUNCTION, "select-buffer-7", WIRED_CMD(Buf7Select),
 531:     FUNCTION, "select-buffer-8", WIRED_CMD(Buf8Select),
 532:     FUNCTION, "select-buffer-9", WIRED_CMD(Buf9Select),
 533:     FUNCTION, "select-buffer-10", WIRED_CMD(Buf10Select),
 534: #endif /* MSDOS */
 535:     FUNCTION, "self-insert", WIRED_CMD(SelfInsert),
 536:     FUNCTION, "set", WIRED_CMD(SetVar),
 537:     FUNCTION, "set-mark", WIRED_CMD(SetMark),
 538: #ifdef IPROCS   /* for GNU compatibility */
 539:     FUNCTION, "shell", WIRED_CMD(ShellProc),
 540: #endif
 541: #ifndef MAC
 542:     FUNCTION, "shell-command", WIRED_CMD(ShellCom),
 543:     FUNCTION, "shell-command-no-buffer", WIRED_CMD(ShNoBuf),
 544:     FUNCTION, "shell-command-to-buffer", WIRED_CMD(ShToBuf),
 545:     FUNCTION, "shell-command-with-typeout", WIRED_CMD(Shtypeout),
 546: #endif
 547:     DefMinor(ShowMatch), "show-match-mode", WIRED_CMD(0),
 548:     FUNCTION, "shrink-window", WIRED_CMD(ShrWindow),
 549:     FUNCTION, "source", WIRED_CMD(Source),
 550: #ifdef SPELL
 551:     FUNCTION, "spell-buffer", WIRED_CMD(SpelBuffer),
 552: #endif
 553:     FUNCTION, "split-current-window", WIRED_CMD(SplitWind),
 554:     FUNCTION, "start-remembering", WIRED_CMD(Remember),
 555: #ifdef IPROCS
 556: #  ifndef PIPEPROCS
 557:     FUNCTION, "stop-process", WIRED_CMD(ProcStop),
 558: #  endif
 559: #endif
 560:     FUNCTION, "stop-remembering", WIRED_CMD(Forget),
 561:     FUNCTION, "string-length", WIRED_CMD(StrLength),
 562: #ifdef JOB_CONTROL
 563:     FUNCTION, "suspend-jove", WIRED_CMD(PauseJove),
 564: #endif
 565:     DefMajor(TEXT), "text-mode", WIRED_CMD(0),
 566:     FUNCTION, "transpose-characters", WIRED_CMD(TransChar),
 567:     FUNCTION, "transpose-lines", WIRED_CMD(TransLines),
 568:     FUNCTION, "unbind-key", WIRED_CMD(UnbindC),
 569:     FUNCTION, "version", WIRED_CMD(ShowVersion),
 570:     FUNCTION, "visible-spaces-in-window", WIRED_CMD(WVisSpace),
 571:     FUNCTION, "visit-file", WIRED_CMD(ReadFile),
 572:     FUNCTION, "window-find", WIRED_CMD(WindFind),
 573: #ifdef ABBREV
 574:     DefMinor(Abbrev), "word-abbrev-mode", WIRED_CMD(0),
 575:     FUNCTION, "write-word-abbrev-file", WIRED_CMD(SaveAbbrevs),
 576: #endif
 577:     FUNCTION, "write-file", WIRED_CMD(WriteFile),
 578:     FUNCTION, "write-macros-to-file", WIRED_CMD(WriteMacs),
 579:     FUNCTION, "write-modified-files", WIRED_CMD(WtModBuf),
 580:     FUNCTION, "write-region", WIRED_CMD(WrtReg),
 581:     FUNCTION, "yank", WIRED_CMD(Yank),
 582:     FUNCTION, "yank-pop", WIRED_CMD(YankPop),
 583:     FUNCTION, 0, 0
 584: };
 585: 
 586: #ifndef TXT_TO_C
 587: data_obj *
 588: findcom(prompt)
 589: char    *prompt;
 590: {
 591:     /* This is for faster startup.  This just reads until a space or a
 592: 	   tab or a newline character is reached, and then does a
 593: 	   semi-hashed lookup on that string.  This should be much faster
 594: 	   than initializing the minibuffer for each line. */
 595:     if (InJoverc) {
 596:         char    cmdbuf[128];
 597:         register struct cmd *cmd;
 598:         register char   *cp = cmdbuf;
 599: #if !(defined(IBMPC) || defined(MAC))
 600:         register int    c;
 601: #else
 602:         int c;
 603: #endif
 604:         struct cmd  *which;
 605:         int cmdlen,
 606:             found = 0;
 607:         static struct cmd   *cmdhash[26];
 608:         static int  beenhere = NO;
 609: 
 610: /* special case for prefix commands--only upper case ones */
 611: #define hash(c) (c - 'a')
 612: 
 613:         /* initialize the hash table */
 614:         if (beenhere == NO) {
 615:             int lastc = 0;
 616: 
 617:             for (cmd = commands; cmd->Name != 0; cmd++)
 618:                 if (lastc != cmd->Name[0]) {
 619:                     lastc = cmd->Name[0];
 620:                     cmdhash[hash(lastc)] = cmd;
 621:                 }
 622:             beenhere = YES;
 623:         }
 624: #ifdef MAC
 625:         menus_off();    /* Block menu choices during input */
 626: #endif
 627:         /* gather the cmd name */
 628:         while (((c = getch()) != EOF) && !index(" \t\r\n", c)) {
 629: #if (defined(IBMPC) || defined(MAC))
 630:             lower(&c);
 631: #else
 632:             if (isupper(c))
 633:                 c = tolower(c);
 634: #endif
 635:             *cp++ = c;
 636:         }
 637:         if (c == EOF)
 638:             return 0;
 639:         *cp = '\0';
 640:         cmdlen = cp - cmdbuf;
 641:         if (cmdlen == 0)
 642:             return 0;
 643: 
 644:         /* look it up (in the reduced search space) */
 645:         if (islower(cmdbuf[0]))
 646:             for (cmd = cmdhash[hash(cmdbuf[0])]; cmd != 0 && cmd->Name[0] == cmdbuf[0]; cmd++) {
 647:             if (strncmp(cmd->Name, cmdbuf, cmdlen) == 0) {
 648:                 if (strcmp(cmd->Name, cmdbuf) == 0)
 649:                     return (data_obj *) cmd;
 650:                 found += 1;
 651:                 which = cmd;
 652:             }
 653:             }
 654:         if (found > 1)
 655:             complain("[\"%s\" ambiguous]", cmdbuf);
 656:         else if (found == 0)
 657:             complain("[\"%s\" unknown]", cmdbuf);
 658:         else
 659:             return (data_obj *) which;
 660:     } else {
 661:         static char *strings[(sizeof commands) / sizeof (commands[0])];
 662:         static int  beenhere = NO;
 663:         register int    com;
 664: 
 665:         if (beenhere == NO) {
 666:             register char   **strs = strings;
 667:             register struct cmd *c;
 668: 
 669:             for (c = commands; c->Name != 0; c++)
 670:                 *strs++ = c->Name;
 671:             *strs = 0;
 672:             beenhere = YES;
 673:         }
 674: 
 675:         if ((com = complete(strings, prompt, CASEIND)) < 0)
 676:             return 0;
 677:         return (data_obj *) &commands[com];
 678:     }
 679:     /* NOTREACHED */
 680: }
 681: #endif

Defined functions

Defined variables

commands defined in line 273; used 9 times

Defined macros

WIRED_CMD defined in line 269; used 218 times
hash defined in line 611; used 2 times

Usage of this include

Last modified: 1988-03-15
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 4410
Valid CSS Valid XHTML 1.0 Strict