linedel.c

来自「该程序是C语言编写的」· C语言 代码 · 共 97 行

C
97
字号
/****************************************************************/
/* Wdeleteln() routine of the PCcurses package			*/
/*								*/
/****************************************************************/
/* This version of curses is based on ncurses, a curses version	*/
/* originally written by Pavel Curtis at Cornell University.	*/
/* I have made substantial changes to make it run on IBM PC's,	*/
/* and therefore consider myself free to make it public domain.	*/
/*		Bjorn Larsson (...mcvax!enea!infovax!bl)	*/
/****************************************************************/
/* 1.4:  Use of short wherever possible. Portability		*/
/*	 improvements:					900114	*/
/* 1.3:	 MSC -W3, Turbo'C' -w -w-pro checkes:		881005	*/
/* 1.2:	 Max limits off by 1. Fixed thanks to S. Creps:	881002	*/
/* 1.0:	 Release:					870515	*/
/****************************************************************/

#include <curses.h>
#include <curspriv.h>

char _curses_linedel_rcsid[] = "@(#)linedel.c    v.1.4  - 900114";

/****************************************************************/
/* Wdeleteln() deletes the line at the window cursor, and the	*/
/* lines below it are shifted up, inserting a blank line at	*/
/* the bottom of the window.					*/
/****************************************************************/

int	wdeleteln(win)
  WINDOW	*win;
  {
  short		*end;
  short		*temp;
  short	 y;
  static short	 blank;
  
  blank = ' ' | (win->_attrs & ATR_MSK);

  temp = win->_line[win->_cury];
  for (y = win->_cury; y < win->_regbottom; y++)
    {
    win->_line[y] = win->_line[y+1];
    win->_minchng[y] = 0;
    win->_maxchng[y] = win->_maxx - 1;
    }
  win->_minchng[y] = 0;
  win->_maxchng[y] = win->_maxx - 1;
  win->_line[win->_regbottom] = temp;
  for (end = &(temp[win->_maxx -1]); temp <= end;)
    *temp++ = blank;
  return(OK);
  } /* wdeleteln */

/****************************************************************/
/* Deleteln() deletes the line at the stdscr cursor, and the	*/
/* lines below it are shifted up, inserting a blank line at	*/
/* the bottom of stdscr.					*/
/****************************************************************/

int deleteln()
  {
  return(wdeleteln(stdscr));
  } /* deleteln */

/****************************************************************/
/* Mvdeleteln() moves the cursor to a new position in stdscr,	*/
/* then deletes the line at the window cursor, and the lines	*/
/* below it are shifted up, inserting a blank line at the bot-	*/
/* tom of stdscr.						*/
/****************************************************************/

int mvdeleteln(y,x)
  int y;
  int x;
  {
  if (wmove(stdscr,y,x) == ERR)
    return(ERR);
  return(wdeleteln(stdscr));
  } /* mvdeleteln */

/****************************************************************/
/* Mvwdeleteln() moves the cursor to a new position in a win-	*/
/* dow, then deletes the line at the window cursor, and the	*/
/* lines below it are shifted up, inserting a blank line at	*/
/* the bottom of the window.					*/
/****************************************************************/

int mvwdeleteln(win,y,x)
  WINDOW *win;
  int y;
  int x;
  {
  if (wmove(win,y,x) == ERR)
    return(ERR);
  return(wdeleteln(win));
  } /* mvwdeleteln */

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?