home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / CURS13_2.ZIP / CHARDEL.C < prev    next >
Text File  |  1989-12-08  |  3KB  |  92 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 (...mcvax!enea!infovax!bl)    */
  10. /****************************************************************/
  11. /* 1.0:    Release:                    870515    */
  12. /* 1.2:    Max limits off by 1. Fixed thanks to S. Creps:    881002    */
  13. /* 1.3:    MSC -W3, Turbo'C' -w -w-pro checkes:        881005    */
  14. /****************************************************************/
  15.  
  16. #include <curses.h>
  17. #include <curspriv.h>
  18.  
  19. char _curses_chardel_rcsid[] = "@(#)chardel.c v1.3 - 881005";
  20.  
  21. /****************************************************************/
  22. /* Wdelch() deletes the character at the window cursor, and the    */
  23. /* characters to the right of it are shifted left, inserting a    */
  24. /* space at the last position of the line.            */
  25. /****************************************************************/
  26.  
  27. int    wdelch(win)
  28.   WINDOW    *win;
  29.   {
  30.   int        *temp1;
  31.   int        *temp2;
  32.   int        *end;
  33.   short     y = win->_cury;
  34.   short     x = win->_curx;
  35.   short     maxx = win->_maxx - 1;
  36.  
  37.   end = &win->_line[y][maxx];
  38.   temp1 = &win->_line[y][x];
  39.   temp2 = temp1 + 1;
  40.   while (temp1 < end)
  41.     *temp1++ = *temp2++;
  42.   *temp1 = ' ' | (win->_attrs & ATR_MSK);
  43.   win->_maxchng[y] = maxx;
  44.   if (win->_minchng[y] == _NO_CHANGE || win->_minchng[y] > x)
  45.     win->_minchng[y] = x;
  46.   return(OK);
  47.   } /* wdelch */
  48.  
  49. /****************************************************************/
  50. /* Delch() deletes the character at the stdscr cursor, and the    */
  51. /* characters to the right of it are shifted left, inserting a    */
  52. /* space at the last position of the line.            */
  53. /****************************************************************/
  54.  
  55. int delch()
  56.   {
  57.   return(wdelch(stdscr));
  58.   } /* delch */
  59.  
  60. /****************************************************************/
  61. /* Mvdelch() moves the stdscr cursor to a new position, then    */
  62. /* deletes the character at the stdscr cursor, and the charac-    */
  63. /* ters to the right of it are shifted left, inserting a space    */
  64. /* at the last position of the line.                */
  65. /****************************************************************/
  66.  
  67. int mvdelch(y,x)
  68.   int y;
  69.   int x;
  70.   {
  71.   if (wmove(stdscr,y,x) == ERR)
  72.     return(ERR);
  73.   return(wdelch(stdscr));
  74.   } /* mvdelch */
  75.  
  76. /****************************************************************/
  77. /* Mvwdelch() moves the cursor of window 'win' to a new posi-    */
  78. /* tion, then deletes the character at the stdscr cursor, and    */
  79. /* the characters to the right of it are shifted left, inser-    */
  80. /* ting a space at the last position of the line.        */
  81. /****************************************************************/
  82.  
  83. int mvwdelch(win,y,x)
  84.   WINDOW *win;
  85.   int y;
  86.   int x;
  87.   {
  88.   if (wmove(win,y,x) == ERR)
  89.     return(ERR);
  90.   return(wdelch(win));
  91.   } /* mvwdelch */
  92.