Beispiel #1
0
void
TermView::_Init()
{
	SetFont(be_fixed_font);

	font_height height;
	GetFontHeight(&height);
	fFontHeight = (int)(ceilf(height.ascent) + ceilf(height.descent)
		+ ceilf(height.leading));
	fFontWidth = (int)be_fixed_font->StringWidth("X");
	fTerm = vterm_new(kDefaultHeight, kDefaultWidth);

	fTermScreen = vterm_obtain_screen(fTerm);
	vterm_screen_set_callbacks(fTermScreen, &sScreenCallbacks, this);
	vterm_screen_reset(fTermScreen, 1);

	vterm_parser_set_utf8(fTerm, 1);

	VTermScreenCell cell;
	VTermPos firstPos;
	firstPos.row = 0;
	firstPos.col = 0;
	_GetCell(firstPos, cell);

	rgb_color background;
	background.red = cell.bg.red;
	background.green = cell.bg.green;
	background.blue = cell.bg.blue;
	background.alpha = 255;

	SetViewColor(background);
	SetLineTerminator("\n");
}
Beispiel #2
0
void term_clear_callbacks(struct aug_term *term) {
	VTermScreen *vts;
	
	vts = vterm_obtain_screen(term->vt);
	vterm_screen_set_callbacks(vts, &CB_SCREEN_NULL, term->user);
	term->io_callbacks.refresh = NULL;	
}
Beispiel #3
0
void term_set_callbacks(struct aug_term *term, const VTermScreenCallbacks *screen_callbacks, 
							const struct aug_term_io_callbacks *io_callbacks, void *user) {
	VTermScreen *vts;

	term->user = user;
	vts = vterm_obtain_screen(term->vt);
	vterm_screen_set_callbacks(vts, screen_callbacks, user);
	term->io_callbacks = *io_callbacks;
}
Beispiel #4
0
int init(void) {
    context_t* cx = kcalloc(1, sizeof(context_t), GFP_KERNEL);
    if(unlikely(!cx)) {
        errno = ENOMEM;
        return -1;
    }


    cx->vmode = KD_TEXT;

    if(fb_init(cx) != 0)
        return -1;

    
    cx->vt = vterm_new_with_allocator(cx->console.rows, cx->console.cols, &mm, NULL);
    cx->vs = vterm_obtain_screen(cx->vt);
    cx->vc = vterm_obtain_state(cx->vt);

    //vterm_set_utf8(cx->vt, 1);
    vterm_screen_set_callbacks(cx->vs, &cbs, cx);
    vterm_screen_reset(cx->vs, 0);
    vterm_state_reset(cx->vc, 0);


    VTermRect r = {
        .start_row = 0,
        .start_col = 0,
        .end_row = cx->console.rows,
        .end_col = cx->console.cols
    };

    console_cbs_damage(r, cx);
    vterm_input_write(cx->vt, "\e[20h", 5);


    inode_t* ino = vfs_mkdev("console", -1, S_IFCHR | 0222);
    ino->ioctl = console_ioctl;
    ino->write = console_write;
    ino->userdata = cx;

    return 0;
}

int dnit(void) {
    return 0;
}
Beispiel #5
0
TermView::TermView()
	:
	BView("TermView", B_WILL_DRAW | B_FRAME_EVENTS)
{
	SetFont(be_fixed_font);

	font_height height;
	GetFontHeight(&height);
	fFontHeight = height.ascent + height.descent + height.leading;
	fFontWidth = be_fixed_font->StringWidth("X");
	fTerm = vterm_new(kDefaultHeight, kDefaultWidth);

	fTermScreen = vterm_obtain_screen(fTerm);
	vterm_screen_set_callbacks(fTermScreen, &sScreenCallbacks, this);
	vterm_screen_reset(fTermScreen, 1);

	vterm_parser_set_utf8(fTerm, 1);
}
Beispiel #6
0
int fbterm_init(struct fbterm_ctx *ctx)
{
    if (!font) {
        font = font_open(DEFAULT_FONT);

        if (!font)
            return -1;
    }

    memset(ctx, 0, sizeof(struct fbterm_ctx));
    ctx->font = font;

    fb_term_init(ctx);
    fb_cook_wallpaper(ctx, DEFAULT_WALLPAPER);

    VTerm *vt = vterm_new(ctx->rows, ctx->cols);
    ctx->vt = vt;

    VTermScreen *sc = vterm_obtain_screen(vt);
    vterm_screen_set_callbacks(sc, &screen_cbs, ctx);
    vterm_screen_reset(sc, 0);
    ctx->screen = sc;

    VTermRect r = {.start_row = 0, .end_row = ctx->rows, .start_col = 0, .end_col = ctx->cols};
    damage(r, ctx);

    return 0;
}

int kbd_fd = -1;
int pty    = -1;

int fbterm_main()
{
    struct fbterm_ctx *active = &term[0]; 

    struct winsize ws;
    ws.ws_row = active->rows;
    ws.ws_col = active->cols;
    ioctl(pty, TIOCSWINSZ, &ws);

    fbterm_redraw(active);

    size_t len;
    char buf[1024];

    while (1) {
        /* Read input */
        if ((len = read(pty, buf, sizeof(buf))) > 0) {
            vterm_input_write(active->vt, buf, len);
        }

        fbterm_redraw(active);

        /* Write output */
        while (vterm_output_get_buffer_current(active->vt) > 0) {
            size_t s = vterm_output_read(active->vt, buf, 1024);
            write(pty, buf, s);
        }
    }

    return 0;
}

char *pts_fn = NULL;    /* XXX */
void launch_shell()
{
    int shell_pid = 0;
relaunch:
    if (shell_pid = fork()) {   /* Relaunch shell if died */
        int s, pid;
        do {
            pid = waitpid(shell_pid, &s, 0);
        } while (pid != shell_pid);

        /* Uh..Oh shell died */
        goto relaunch;
    } else {
        for (int i = 0; i < 10; ++i)
            close(i);

        int stdin_fd  = open(pts_fn, O_RDONLY);
        int stdout_fd = open(pts_fn, O_WRONLY);
        int stderr_fd = open(pts_fn, O_WRONLY);

        /* run login shell */
        char *argp[] = {DEFAULT_SHELL, "login", NULL};
        char *envp[] = {"PWD=/", "TERM=VT100", NULL};
        execve(DEFAULT_SHELL, argp, envp);
        for (;;);
    }
}