コード例 #1
0
ファイル: dedview.c プロジェクト: ThomasDickey/ded-snapshots
/*
 * Display all files in the current screen (all viewports), and then show the
 * remaining stuff on the screen (position in each viewport and workspace
 * marker).
 */
void
showFILES(RING * gbl, int reset_cols)
{
    unsigned current = curview;
    int j;
    unsigned k;

    TRACE(("showFILES(%s,%d)\n", gbl->new_wd, reset_cols));
    if (reset_cols)
	for (j = 0; j < CCOL_MAX; j++)
	    gbl->cmdcol[j] = 0;

    save_view(gbl);
    for (k = 0; k < maxview; k++) {
	show_view(vue->gbl);
	if (maxview > 1) {
	    if (vue->gbl != viewlist[current].gbl)
		show_what(vue);
	    next_view();
	}
    }
    showMARK(gbl->Xbase);
    clear_work();
    showC(gbl);
    TRACE(("...done showFILES\n"));
}
コード例 #2
0
ファイル: dedview.c プロジェクト: ThomasDickey/ded-snapshots
/*
 * Show, in the viewport-header, where the cursor points (which file, which
 * path) as well as the current setting of the 'C' command.  If any files are
 * tagged, show the heading highlighted.
 */
void
showWHAT(RING * gbl)
{
    unsigned save = vue->curfile = gbl->curfile;
    unsigned j;

    for (j = 0; j < maxview; j++)
	if (viewlist[j].gbl == gbl) {
	    gbl->curfile = viewlist[j].curfile;
	    show_what(&viewlist[j]);
	}
    gbl->curfile = save;
}
コード例 #3
0
ファイル: savescreen.c プロジェクト: Brainiarc7/ralink_sdk
static int
get_command(int which, int last)
{
    int ch;

    timeout(100);

    do {
	show_what(which, last);
	ch = getch();
    } while (ch == ERR);

    return ch;
}
コード例 #4
0
ファイル: savescreen.c プロジェクト: Brainiarc7/ralink_sdk
int
main(int argc, char *argv[])
{
    int ch;
    int which = 0;
    int last;
    bool replaying = FALSE;
    bool done = FALSE;
    char **files;

    while ((ch = getopt(argc, argv, "ir")) != -1) {
	switch (ch) {
	case 'i':
	    use_init = TRUE;
	    break;
	case 'r':
	    replaying = TRUE;
	    break;
	default:
	    usage();
	    break;
	}
    }

    initscr();
    cbreak();
    noecho();
    keypad(stdscr, TRUE);
    curs_set(0);
    if (has_colors()) {
	start_color();
	for (ch = 0; ch < COLOR_PAIRS; ++ch) {
	    short pair = ch % COLOR_PAIRS;
	    init_pair(pair, COLOR_WHITE, ch % COLORS);
	}
    }

    files = argv + optind;
    last = argc - optind - 1;
    if (replaying) {

	/*
	 * Use the last file as the initial/current screen.
	 */
	if (last < 0) {
	    endwin();
	    printf("No screen-dumps given\n");
	    ExitProgram(EXIT_FAILURE);
	}

	which = last;
	if (load_screen(files[which]) == ERR) {
	    endwin();
	    printf("Cannot load screen-dump %s\n", files[which]);
	    ExitProgram(EXIT_FAILURE);
	}
	after_load();

	while (!done && (ch = getch()) != ERR) {
	    switch (ch) {
	    case 'n':
		/*
		 * If we got a "next" here, skip to the final screen before
		 * moving to the next process.
		 */
		setup_next();
		which = last;
		done = TRUE;
		break;
	    case 'q':
		endwin();
		cleanup(files);
		done = TRUE;
		break;
	    case KEY_BACKSPACE:
	    case '\b':
		if (--which < 0)
		    which = last;
		break;
	    case ' ':
		if (++which > last)
		    which = 0;
		break;
	    default:
		beep();
		continue;
	    }

	    if (ch == 'q') {
		;
	    } else if (scr_restore(files[which]) == ERR) {
		endwin();
		printf("Cannot load screen-dump %s\n", files[which]);
		cleanup(files);
		ExitProgram(EXIT_FAILURE);
	    } else {
		wrefresh(curscr);
	    }
	}
    } else {
	int y;
	int x;

	move(2, 0);
	printw("Use h,j,k,l or arrows to move around the screen\n");
	printw("Press 'q' to quit, ' ' to dump a screen\n");
	printw("When the last screen has been dumped, press 'n' to run the\n");
	printw("screen-loader.  That allows only 'q', backspace and ' ' for\n");
	printw("stepping through the dumped/restored screens.\n");
	getyx(stdscr, y, x);

	while (!done) {
	    switch (ch = get_command(which, last)) {
	    case 'n':
		setup_next();
		done = TRUE;
		break;
	    case 'q':
		endwin();
		cleanup(files);
		done = TRUE;
		break;
	    case ' ':
		if (files[which] != 0) {
		    show_what(which + 1, last);
		    if (scr_dump(files[which]) == ERR) {
			endwin();
			printf("Cannot write screen-dump %s\n", files[which]);
			cleanup(files);
			done = TRUE;
			break;
		    }
		    ++which;
		    if (has_colors()) {
			short pair = which % COLOR_PAIRS;
			bkgd(COLOR_PAIR(pair));
		    }
		} else {
		    beep();
		}
		break;
	    case KEY_LEFT:
	    case 'h':
		if (--x < 0)
		    x = COLS - 1;
		break;
	    case KEY_DOWN:
	    case 'j':
		if (++y >= LINES)
		    y = 1;
		break;
	    case KEY_UP:
	    case 'k':
		if (--y < 1)
		    y = LINES - 1;
		break;
	    case KEY_RIGHT:
	    case 'l':
		if (++x >= COLS)
		    x = 0;
		break;
	    }
	    if (!done) {
		time_t now = time((time_t *) 0);

		move(0, 0);
		addstr(ctime(&now));
		move(y, x);
		addch('#' | A_REVERSE);
		move(y, x);
	    }
	}
    }
    ExitProgram(EXIT_SUCCESS);
}