home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / vol_300 / 332_01 / chardel.c < prev    next >
C/C++ Source or Header  |  1990-01-06  |  3KB  |  94 lines

  1. /****************************************************************/
  2. /* Wdelch() routine of the PCcurses package            */
  3. /*                                */
  4. /****************************************************************/
  5. /* This version of curses is based on ncurses, a curses version    */
  6. /* originally written by Pavel Curtis at Cornell University.    */
  7. /* I have made substantial changes to make it run on IBM PC's,    */
  8. /* and therefore consider myself free to make it public domain.    */
  9. /*                Bjorn Larsson (bl@infovox.se)    */
  10. /****************************************************************/
  11. /* 1.4:  Use short wherever possible. Portability        */
  12. /*     improvements:                    900114    */
  13. /* 1.3:     MSC -W3, Turbo'C' -w -w-pro checkes:        881005    */
  14. /* 1.2:     Max limits off by 1. Fixed thanks to S. Creps:    881002    */
  15. /* 1.0:     Release:                    870515    */
  16. /****************************************************************/
  17.  
  18. #include <curses.h>
  19. #include <curspriv.h>
  20.  
  21. char _curses_chardel_rcsid[] = "@(#)chardel.c    v.1.4  - 900114";
  22.  
  23. /****************************************************************/
  24. /* Wdelch() deletes the character at the window cursor, and the    */
  25. /* characters to the right of it are shifted left, inserting a    */
  26. /* space at the last position of the line.            */
  27. /****************************************************************/
  28.  
  29. int    wdelch(win)
  30.   WINDOW    *win;
  31.   {
  32.   short        *temp1;
  33.   short        *temp2;
  34.   short        *end;
  35.   short     y = win->_cury;
  36.   short     x = win->_curx;
  37.   short     maxx = win->_maxx - 1;
  38.  
  39.   end = &win->_line[y][maxx];
  40.   temp1 = &win->_line[y][x];
  41.   temp2 = temp1 + 1;
  42.   while (temp1 < end)
  43.     *temp1++ = *temp2++;
  44.   *temp1 = ' ' | (win->_attrs & ATR_MSK);
  45.   win->_maxchng[y] = maxx;
  46.   if (win->_minchng[y] == _NO_CHANGE || win->_minchng[y] > x)
  47.     win->_minchng[y] = x;
  48.   return(OK);
  49.   } /* wdelch */
  50.  
  51. /****************************************************************/
  52. /* Delch() deletes the character at the stdscr cursor, and the    */
  53. /* characters to the right of it are shifted left, inserting a    */
  54. /* space at the last position of the line.            */
  55. /****************************************************************/
  56.  
  57. int delch()
  58.   {
  59.   return(wdelch(stdscr));
  60.   } /* delch */
  61.  
  62. /****************************************************************/
  63. /* Mvdelch() moves the stdscr cursor to a new position, then    */
  64. /* deletes the character at the stdscr cursor, and the charac-    */
  65. /* ters to the right of it are shifted left, inserting a space    */
  66. /* at the last position of the line.                */
  67. /****************************************************************/
  68.  
  69. int mvdelch(y,x)
  70.   int y;
  71.   int x;
  72.   {
  73.   if (wmove(stdscr,y,x) == ERR)
  74.     return(ERR);
  75.   return(wdelch(stdscr));
  76.   } /* mvdelch */
  77.  
  78. /****************************************************************/
  79. /* Mvwdelch() moves the cursor of window 'win' to a new posi-    */
  80. /* tion, then deletes the character at the stdscr cursor, and    */
  81. /* the characters to the right of it are shifted left, inser-    */
  82. /* ting a space at the last position of the line.        */
  83. /****************************************************************/
  84.  
  85. int mvwdelch(win,y,x)
  86.   WINDOW *win;
  87.   int y;
  88.   int x;
  89.   {
  90.   if (wmove(win,y,x) == ERR)
  91.     return(ERR);
  92.   return(wdelch(win));
  93.   } /* mvwdelch */
  94.