overwrite man page on SmartOS

Man page or keyword search:  
man Server   16655 pages
apropos Keyword Search (all sections)
Output format
SmartOS logo
[printable version]


       overlay, overwrite - copy overlapped windows

       cc [ flag... ] file... -I /usr/xpg4/include  -L	/usr/xpg4/lib \
	-R  /usr/xpg4/lib  -lcurses  [ library... ]

       c89 [ flag... ] file... -lcurses [ library... ]

       #include <curses.h>

       int overlay(const WINDOW *srcwin, WINDOW *dstwin);

       int overwrite(const WINDOW *srcwin, WINDOW *dstwin);

		 Is a pointer to the source window to be copied.

		 Is  a	pointer	 to  the destination window to be overlayed or

       The overwrite() and overlay() functions overlay srcwin on top of	 dest‐
       win.  The  srcwin and dstwin arguments do not have to be the same size;
       only text where the two windows overlap is copied.

       The overwrite() function copies characters  as  though  a  sequence  of
       win_wch(3XCURSES) and wadd_wch(3XCURSES) were performed with the desti‐
       nation window's attributes and background attributes cleared.

       The overlay() function does the same thing,  except  that,  whenever  a
       character  to  be copied is the background character of the source win‐
       dow, overlay() does not copy the character but merely moves the	desti‐
       nation cursor the width of the source background character.

       If  any portion of the overlaying window border is not the first column
       of a multi-column character, then all  the  column  positions  will  be
       replaced with the background character and rendition before the overlay
       is done. If the default background character is a multi-column  charac‐
       ter when this occurs, then these functions fail.

       Upon  successful completion, these functions return OK. Otherwise, they
       return ERR.

       No errors are defined.

       Example 1 Implement a pop-up dialog

       The following example demonstrates the use of overwrite() to  implement
       a pop-up dialog box.

	 #include <curses.h>
	  *   Pop-up a window on top of curscr.	 If row and/or col
	  *   are -1 then that dimension will be centered within
	  *   curscr.  Return 0 for success or -1 if malloc() failed.
	  *   Pass back the working window and the saved window for the
	  *   pop-up.  The saved window should not be modified.
	 popup(work, save, nrows, ncols, row, col)
	 WINDOW **work, **save;
	 int nrows, ncols, row, col;
	      int mr, mc;
	      getmaxyx(curscr, mr, mc);
	      /* Windows are limited to the size of curscr. */
	      if (mr < nrows)
		   nrows = mr;
	      if (mc < ncols)
		   ncols = mc;
	      /* Center dimensions. */
	      if (row == -1)
		   row = (mr-nrows)/2;
	      if (col == -1)
		   col = (mc-ncols)/2;
	      /* The window must fit entirely in curscr. */
	      if (mr < row+nrows)
		   row = 0;
	      if (mc < col+ncols)
		   col = 0;
	      *work = newwin(nrows, ncols, row, col);
	      if (*work == NULL)
		   return (-1);
	      if ((*save = dupwin(*work)) == NULL) {
		   return (-1);
	      overwrite(curscr, *save);
	      return (0);
	  * Restore the region covered by a pop-up window.
	  * Delete the working window and the saved window.
	  * This function is the complement to popup().	 Return
	  * 0 for success or -1 for an error.
	 popdown(work, save)
	 WINDOW *work, *save;
	      (void) wnoutrefresh(save);
	      (void) delwin(save);
	      (void) delwin(work);
	      return (0);
	  * Compute the size of a dialog box that would fit around
	  * the string.
	 dialsize(str, nrows, ncols)
	 char *str;
	 int *nrows, *ncols;
	      int rows, cols, col;
	      for (rows = 1, cols = col = 0; *str != '\0'; ++str) {
		   if (*str == '\n') {
			if (cols < col)
			    cols = col;
			col = 0;
		   } else {
	       if (cols < col)
		    cols = col;
	       *nrows = rows;
	       *ncols = cols;
	  * Write a string into a dialog box.
	 dialfill(w, s)
	 WINDOW *w;
	 char *s;
	      int row;
	      (void) wmove(w, 1, 1);
	      for (row = 1; *s != '\0'; ++s) {
		   (void) waddch(w, *((unsigned char*) s));
		   if (*s == '\n')
			wmove(w, ++row, 1);
	      box(w, 0, 0);
	 char *str;
	      WINDOW *work, *save;
	      int nrows, ncols, row, col;
	      /* Figure out size of window. */
	      dialsize(str, &nrows, &ncols);
	      /* Create a centered working window with extra */
	      /* room for a border. */
	      (void) popup(&work, &save, nrows+2, ncols+2, -1, -1);
	      /* Write text into the working window. */
	      dialfill(work, str);
	      /* Pause.	 Remember that wgetch() will do a wrefresh() */
	      /* for us. */
	      (void) wgetch(work);
	      /* Restore curscr and free windows. */
	      (void) popdown(work, save);
	      /* Redraw curscr to remove window from physical screen. */
	      (void) doupdate();

       See attributes(5) for descriptions of the following attributes:

       │Interface Stability │ Standard	      │
       │MT-Level	    │ Unsafe	      │

       copywin(3XCURSES),	libcurses(3XCURSES),	   wadd_wch(3XCURSES),
       win_wch(3XCURSES), attributes(5), standards(5)

				  Jun 5, 2002		     OVERLAY(3XCURSES)

List of man pages available for SmartOS

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
Vote for polarhome
Free Shell Accounts :: the biggest list on the net