home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / v / vim_src.zip / MESSAGE.C < prev    next >
C/C++ Source or Header  |  1993-01-12  |  3KB  |  132 lines

  1. /* vi:ts=4:sw=4
  2.  *
  3.  * VIM - Vi IMitation
  4.  *
  5.  * Code Contributions By:    Bram Moolenaar            mool@oce.nl
  6.  *                            Tim Thompson            twitch!tjt
  7.  *                            Tony Andrews            onecom!wldrdg!tony 
  8.  *                            G. R. (Fred) Walter        watmath!watcgl!grwalter 
  9.  */
  10.  
  11. /*
  12.  * message.c: functions for displaying messages on the command line
  13.  */
  14.  
  15. #include "vim.h"
  16. #include "globals.h"
  17. #define MESSAGE
  18. #include "proto.h"
  19. #include "param.h"
  20.  
  21. static int msg_invert = FALSE;
  22.  
  23. /*
  24.  * msg(s) - displays the string 's' on the status line
  25.  */
  26.     void
  27. msg(s)
  28.     char           *s;
  29. {
  30.     int len;
  31.  
  32.     if (Columns == 0)    /* terminal not initialized */
  33.     {
  34.         fprintf(stderr, s);
  35.         fflush(stderr);
  36.         return;
  37.     }
  38.  
  39.     gotocmdline(TRUE, NUL);
  40.     if (msg_invert)
  41.         outstr(T_TI);
  42.     len = outtrans(s, -1);
  43.     if (msg_invert)
  44.     {
  45.         outstr(T_TP);
  46.         msg_invert = FALSE;
  47.     }
  48.     flushbuf();
  49.     /*
  50.      * if the string is larger than the window,
  51.      * or the ruler option is set and we run into it,
  52.      * we have to redraw the window.
  53.      * Do not do this if we are abandoning the file.
  54.      */
  55.     if (!exiting && len >= Columns - (p_ru ? 22 : 0))
  56.     {
  57.         outchar('\n');
  58.         wait_return(TRUE);
  59.     }
  60. }
  61.  
  62. /* VARARGS */
  63. #ifndef PROTO        /* automatic prototype generation does not understand this */
  64.     void
  65. smsg(s, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10)
  66.     char        *s;
  67.     long        a1, a2, a3, a4, a5, a6, a7, a8, a9, a10;
  68. {
  69.     sprintf(IObuff, s, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10);
  70.     msg(IObuff);
  71. }
  72. #endif
  73.  
  74. /*
  75.  * emsg() - display an error message
  76.  *
  77.  * Rings the bell, if appropriate, and calls message() to do the real work
  78.  */
  79.     void
  80. emsg(s)
  81.     char           *s;
  82. {
  83.     if (p_eb)
  84.         beep();                /* also includes flush_buffers() */
  85.     else
  86.         flush_buffers();        /* delete all typeahead characters */
  87.     msg_invert = TRUE;
  88.     msg(s);
  89.     flushbuf();
  90.     if (got_int)        /* remove typeahead now, allow typeadhead during sleep */
  91.         inchar(TRUE);
  92.     sleep(1);    /* give the user a chance to read the message */
  93. }
  94.  
  95.     void
  96. wait_return(redraw)
  97.     int        redraw;
  98. {
  99.     u_char            c;
  100.     int                oldstate;
  101.  
  102.     oldstate = State;
  103.     State = HITRETURN;
  104.     if (got_int)
  105.         outstrn("Interrupt: ");
  106.  
  107. #ifdef ORG_HITRETURN
  108.     outstrn("Press RETURN to continue");
  109.     do {
  110.         c = vgetc();
  111.     } while (strchr("\r\n: ", c) == NULL);
  112.     if (c == ':')             /* this can vi too (but not always!) */
  113.         stuffReadbuff(mkstr(c));
  114. #else
  115.     outstrn("Press RETURN or enter command to continue");
  116.     c = vgetc();
  117.     if (strchr("\r\n ", c) == NULL)
  118.         stuffReadbuff(mkstr(c));
  119. #endif
  120.  
  121.     if (State == SETWINSIZE)
  122.     {
  123.         State = oldstate;
  124.         set_winsize(0, 0, FALSE);
  125.     }
  126.     State = oldstate;
  127.     script_winsize_pp();
  128.  
  129.     if (redraw)
  130.         updateScreen(CLEAR);
  131. }
  132.