예제 #1
0
파일: mloop.c 프로젝트: dank101/386BSD
mloop()
{
	while (!quit) {
		if (incmd) {
			docmd();
		} else if (wwcurwin->ww_state != WWS_HASPROC) {
			if (!wwcurwin->ww_keepopen)
				closewin(wwcurwin);
			setcmd(1);
			if (wwpeekc() == escapec)
				(void) wwgetc();
			error("Process died.");
		} else {
			register struct ww *w = wwcurwin;
			register char *p;
			register n;

			if (wwibp >= wwibq)
				wwiomux();
			for (p = wwibp; p < wwibq && *p != escapec;
			     p++)
				;
			if ((n = p - wwibp) > 0) {
				if (!w->ww_ispty && w->ww_stopped)
					startwin(w);
				(void) write(w->ww_pty, wwibp, n);
				wwibp = p;
			}
			if (wwpeekc() == escapec) {
				(void) wwgetc();
				setcmd(1);
			}
		}
	}
}
예제 #2
0
int
waitnl1(struct ww *w, const char *prompt)
{
	int uc = ISSET(w->ww_wflags, WWW_UNCTRL);

	CLR(w->ww_wflags, WWW_UNCTRL);
	front(w, 0);
	wwprintf(w, "\033Y%c%c\033sA%s\033rA ",
		w->ww_w.nr - 1 + ' ', ' ', prompt);	/* print on last line */
	wwcurtowin(w);
	while (wwpeekc() < 0)
		wwiomux();
	SET(w->ww_wflags, uc);
	return wwgetc();
}
예제 #3
0
void
c_quit(void)
{
	char oldterse = terse;

	setterse(0);
	wwputs("Really quit [yn]? ", cmdwin);
	wwcurtowin(cmdwin);
	while (wwpeekc() < 0)
		wwiomux();
	if (wwgetc() == 'y') {
		wwputs("Yes", cmdwin);
		quit++;
	} else
		wwputc('\n', cmdwin);
	setterse(!quit && oldterse);
}
예제 #4
0
/*
 * Window size.
 */
void
c_size(struct ww *w)
{
	int col, row;

	if (!terse)
		wwputs("New window size (lower right corner): ", cmdwin);
	col = MIN(w->ww_w.r, wwncol) - 1;
	row = MIN(w->ww_w.b, wwnrow) - 1;
	wwadd(boxwin, framewin->ww_back);
	for (;;) {
		wwbox(boxwin, w->ww_w.t - 1, w->ww_w.l - 1,
			row - w->ww_w.t + 3, col - w->ww_w.l + 3);
		wwsetcursor(row, col);
		while (wwpeekc() < 0)
			wwiomux();
		switch (getpos(&row, &col, w->ww_w.t, w->ww_w.l,
			wwnrow - 1, wwncol - 1)) {
		case 3:
			wwunbox(boxwin);
			wwdelete(boxwin);
			return;
		case 2:
			wwunbox(boxwin);
			break;
		case 1:
			wwunbox(boxwin);
		case 0:
			continue;
		}
		break;
	}
	wwdelete(boxwin);
	if (!terse)
		wwputc('\n', cmdwin);
	wwcurtowin(cmdwin);
	sizewin(w, row - w->ww_w.t + 1, col - w->ww_w.l + 1);
}
예제 #5
0
c_debug()
{
	register struct ww *w;

	if (!terse)
		wwputs("[m(smap) n(ns) o(os) s(string) v(nvis) w(win)]? ", cmdwin);
	wwcurtowin(cmdwin);
	while (wwpeekc() < 0)
		wwiomux();
	if (!terse)
		wwputc('\n', cmdwin);
	switch (wwgetc()) {
	case 'm':
		wwdumpsmap();
		break;
	case 'n':
		wwdumpns();
		break;
	case 'o':
		wwdumpos();
		break;
	case 's':
		debug_str();
		break;
	case 'v':
		if ((w = getwin()) != 0)
			wwdumpnvis(w);
		break;
	case 'w':
		if ((w = getwin()) != 0)
			wwdumpwin(w);
		break;
	default:
		wwbell();
	}
}
예제 #6
0
void
c_yank(void)
{
	struct ww *w = selwin;
	int col1, row1;
	int col2, row2;
	int r, c;

	if (!terse)
		wwputs("Yank starting position: ", cmdwin);
	wwcursor(w, 0);
	row1 = w->ww_cur.r;
	col1 = w->ww_cur.c;
	for (;;) {
		wwsetcursor(row1, col1);
		while (wwpeekc() < 0)
			wwiomux();
		switch (getpos(&row1, &col1, w->ww_i.t, w->ww_i.l,
			       w->ww_i.b - 1, w->ww_i.r - 1)) {
		case 3:
			goto out;
		case 2:
			break;
		case 1:
		case 0:
			continue;
		}
		break;
	}
	if (!terse)
		wwputs("\nYank ending position: ", cmdwin);
	row2 = row1;
	col2 = col1;
	for (;;) {
		wwsetcursor(row2, col2);
		while (wwpeekc() < 0)
			wwiomux();
		r = row2;
		c = col2;
		switch (getpos(&row2, &col2, w->ww_i.t, w->ww_i.l,
			       w->ww_i.b - 1, w->ww_i.r - 1)) {
		case 3:
			yank_highlight(row1, col1, r, c);
			goto out;
		case 2:
			break;
		case 1:
			yank_highlight(row1, col1, r, c);
			yank_highlight(row1, col1, row2, col2);
		case 0:
			continue;
		}
		break;
	}
	if (row2 < row1 || (row2 == row1 && col2 < col1)) {
		r = row1;
		c = col1;
		row1 = row2;
		col1 = col2;
		row2 = r;
		col2 = c;
	}
	unyank();
	c = col1;
	for (r = row1; r < row2; r++) {
		yank_line(r, c, w->ww_b.r);
		c = w->ww_b.l;
	}
	yank_line(r, c, col2);
	yank_highlight(row1, col1, row2, col2);
	if (!terse)
		wwputc('\n', cmdwin);
out:
	wwcursor(w, 1);
}
예제 #7
0
c_window()
{
    int col, row, xcol, xrow;
    int id;

    if ((id = findid()) < 0)
        return;
    if (!terse)
        wwputs("New window (upper left corner): ", cmdwin);
    col = 0;
    row = 1;
    wwadd(boxwin, framewin->ww_back);
    for (;;) {
        wwbox(boxwin, row - 1, col - 1, 3, 3);
        wwsetcursor(row, col);
        while (wwpeekc() < 0)
            wwiomux();
        switch (getpos(&row, &col, row > 1, 0,
                       wwnrow - 1, wwncol - 1)) {
        case 3:
            wwunbox(boxwin);
            wwdelete(boxwin);
            return;
        case 2:
            wwunbox(boxwin);
            break;
        case 1:
            wwunbox(boxwin);
        case 0:
            continue;
        }
        break;
    }
    if (!terse)
        wwputs("\nNew window (lower right corner): ", cmdwin);
    xcol = col;
    xrow = row;
    for (;;) {
        wwbox(boxwin, row - 1, col - 1,
              xrow - row + 3, xcol - col + 3);
        wwsetcursor(xrow, xcol);
        wwflush();
        while (wwpeekc() < 0)
            wwiomux();
        switch (getpos(&xrow, &xcol, row, col, wwnrow - 1, wwncol - 1))
        {
        case 3:
            wwunbox(boxwin);
            wwdelete(boxwin);
            return;
        case 2:
            wwunbox(boxwin);
            break;
        case 1:
            wwunbox(boxwin);
        case 0:
            continue;
        }
        break;
    }
    wwdelete(boxwin);
    if (!terse)
        wwputc('\n', cmdwin);
    wwcurtowin(cmdwin);
    (void) openwin(id, row, col, xrow-row+1, xcol-col+1, nbufline,
                   (char *) 0, 1, 1, shellfile, shell);
}