1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Fix editor writing NUL bytes to terminal.

This commit is contained in:
Jonas 'Sortie' Termansen 2014-04-19 20:21:50 +02:00
parent 6cf417532e
commit 4674017303

View file

@ -148,6 +148,7 @@ void update_terminal_cursor(FILE* fp, int x, int y,
void update_terminal_entry(FILE* fp, uint16_t entry, int x, int y, void update_terminal_entry(FILE* fp, uint16_t entry, int x, int y,
struct terminal_state* current) struct terminal_state* current)
{ {
assert(entry & 0xFF);
size_t index = y * current->width + x; size_t index = y * current->width + x;
uint16_t current_entry = current->data[index]; uint16_t current_entry = current->data[index];
if ( entry == current_entry ) if ( entry == current_entry )
@ -190,9 +191,9 @@ void make_terminal_state(FILE* fp, struct terminal_state* state)
tcgetwinsize(fileno(fp), &terminal_size); tcgetwinsize(fileno(fp), &terminal_size);
state->width = (int) terminal_size.ws_col; state->width = (int) terminal_size.ws_col;
state->height = (int) terminal_size.ws_row; state->height = (int) terminal_size.ws_row;
size_t data_size = sizeof(uint16_t) * state->width * state->height; size_t data_length = state->width * state->height;
state->data = (uint16_t*) malloc(data_size); state->data = (uint16_t*) malloc(sizeof(uint16_t) * data_length);
for ( size_t i = 0; i < data_size / sizeof(uint16_t); i++ ) for ( size_t i = 0; i < data_length; i++ )
state->data[i] = 0x0000 | ' '; state->data[i] = 0x0000 | ' ';
} }
@ -328,7 +329,7 @@ void render_editor(struct editor* editor, struct terminal_state* state)
// Create the header title bar. // Create the header title bar.
for ( int x = 0; x < state->width; x++ ) for ( int x = 0; x < state->width; x++ )
state->data[0 * state->width + x] = 0x7000; state->data[0 * state->width + x] = 0x7000 | ' ';
// Render the name of the program. // Render the name of the program.
const char* header_start = editor->dirty ? " editor *" const char* header_start = editor->dirty ? " editor *"