Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sheet: resize display on window resize. TO DO: add tests #224

Merged
merged 3 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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