Exemplo n.º 1
0
/*
 * Delete the character under the cursor; all characters to the right of
 * the cursor on the same line are moved to the left by one position and
 * the last character on the line is filled with a blank. The cursor
 * position does not change.
 */
int
wdelch(WINDOW *w)
{
	int	next, width, y, x;

	y = w->_cury;
	x = w->_curx;

	next = __m_cc_next(w, y, x);
	x = __m_cc_first(w, y, x);

	/* Determine the character width to delete. */
	width = __m_cc_width(&w->_line[y][x]);

	/* Shift line left to erase the character under the cursor. */
	(void) memcpy(&w->_line[y][x], &w->_line[y][next],
		(w->_maxx - next) * sizeof (**w->_line));

	/*
	 * Add blank(s) to the end of line based on the width
	 * of the character that was deleted.
	 */
	(void) __m_cc_erase(w, y, w->_maxx - width, y, w->_maxx - 1);

	/* Set dity region markers. */
	if (x < w->_first[y])
		w->_first[y] = (short) x;
	w->_last[y] = w->_maxx;

	WSYNC(w);

	return (WFLUSH(w));
}
Exemplo n.º 2
0
/*
 * Erase from the current cursor location right and down to the end of
 * the screen. The cursor position is not changed.
 */
int
clrtoeol(void)
{
	int x, value;

	x = __m_cc_first(stdscr, stdscr->_cury, stdscr->_curx);
	value = __m_cc_erase(stdscr,
		stdscr->_cury, x, stdscr->_cury, stdscr->_maxx - 1);

	return ((value == 0) ? OK : ERR);
}
Exemplo n.º 3
0
/*
 * Erase from the current cursor position in the window to the right
 * margin.
 */
int
wclrtoeol(WINDOW *w)
{
	int	x;

	x = __m_cc_first(w, w->_cury, w->_curx);
	if (__m_cc_erase(w, w->_cury, x, w->_cury, w->_maxx-1) != 0)
		return (ERR);

	WSYNC(w);

	return (WFLUSH(w));
}
Exemplo n.º 4
0
/*f
 * Erase from the current cursor location right and down to the end of
 * the screen. The cursor position is not changed.
 */
int
clrtobot()
{
	int x, value;

#ifdef M_CURSES_TRACE
	__m_trace("clrtobot(void) from (%d, %d)", stdscr->_cury, stdscr->_curx);
#endif

	x = __m_cc_first(stdscr, stdscr->_cury, stdscr->_curx);
	value = __m_cc_erase(
		stdscr, stdscr->_cury, x, stdscr->_maxy-1, stdscr->_maxx-1
	);

	return __m_return_code("clrtobot", value == 0 ? OK : ERR);
}
Exemplo n.º 5
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));
}
Exemplo n.º 6
0
/*
 * Update newscr with the given pad.  This allows newscr to
 * be updated with several windows before doing a doupdate().
 *
 * MKS extension permits windows that are not pads to be refreshed
 * using this function.
 */
int
pnoutrefresh(WINDOW *pad, int pminr, int pminc, int sminr, int sminc,
	int smaxr, int smaxc)
{
	WINDOW	*ns;
	int	row, dy, dx;

	ns = __m_screen->_newscr;

	/* Adjust regions to be within bounds. */
	if (pminr < 0)
		pminr = 0;
	if (pminc < 0)
		pminc = 0;
	if (sminr < 0)
		sminr = 0;
	if (sminc < 0)
		sminc = 0;
	if (ns->_maxy <= smaxr)
		smaxr = ns->_maxy-1;
	if (ns->_maxx <= smaxc)
		smaxc = ns->_maxx-1;

	if (pad->_maxy <= pminr || pad->_maxx <= pminc ||
		smaxr < sminr || smaxc < sminc)
		return (ERR);

	/* Clear displayed region. */
	for (row = sminr; row < smaxr; ++row) {
		(void) __m_cc_erase(ns, row, sminc, row, smaxc);
	}

	/*
	 * Determine the proper maximums in case smaxr and smaxc mapped
	 * beyond the bottom and right-hand edges of the pad.
	 */
	if (pad->_maxx <= pminc + smaxc-sminc + 1)
		smaxc = sminc + pad->_maxx - 1 - pminc;
	if (pad->_maxy <= pminr + smaxr-sminr + 1)
		smaxr = sminr + pad->_maxy - 1 - pminr;

	/* Remember refresh region (inclusive). */
	pad->_refy = (short) pminr;
	pad->_refx = (short) pminc;
	pad->_sminy = (short) sminr;
	pad->_sminx = (short) sminc;
	pad->_smaxy = (short) smaxr;
	pad->_smaxx = (short) smaxc;

	(void) copywin(pad, ns, pminr, pminc, sminr, sminc, smaxr, smaxc, 0);

	/* Last refreshed window controls W_LEAVE_CURSOR flag. */
	ns->_flags &= ~W_LEAVE_CURSOR;
	ns->_flags |= pad->_flags &
		(W_CLEAR_WINDOW | W_REDRAW_WINDOW | W_LEAVE_CURSOR);
	pad->_flags &= ~(W_CLEAR_WINDOW | W_REDRAW_WINDOW);

	/* Figure out where to leave the cursor. */
	dy = pad->_cury - pminr + pad->_begy;
	dx = pad->_curx - pminc + pad->_begx;

	ns->_cury = (dy < 0) ? 0 :
		((ns->_maxy <= dy) ? ns->_maxy - 1 : (short) dy);
	ns->_curx = (dx < 0) ? 0 :
		((ns->_maxx <= dx) ? ns->_maxx - 1 : (short) dx);

	return (OK);
}
Exemplo n.º 7
0
int
slk_wset(int index, const wchar_t *label, int justify)
{
	cchar_t cc;
	short (*k)[2];
	int i, width, code = ERR;
	wchar_t wcs[M_CCHAR_MAX * 8 + 1], *wp;
	char mbs[MB_LEN_MAX * ((1 + M_CCHAR_MAX) * 8) + 1];

	/* 
	 * These label start columns assume 80 columns in order to
	 * fit 8 _slk._labels of 8 columns.
	 */
	static short format[][8] = {
		{ 0, 10, 20, 31, 41, 52, 62, 72 },
		{ 0, 10, 20, 30, 42, 52, 62, 72 },
	};

#ifdef M_CURSES_TRACE
	__m_trace("slk_wset(%d, %p, %d)", index, label, justify);
#endif

	if (index < 1 || 8 < index || justify < 0 || 2 < justify)
		goto error1;

	if (label == (wchar_t *) 0)
		label = M_MB_L("");

	/* Copy the characters that fill the first 8 columns of the label. */
	for (wp = wcs, width = 0; label != '\0'; label += i, wp += cc._n) {
		if ((i = __m_wcs_cc(label, A_NORMAL, 0, &cc)) < 0)
			goto error1;	


		if (8 < (width += __m_cc_width(&cc)))
			break;

		(void) wcsncpy(wp, cc._wc, cc._n);
	}
	*wp = '\0';

	if (wcstombs(mbs, wcs, sizeof mbs) == (size_t) -1)
		goto error1;

	/* Remember the new label. */
	__m_screen->_slk._justify[index] = (short) justify;
	if (__m_screen->_slk._labels[index] != (char *) 0)
		free(__m_screen->_slk._labels[index]);
	if ((__m_screen->_slk._labels[index] = m_strdup(mbs)) == (char *) 0)
		goto error1;
	
	if (__m_screen->_slk._w != (WINDOW *) 0) {
		/* Write the justified label into the slk window. */
		i = format[__m_slk_format][index];
		(void) __m_cc_erase(__m_screen->_slk._w, 0, i, 0, i + 7);

		switch (justify) {
		case 0:
			break;
		case 1:
			i += width / 2;
			break;
		case 2:
			i = i + 8 - width;
			break;
		}

		(void) mvwaddstr(__m_screen->_slk._w, 0, i, mbs);
	} else if (plab_norm != (char *) 0) {
		(void) tputs(
			tparm(
				plab_norm, (long) index, (long) mbs,
				0L, 0L, 0L, 0L, 0L, 0L, 0L
			), 1, __m_outc
		);
	} else if (pkey_plab != (char *) 0) {
		/* Lookup multibyte sequence for the function key. */
		for (i = KEY_F(index), k = __m_keyindex; (*k)[1] != i; ++k)
			;

		if (cur_term->_str[**k] != (char *) 0) {
			(void) tputs(
				tparm(
					pkey_plab, (long) index, 
					(long) cur_term->_str[**k], 
					(long) mbs, 0L, 0L, 0L, 0L, 0L, 0L
				), 1, __m_outc
			);
		}
	}

	code = OK;
error1:
	return __m_return_code("slk_wset", code);
}