home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-387-Vol-3of3.iso / x / xvisrc.zoo / status.c < prev    next >
C/C++ Source or Header  |  1992-07-28  |  2KB  |  117 lines

  1. /* Copyright (c) 1990,1991,1992 Chris and John Downey */
  2. #ifndef lint
  3. static char *sccsid = "@(#)status.c    2.1 (Chris & John Downey) 7/29/92";
  4. #endif
  5.  
  6. /***
  7.  
  8. * program name:
  9.     xvi
  10. * function:
  11.     PD version of UNIX "vi" editor, with extensions.
  12. * module name:
  13.     status.c
  14. * module function:
  15.     Routines to print status line messages.
  16. * history:
  17.     STEVIE - ST Editor for VI Enthusiasts, Version 3.10
  18.     Originally by Tim Thompson (twitch!tjt)
  19.     Extensive modifications by Tony Andrews (onecom!wldrdg!tony)
  20.     Heavily modified by Chris & John Downey
  21.  
  22. ***/
  23.  
  24. #include "xvi.h"
  25.  
  26. /*
  27.  * Set up the "slinetype" field in the given buffer structure,
  28.  * according to the number of columns available.
  29.  */
  30. void
  31. init_sline(win)
  32. Xviwin    *win;
  33. {
  34.     flexclear(&win->w_statusline);
  35. }
  36.  
  37. /*VARARGS2*/
  38. /*PRINTFLIKE*/
  39. void
  40. show_message
  41. #ifdef    __STDC__
  42.     (Xviwin *window, char *format, ...)
  43. #else /* not __STDC__ */
  44.     (window, format, va_alist)
  45.     Xviwin    *window;
  46.     char    *format;
  47.     va_dcl
  48. #endif    /* __STDC__ */
  49. {
  50.     va_list    argp;
  51.  
  52.     VA_START(argp, format);
  53.     (void) flexclear(&window->w_statusline);
  54.     (void) vformat(&window->w_statusline, format, argp);
  55.     va_end(argp);
  56.  
  57.     update_sline(window);
  58. }
  59.  
  60. /*VARARGS2*/
  61. /*PRINTFLIKE*/
  62. void
  63. show_error
  64. #ifdef    __STDC__
  65.     (Xviwin *window, char *format, ...)
  66. #else /* not __STDC__ */
  67.     (window, format, va_alist)
  68.     Xviwin    *window;
  69.     char    *format;
  70.     va_dcl
  71. #endif    /* __STDC__ */
  72. {
  73.     va_list    argp;
  74.  
  75.     beep(window);
  76.     VA_START(argp, format);
  77.     (void) flexclear(&window->w_statusline);
  78.     (void) vformat(&window->w_statusline, format, argp);
  79.     va_end(argp);
  80.  
  81.     update_sline(window);
  82. }
  83.  
  84. void
  85. show_file_info(window)
  86. Xviwin    *window;
  87. {
  88.     if (echo & e_SHOWINFO) {
  89.     Buffer    *buffer;
  90.     Flexbuf    *slp;
  91.     long    position, total;
  92.     long    percentage;
  93.  
  94.     buffer = window->w_buffer;
  95.  
  96.     position = lineno(buffer, window->w_cursor->p_line);
  97.     total = lineno(buffer, buffer->b_lastline->l_prev);
  98.     percentage = (total > 0) ? (position * 100) / total : 0;
  99.  
  100.     slp = &window->w_statusline;
  101.     flexclear(slp);
  102.     if (buffer->b_filename == NULL) {
  103.         (void) lformat(slp, "No File ");
  104.     } else {
  105.         (void) lformat(slp, "\"%s\" ", buffer->b_filename);
  106.     }
  107.     (void) lformat(slp, "%s%s%sline %ld of %ld (%ld%%)",
  108.         is_readonly(buffer) ? "[Read only] " : "",
  109.         not_editable(buffer) ? "[Not editable] " : "",
  110.         is_modified(buffer) ? "[Modified] " : "",
  111.         position,
  112.         total,
  113.         percentage);
  114.     }
  115.     update_sline(window);
  116. }
  117.