예제 #1
0
_nc_insert_wch(WINDOW *win, const cchar_t *wch)
{
    int cells = wcwidth(CharOf(CHDEREF(wch)));
    int cell;
    int code = OK;

    if (cells < 0) {
	code = winsch(win, (chtype) CharOf(CHDEREF(wch)));
    } else {
	if (cells == 0)
	    cells = 1;

	if (win->_curx <= win->_maxx) {
	    struct ldat *line = &(win->_line[win->_cury]);
	    NCURSES_CH_T *end = &(line->text[win->_curx]);
	    NCURSES_CH_T *temp1 = &(line->text[win->_maxx]);
	    NCURSES_CH_T *temp2 = temp1 - cells;

	    CHANGED_TO_EOL(line, win->_curx, win->_maxx);
	    while (temp1 > end)
		*temp1-- = *temp2--;

	    *temp1 = _nc_render(win, *wch);
	    for (cell = 1; cell < cells; ++cell) {
		SetWidecExt(temp1[cell], cell);
	    }

	    win->_curx = (NCURSES_SIZE_T) (win->_curx + cells);
	}
    }
    return code;
}
예제 #2
0
// Force a character to the input screen
void Terminal::in_char_(const char input_){
	cursX++;
	//If in insert mode we overwite the character otherwise insert it.
	if (cmd.GetInsertMode()) waddch(input_window, input_);
	else winsch(input_window, input_);
	update_cursor_();
	refresh_();
}
예제 #3
0
int
insch(chtype ch)
{
	int code;

	code = winsch(stdscr, ch);

	return (code);
}
예제 #4
0
파일: insch.c 프로젝트: bugengine/BugEngine
int mvinsch(int y, int x, chtype ch)
{
    PDC_LOG(("mvinsch() - called\n"));

    if (move(y, x) == ERR)
        return ERR;

    return winsch(stdscr, ch);
}
예제 #5
0
파일: insch.c 프로젝트: bugengine/BugEngine
int mvwinsch(WINDOW *win, int y, int x, chtype ch)
{
    PDC_LOG(("mvwinsch() - called\n"));

    if (wmove(win, y, x) == ERR)
        return ERR;

    return winsch(win, ch);
}
예제 #6
0
int
mvinsch(int y, int x, chtype ch)
{
	int code;

	if ((code = wmove(stdscr, y, x)) == OK)
		code = winsch(stdscr, ch);

	return (code);
}
예제 #7
0
int
mvwinsch(WINDOW *w, int y, int x, chtype ch)
{
	int code;

	if ((code = wmove(w, y, x)) == OK)
		code = winsch(w, ch);

	return (code);
}
예제 #8
0
파일: insch.c 프로젝트: bugengine/BugEngine
int winsrawch(WINDOW *win, chtype ch)
{
    PDC_LOG(("winsrawch() - called: win=%p ch=%x "
             "(char=%c attr=0x%x)\n", win, ch,
             ch & A_CHARTEXT, ch & A_ATTRIBUTES));

    if ((ch & A_CHARTEXT) < ' ' || (ch & A_CHARTEXT) == 0x7f)
        ch |= A_ALTCHARSET;

    return winsch(win, ch);
}
예제 #9
0
wins_nwstr(WINDOW *win, const wchar_t * wstr, int n)
{
    int code = ERR;
    NCURSES_SIZE_T oy;
    NCURSES_SIZE_T ox;
    const wchar_t *cp;

    T((T_CALLED("wins_nwstr(%p,%s,%d)"), win, _nc_viswbufn(wstr,n), n));

    if (win != 0
	&& wstr != 0
	&& wcwidth(*wstr) > 0) {
	code = OK;
	if (n < 1)
	    n = wcslen(wstr);
	oy = win->_cury;
	ox = win->_curx;
	for (cp = wstr; *cp && ((cp - wstr) < n); cp++) {
	    NCURSES_CH_T wch;
	    SetChar2(wch, *cp);
	    if (*cp == '\n' || *cp == '\r' || *cp == '\t' || *cp == '\b') {
		_nc_waddch_nosync(win, wch);
	    } else if (is7bits(*cp) && iscntrl(*cp)) {
		winsch(win, ' ' + (chtype) (*cp));
		winsch(win, (chtype) '^');
		win->_curx += 2;
	    } else if (wins_wch(win, &wch) == ERR
		       || win->_curx > win->_maxx) {
		break;
	    }
	}

	win->_curx = ox;
	win->_cury = oy;
	_nc_synchook(win);
	code = OK;
    }
    returnCode(code);
}
예제 #10
0
static int
WInsCh(WINDOW *win, chtype ch)
{
    int code;
    cchar_t tmp_cchar;

    if (ConvertCh(ch, &tmp_cchar)) {
	code = wins_wch(win, &tmp_cchar);
    } else {
	code = winsch(win, ch);
    }
    return code;
}
예제 #11
0
NCURSES_EXPORT(int) (mvwinsch) (WINDOW * a1, int a2, int a3, chtype z)
{
	T((T_CALLED("mvwinsch(%p,%d,%d,%s)"), (const void *)a1, a2, a3, _tracechtype2(3,z))); returnCode((wmove(a1,a2,a3) == (-1) ? (-1) : winsch(a1,z)));
}
예제 #12
0
int
mvwinsch(WINDOW *win, int y, int x, chtype c)
{
	return (wmove(win, y, x) == ERR ? ERR : winsch(win, c));
}
예제 #13
0
파일: insch.c 프로젝트: bugengine/BugEngine
int winsch(WINDOW *win, chtype ch)
{
    int x, y;
    chtype attr;
    bool xlat;

    PDC_LOG(("winsch() - called: win=%p ch=%x (text=%c attr=0x%x)\n",
             win, ch, ch & A_CHARTEXT, ch & A_ATTRIBUTES));

    if (!win)
        return ERR;

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

    if (y > win->_maxy || x > win->_maxx || y < 0 || x < 0)
        return ERR;

    xlat = !SP->raw_out && !(ch & A_ALTCHARSET);
    attr = ch & A_ATTRIBUTES;
    ch &= A_CHARTEXT;

    if (xlat && (ch < ' ' || ch == 0x7f))
    {
        int x2;

        switch (ch)
        {
        case '\t':
            for (x2 = ((x / TABSIZE) + 1) * TABSIZE; x < x2; x++)
            {
                if (winsch(win, attr | ' ') == ERR)
                    return ERR;
            }
            return OK;

        case '\n':
            wclrtoeol(win);
            break;

        case 0x7f:
            if (winsch(win, attr | '?') == ERR)
                return ERR;

            return winsch(win, attr | '^');

        default:
            /* handle control chars */

            if (winsch(win, attr | (ch + '@')) == ERR)
                return ERR;

            return winsch(win, attr | '^');
        }
    }
    else
    {
        int maxx;
        chtype *temp;

        /* If the incoming character doesn't have its own attribute,
           then use the current attributes for the window. If it has
           attributes but not a color component, OR the attributes to
           the current attributes for the window. If it has a color
           component, use the attributes solely from the incoming
           character. */

        if (!(attr & A_COLOR))
            attr |= win->_attrs;

        /* wrs (4/10/93): Apply the same sort of logic for the window
           background, in that it only takes precedence if other color
           attributes are not there and that the background character
           will only print if the printing character is blank. */

        if (!(attr & A_COLOR))
            attr |= win->_bkgd & A_ATTRIBUTES;
        else
            attr |= win->_bkgd & (A_ATTRIBUTES ^ A_COLOR);

        if (ch == ' ')
            ch = win->_bkgd & A_CHARTEXT;

        /* Add the attribute back into the character. */

        ch |= attr;

        maxx = win->_maxx;
        temp = &win->_y[y][x];

        memmove(temp + 1, temp, (maxx - x - 1) * sizeof(chtype));

        win->_lastch[y] = maxx - 1;

        if ((win->_firstch[y] == _NO_CHANGE) || (win->_firstch[y] > x))
            win->_firstch[y] = x;

        *temp = ch;
    }

    PDC_sync(win);

    return OK;
}
예제 #14
0
/*#DOC*/
int view_insc(View v, int chr)
{
	return winsch(view_win(v), viewP_style2chtype((Style) chr));
}
예제 #15
0
int insch(chtype ch) {
	return winsch(stdscr, ch);
}
예제 #16
0
파일: insch.c 프로젝트: bugengine/BugEngine
int wins_wch(WINDOW *win, const cchar_t *wch)
{
    PDC_LOG(("wins_wch() - called\n"));

    return wch ? winsch(win, *wch) : ERR;
}
예제 #17
0
int chkr_winsch(WINDOW *win,chtype ch)
{
   CHECK_WIN(win);
   return(winsch(win,ch));
}
예제 #18
0
static void
outputTest(WINDOW *win)
{
    WINDOW *win1;
    char Buffer[80];
    chtype ch;
    int by, bx;

#if !HAVE_TIGETSTR
#if HAVE_TGETENT
    char tc_buffer[4096];
    char tc_parsed[4096];
    char *area_pointer = tc_parsed;
    tgetent(tc_buffer, getenv("TERM"));
#else
#define tgetstr(a,b) 0
#endif
#endif /* !HAVE_TIGETSTR */

    nl();
    wclear(win);
    MvWAddStr(win, 1, 1,
	      "You should now have a screen in the upper left corner, and this text should have wrapped");
    mvwin(win, 2, 1);
    waddstr(win, "\nThis text should be down\n");
    waddstr(win, "and broken into two here ^");
    Continue(win);

    wclear(win);
    wattron(win, A_BOLD);
    MvWAddStr(win, 1, 1, "A new window will appear with this text in it");
    MvWAddStr(win, 8, 1, "Press any key to continue");
    wrefresh(win);
    wgetch(win);

    getbegyx(win, by, bx);

    if (LINES < 24 || COLS < 75) {
	MvWAddStr(win, 5, 1,
		  "Some tests have been skipped as they require a");
	MvWAddStr(win, 6, 1, "display of at least 24 LINES by 75 COLUMNS");
	Continue(win);
    } else {
	win1 = newwin(10, 50, 14, 25);
	if (win1 == NULL) {
	    endwin();
	    return;
	}
#ifdef A_COLOR
	if (has_colors()) {
	    init_pair(3, COLOR_BLUE, COLOR_WHITE);
	    wbkgd(win1, (chtype) COLOR_PAIR(3));
	} else
	    wbkgd(win1, A_NORMAL);
#else
	wbkgd(win1, A_NORMAL);
#endif
	wclear(win1);
	MvWAddStr(win1, 5, 1,
		  "This text should appear; using overlay option");
	copywin(win, win1, 0, 0, 0, 0, 9, 49, TRUE);

#if defined(PDCURSES) && !defined(XCURSES)
	box(win1, 0xb3, 0xc4);
#else
	box(win1, ACS_VLINE, ACS_HLINE);
#endif
	wmove(win1, 8, 26);
	wrefresh(win1);
	wgetch(win1);

	wclear(win1);
	wattron(win1, A_BLINK);
	MvWAddStr(win1, 4, 1,
		  "This blinking text should appear in only the second window");
	wattroff(win1, A_BLINK);
	mvwin(win1, by, bx);
	overlay(win, win1);
	mvwin(win1, 14, 25);
	wmove(win1, 8, 26);
	wrefresh(win1);
	wgetch(win1);
	delwin(win1);
    }

    clear();
    wclear(win);
    wrefresh(win);
    MvWAddStr(win, 6, 2, "This line shouldn't appear");
    MvWAddStr(win, 4, 2, "Only half of the next line is visible");
    MvWAddStr(win, 5, 2, "Only half of the next line is visible");
    wmove(win, 6, 1);
    wclrtobot(win);
    wmove(win, 5, 20);
    wclrtoeol(win);
    MvWAddStr(win, 8, 2, "This line also shouldn't appear");
    wmove(win, 8, 1);
    wdeleteln(win);
    Continue(win);

    wmove(win, 5, 9);
    ch = winch(win);

    wclear(win);
    wmove(win, 6, 2);
    waddstr(win, "The next char should be l:  ");
    winsch(win, ch);
    Continue(win);

#if HAVE_WINSSTR
    (void) mvwinsstr(win, 6, 2, "A1B2C3D4E5");
    Continue(win);
#endif

    wmove(win, 5, 1);
    winsertln(win);
    MvWAddStr(win, 5, 2, "The lines below should have moved down");
    Continue(win);

    wclear(win);
    wmove(win, 2, 2);
    wprintw(win, "This is a formatted string in a window: %d %s\n", 42,
	    "is it");
    MvWAddStr(win, 10, 1, "Enter a string: ");
    wrefresh(win);
    noraw();
    echo();
    *Buffer = 0;
    wscanw(win, "%s", Buffer);

    printw("This is a formatted string in stdscr: %d %s\n", 42, "is it");
    MvAddStr(10, 1, "Enter a string: ");
    *Buffer = 0;
    scanw("%s", Buffer);

    if (TIGETSTR("cvvis", "vs") != 0) {
	wclear(win);
	curs_set(2);
	MvWAddStr(win, 1, 1, "The cursor should appear as a block (visible)");
	Continue(win);
    }

    if (TIGETSTR("civis", "vi") != 0) {
	wclear(win);
	curs_set(0);
	MvWAddStr(win, 1, 1,
		  "The cursor should have disappeared (invisible)");
	Continue(win);
    }

    if (TIGETSTR("cnorm", "ve") != 0) {
	wclear(win);
	curs_set(1);
	MvWAddStr(win, 1, 1, "The cursor should be an underline (normal)");
	Continue(win);
    }
#ifdef A_COLOR
    if (has_colors()) {
	wclear(win);
	MvWAddStr(win, 1, 1, "Colors should change after you press a key");
	Continue(win);
	init_pair(1, COLOR_RED, COLOR_WHITE);
	wrefresh(win);
    }
#endif

    werase(win);

#if HAVE_TERMNAME
    MvWAddStr(win, 1, 1, "Information About Your Terminal");
    MvWAddStr(win, 3, 1, termname());
    MvWAddStr(win, 4, 1, longname());
    if (termattrs() & A_BLINK)
	MvWAddStr(win, 5, 1, "This terminal supports blinking.");
    else
	MvWAddStr(win, 5, 1, "This terminal does NOT support blinking.");
#endif

    (void) mvwaddnstr(win, 7, 5, "Have a nice day!ok", 16);
    wrefresh(win);

    (void) mvwinnstr(win, 7, 5, Buffer, 18);
    MvAddStr(LINES - 2, 10, Buffer);
    refresh();
    Continue(win);
}
예제 #19
0
파일: insch.c 프로젝트: bugengine/BugEngine
int insch(chtype ch)
{
    PDC_LOG(("insch() - called\n"));

    return winsch(stdscr, ch);
}
예제 #20
0
NCURSES_EXPORT(int) (mvinsch) (int a1, int a2, chtype z)
{
	T((T_CALLED("mvinsch(%d,%d,%s)"), a1, a2, _tracechtype2(2,z))); returnCode((wmove(stdscr,a1,a2) == (-1) ? (-1) : winsch(stdscr,z)));
}
예제 #21
0
void outputTest(WINDOW *win)
{
    WINDOW *win1;
    char Buffer[80];
    chtype ch;
    int by, bx;

    nl();
    wclear(win);
    mvwaddstr(win, 1, 1, "You should now have a screen in the upper "
                         "left corner, and this text should have wrapped");
    waddstr(win,"\nThis text should be down\n");
    waddstr(win,  "and broken into two here ^");
    Continue(win);

    wclear(win);
    wattron(win, A_BOLD);
    mvwaddstr(win, 1, 1, "A new window will appear with this text in it");
    mvwaddstr(win, 8, 1, "Press any key to continue");
    wrefresh(win);
    wgetch(win);

    getbegyx(win, by, bx);

    if (LINES < 24 || COLS < 75)
    {
        mvwaddstr(win, 5, 1, "Some tests have been skipped as they require a");
        mvwaddstr(win, 6, 1, "display of at least 24 LINES by 75 COLUMNS");
        Continue(win);
    }
    else
    {
        win1 = newwin(10, 50, 14, 25);

        if (win1 == NULL)
        {
            endwin();
            return;
        }

#ifdef A_COLOR
        if (has_colors())
        {
            init_pair(3, COLOR_BLUE, COLOR_WHITE);
            wbkgd(win1, COLOR_PAIR(3));
        }
        else
#endif
            wbkgd(win1, A_NORMAL);

        wclear(win1);
        mvwaddstr(win1, 5, 1, "This text should appear; using overlay option");
        copywin(win, win1, 0, 0, 0, 0, 9, 49, TRUE);
        box(win1, ACS_VLINE, ACS_HLINE);
        wmove(win1, 8, 26);
        wrefresh(win1);
        wgetch(win1);

        wclear(win1);

        wattron(win1, A_BLINK);
        mvwaddstr(win1, 4, 1,
                  "This blinking text should appear in only the second window");
        wattroff(win1, A_BLINK);

        mvwin(win1, by, bx);
        overlay(win, win1);
        mvwin(win1, 14, 25);
        wmove(win1, 8, 26);
        wrefresh(win1);
        wgetch(win1);

        delwin(win1);
    }

    clear();
    wclear(win);
    wrefresh(win);
    mvwaddstr(win, 6, 2, "This line shouldn't appear");
    mvwaddstr(win, 4, 2, "Only half of the next line is visible");
    mvwaddstr(win, 5, 2, "Only half of the next line is visible");
    wmove(win, 6, 1);
    wclrtobot(win);
    wmove(win, 5, 20);
    wclrtoeol(win);
    mvwaddstr(win, 8, 2, "This line also shouldn't appear");
    wmove(win, 8, 1);
    winsdelln(win, -1);
    Continue(win);

    wmove(win, 5, 9);
    ch = winch(win);

    wclear(win);
    wmove(win, 6, 2);
    waddstr(win, "The next char should be l:  ");
    winsch(win, ch);
    Continue(win);

    mvwinsstr(win, 6, 2, "A1B2C3D4E5");
    Continue(win);

    wmove(win, 5, 1);
    winsdelln(win, 1);
    mvwaddstr(win, 5, 2, "The lines below should have moved down");
    Continue(win);

    wclear(win);
    wmove(win, 2, 2);
    wprintw(win, "This is a formatted string in a window: %d %s\n",
            42, "is it");
    mvwaddstr(win, 10, 1, "Enter a string: ");
    wrefresh(win);
    echo();
    wscanw(win, "%s", Buffer);

    printw("This is a formatted string in stdscr: %d %s\n", 42, "is it");
    mvaddstr(10, 1, "Enter a string: ");
    scanw("%s", Buffer);

    wclear(win);
    curs_set(2);
    mvwaddstr(win, 1, 1, "The cursor should be in high-visibility mode");
    Continue(win);

    wclear(win);
    curs_set(0);
    mvwaddstr(win, 1, 1, "The cursor should have disappeared");
    Continue(win);

    wclear(win);
    curs_set(1);
    mvwaddstr(win, 1, 1, "The cursor should be normal");
    Continue(win);

#ifdef A_COLOR
    if (has_colors())
    {
        wclear(win);
        mvwaddstr(win, 1, 1, "Colors should change after you press a key");
        Continue(win);

        init_pair(1, COLOR_RED, COLOR_WHITE);
        wrefresh(win);
    }
#endif
    werase(win);
    mvwaddstr(win, 1, 1, "Information About Your Terminal");
    mvwaddstr(win, 3, 1, termname());
    mvwaddstr(win, 4, 1, longname());

    if (termattrs() & A_BLINK)
        mvwaddstr(win, 5, 1, "This terminal claims to support blinking.");
    else
        mvwaddstr(win, 5, 1, "This terminal does NOT support blinking.");

    mvwaddnstr(win, 7, 5, "Have a nice day!ok", 16);
    wrefresh(win);

    mvwinnstr(win, 7, 5, Buffer, 18);
    mvaddstr(LINES - 2, 10, Buffer);
    refresh();
    Continue(win);
}
예제 #22
0
EIF_INTEGER c_ecurses_winsch (EIF_POINTER w, EIF_INTEGER ch)
{
    return winsch( ((WINDOW *) w), (chtype) ch);
};
예제 #23
0
NCURSES_EXPORT(int) (insch) (chtype z)
{
	T((T_CALLED("insch(%s)"), _tracechtype2(0,z))); returnCode(winsch(stdscr,z));
}