ref: 09697c50bf8815cffdca16508f87b751ad7d7ce4
parent: 1ec84d552d2afd1509caeddc9d74388cf2daf697
author: cancel <cancel@cancel.fm>
date: Mon Dec 3 04:32:08 EST 2018
Add field_resize_raw_if_necessary
--- a/field.c
+++ b/field.c
@@ -24,6 +24,12 @@
f->width = (U16)width;
}
+void field_resize_raw_if_necessary(Field* field, Usz height, Usz width) {
+ if (field->height != height || field->width != width) {
+ field_resize_raw(field, height, width);
+ }
+}
+
void field_deinit(Field* f) { free(f->buffer); }
void field_copy_subrect(Field* src, Field* dest, Usz src_y, Usz src_x,
--- a/field.h
+++ b/field.h
@@ -4,6 +4,7 @@
void field_init(Field* field);
void field_init_fill(Field* field, Usz height, Usz width, Glyph fill_char);
void field_resize_raw(Field* field, Usz height, Usz width);
+void field_resize_raw_if_necessary(Field* field, Usz height, Usz width);
void field_deinit(Field* field);
void field_copy_subrect(Field* src, Field* dest, Usz src_y, Usz src_x,
Usz dest_y, Usz dest_x, Usz height, Usz width);
--- a/tui_main.c
+++ b/tui_main.c
@@ -245,6 +245,8 @@
hist->first = new_node->next;
hist->first->prev = NULL;
}
+ field_resize_raw_if_necessary(&new_node->field, field->height,
+ field->width);
} else {
new_node = malloc(sizeof(Undo_node));
++hist->count;