/* * Allocate a new screen and return it. * Return NULL when out of memory. */ static VTermScreen *screen_new(VTerm *vt) { VTermState *state = vterm_obtain_state(vt); VTermScreen *screen; int rows, cols; if (state == NULL) return NULL; screen = vterm_allocator_malloc(vt, sizeof(VTermScreen)); if (screen == NULL) return NULL; vterm_get_size(vt, &rows, &cols); screen->vt = vt; screen->state = state; screen->damage_merge = VTERM_DAMAGE_CELL; screen->damaged.start_row = -1; screen->pending_scrollrect.start_row = -1; screen->rows = rows; screen->cols = cols; screen->callbacks = NULL; screen->cbdata = NULL; screen->buffers[0] = realloc_buffer(screen, NULL, rows, cols); screen->buffer = screen->buffers[0]; screen->sb_buffer = vterm_allocator_malloc(screen->vt, sizeof(VTermScreenCell) * cols); if (screen->buffer == NULL || screen->sb_buffer == NULL) { vterm_screen_free(screen); return NULL; } vterm_state_set_callbacks(screen->state, &state_cbs, screen); return screen; }
VTermMM::VTermMM(int rows, int columns) : fd(0), foreground(VTERMMM_WHITE), background(VTERMMM_BLACK), cells(rows, vrow(columns)), reverse(false), invalid_region() { for(int row = 0; row < rows; ++row) { for(int col = 0; col < columns; ++col) { cells[row][col].SetX(col); cells[row][col].SetY(row); } } cursor.row = 0; cursor.col = 0; invalidate(0, rows, 0, columns); _term = vterm_new(rows, columns); vterm_parser_set_utf8(_term, 1); VTermState *vts = vterm_obtain_state(_term); vterm_state_set_callbacks(vts, &vterm_callbacks, this); }