Path: blob/master/Utilities/cmpdcurses/pdcurses/deleteln.c
3153 views
/* PDCurses */12#include <curspriv.h>34/*man-start**************************************************************56deleteln7--------89### Synopsis1011int deleteln(void);12int wdeleteln(WINDOW *win);13int insdelln(int n);14int winsdelln(WINDOW *win, int n);15int insertln(void);16int winsertln(WINDOW *win);1718int mvdeleteln(int y, int x);19int mvwdeleteln(WINDOW *win, int y, int x);20int mvinsertln(int y, int x);21int mvwinsertln(WINDOW *win, int y, int x);2223### Description2425With the deleteln() and wdeleteln() functions, the line under the26cursor in the window is deleted. All lines below the current line are27moved up one line. The bottom line of the window is cleared. The28cursor position does not change.2930With the insertln() and winsertn() functions, a blank line is31inserted above the current line and the bottom line is lost.3233mvdeleteln(), mvwdeleteln(), mvinsertln() and mvwinsertln() allow34moving the cursor and inserting/deleting in one call.3536### Return Value3738All functions return OK on success and ERR on error.3940### Portability41X/Open ncurses NetBSD42deleteln Y Y Y43wdeleteln Y Y Y44mvdeleteln - - -45mvwdeleteln - - -46insdelln Y Y Y47winsdelln Y Y Y48insertln Y Y Y49winsertln Y Y Y50mvinsertln - - -51mvwinsertln - - -5253**man-end****************************************************************/5455int wdeleteln(WINDOW *win)56{57chtype blank, *temp, *ptr;58int y;5960PDC_LOG(("wdeleteln() - called\n"));6162if (!win)63return ERR;6465/* wrs (4/10/93) account for window background */6667blank = win->_bkgd;6869temp = win->_y[win->_cury];7071for (y = win->_cury; y < win->_bmarg; y++)72{73win->_y[y] = win->_y[y + 1];74win->_firstch[y] = 0;75win->_lastch[y] = win->_maxx - 1;76}7778for (ptr = temp; (ptr - temp < win->_maxx); ptr++)79*ptr = blank; /* make a blank line */8081if (win->_cury <= win->_bmarg)82{83win->_firstch[win->_bmarg] = 0;84win->_lastch[win->_bmarg] = win->_maxx - 1;85win->_y[win->_bmarg] = temp;86}8788return OK;89}9091int deleteln(void)92{93PDC_LOG(("deleteln() - called\n"));9495return wdeleteln(stdscr);96}9798int mvdeleteln(int y, int x)99{100PDC_LOG(("mvdeleteln() - called\n"));101102if (move(y, x) == ERR)103return ERR;104105return wdeleteln(stdscr);106}107108int mvwdeleteln(WINDOW *win, int y, int x)109{110PDC_LOG(("mvwdeleteln() - called\n"));111112if (wmove(win, y, x) == ERR)113return ERR;114115return wdeleteln(win);116}117118int winsdelln(WINDOW *win, int n)119{120int i;121122PDC_LOG(("winsdelln() - called\n"));123124if (!win)125return ERR;126127if (n > 0)128{129for (i = 0; i < n; i++)130if (winsertln(win) == ERR)131return ERR;132}133else if (n < 0)134{135n = -n;136for (i = 0; i < n; i++)137if (wdeleteln(win) == ERR)138return ERR;139}140141return OK;142}143144int insdelln(int n)145{146PDC_LOG(("insdelln() - called\n"));147148return winsdelln(stdscr, n);149}150151int winsertln(WINDOW *win)152{153chtype blank, *temp, *end;154int y;155156PDC_LOG(("winsertln() - called\n"));157158if (!win)159return ERR;160161/* wrs (4/10/93) account for window background */162163blank = win->_bkgd;164165temp = win->_y[win->_maxy - 1];166167for (y = win->_maxy - 1; y > win->_cury; y--)168{169win->_y[y] = win->_y[y - 1];170win->_firstch[y] = 0;171win->_lastch[y] = win->_maxx - 1;172}173174win->_y[win->_cury] = temp;175176for (end = &temp[win->_maxx - 1]; temp <= end; temp++)177*temp = blank;178179win->_firstch[win->_cury] = 0;180win->_lastch[win->_cury] = win->_maxx - 1;181182return OK;183}184185int insertln(void)186{187PDC_LOG(("insertln() - called\n"));188189return winsertln(stdscr);190}191192int mvinsertln(int y, int x)193{194PDC_LOG(("mvinsertln() - called\n"));195196if (move(y, x) == ERR)197return ERR;198199return winsertln(stdscr);200}201202int mvwinsertln(WINDOW *win, int y, int x)203{204PDC_LOG(("mvwinsertln() - called\n"));205206if (wmove(win, y, x) == ERR)207return ERR;208209return winsertln(win);210}211212213