Example #1
0
/*
 * wredrawln --
 *	Mark count lines starting at start as corrupted.  Implemented using
 *	wtouchln().
 */
int wredrawln(WINDOW *win, int start, int count)
{
#ifdef DEBUG
	__CTRACE(__CTRACE_LINE, "wredrawln: (%p, %d, %d)\n", win, start, count);
#endif
	return wtouchln(win, start, count, 1);
}
Example #2
0
/*
 * redrawwin --
 *	Mark entire window as corrupted.  Implemented using wtouchln().
 */
int
redrawwin(WINDOW *win)
{
#ifdef DEBUG
	__CTRACE(__CTRACE_LINE, "redrawwin: (%p)\n", win);
#endif
	return wtouchln(win, 0, win->maxy, 1);
}
Example #3
0
/*
 * untouchwin --
 *	 Make it look like the window has not been changed.
 */
int
untouchwin(WINDOW *win)
{
#ifdef DEBUG
	__CTRACE(__CTRACE_LINE, "untouchwin: (%p)\n", win);
#endif
	return wtouchln(win, 0, win->maxy, 0);
}
Example #4
0
static void
_useceod(int topy, int boty)
{
	short	*begns, *begch;

	/* skip lines already blanked */
	begch = _virtscr->_firstch + topy;
	begns = _BEGNS + topy;
	for (; topy < boty; ++topy, ++begns, ++begch)
		if (*begns < scrco || *begch == _REDRAW)
			break;
		else
			*begch = _INFINITY;

	/* nothing to do */
	if (topy + 1 >= boty)
		return;

	/* see if bottom is clear */
	for (begns = _BEGNS + boty; boty < scrli; ++boty, ++begns)
		if (*begns < scrco)
			return;

	/* use clear-screen if appropriate */
	if (topy == 0) {
		/* SS: colors */
		if (back_color_erase)
			_turn_off_background();

		_PUTS(clear_screen, scrli);
		cy = 0; cx = 0;
		(void) werase(curscr);
	} else

		/* use clear-to-end-of-display or delete lines */
		if (clr_eos || (parm_delete_line && !memory_below)) {
			(void) mvcur(cy, cx, topy, 0);
			/* LINTED */
			cy = (short) topy;
			cx = 0;
			/* SS: colors */
			if (back_color_erase)
				_turn_off_background();
			_PUTS(clr_eos ? clr_eos : tparm_p1(parm_delete_line,
			    scrli - topy), scrli - topy);

			/* update curscr */
			/* LINTED */
			curscr->_cury = (short) topy;
			curscr->_curx = 0;
			(void) wclrtobot(curscr);
		} else
			/* no hardware support */
			return;

		/* correct the update structure */
		(void) wtouchln(_virtscr, topy, scrli, FALSE);
}
Example #5
0
/********************************************************\
 * Description:	Similar to popupWin, only it prmpts the	*
 *		user for a character, such as (y/n)	*
 * Returns:	Returns character pressed		*
\********************************************************/
short int questionWin(char *msg)
{
    WINDOW *tmpwin;
    short int ch;

    int y = (LINES / 2) - 3,				/* calc location      */
        len = strlen(msg),
        x = (COLS - len)/2;

    y = (y < 2) ? 2 : y;				/* minimum height     */

    tmpwin = drawbox(y, x, 5, len + 6);			/* create window      */

    mvwprintw(tmpwin,2,3, msg);
    wmove(tmpwin,2,len+4);
    wrefresh(tmpwin);

    ch = wgetch(tmpwin);

    delwin(tmpwin);

    wtouchln(windows->hex, y - 1, 5, 1);		/* touch the lines    */
    wtouchln(windows->ascii, y - 1, 5, 1);		/* covered by win     */
    wtouchln(windows->address, y - 1, 5, 1);
    wtouchln(windows->hex_outline, y, 5, 1);
    wtouchln(windows->ascii_outline, y, 5, 1);
    wtouchln(windows->scrollbar, y, 5, 1);

    refreshall(windows);				/* refresh all wins   */

    doupdate();

    return ch;
}
Example #6
0
int
mvwin(WINDOW *win, int by, int bx)
{
	if ((by + win->_maxy) > LINES || (bx + win->_maxx) > COLS ||
	    by < 0 || bx < 0)
		return (ERR);
	/*LINTED*/
	win->_begy = (short) by;
	/*LINTED*/
	win->_begx = (short) bx;
	(void) wtouchln(win, 0, win->_maxy, -1);
	return (win->_immed ? wrefresh(win) : OK);
}
Example #7
0
int 
slk_touch()
{
	int code = ERR;

#ifdef M_CURSES_TRACE
	__m_trace("slk_touch(void)");
#endif

	if (__m_screen->_slk._w != (WINDOW *) 0)
		code = wtouchln(__m_screen->_slk._w, 0, 1, 1);

	return __m_return_code("slk_touch", code);
}
Example #8
0
void LYsubwindow( WINDOW *param )
{
  if ( param )
  {
    my_subwindow = param;
    keypad( my_subwindow, 1 );
    curses_w_style( my_subwindow, s_menu_bg, 1 );
  {
    long b = LYgetattrs( my_subwindow );
    wbkgd( my_subwindow, b | 32 );
    curses_w_style( my_subwindow, s_menu_bg, 0 );
    scrollok( my_subwindow, 1 );
  }
  }
  else
  {
    wtouchln( LYwin, 0, -1, 1 );
    delwin( my_subwindow );
    my_subwindow = 0;
  }
  return;
}
Example #9
0
void LYrefresh( void )
{
  if ( stdscr != LYwin )
  {
    int y = -1, x = -1;
    if ( LYcols - ( LYShowScrollbar != 0 ) < x )
      x = LYcols - ( LYShowScrollbar != 0 );
    wmove( stdscr, y, x );
    wnoutrefresh( stdscr );
    pnoutrefresh( LYwin, 0, LYshiftWin, 0, 0, LYlines, LYscreenWidth( ) + -1 );
    if ( my_subwindow )
    {
      wtouchln( my_subwindow, 0, -1, 1 );
      wnoutrefresh( my_subwindow );
    }
    doupdate( );
  }
  else
  {
    wrefresh( stdscr );
  }
  return;
}
Example #10
0
/******************************************************\
 * Description:	Creates a "window popup" where given  *
 * 		the parameters, and message, it       *
 * 		creates a window and displays the     *
 * 		message.  Some current restrictions   *
 * 		are that it must only be one line, and*
 * 		it is assumed that the text is padded *
 * 		with one space left for the border and*
 * 		another space left for aesthetics     *
\******************************************************/
void popupWin(char *msg, int time)
{
    WINDOW *tmpwin;

    int y = (LINES / 2) - 3,				/* calc location      */
        len = strlen(msg),
        x = (COLS - len)/2;

    y = (y < 2) ? 2 : y;				/* minimum height     */
    time = (!time) ? 2 : time;

    tmpwin = drawbox(y, x, 5, len + 6);			/* create window      */

    keypad(tmpwin, TRUE);

    mvwprintw(tmpwin,2,3, msg);				/* output mesg        */
    wmove(tmpwin,2,len+4);
    wrefresh(tmpwin);

    if (time == -1)
        wgetch(tmpwin);
    else
        sleep(time);					/* wait               */

    delwin(tmpwin);

    wtouchln(windows->hex, y - 1, 5, 1);		/* touch windows      */
    wtouchln(windows->ascii, y - 1, 5, 1);
    wtouchln(windows->address, y - 1, 5, 1);
    wtouchln(windows->hex_outline, y, 5, 1);
    wtouchln(windows->ascii_outline, y, 5, 1);
    wtouchln(windows->scrollbar, y, 5, 1);

    refreshall(windows);				/* refresh all wins   */

    doupdate();
}
Example #11
0
/*
 * Create and return a pointer to a new window or pad.
 *
 * For a window, provide the dimensions and location of the upper
 * left hand corner of the window.  If either dimension is zero (0)
 * then the default sizes will be LINES-begy and COLS-begx.
 *
 * For a pad, provide the dimensions and -1 for begy and begx.
 * If either dimension is zero (0) then the default sizes will be
 * LINES and COLS.
 *
 * If parent is not null, then create a sub-window of the parent
 * window.
 */
WINDOW *
__m_newwin(WINDOW *parent,
	int nlines, int ncols, int begy, int begx)
{
	WINDOW	*w;
	int	x, y, dx, dy;
	int	isPad;

	isPad = ((begy < 0) && (begx < 0)) ||
		(parent && (parent->_flags & W_IS_PAD));

	if (parent == NULL) {
		/* Check for default dimensions. */
		if (nlines == 0) {
			nlines = lines;
			if (0 <= begy)
				nlines -= begy;
		}
		if (ncols == 0) {
			ncols = columns;
			if (0 <= begx)
				ncols -= begx;
		}
	} else {
		/*
		 * Make sure window dimensions remain within parent's
		 * window so that the new subwindow is a proper subset
		 * of the parent.
		 */
		if (begy < parent->_begy || begx < parent->_begx ||
			parent->_maxy < (begy-parent->_begy) + nlines ||
			parent->_maxx < (begx-parent->_begx) + ncols)
			goto error_1;

		/*
		 * If either dimension is zero (0), use the max size
		 * for the dimension from the parent window less the
		 * subwindow's starting location.
		 */
		if (nlines == 0)
			nlines = parent->_maxy - (begy - parent->_begy);
		if (ncols == 0)
			ncols = parent->_maxx - (begx - parent->_begx);
	}

	if (!isPad) {
		/* Check that a window fits on the screen. */
		if (0 <= begy) {
			if (lines < begy + nlines) {
				goto error_1;
			}
		}
		if (0 <= begx) {
			if (columns < begx + ncols) {
				goto error_1;
			}
		}
	}

	w = (WINDOW *) calloc(1, sizeof (*w));
	if (w == NULL)
		goto error_1;

	w->_first = (short *) calloc((size_t) (nlines + nlines),
		sizeof (*w->_first));
	if (w->_first == NULL)
		goto error_2;

	w->_last = &w->_first[nlines];

	w->_line = (cchar_t **) calloc((size_t) nlines, sizeof (*w->_line));
	if (w->_line == NULL)
		goto error_2;

	/* Window rendition. */
	(void) setcchar(&w->_bg, L" ", WA_NORMAL, 0, (void *) 0);
	(void) setcchar(&w->_fg, L" ", WA_NORMAL, 0, (void *) 0);
	if (parent == NULL) {
		w->_base = (cchar_t *) malloc((size_t) (nlines * ncols) *
			sizeof (*w->_base));
		if (w->_base == NULL)
			goto error_2;

		w->_line[0] = w->_base;
		for (y = 0; y < nlines; y++) {
			if (y)
				w->_line[y] = &w->_line[y-1][ncols];
			for (x = 0; x < ncols; ++x) {
				w->_line[y][x] = w->_bg;
			}
		}
	} else {
		/*
		 * The new window's origin (0,0) maps to (begy, begx) in the
		 * parent's window.  In effect, subwin() is a method by which
		 * a portion of a parent's window can be addressed using a
		 * (0,0) origin.
		 */
		dy = begy - parent->_begy;
		dx = begx - parent->_begx;

		w->_base = NULL;

		for (y = 0; y < nlines; ++y)
			w->_line[y] = &parent->_line[dy++][dx];
	}

	w->_begy = (short) begy;
	w->_begx = (short) begx;
	w->_cury = w->_curx = 0;
	w->_maxy = (short) nlines;
	w->_maxx = (short) ncols;
	w->_parent = parent;

	/* Software scroll region. */
	w->_top = 0;
	w->_bottom = (short) nlines;
	w->_scroll = 0;

	/* Window initially blocks for input. */
	w->_vmin = 1;
	w->_vtime = 0;
	w->_flags = W_USE_TIMEOUT;

	/* Determine window properties. */
	if (isPad) {
		/* This window is a PAD */
		w->_flags |= W_IS_PAD;	/* Inherit PAD attribute */
		if (((begy < 0) && (begx < 0)) ||
			(parent && !(parent->_flags & W_IS_PAD))) {
			/* Child of a normal window */
			w->_begy = w->_begx = 0;
			/*
			 * Map to upper left portion of
			 * display by default (???)
			 */
			w->_sminy = w->_sminx = 0;
			w->_smaxx = w->_maxx;
			w->_smaxy = w->_maxy;
		}
	} else if (begx + ncols == columns) {
		/* Writing to last column should trigger auto-margin wrap. */
		w->_flags |= W_END_LINE;

		if (begx == 0) {
			w->_flags |= W_FULL_LINE;

			if (begy == 0 && nlines == lines)
				w->_flags |= W_FULL_WINDOW;
		}

		/* Will writing to bottom-right triggers scroll? */
		if (begy + nlines == lines)
			w->_flags |= W_SCROLL_WINDOW;
	}

	/* Initial screen clear for full screen windows only. */
	if (w->_flags & W_FULL_WINDOW) {
		w->_flags |= W_CLEAR_WINDOW;
		/* Reset dirty region markers. */
		(void) wtouchln(w, 0, w->_maxy, 0);
	} else {
		if (!parent) {
			/* Do not erase sub windows */
			(void) werase(w);
		}
	}

	return (w);
error_2:
	(void) delwin(w);
error_1:
	return (NULL);
}
EIF_INTEGER c_ecurses_wtouchln (EIF_POINTER w, EIF_INTEGER  y, EIF_INTEGER x, EIF_BOOLEAN changed)
{
    return wtouchln( ((WINDOW *) w) , (int) y,(int) x,(int) changed) ;
};
Example #13
0
/*
 * For positive n scroll the window up n lines (line i+n becomes i);
 * otherwise scroll the window down n lines.
 */
int
wscrl(WINDOW *w, int n)
{
	int	start, finish, to;

	if (!(w->_flags & W_CAN_SCROLL))
		return (ERR);

	if (n == 0)
		return (OK);

	if (w->_parent) {
		/* Sub-window should not shuffle pointers (parent owns them) */
		int	row;
		cchar_t	save;
		int	first;

		if (n > 0) {
			for (row = w->_top; row < w->_bottom; row++) {
				if (row < w->_bottom - n) {
					if (!w->_line[row+n][0]._f)	{
						/*
						 * Tail end of
						 * a multi-col-char
						 */
						(void) __m_cc_erase(w, row + n,
							0, row + n, 0);
					}
					/*
					 * Erase trailing multi-col-chars
					 * where they hang into parent window
					 */
					first = __m_cc_first(w, row + n,
						w->_maxx - 1);
					save = w->_line[row + n][first];
					(void) __m_cc_erase(w, row + n,
						first, row + n, first);
					w->_line[row + n][first] = save;
					(void) memcpy(w->_line[row],
						w->_line[row + n],
						sizeof (cchar_t) * w->_maxx);
				} else {
					(void) __m_cc_erase(w, row, 0,
						w->_bottom -1, w->_maxx - 1);
					break;
				}
			}
		} else {
			abort();
		}
	} else {
		/*
		 * Shuffle pointers in order to scroll.  The region
		 * from start to finish inclusive will be moved to
		 * either the top or bottom of _line[].
		 */
		if (0 < n) {
			start = w->_top;
			finish = w->_top + n - 1;
			to = w->_bottom;
		} else {
			start = w->_bottom + n;
			finish = w->_bottom - 1;
			to = w->_top;
		}

		/* Blank out new lines. */
		(void) __m_cc_erase(w, start, 0, finish, w->_maxx - 1);

		/* Scroll lines by shuffling pointers. */
		(void) __m_ptr_move((void **) w->_line, w->_maxy,
			start, finish, to);
	}

	if ((w->_flags & W_FULL_WINDOW) &&
		w->_top == 0 && w->_bottom == w->_maxy)
		w->_scroll += (short) n;
	else
		w->_scroll = 0;

	(void) wtouchln(w, 0, w->_maxy, 1);
	wtouchln_hard(w, 0, w->_maxy);

#ifdef	BREAKS_fimmedok_fimmedok1_2
	w->_flags |= W_FLUSH;
#endif	/* BREAKS_fimmedok_fimmedok1_2 */

	WSYNC(w);

	return (WFLUSH(w));
}
Example #14
0
int
wrefresh(WINDOW *win)
{

	short	*bnsch, *ensch;
	SLK_MAP	*slk;
	int	wx, wy, nc, boty, clby, idby, *hs, curwin;

	curwin = (win == curscr);

	/* don't allow curscr refresh if the screen was just created */

	if (curwin && curscr->_sync)
		return (OK);

	/* go thru _stdbody */
	if (!curwin && (win != _virtscr))
		(void) wnoutrefresh(win);

	/* if there is typeahead */
	if ((_INPUTPENDING = _chkinput()) == TRUE) {
		if (curwin)
			curscr->_clear = TRUE;
		return (OK);
	}

	if (curwin || curscr->_clear)
		_virtscr->_clear = TRUE;

	/* save curscr cursor coordinates */
	cy = curscr->_cury;
	cx = curscr->_curx;

	/* to simplify code in some cases */
	marks = _MARKS;
	color_marks = _COLOR_MARKS;
	scrli = curscr->_maxy;
	scrco = curscr->_maxx;
	slk = SP->slk;

	outchcount = 0;

	/* make sure we're in program mode */
	if (SP->fl_endwin) {
		/* If endwin is equal to 2 it means we just did a newscreen. */
		if (SP->fl_endwin == TRUE) {
			(void) reset_prog_mode();
			if (SP->kp_state)
				(void) tputs(keypad_xmit, 1, _outch);
			if (slk)
				(*_do_slk_tch)();
			if (SP->fl_meta)
				(void) tputs(meta_on, 1, _outch);
			if (cur_term->_cursorstate != 1)
				_PUTS(cur_term->cursor_seq[cur_term->
				    _cursorstate], 0);
		}
		_PUTS(enter_ca_mode, 1);
		(void) tputs(ena_acs, 1, _outch);

		if (exit_attribute_mode)
			_PUTS(tparm_p0(exit_attribute_mode), 1);
		else
			/*
			 * If there is no exit_attribute mode, then vidupdate
			 * could only possibly turn off one of the below three
			 * so that's all we ask it turn off.
			*/
			vidupdate(A_NORMAL, (A_ALTCHARSET | A_STANDOUT |
			    A_UNDERLINE), _outch);

		SP->fl_endwin = FALSE;

#ifdef	_VR2_COMPAT_CODE
		_endwin = (char) FALSE;
#endif	/* _VR2_COMPAT_CODE */
	}

	/* clear the screen if required */
	if (_virtscr->_clear) {
/* SS: colors */
		if (back_color_erase)
			_turn_off_background();

		_PUTS(clear_screen, scrli);
		cy = cx = curscr->_curx = curscr->_cury = 0;

		/* _sync indicates that this a new screen */
		if (!curscr->_sync)
			(void) werase(curscr);
		else {
			nc = scrco / BITSPERBYTE - (scrco %
			    BITSPERBYTE ? 0 : 1);
			wy = scrli - 1;
			bnsch = _BEGNS; ensch = _ENDNS;
			hs = _CURHASH;
			for (; wy >= 0; --wy) {
				*bnsch++ = scrco;
				*ensch++ = -1;
				*hs++ = 0;
				if (marks)
					for (wx = nc; wx >= 0; --wx)
						marks[wy][wx] = 0;
			}
		}

		_virtscr->_clear = curscr->_sync = curscr->_clear = FALSE;
		if (slk)
			(*_do_slk_tch)();

		/* pretend _virtscr has been totally changed */
		(void) wtouchln(_virtscr, 0, scrli, -1);
		_VIRTTOP = 0;
		_VIRTBOT = scrli - 1;

		/* will not do clear-eod or ins/del lines */
		clby = idby = scrli;
	} else
		clby = idby = -1;

	/* Software soft labels; if _changed == 2, slk's are in clear mode. */
	if (slk && slk->_win && (slk->_changed == TRUE))
		(*_do_slk_noref)();

	/* do line updating */
	_virtscr->_clear = FALSE;
	wy = _VIRTTOP;
	boty = _VIRTBOT + 1;
	bnsch = _virtscr->_firstch + wy;
	ensch = _virtscr->_lastch + wy;

	for (; wy < boty; ++wy, ++bnsch, ++ensch) {
		/* this line is up-to-date */
		if (*bnsch >= scrco)
			goto next;

		/* there is type-ahead */
		if (!curwin && (_INPUTPENDING = _chkinput()) == TRUE) {
			/* LINTED */
			_VIRTTOP = (short) wy;
			goto done;
		}

		if (clby < 0) {
			/* now we have to work, check for ceod */
			clby = _getceod(wy, boty);

			/* check for insert/delete lines */
			if (_virtscr->_use_idl)
				idby = (*_setidln)();
		}

		/* try clear-to-eod */
		if (wy == clby)
			_useceod(wy, boty);

		/* try ins/del lines */
		if (wy == idby) {
			curscr->_cury = cy;
			curscr->_curx = cx;
			(*_useidln)();
			cy = curscr->_cury;
			cx = curscr->_curx;
		}

		if (*bnsch < scrco)
			_updateln(wy);

next:
		*bnsch = _INFINITY;
		*ensch = -1;
	}

	/* do hardware soft labels; if _changed == 2, */
	/* slk's are in clear mode. */
	if (slk && (slk->_changed == TRUE) && !(slk->_win))
		(*_do_slk_ref)();

	/* move cursor */
	wy = _virtscr->_cury;
	wx = _virtscr->_curx;
	if (wy != cy || wx != cx) {
		(void) mvcur(cy, cx, wy, wx);
		/* LINTED */
		cy = (short) wy;
		/* LINTED */
		cx = (short) wx;
	}

	/* reset the flags */
	curscr->_clear = FALSE;
	_virtscr->_use_idl = FALSE;
	_virtscr->_use_idc = TRUE;
	_INPUTPENDING = FALSE;

	/* virtual image is now up-to-date */
	_VIRTTOP = scrli;
	_VIRTBOT = -1;

done :
	curscr->_cury = cy;
	curscr->_curx = cx;
	(void) fflush(SP->term_file);
	return (outchcount);
}
Example #15
0
void LYtouchline( int row )
{
  int edx;
  wtouchln( LYwin, row, ebp_16, ebp_16 );
  return;
}
Example #16
0
NCURSES_EXPORT(int) (touchline) (WINDOW * a1, int a2, int z)
{
	T((T_CALLED("touchline(%p,%d,%d)"), (const void *)a1, a2, z)); returnCode(wtouchln((a1), a2, z, 1));
}
Example #17
0
NCURSES_EXPORT(int) (untouchwin) (WINDOW * z)
{
	T((T_CALLED("untouchwin(%p)"), (const void *)z)); returnCode(wtouchln((z), 0, ((z) ? ((z)->_maxy + 1) : (-1)), 0));
}
Example #18
0
int chkr_wtouchln(WINDOW *win,int arg1,int arg2,int arg3)
{
   CHECK_WIN(win);
   return(wtouchln(win,arg1,arg2,arg3));
}