home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 5 / FreshFish_July-August1994.bin / bbs / util / jade-3.0.lha / Jade / src / commandline.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-19  |  1.7 KB  |  68 lines

  1. /* commandline.c -- Braindead prompt
  2.    Copyright (C) 1993, 1994 John Harper <jsh@ukc.ac.uk>
  3.  
  4. This file is part of Jade.
  5.  
  6. Jade is free software; you can redistribute it and/or modify it
  7. under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; either version 2, or (at your option)
  9. any later version.
  10.  
  11. Jade is distributed in the hope that it will be useful, but
  12. WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with Jade; see the file COPYING.  If not, write to
  18. the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
  19.  
  20. #include "jade.h"
  21. #include "jade_protos.h"
  22.  
  23. #include <string.h>
  24.  
  25. _PR void commandline_init(void);
  26. _PR void commandline_kill(void);
  27. _PR u_char *LastPrompted;      /* one line history */
  28. u_char *LastPrompted;
  29.  
  30. _PR VALUE cmd_prompt(VALUE prompt, VALUE string);
  31. DEFUN("prompt", cmd_prompt, subr_prompt, (VALUE prompt, VALUE string), V_Subr2, DOC_prompt) /*
  32. ::doc:prompt::
  33. (prompt PROMPT [STRING])
  34. Displays PROMPT and waits for the user to enter a string, which is
  35. then returned. If STRING is provided it is used as the starting value
  36. of the string.
  37. ::end:: */
  38. {
  39.     u_char *str = NULL;
  40.     VALUE res;
  41.     DECLARE1(prompt, STRINGP);
  42.     if(STRINGP(string))
  43.     str = VSTR(string);
  44.     str = docmdline(CurrVW, VSTR(prompt), str);
  45.     if(str)
  46.     {
  47.     res = valstrdup(str);
  48.     mystrfree(str);
  49.     return(res);
  50.     }
  51.     return(sym_nil);
  52. }
  53.  
  54. void
  55. commandline_init(void)
  56. {
  57.     ADD_SUBR(subr_prompt);
  58. }
  59. void
  60. commandline_kill(void)
  61. {
  62.     if(LastPrompted)
  63.     {
  64.     mystrfree(LastPrompted);
  65.     LastPrompted = NULL;
  66.     }
  67. }
  68.