Beispiel #1
0
Error Terminal::initialize()
{
    teken_pos_t winsz;

    /*
     * Attempt to open input file.
     */
    if ((input = open(inputFile, O_RDONLY)) < 0)
    {
	printf("failed to open `%s': %s\r\n",
		inputFile, strerror(errno));
	exit(EXIT_FAILURE);
    }
    /*
     * Then open the output file.
     */
    if ((output = open(outputFile, O_RDWR)) < 0)
    {
	printf("failed to open `%s': %s\r\n",
		outputFile, strerror(errno));
	exit(EXIT_FAILURE);
    }
    /* Fill in function pointers. */
    funcs.tf_bell    = (tf_bell_t *)    bell;
    funcs.tf_cursor  = (tf_cursor_t *)  cursor;
    funcs.tf_putchar = (tf_putchar_t *) putchar;
    funcs.tf_fill    = (tf_fill_t *)    fill;
    funcs.tf_copy    = (tf_copy_t *)    copy;
    funcs.tf_param   = (tf_param_t *)   param;
    funcs.tf_respond = (tf_respond_t *) respond;

    /* Reset cursor. */
    memset(&cursorPos, 0, sizeof(cursorPos));

    /* Initialize libteken. */
    teken_init(&state, &funcs, this);
    
    /* Set appropriate terminal sizes. */
    winsz.tp_col = 80;
    winsz.tp_row = 25;
    teken_set_winsize(&state, &winsz);
    
    /* Print banners. */
    this->write((s8 *) BANNER, strlen(BANNER), ZERO);
    this->write((s8 *) COPYRIGHT "\r\n", strlen(COPYRIGHT "\r\n"), ZERO);
    
    /* Done! */
    return ESUCCESS;
}
Beispiel #2
0
static int
scteken_init(scr_stat *scp, void **softc, int code)
{
	teken_stat *ts;
	teken_pos_t tp;

	if (*softc == NULL) {
		if (reserved_teken_stat.ts_busy)
			return (EINVAL);
		*softc = &reserved_teken_stat;
	}
	ts = *softc;

	switch (code) {
	case SC_TE_COLD_INIT:
		++sc_term_scteken.te_refcount;
		ts->ts_busy = 1;
		/* FALLTHROUGH */
	case SC_TE_WARM_INIT:
		teken_init(&ts->ts_teken, &scteken_funcs, scp);
#ifndef TEKEN_UTF8
		teken_set_8bit(&ts->ts_teken);
#endif /* !TEKEN_UTF8 */
#ifdef TEKEN_CONS25
		teken_set_cons25(&ts->ts_teken);
#endif /* TEKEN_CONS25 */

		tp.tp_row = scp->ysize;
		tp.tp_col = scp->xsize;
		teken_set_winsize(&ts->ts_teken, &tp);

		if (scp->cursor_pos < scp->ysize * scp->xsize) {
			/* Valid old cursor position. */
			tp.tp_row = scp->cursor_pos / scp->xsize;
			tp.tp_col = scp->cursor_pos % scp->xsize;
			teken_set_cursor(&ts->ts_teken, &tp);
		}
		break;
	}

	return (0);
}
Beispiel #3
0
Error Terminal::initialize()
{
    teken_pos_t winsz;

    // TODO: hack
    close(0);
    close(1);

    /*
     * Attempt to open input file.
     */
    if ((input = open(inputFile, O_RDONLY)) < 0)
    {
	printf("failed to open `%s': %s\r\n",
		inputFile, strerror(errno));
	exit(EXIT_FAILURE);
    }
    /*
     * Then open the output file.
     */
    if ((output = open(outputFile, O_RDWR)) < 0)
    {
	printf("failed to open `%s': %s\r\n",
		outputFile, strerror(errno));
	exit(EXIT_FAILURE);
    }

    // TODO: Hack the file descriptors table...
    Vector<FileDescriptor> *files = getFiles();
    (*files)[0].open = true;
    strlcpy((*files)[0].path, inputFile, PATHLEN); /* keyboard0 */
    (*files)[0].mount = 7;
    (*files)[1].open = true;
    strlcpy((*files)[1].path, outputFile, PATHLEN); /* vga0 */
    (*files)[1].mount = 9;

    /* Fill in function pointers. */
    funcs.tf_bell    = (tf_bell_t *)    bell;
    funcs.tf_cursor  = (tf_cursor_t *)  cursor;
    funcs.tf_putchar = (tf_putchar_t *) putchar;
    funcs.tf_fill    = (tf_fill_t *)    fill;
    funcs.tf_copy    = (tf_copy_t *)    copy;
    funcs.tf_param   = (tf_param_t *)   param;
    funcs.tf_respond = (tf_respond_t *) respond;

    /* Reset cursor. */
    memset(&cursorPos, 0, sizeof(cursorPos));

    /* Initialize libteken. */
    teken_init(&state, &funcs, this);
    
    /* Set appropriate terminal sizes. */
    winsz.tp_col = 80;
    winsz.tp_row = 25;
    teken_set_winsize(&state, &winsz);
    
    /* Print banners. */
    this->write((s8 *) BANNER, strlen(BANNER), ZERO);
    this->write((s8 *) COPYRIGHT "\r\n", strlen(COPYRIGHT "\r\n"), ZERO);
    
    /* Done! */
    return ESUCCESS;
}