Skip to content

Commit

Permalink
sheet: resize display on window resize. TO DO: add tests (#224)
Browse files Browse the repository at this point in the history
* sheet: resize display on window resize. TO DO: add tests
  • Loading branch information
liquidaty authored Oct 13, 2024
1 parent 2ef8148 commit 6a49fae
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion app/sheet.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <stdarg.h>
#include <ctype.h>
#include <errno.h>
#include <signal.h>

#include <zsv.h>
#include "sheet/sheet_internal.h"
Expand Down Expand Up @@ -238,7 +239,6 @@ int ZSV_MAIN_FUNC(ZSV_COMMAND)(int argc, const char *argv[], struct zsv_opts *op
keypad(stdscr, TRUE);
cbreak();
struct zsvsheet_display_dimensions display_dims = get_display_dimensions(1, 1);

int zsvsheetch;
size_t rownum_col_offset = 1;
display_buffer_subtable(current_ui_buffer, rownum_col_offset, header_span, &display_dims);
Expand All @@ -248,6 +248,9 @@ int ZSV_MAIN_FUNC(ZSV_COMMAND)(int argc, const char *argv[], struct zsv_opts *op
zsvsheet_set_status(&display_dims, 1, "");
int update_buffer = 0;
switch (zsvsheetch) {
case zsvsheet_key_resize:
display_dims = get_display_dimensions(1, 1);
break;
case zsvsheet_key_move_top:
update_buffer =
zsvsheet_goto_input_raw_row(current_ui_buffer, 1, header_span, &display_dims, display_dims.header_span);
Expand Down Expand Up @@ -388,6 +391,8 @@ int ZSV_MAIN_FUNC(ZSV_COMMAND)(int argc, const char *argv[], struct zsv_opts *op
zsvsheet_set_status(&display_dims, 1, "Not found: %s", cmdbuff);
}
break;
default:
continue;
}
if (update_buffer) {
struct zsvsheet_opts zsvsheet_opts = {0};
Expand Down
2 changes: 2 additions & 0 deletions app/sheet/key-bindings.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ static enum zsvsheet_key zsvsheet_key_binding(int ch) {
return zsvsheet_key_find;
if (ch == 'q')
return zsvsheet_key_quit;
if (ch == KEY_RESIZE)
return zsvsheet_key_resize;
return zsvsheet_key_unknown;
}
3 changes: 2 additions & 1 deletion app/sheet/key-bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ enum zsvsheet_key {
zsvsheet_key_filter,
zsvsheet_key_find,
zsvsheet_key_find_next,
zsvsheet_key_open_file
zsvsheet_key_open_file,
zsvsheet_key_resize
};

#endif

0 comments on commit 6a49fae

Please sign in to comment.