diff options
author | Leo Tenenbaum <pommicket@gmail.com> | 2021-01-04 17:18:15 -0500 |
---|---|---|
committer | Leo Tenenbaum <pommicket@gmail.com> | 2021-01-04 17:18:15 -0500 |
commit | 306505e714b7caf146b8ec8386b407d57555563d (patch) | |
tree | 9cebf2eaf83899a7aa80fff70dd4d56cf4aa29d6 /command.c | |
parent | 16ab3629d435d52539b6345d79433e27c367ce83 (diff) |
commands to change the font size
Diffstat (limited to 'command.c')
-rw-r--r-- | command.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -19,6 +19,8 @@ char const *command_to_str(Command c) { void command_execute(Ted *ted, Command c, i64 argument) { TextBuffer *buffer = ted->active_buffer; + Settings *settings = &ted->settings; + switch (c) { case CMD_UNKNOWN: case CMD_COUNT: @@ -120,7 +122,23 @@ void command_execute(Ted *ted, Command c, i64 argument) { case CMD_REDO: buffer_redo(buffer, argument); break; + + case CMD_TEXT_SIZE_INCREASE: { + i64 new_text_size = settings->text_size + argument; + if (new_text_size >= TEXT_SIZE_MIN && new_text_size <= TEXT_SIZE_MAX) { + settings->text_size = (u16)new_text_size; + ted_load_font(ted); + } + } break; + case CMD_TEXT_SIZE_DECREASE: { + i64 new_text_size = settings->text_size - argument; + if (new_text_size >= TEXT_SIZE_MIN && new_text_size <= TEXT_SIZE_MAX) { + settings->text_size = (u16)new_text_size; + ted_load_font(ted); + } + } break; } + if (buffer_haserr(buffer)) { strncpy(ted->error, buffer_geterr(buffer), sizeof ted->error - 1); buffer_clearerr(buffer); |