home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS 1992 June / SIMTEL_0692.cdr / msdos / eel / lenoil.arc / PROMPT.E < prev    next >
Encoding:
Internet Message Format  |  1988-12-12  |  3.5 KB

  1. From:    IN%"lenoil@APPLE.COM"  "Robert Lenoil"  9-DEC-1988 21:07
  2. To:    p150bk19@VB.CC.CMU.EDU
  3. Subj:    Disregard prev. msg - PROMPT.E (enclosed) has been found!
  4.  
  5. Received: from apple.com by VB.CC.CMU.EDU; Fri, 9 Dec 88 21:06 EST
  6. Received: by apple.com (5.59/25-eef) id AA28069; Fri, 9 Dec 88 18:05:21 PST
  7. Date: Fri, 9 Dec 88 18:05:21 PST
  8. From: Robert Lenoil <lenoil@APPLE.COM>
  9. Subject: Disregard prev. msg - PROMPT.E (enclosed) has been found!
  10. To: p150bk19@VB.CC.CMU.EDU
  11. Message-Id: <8812100205.AA28069@apple.com>
  12.  
  13. /* The following copyright and trademark notice applies to some of the code
  14.  * herein; all other material is Copyright (c) 1986, 1987 by Robert Lenoil,
  15.  * with free copying allowed for any purpose, provided that this copyright
  16.  * notice is included.
  17.  */
  18.  
  19. /************************************************************************
  20. * "Epsilon", "EEL" and "Lugaru" are trademarks of Lugaru Software, Ltd. *
  21. *                                                                       *
  22. *     Copyright (C) 1985 Lugaru Software Ltd.  All rights reserved.     *
  23. *                                                                       *
  24. * Limited permission is hereby granted to reproduce and modify this     *
  25. * copyrighted material provided that the resulting code is used only in *
  26. * conjunction with Lugaru products and that this notice is retained in  *
  27. * any such reproduction or modification.                                *
  28. ************************************************************************/
  29.  
  30. #include <eel.h>
  31.  
  32. /* This file adds the following Epsilon commands/procedures:
  33. COMMAND           WRITTEN FOR VERSION
  34. prompt                  3.1
  35.  
  36. /* PROMPT inputs a prompt, then prompts the user with that prompt, storing
  37.  * the response on the kill ring.  Completion varies depending upon argument
  38.  * to prompt command: 1=filename, 2=command name, 3=buffer name, else normal
  39.  * string input.  Input always comes from keyboard.  Written for 3.1; function
  40.  * was originally present in 2.x.
  41.  */
  42.  
  43. command prompt()
  44. {  char prompt[80], *thisbuf = bufname;
  45.    int save_ptr = 1, (*func)();
  46.    short *macro_save = (short *) malloc(sizeof(short [MAX_MACRO]));
  47.    jmp_buf new_top_level, *top_level_save = top_level;
  48.  
  49.    if (setjmp(top_level = &new_top_level))
  50.    {  free((char *) macro_save);
  51.       longjmp(top_level = top_level_save, 1);
  52.    }
  53.  
  54.    get_string(prompt, "String To Prompt With: ");
  55.  
  56.    /* We want the following input to come from the keyboard, so we must
  57.     * drain any executing macro of input, saving it away.  Also use
  58.     * wait_for_key instead of getkey so that input is not recorded in any
  59.     * macro definition.
  60.     */
  61.    while (in_macro()) macro_save[save_ptr++] = (wait_for_key(), key);
  62.  
  63.    /* Input line without recording and save on kill ring. */
  64.    switch (iter)
  65.    {  int get_file(), get_cmd(), get_buf(), get_string();
  66.       case 1: func = get_file; break;
  67.       case 2: func = get_cmd; break;
  68.       case 3: func = get_buf; break;
  69.       default: func = get_string;
  70.    }
  71.    (*func)(prompt, prompt);
  72.    if (len_def_mac)
  73.    {  int input_length = strlen(prompt)+1;
  74.       len_def_mac -= input_length;
  75.       cmd_len -= input_length;
  76.    }
  77.    push_kill();
  78.    bufname = cur_kill_buf;
  79.    stuff(prompt);
  80.    bufname = thisbuf;
  81.  
  82.    /* execute any remaining macro text */
  83.    if (save_ptr > (iter=1))
  84.    {  macro_save[0] = save_ptr;
  85.       name_macro("prompt-macro", macro_save);
  86.       cmd_len = has_arg = 0;
  87.       prompt_macro();
  88.    }
  89.    free((char *) macro_save);
  90.    top_level = top_level_save;
  91. }
  92.