- for (i = 0; i < total_rows; i++) {
- memcpy(&data[width * i],
- terminal_get_row(terminal, i),
- l * sizeof(union utf8_char));
- memcpy(&data_attr[width * i],
- terminal_get_attr_row(terminal, i),
- l * sizeof(struct attr));
+ terminal->start += d;
+ terminal->row -= d;
+ } else {
+ terminal->max_width = width;
+ data_pitch = width * sizeof(union utf8_char);
+ data = zalloc(data_pitch * terminal->buffer_height);
+ attr_pitch = width * sizeof(struct attr);
+ data_attr = malloc(attr_pitch * terminal->buffer_height);
+ tab_ruler = zalloc(width);
+ attr_init(data_attr, terminal->curr_attr,
+ width * terminal->buffer_height);
+
+ if (terminal->data && terminal->data_attr) {
+ if (width > terminal->width)
+ l = terminal->width;
+ else
+ l = width;
+
+ if (terminal->height > height) {
+ total_rows = height;
+ i = 1 + terminal->row - height;
+ if (i > 0) {
+ terminal->start += i;
+ terminal->row = terminal->row - i;
+ }
+ } else {
+ total_rows = terminal->height;
+ }
+
+ for (i = 0; i < total_rows; i++) {
+ memcpy(&data[width * i],
+ terminal_get_row(terminal, i),
+ l * sizeof(union utf8_char));
+ memcpy(&data_attr[width * i],
+ terminal_get_attr_row(terminal, i),
+ l * sizeof(struct attr));
+ }
+
+ free(terminal->data);
+ free(terminal->data_attr);
+ free(terminal->tab_ruler);