From e60c32c46801cfe47ecddc4da1d109640f19fdc2 Mon Sep 17 00:00:00 2001 From: br1tney5pear5 Date: Sun, 15 Dec 2024 13:26:41 +0000 Subject: [PATCH 01/15] lol --- app/sheet.c | 7 +++ app/sheet/context-menu.c | 114 +++++++++++++++++++++++++++++++++++++++ app/sheet/key-bindings.c | 4 +- app/sheet/procedure.h | 1 + 4 files changed, 124 insertions(+), 2 deletions(-) create mode 100644 app/sheet/context-menu.c diff --git a/app/sheet.c b/app/sheet.c index d2d74ff6..6c20143a 100644 --- a/app/sheet.c +++ b/app/sheet.c @@ -43,6 +43,7 @@ #include "sheet/sheet_internal.h" #include "sheet/screen_buffer.c" #include "sheet/procedure.c" +#include "sheet/context-menu.c" /* TODO: move this somewhere else like common or utils */ #define UNUSED(X) ((void)X) @@ -447,6 +448,11 @@ static zsvsheet_status zsvsheet_filter_handler(struct zsvsheet_proc_context *ctx return zsvsheet_status_ok; } +static zsvsheet_status zsvsheet_open_cell_context_menu_handler(struct zsvsheet_proc_context *ctx) +{ + fprintf(stderr, "context menu\n"); +} + static zsvsheet_status zsvsheet_help_handler(struct zsvsheet_proc_context *ctx) { struct zsvsheet_builtin_proc_state *state = (struct zsvsheet_builtin_proc_state *)ctx->subcommand_context; struct zsvsheet_display_info *di = &state->display_info; @@ -604,6 +610,7 @@ struct builtin_proc_desc { { zsvsheet_builtin_proc_resize, "resize", "Resize the layout to fit new terminal dimensions", zsvsheet_builtin_proc_handler }, { zsvsheet_builtin_proc_open_file, "open", "Open a another CSV file", zsvsheet_open_file_handler }, { zsvsheet_builtin_proc_filter, "filter", "Hide rows that do not contain the specified text", zsvsheet_filter_handler }, + { zsvsheet_builtin_proc_open_cell_context_menu, "open-cell-context-menu", "Open cell context menu", zsvsheet_open_cell_context_menu_handler }, { zsvsheet_builtin_proc_help, "help", "Display a list of actions and key-bindings", zsvsheet_help_handler }, { -1, NULL, NULL } }; diff --git a/app/sheet/context-menu.c b/app/sheet/context-menu.c new file mode 100644 index 00000000..f572519e --- /dev/null +++ b/app/sheet/context-menu.c @@ -0,0 +1,114 @@ +#include "procedure.h" + +#ifndef MIN +# define MIN(A,B) ((A)<(B)?(A):(B)) +#endif +#ifndef MAX +# define MAX(A,B) ((A)>(B)?(A):(B)) +#endif + +struct context_menu_entry { + const char *name; + zsvsheet_proc_id_t proc_id; + struct context_menu_entry *next; + /* Entries can be created on stack and linked to the menu but when using + * using context_menu_add_entry* the entries are allocated. + * This bit indicates whether or not this entry should be freed on cleanup. + */ + uint8_t allocated : 1; +}; + + +struct context_menu { + struct context_menu_entry *entries; + struct context_menu_entry *last_entry; +}; + +/* Context menu linking to existing procedure */ +int context_menu_entry_init( + struct context_menu_entry *entry, const char *name) +{ + memset(entry, 0, sizeof(*entry)); + entry->name = name; + return 0; +} + +int context_menu_init(struct context_menu *menu) +{ + memset(menu, 0, sizeof(*menu)); + return 0; +} + +void context_menu_add_entry( + struct context_menu *menu, struct context_menu_entry *entry) +{ + if(menu->last_entry) { + menu->last_entry->next = entry; + menu->last_entry = entry; + } else { + assert(menu->entries == NULL); + menu->entries = menu->last_entry = entry; + } +} + +int context_menu_new_entry( + struct context_menu *menu, const char *name) +{ + struct context_menu_entry *entry = malloc(sizeof(struct context_menu_entry)); + if(!entry) + return -ENOMEM; + if(context_menu_entry_init(entry, name)) + return -1; + entry->allocated = true; + context_menu_add_entry(menu, entry); + return 0; +} + +int context_menu_display( + struct context_menu *menu, int row, int col, struct zsvsheet_display_dimensions *display_dims) +{ + int padding = 2; + int menu_width = 0, menu_height = 0; + + for(struct context_menu_entry *entry = menu->entries; entry; entry = entry->next) { + int len = strlen(entry->name); + menu_width = MAX(menu_width, len); + menu_height += 1; + } + /* add padding */ + menu_width += padding * 2; + + /* Make sure we don't overrun the screen horizontally */ + col -= MAX(0, col + menu_width - (int)display_dims->columns); + + /* TODO: don't write over footer */ + if(row + menu_height > display_dims->rows) + row -= menu_height; + else + row -= 1; /* Display the menu under the selected cell by default */ + + attron(A_REVERSE); + int i = 0; + for(struct context_menu_entry *entry = menu->entries; entry; entry = entry->next) + { + mvprintw(row + i, col, "%-*s", menu_width, ""); + mvprintw(row + i, col + padding, "%s", entry->name); + i += 1; + } + attroff(A_REVERSE); + return 0; +} + +int context_menu_cleanup(struct context_menu *menu) +{ + struct context_menu_entry *entry = menu->entries, *next; + while(entry) { + next = entry->next; + entry->next = NULL; + if(entry->allocated) + free(entry); + entry = next; + } + memset(menu, 0, sizeof(*menu)); +} + diff --git a/app/sheet/key-bindings.c b/app/sheet/key-bindings.c index dc92242f..58db6425 100644 --- a/app/sheet/key-bindings.c +++ b/app/sheet/key-bindings.c @@ -26,8 +26,7 @@ zsvsheet_status zsvsheet_proc_key_binding_handler(struct zsvsheet_key_binding_co return zsvsheet_proc_invoke_from_keypress(ctx->binding->proc_id, ctx->ch, ctx->subcommand_context); } -int zsvsheet_register_key_binding(struct zsvsheet_key_binding *binding) { - if (zsvsheet_find_key_binding(binding->ch)) +int zsvsheet_register_key_binding(struct zsvsheet_key_binding *binding) { if (zsvsheet_find_key_binding(binding->ch)) return EEXIST; /* Key bound already */ if (binding->proc_id != ZSVSHEET_PROC_INVALID && binding->handler == NULL) @@ -170,6 +169,7 @@ struct zsvsheet_key_binding zsvsheet_vim_key_bindings[] = { /* Open is a subcommand only in vim. Keeping the binding for now */ { .ch = 'e', .proc_id = zsvsheet_builtin_proc_open_file, }, { .ch = 'f', .proc_id = zsvsheet_builtin_proc_filter, }, + { .ch = 'c', .proc_id = zsvsheet_builtin_proc_open_cell_context_menu, }, { .ch = '?', .proc_id = zsvsheet_builtin_proc_help, }, { .ch = -1 } diff --git a/app/sheet/procedure.h b/app/sheet/procedure.h index bca5fa91..508c7fdf 100644 --- a/app/sheet/procedure.h +++ b/app/sheet/procedure.h @@ -30,6 +30,7 @@ enum { zsvsheet_builtin_proc_open_file, zsvsheet_builtin_proc_resize, zsvsheet_builtin_proc_prompt, + zsvsheet_builtin_proc_open_cell_context_menu, zsvsheet_builtin_proc_help, zsvsheet_builtin_proc_vim_g_key_binding_dmux, }; From bc2b97a20da295afb40c39e9b8db08eb7ee83cfd Mon Sep 17 00:00:00 2001 From: br1tney5pear5 Date: Sun, 15 Dec 2024 23:39:10 +0000 Subject: [PATCH 02/15] fixes --- app/sheet.c | 119 ++++++++++++++++++++++++++++++++++++++- app/sheet/context-menu.c | 94 ++++++++++++++++++++++++------- app/sheet/key-bindings.c | 10 ++-- app/sheet/procedure.c | 6 ++ app/sheet/procedure.h | 7 +++ 5 files changed, 211 insertions(+), 25 deletions(-) diff --git a/app/sheet.c b/app/sheet.c index 064ee21a..c4de930b 100644 --- a/app/sheet.c +++ b/app/sheet.c @@ -75,8 +75,23 @@ struct zsvsheet_sheet_context { struct zsvsheet_display_info display_info; char *find; struct zsv_prop_handler *custom_prop_handler; + + struct { + bool active; + int row; + int col; + struct context_menu menu; + } context_menu; }; +void zsvsheet_display_context_menu(struct zsvsheet_sheet_context *state) +{ + if(state->context_menu.active) { + context_menu_display(&state->context_menu.menu, + state->context_menu.row, state->context_menu.col, state->display_info.dimensions); + } +} + static void get_subcommand(const char *prompt, char *buff, size_t buffsize, int footer_row) { *buff = '\0'; // this is a hack to blank-out the currently-selected cell value @@ -440,9 +455,80 @@ static zsvsheet_status zsvsheet_filter_handler(struct zsvsheet_proc_context *ctx return zsvsheet_status_ok; } +static zsvsheet_status zsvsheet_context_menu_filter_handler(struct zsvsheet_proc_context *ctx) { + if(ctx->invocation.type != zsvsheet_proc_invocation_type_context_menu) + return zsvsheet_status_error; + + struct zsvsheet_sheet_context *state = (struct zsvsheet_sheet_context *)ctx->subcommand_context; + struct zsvsheet_ui_buffer *current_ui_buffer = *(state->display_info.ui_buffers.current); + const char *contents = zsvsheet_screen_buffer_cell_display(current_ui_buffer->buffer, + current_ui_buffer->cursor_row, current_ui_buffer->cursor_col); + + fprintf(stderr, "filtering for %s\n", contents); + struct zsvsheet_proc_context context = { + .proc_id = zsvsheet_builtin_proc_filter, + .invocation.type = zsvsheet_proc_invocation_type_proc, + .invocation.interactive = false, + .invocation.u.proc.id = ctx->proc_id, + .subcommand_context = ctx->subcommand_context, + .num_params = 1, + .params[0].u.string = contents, + }; + return zsvsheet_proc_invoke(context.proc_id, &context); +} + +static zsvsheet_status zsvsheet_context_menu_open_link_handler(struct zsvsheet_proc_context *ctx) { + if(ctx->invocation.type != zsvsheet_proc_invocation_type_context_menu) + return zsvsheet_status_error; + + struct zsvsheet_sheet_context *state = (struct zsvsheet_sheet_context *)ctx->subcommand_context; + struct zsvsheet_ui_buffer *current_ui_buffer = *(state->display_info.ui_buffers.current); + const char *contents = zsvsheet_screen_buffer_cell_display(current_ui_buffer->buffer, + current_ui_buffer->cursor_row, current_ui_buffer->cursor_col); + + char command[256]; + + /* Just an example, won't work on most platforms, escaping etc.... */ + snprintf(command, sizeof(command), "xdg-open '%s'", contents); + fprintf(stderr, "opening link '%s'...\n", contents); + fprintf(stderr, "%s\n", command); + + system(command); + + return zsvsheet_status_ok; +} + +void zsvsheet_open_context_menu(struct zsvsheet_sheet_context *state) +{ + /* create context menu based on the cell contents/metadata */ + struct zsvsheet_ui_buffer *current_ui_buffer = *(state->display_info.ui_buffers.current); + struct zsvsheet_display_dimensions *ddims = state->display_info.dimensions; + size_t cell_display_width = zsvsheet_cell_display_width(current_ui_buffer, ddims); + char entry_name[64]; + + context_menu_cleanup(&state->context_menu.menu); + if(context_menu_init(&state->context_menu.menu)) + return; + + snprintf(entry_name, sizeof(entry_name), "Filter for '%s'", + zsvsheet_screen_buffer_cell_display(current_ui_buffer->buffer, + current_ui_buffer->cursor_row, current_ui_buffer->cursor_col)); + if(context_menu_new_entry_func(&state->context_menu.menu, entry_name, zsvsheet_context_menu_filter_handler)) + return; + if(context_menu_new_entry_func(&state->context_menu.menu, "Open link...", zsvsheet_context_menu_open_link_handler)) + return; + + state->context_menu.row = current_ui_buffer->cursor_row; + state->context_menu.col = current_ui_buffer->cursor_col * cell_display_width; + state->context_menu.active = true; +} + static zsvsheet_status zsvsheet_open_cell_context_menu_handler(struct zsvsheet_proc_context *ctx) { - fprintf(stderr, "context menu\n"); + struct zsvsheet_sheet_context *state = (struct zsvsheet_sheet_context *)ctx->subcommand_context; + zsvsheet_open_context_menu(state); + zsvsheet_display_context_menu(state); + return zsvsheet_status_ok; } static zsvsheet_status zsvsheet_subcommand_handler(struct zsvsheet_proc_context *ctx) { @@ -553,6 +639,31 @@ zsvsheet_status zsvsheet_builtin_proc_handler(struct zsvsheet_proc_context *ctx) struct zsvsheet_sheet_context *state = (struct zsvsheet_sheet_context *)ctx->subcommand_context; struct zsvsheet_ui_buffer *current_ui_buffer = *(state->display_info.ui_buffers.current); + if(state->context_menu.active) { + zsvsheet_status context_menu_status = zsvsheet_status_ok; + switch(ctx->proc_id) { + case zsvsheet_builtin_proc_move_up: + context_menu_move_up(&state->context_menu.menu); + break; + case zsvsheet_builtin_proc_move_down: + context_menu_move_down(&state->context_menu.menu); + break; + case zsvsheet_builtin_proc_escape: + state->context_menu.active = false; + break; + case zsvsheet_builtin_proc_confirm: + context_menu_status = context_menu_confirm(&state->context_menu.menu, state); + state->context_menu.active = false; + break; + default: + state->context_menu.active = false; + goto non_context_menu_action; + } + zsvsheet_display_context_menu(state); + return context_menu_status; + } +non_context_menu_action: + switch (ctx->proc_id) { case zsvsheet_builtin_proc_quit: // while(*state->display_info.ui_buffers.current) @@ -594,6 +705,8 @@ zsvsheet_status zsvsheet_builtin_proc_handler(struct zsvsheet_proc_context *ctx) } } break; + case zsvsheet_builtin_proc_confirm: + return zsvsheet_newline_handler(ctx); case zsvsheet_builtin_proc_find: return zsvsheet_find(state, false); @@ -631,7 +744,7 @@ struct builtin_proc_desc { { zsvsheet_builtin_proc_subcommand, "subcommand", "Editor subcommand", zsvsheet_subcommand_handler }, { zsvsheet_builtin_proc_open_cell_context_menu, "open-cell-context-menu", "Open cell context menu", zsvsheet_open_cell_context_menu_handler }, { zsvsheet_builtin_proc_help, "help", "Display a list of actions and key-bindings", zsvsheet_help_handler }, - { zsvsheet_builtin_proc_newline, "","Follow hyperlink (if any)", zsvsheet_newline_handler }, + { zsvsheet_builtin_proc_confirm, "confirm", "Confirm", zsvsheet_builtin_proc_handler }, { -1, NULL, NULL, NULL } }; /* clang-format on */ @@ -733,6 +846,7 @@ int ZSV_MAIN_FUNC(ZSV_COMMAND)(int argc, const char *argv[], struct zsv_opts *op .find = NULL, .custom_prop_handler = custom_prop_handler, }; + memset(&handler_state.context_menu, 0, sizeof(handler_state.context_menu)); zsvsheet_status status; @@ -768,6 +882,7 @@ int ZSV_MAIN_FUNC(ZSV_COMMAND)(int argc, const char *argv[], struct zsv_opts *op } display_buffer_subtable(ub, header_span, &display_dims); + zsvsheet_display_context_menu(&handler_state); } endwin(); diff --git a/app/sheet/context-menu.c b/app/sheet/context-menu.c index f572519e..8e7792f9 100644 --- a/app/sheet/context-menu.c +++ b/app/sheet/context-menu.c @@ -8,31 +8,25 @@ #endif struct context_menu_entry { - const char *name; - zsvsheet_proc_id_t proc_id; + struct context_menu_entry *prev; struct context_menu_entry *next; + char *name; + zsvsheet_proc_id_t proc_id; /* Entries can be created on stack and linked to the menu but when using * using context_menu_add_entry* the entries are allocated. * This bit indicates whether or not this entry should be freed on cleanup. */ uint8_t allocated : 1; + uint8_t proc_ephemeral : 1; }; struct context_menu { struct context_menu_entry *entries; struct context_menu_entry *last_entry; + struct context_menu_entry *selected_entry; }; -/* Context menu linking to existing procedure */ -int context_menu_entry_init( - struct context_menu_entry *entry, const char *name) -{ - memset(entry, 0, sizeof(*entry)); - entry->name = name; - return 0; -} - int context_menu_init(struct context_menu *menu) { memset(menu, 0, sizeof(*menu)); @@ -44,26 +38,51 @@ void context_menu_add_entry( { if(menu->last_entry) { menu->last_entry->next = entry; + entry->prev = menu->last_entry; menu->last_entry = entry; + menu->last_entry->next = NULL; } else { assert(menu->entries == NULL); menu->entries = menu->last_entry = entry; + menu->last_entry->next = menu->last_entry->prev = NULL; + menu->selected_entry = entry; } } -int context_menu_new_entry( - struct context_menu *menu, const char *name) +int _context_menu_alloc_entry( + struct context_menu *menu, const char *name, zsvsheet_proc_id_t proc_id, + bool proc_ephemeral) { struct context_menu_entry *entry = malloc(sizeof(struct context_menu_entry)); if(!entry) return -ENOMEM; - if(context_menu_entry_init(entry, name)) - return -1; + memset(entry, 0, sizeof(*entry)); + entry->name = strdup(name); + entry->proc_id = proc_id; entry->allocated = true; + entry->proc_ephemeral = proc_ephemeral; context_menu_add_entry(menu, entry); return 0; } +/* New entry calling existing procedure */ +int context_menu_new_entry( + struct context_menu *menu, const char *name, zsvsheet_proc_id_t proc_id) +{ + return _context_menu_alloc_entry(menu, name, proc_id, false); + +} + +/* New entry calling existing a newly created procedure */ +int context_menu_new_entry_func( + struct context_menu *menu, const char *name, zsvsheet_proc_fn handler) +{ + zsvsheet_proc_id_t proc_id = zsvsheet_register_proc(NULL, NULL, handler); + if(!is_valid_proc_id(proc_id)) + return -EINVAL; + return _context_menu_alloc_entry(menu, name, proc_id, true); +} + int context_menu_display( struct context_menu *menu, int row, int col, struct zsvsheet_display_dimensions *display_dims) { @@ -81,30 +100,67 @@ int context_menu_display( /* Make sure we don't overrun the screen horizontally */ col -= MAX(0, col + menu_width - (int)display_dims->columns); - /* TODO: don't write over footer */ - if(row + menu_height > display_dims->rows) + if(row + menu_height > display_dims->rows - display_dims->footer_span - display_dims->header_span) row -= menu_height; else - row -= 1; /* Display the menu under the selected cell by default */ + row += 1; /* Display the menu under the selected cell by default */ attron(A_REVERSE); int i = 0; for(struct context_menu_entry *entry = menu->entries; entry; entry = entry->next) { mvprintw(row + i, col, "%-*s", menu_width, ""); + if(entry == menu->selected_entry) + attron(A_UNDERLINE); mvprintw(row + i, col + padding, "%s", entry->name); + if(entry == menu->selected_entry) { + attroff(A_UNDERLINE); + if(padding) /* add a lil star if we have space */ + mvprintw(row + i, col, "*"); + } i += 1; } attroff(A_REVERSE); return 0; } -int context_menu_cleanup(struct context_menu *menu) +zsvsheet_status context_menu_confirm(struct context_menu *menu, void *subcommand_context) +{ + if(!menu->selected_entry) + return zsvsheet_status_error; + + zsvsheet_proc_id_t proc_id = menu->selected_entry->proc_id; + struct zsvsheet_proc_context context = { + .proc_id = proc_id, + .invocation.type = zsvsheet_proc_invocation_type_context_menu, + .invocation.interactive = true, + .invocation.u.context_menu.entry = menu->selected_entry, + .subcommand_context = subcommand_context, + }; + return zsvsheet_proc_invoke(proc_id, &context); +} + +void context_menu_move_up(struct context_menu *menu) +{ + if(menu->selected_entry && menu->selected_entry->prev) + menu->selected_entry = menu->selected_entry->prev; +} + +void context_menu_move_down(struct context_menu *menu) +{ + if(menu->selected_entry && menu->selected_entry->next) + menu->selected_entry = menu->selected_entry->next; +} + +void context_menu_cleanup(struct context_menu *menu) { struct context_menu_entry *entry = menu->entries, *next; while(entry) { next = entry->next; entry->next = NULL; + free(entry->name); + if(entry->proc_ephemeral) + zsvsheet_unregister_proc(entry->proc_id); if(entry->allocated) free(entry); entry = next; diff --git a/app/sheet/key-bindings.c b/app/sheet/key-bindings.c index a273c0e9..377ad7ac 100644 --- a/app/sheet/key-bindings.c +++ b/app/sheet/key-bindings.c @@ -172,8 +172,9 @@ struct zsvsheet_key_binding zsvsheet_vim_key_bindings[] = { { .ch = 'c', .proc_id = zsvsheet_builtin_proc_open_cell_context_menu, }, { .ch = ':', .proc_id = zsvsheet_builtin_proc_subcommand, }, { .ch = '?', .proc_id = zsvsheet_builtin_proc_help, }, - { .ch = '\n', .proc_id = zsvsheet_builtin_proc_newline, }, - { .ch = '\r', .proc_id = zsvsheet_builtin_proc_newline, }, + { .ch = '\n', .proc_id = zsvsheet_builtin_proc_confirm, }, + { .ch = '\r', .proc_id = zsvsheet_builtin_proc_confirm, }, + { .ch = KEY_ENTER, .proc_id = zsvsheet_builtin_proc_confirm, }, { .ch = -1 } }; @@ -234,8 +235,9 @@ struct zsvsheet_key_binding zsvsheet_emacs_key_bindings[] = { /* No such thing in emacs, find a more suitable binding */ { .ch = 'f', .proc_id = zsvsheet_builtin_proc_filter, }, { .ch = ZSVSHEET_CTRL('h'), .proc_id = zsvsheet_builtin_proc_help, }, - { .ch = '\n', .proc_id = zsvsheet_builtin_proc_newline, }, - { .ch = '\r', .proc_id = zsvsheet_builtin_proc_newline, }, + { .ch = '\n', .proc_id = zsvsheet_builtin_proc_confirm, }, + { .ch = '\r', .proc_id = zsvsheet_builtin_proc_confirm, }, + { .ch = KEY_ENTER, .proc_id = zsvsheet_builtin_proc_confirm, }, { .ch = -1 } }; diff --git a/app/sheet/procedure.c b/app/sheet/procedure.c index b821da9b..bbf0c7cf 100644 --- a/app/sheet/procedure.c +++ b/app/sheet/procedure.c @@ -132,3 +132,9 @@ zsvsheet_proc_id_t zsvsheet_register_proc(const char *name, const char *descript .id = zsvsheet_generate_proc_id(), .name = name, .description = description, .handler = handler}; return zsvsheet_do_register_proc(&procedure); } + +void zsvsheet_unregister_proc(zsvsheet_proc_id_t id) { + struct zsvsheet_procedure *proc = &procedure_lookup[id]; + proc_debug("unregister proc %d %s\n", proc->id, proc->name ? proc->name : "(unnamed)"); + proc->id = ZSVSHEET_PROC_INVALID; +} diff --git a/app/sheet/procedure.h b/app/sheet/procedure.h index 16240615..3cfae010 100644 --- a/app/sheet/procedure.h +++ b/app/sheet/procedure.h @@ -3,6 +3,8 @@ #include #include +struct zsvsheet_context_menu_entry; + /* ID's of bulitin procedures, extensions can register more. * * TODO: What specific procedures are bulitin and what are their @@ -35,6 +37,7 @@ enum { zsvsheet_builtin_proc_help, zsvsheet_builtin_proc_vim_g_key_binding_dmux, zsvsheet_builtin_proc_newline, + zsvsheet_builtin_proc_confirm, }; #define ZSVSHEET_PROC_INVALID 0 @@ -46,6 +49,7 @@ enum { enum zsvsheet_proc_invocation_type { zsvsheet_proc_invocation_type_keypress, zsvsheet_proc_invocation_type_proc, + zsvsheet_proc_invocation_type_context_menu, /* Add more... */ }; @@ -67,6 +71,9 @@ struct zsvsheet_proc_context { struct { zsvsheet_proc_id_t id; } proc; + struct { + struct zsvsheet_context_menu_entry *entry; + } context_menu; } u; } invocation; From be9e55656a1ea52cdb0f576acfec2e37019416d7 Mon Sep 17 00:00:00 2001 From: br1tney5pear5 Date: Mon, 16 Dec 2024 00:06:23 +0000 Subject: [PATCH 03/15] not calling system on context menu open-link, has to be properly implemented at some point --- app/sheet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/sheet.c b/app/sheet.c index c4de930b..386e4a21 100644 --- a/app/sheet.c +++ b/app/sheet.c @@ -493,7 +493,7 @@ static zsvsheet_status zsvsheet_context_menu_open_link_handler(struct zsvsheet_p fprintf(stderr, "opening link '%s'...\n", contents); fprintf(stderr, "%s\n", command); - system(command); + //system(command); return zsvsheet_status_ok; } From f07de89322a7b2e5a1e3c1c0b81e23d35e45d39f Mon Sep 17 00:00:00 2001 From: br1tney5pear5 Date: Mon, 16 Dec 2024 00:10:09 +0000 Subject: [PATCH 04/15] clang format fix --- app/2db.c | 12 +----- app/2tsv.c | 5 +-- app/compare_unique_colname.c | 7 ++- app/flatten.c | 5 +-- app/prop.c | 5 +-- app/select-pull.c | 2 +- app/select.c | 2 +- app/sheet.c | 79 ++++++++++++++++------------------ app/sheet/context-menu.c | 76 +++++++++++++------------------- app/sheet/key-bindings.c | 3 +- app/utils/cache.c | 5 +-- include/zsv/common.h | 2 +- include/zsv/utils/cache.h | 6 +-- include/zsv/utils/jq.h | 7 +-- scripts/ci-run-clang-format.sh | 2 +- src/zsv_internal.c | 2 +- 16 files changed, 86 insertions(+), 134 deletions(-) diff --git a/app/2db.c b/app/2db.c index 5e923513..dc56f8d6 100644 --- a/app/2db.c +++ b/app/2db.c @@ -24,17 +24,9 @@ #define ZSV_2DB_DEFAULT_TABLE_NAME "mytable" -enum zsv_2db_action { - zsv_2db_action_create = 1, - zsv_2db_action_append, - zsv_2db_action_index -}; +enum zsv_2db_action { zsv_2db_action_create = 1, zsv_2db_action_append, zsv_2db_action_index }; -enum zsv_2db_state { - zsv_2db_state_header = 1, - zsv_2db_state_data, - zsv_2db_state_done -}; +enum zsv_2db_state { zsv_2db_state_header = 1, zsv_2db_state_data, zsv_2db_state_done }; #define LQ_2DB_MAX_INDEXES 32 diff --git a/app/2tsv.c b/app/2tsv.c index aadfa7b3..f35c47ea 100644 --- a/app/2tsv.c +++ b/app/2tsv.c @@ -14,10 +14,7 @@ #include -enum zsv_2tsv_status { - zsv_2tsv_status_ok = 0, - zsv_2tsv_status_out_of_memory -}; +enum zsv_2tsv_status { zsv_2tsv_status_ok = 0, zsv_2tsv_status_out_of_memory }; #define ZSV_2TSV_BUFF_SIZE 65536 diff --git a/app/compare_unique_colname.c b/app/compare_unique_colname.c index c6123637..a00a4a1a 100644 --- a/app/compare_unique_colname.c +++ b/app/compare_unique_colname.c @@ -1,8 +1,7 @@ static int zsv_compare_unique_colname_cmp(zsv_compare_unique_colname *x, zsv_compare_unique_colname *y) { - return x->instance_num == y->instance_num ? zsv_stricmp(x->name, y->name) - : x->instance_num > y->instance_num ? 1 - : x->instance_num < y->instance_num ? -1 - : 0; + return x->instance_num == y->instance_num + ? zsv_stricmp(x->name, y->name) + : x->instance_num > y->instance_num ? 1 : x->instance_num < y->instance_num ? -1 : 0; } SGLIB_DEFINE_RBTREE_FUNCTIONS(zsv_compare_unique_colname, left, right, color, zsv_compare_unique_colname_cmp); diff --git a/app/flatten.c b/app/flatten.c index 91ff8248..c6fa0d34 100644 --- a/app/flatten.c +++ b/app/flatten.c @@ -21,10 +21,7 @@ #include #include -enum flatten_agg_method { - flatten_agg_method_none = 1, - flatten_agg_method_array -}; +enum flatten_agg_method { flatten_agg_method_none = 1, flatten_agg_method_array }; struct flatten_column_name_and_ix { unsigned char *name; diff --git a/app/prop.c b/app/prop.c index 848f6af9..c88ad583 100644 --- a/app/prop.c +++ b/app/prop.c @@ -659,10 +659,7 @@ static int zsv_prop_foreach_clean(struct zsv_foreach_dirent_handle *h, size_t de return err; } -enum zsv_prop_foreach_copy_mode { - zsv_prop_foreach_copy_mode_check = 1, - zsv_prop_foreach_copy_mode_copy -}; +enum zsv_prop_foreach_copy_mode { zsv_prop_foreach_copy_mode_check = 1, zsv_prop_foreach_copy_mode_copy }; struct zsv_prop_foreach_copy_ctx { struct zsv_dir_filter zsv_dir_filter; diff --git a/app/select-pull.c b/app/select-pull.c index 2b2a5fe6..a8677e81 100644 --- a/app/select-pull.c +++ b/app/select-pull.c @@ -64,7 +64,7 @@ struct zsv_select_data { struct { // merge data: only used with --merge struct zsv_select_uint_list *indexes, **last_index; } merge; - } *out2in; // array of .output_cols_count length; out2in[x] = y where x = output ix, y = input info + } * out2in; // array of .output_cols_count length; out2in[x] = y where x = output ix, y = input info unsigned int output_cols_count; // total count of output columns diff --git a/app/select.c b/app/select.c index 698cd2b4..15ed2001 100644 --- a/app/select.c +++ b/app/select.c @@ -71,7 +71,7 @@ struct zsv_select_data { struct { // merge data: only used with --merge struct zsv_select_uint_list *indexes, **last_index; } merge; - } *out2in; // array of .output_cols_count length; out2in[x] = y where x = output ix, y = input info + } * out2in; // array of .output_cols_count length; out2in[x] = y where x = output ix, y = input info unsigned int output_cols_count; // total count of output columns diff --git a/app/sheet.c b/app/sheet.c index 386e4a21..31abd165 100644 --- a/app/sheet.c +++ b/app/sheet.c @@ -84,11 +84,10 @@ struct zsvsheet_sheet_context { } context_menu; }; -void zsvsheet_display_context_menu(struct zsvsheet_sheet_context *state) -{ - if(state->context_menu.active) { - context_menu_display(&state->context_menu.menu, - state->context_menu.row, state->context_menu.col, state->display_info.dimensions); +void zsvsheet_display_context_menu(struct zsvsheet_sheet_context *state) { + if (state->context_menu.active) { + context_menu_display(&state->context_menu.menu, state->context_menu.row, state->context_menu.col, + state->display_info.dimensions); } } @@ -456,14 +455,14 @@ static zsvsheet_status zsvsheet_filter_handler(struct zsvsheet_proc_context *ctx } static zsvsheet_status zsvsheet_context_menu_filter_handler(struct zsvsheet_proc_context *ctx) { - if(ctx->invocation.type != zsvsheet_proc_invocation_type_context_menu) + if (ctx->invocation.type != zsvsheet_proc_invocation_type_context_menu) return zsvsheet_status_error; struct zsvsheet_sheet_context *state = (struct zsvsheet_sheet_context *)ctx->subcommand_context; struct zsvsheet_ui_buffer *current_ui_buffer = *(state->display_info.ui_buffers.current); - const char *contents = zsvsheet_screen_buffer_cell_display(current_ui_buffer->buffer, - current_ui_buffer->cursor_row, current_ui_buffer->cursor_col); - + const char *contents = zsvsheet_screen_buffer_cell_display(current_ui_buffer->buffer, current_ui_buffer->cursor_row, + current_ui_buffer->cursor_col); + fprintf(stderr, "filtering for %s\n", contents); struct zsvsheet_proc_context context = { .proc_id = zsvsheet_builtin_proc_filter, @@ -478,13 +477,13 @@ static zsvsheet_status zsvsheet_context_menu_filter_handler(struct zsvsheet_proc } static zsvsheet_status zsvsheet_context_menu_open_link_handler(struct zsvsheet_proc_context *ctx) { - if(ctx->invocation.type != zsvsheet_proc_invocation_type_context_menu) + if (ctx->invocation.type != zsvsheet_proc_invocation_type_context_menu) return zsvsheet_status_error; struct zsvsheet_sheet_context *state = (struct zsvsheet_sheet_context *)ctx->subcommand_context; struct zsvsheet_ui_buffer *current_ui_buffer = *(state->display_info.ui_buffers.current); - const char *contents = zsvsheet_screen_buffer_cell_display(current_ui_buffer->buffer, - current_ui_buffer->cursor_row, current_ui_buffer->cursor_col); + const char *contents = zsvsheet_screen_buffer_cell_display(current_ui_buffer->buffer, current_ui_buffer->cursor_row, + current_ui_buffer->cursor_col); char command[256]; @@ -493,13 +492,12 @@ static zsvsheet_status zsvsheet_context_menu_open_link_handler(struct zsvsheet_p fprintf(stderr, "opening link '%s'...\n", contents); fprintf(stderr, "%s\n", command); - //system(command); - + // system(command); + return zsvsheet_status_ok; } -void zsvsheet_open_context_menu(struct zsvsheet_sheet_context *state) -{ +void zsvsheet_open_context_menu(struct zsvsheet_sheet_context *state) { /* create context menu based on the cell contents/metadata */ struct zsvsheet_ui_buffer *current_ui_buffer = *(state->display_info.ui_buffers.current); struct zsvsheet_display_dimensions *ddims = state->display_info.dimensions; @@ -507,15 +505,15 @@ void zsvsheet_open_context_menu(struct zsvsheet_sheet_context *state) char entry_name[64]; context_menu_cleanup(&state->context_menu.menu); - if(context_menu_init(&state->context_menu.menu)) + if (context_menu_init(&state->context_menu.menu)) return; snprintf(entry_name, sizeof(entry_name), "Filter for '%s'", - zsvsheet_screen_buffer_cell_display(current_ui_buffer->buffer, - current_ui_buffer->cursor_row, current_ui_buffer->cursor_col)); - if(context_menu_new_entry_func(&state->context_menu.menu, entry_name, zsvsheet_context_menu_filter_handler)) + zsvsheet_screen_buffer_cell_display(current_ui_buffer->buffer, current_ui_buffer->cursor_row, + current_ui_buffer->cursor_col)); + if (context_menu_new_entry_func(&state->context_menu.menu, entry_name, zsvsheet_context_menu_filter_handler)) return; - if(context_menu_new_entry_func(&state->context_menu.menu, "Open link...", zsvsheet_context_menu_open_link_handler)) + if (context_menu_new_entry_func(&state->context_menu.menu, "Open link...", zsvsheet_context_menu_open_link_handler)) return; state->context_menu.row = current_ui_buffer->cursor_row; @@ -523,8 +521,7 @@ void zsvsheet_open_context_menu(struct zsvsheet_sheet_context *state) state->context_menu.active = true; } -static zsvsheet_status zsvsheet_open_cell_context_menu_handler(struct zsvsheet_proc_context *ctx) -{ +static zsvsheet_status zsvsheet_open_cell_context_menu_handler(struct zsvsheet_proc_context *ctx) { struct zsvsheet_sheet_context *state = (struct zsvsheet_sheet_context *)ctx->subcommand_context; zsvsheet_open_context_menu(state); zsvsheet_display_context_menu(state); @@ -639,25 +636,25 @@ zsvsheet_status zsvsheet_builtin_proc_handler(struct zsvsheet_proc_context *ctx) struct zsvsheet_sheet_context *state = (struct zsvsheet_sheet_context *)ctx->subcommand_context; struct zsvsheet_ui_buffer *current_ui_buffer = *(state->display_info.ui_buffers.current); - if(state->context_menu.active) { + if (state->context_menu.active) { zsvsheet_status context_menu_status = zsvsheet_status_ok; - switch(ctx->proc_id) { - case zsvsheet_builtin_proc_move_up: - context_menu_move_up(&state->context_menu.menu); - break; - case zsvsheet_builtin_proc_move_down: - context_menu_move_down(&state->context_menu.menu); - break; - case zsvsheet_builtin_proc_escape: - state->context_menu.active = false; - break; - case zsvsheet_builtin_proc_confirm: - context_menu_status = context_menu_confirm(&state->context_menu.menu, state); - state->context_menu.active = false; - break; - default: - state->context_menu.active = false; - goto non_context_menu_action; + switch (ctx->proc_id) { + case zsvsheet_builtin_proc_move_up: + context_menu_move_up(&state->context_menu.menu); + break; + case zsvsheet_builtin_proc_move_down: + context_menu_move_down(&state->context_menu.menu); + break; + case zsvsheet_builtin_proc_escape: + state->context_menu.active = false; + break; + case zsvsheet_builtin_proc_confirm: + context_menu_status = context_menu_confirm(&state->context_menu.menu, state); + state->context_menu.active = false; + break; + default: + state->context_menu.active = false; + goto non_context_menu_action; } zsvsheet_display_context_menu(state); return context_menu_status; diff --git a/app/sheet/context-menu.c b/app/sheet/context-menu.c index 8e7792f9..e7034a09 100644 --- a/app/sheet/context-menu.c +++ b/app/sheet/context-menu.c @@ -1,10 +1,10 @@ #include "procedure.h" #ifndef MIN -# define MIN(A,B) ((A)<(B)?(A):(B)) +#define MIN(A, B) ((A) < (B) ? (A) : (B)) #endif #ifndef MAX -# define MAX(A,B) ((A)>(B)?(A):(B)) +#define MAX(A, B) ((A) > (B) ? (A) : (B)) #endif struct context_menu_entry { @@ -20,23 +20,19 @@ struct context_menu_entry { uint8_t proc_ephemeral : 1; }; - struct context_menu { struct context_menu_entry *entries; struct context_menu_entry *last_entry; struct context_menu_entry *selected_entry; }; -int context_menu_init(struct context_menu *menu) -{ +int context_menu_init(struct context_menu *menu) { memset(menu, 0, sizeof(*menu)); return 0; } -void context_menu_add_entry( - struct context_menu *menu, struct context_menu_entry *entry) -{ - if(menu->last_entry) { +void context_menu_add_entry(struct context_menu *menu, struct context_menu_entry *entry) { + if (menu->last_entry) { menu->last_entry->next = entry; entry->prev = menu->last_entry; menu->last_entry = entry; @@ -49,12 +45,10 @@ void context_menu_add_entry( } } -int _context_menu_alloc_entry( - struct context_menu *menu, const char *name, zsvsheet_proc_id_t proc_id, - bool proc_ephemeral) -{ +int _context_menu_alloc_entry(struct context_menu *menu, const char *name, zsvsheet_proc_id_t proc_id, + bool proc_ephemeral) { struct context_menu_entry *entry = malloc(sizeof(struct context_menu_entry)); - if(!entry) + if (!entry) return -ENOMEM; memset(entry, 0, sizeof(*entry)); entry->name = strdup(name); @@ -66,30 +60,24 @@ int _context_menu_alloc_entry( } /* New entry calling existing procedure */ -int context_menu_new_entry( - struct context_menu *menu, const char *name, zsvsheet_proc_id_t proc_id) -{ +int context_menu_new_entry(struct context_menu *menu, const char *name, zsvsheet_proc_id_t proc_id) { return _context_menu_alloc_entry(menu, name, proc_id, false); - } /* New entry calling existing a newly created procedure */ -int context_menu_new_entry_func( - struct context_menu *menu, const char *name, zsvsheet_proc_fn handler) -{ +int context_menu_new_entry_func(struct context_menu *menu, const char *name, zsvsheet_proc_fn handler) { zsvsheet_proc_id_t proc_id = zsvsheet_register_proc(NULL, NULL, handler); - if(!is_valid_proc_id(proc_id)) + if (!is_valid_proc_id(proc_id)) return -EINVAL; return _context_menu_alloc_entry(menu, name, proc_id, true); } -int context_menu_display( - struct context_menu *menu, int row, int col, struct zsvsheet_display_dimensions *display_dims) -{ +int context_menu_display(struct context_menu *menu, int row, int col, + struct zsvsheet_display_dimensions *display_dims) { int padding = 2; int menu_width = 0, menu_height = 0; - for(struct context_menu_entry *entry = menu->entries; entry; entry = entry->next) { + for (struct context_menu_entry *entry = menu->entries; entry; entry = entry->next) { int len = strlen(entry->name); menu_width = MAX(menu_width, len); menu_height += 1; @@ -100,22 +88,21 @@ int context_menu_display( /* Make sure we don't overrun the screen horizontally */ col -= MAX(0, col + menu_width - (int)display_dims->columns); - if(row + menu_height > display_dims->rows - display_dims->footer_span - display_dims->header_span) + if (row + menu_height > display_dims->rows - display_dims->footer_span - display_dims->header_span) row -= menu_height; else row += 1; /* Display the menu under the selected cell by default */ attron(A_REVERSE); int i = 0; - for(struct context_menu_entry *entry = menu->entries; entry; entry = entry->next) - { + for (struct context_menu_entry *entry = menu->entries; entry; entry = entry->next) { mvprintw(row + i, col, "%-*s", menu_width, ""); - if(entry == menu->selected_entry) + if (entry == menu->selected_entry) attron(A_UNDERLINE); mvprintw(row + i, col + padding, "%s", entry->name); - if(entry == menu->selected_entry) { + if (entry == menu->selected_entry) { attroff(A_UNDERLINE); - if(padding) /* add a lil star if we have space */ + if (padding) /* add a lil star if we have space */ mvprintw(row + i, col, "*"); } i += 1; @@ -124,9 +111,8 @@ int context_menu_display( return 0; } -zsvsheet_status context_menu_confirm(struct context_menu *menu, void *subcommand_context) -{ - if(!menu->selected_entry) +zsvsheet_status context_menu_confirm(struct context_menu *menu, void *subcommand_context) { + if (!menu->selected_entry) return zsvsheet_status_error; zsvsheet_proc_id_t proc_id = menu->selected_entry->proc_id; @@ -140,31 +126,27 @@ zsvsheet_status context_menu_confirm(struct context_menu *menu, void *subcommand return zsvsheet_proc_invoke(proc_id, &context); } -void context_menu_move_up(struct context_menu *menu) -{ - if(menu->selected_entry && menu->selected_entry->prev) +void context_menu_move_up(struct context_menu *menu) { + if (menu->selected_entry && menu->selected_entry->prev) menu->selected_entry = menu->selected_entry->prev; } -void context_menu_move_down(struct context_menu *menu) -{ - if(menu->selected_entry && menu->selected_entry->next) +void context_menu_move_down(struct context_menu *menu) { + if (menu->selected_entry && menu->selected_entry->next) menu->selected_entry = menu->selected_entry->next; } -void context_menu_cleanup(struct context_menu *menu) -{ +void context_menu_cleanup(struct context_menu *menu) { struct context_menu_entry *entry = menu->entries, *next; - while(entry) { + while (entry) { next = entry->next; entry->next = NULL; free(entry->name); - if(entry->proc_ephemeral) + if (entry->proc_ephemeral) zsvsheet_unregister_proc(entry->proc_id); - if(entry->allocated) + if (entry->allocated) free(entry); entry = next; } memset(menu, 0, sizeof(*menu)); } - diff --git a/app/sheet/key-bindings.c b/app/sheet/key-bindings.c index 377ad7ac..d54be2f0 100644 --- a/app/sheet/key-bindings.c +++ b/app/sheet/key-bindings.c @@ -26,7 +26,8 @@ zsvsheet_status zsvsheet_proc_key_binding_handler(struct zsvsheet_key_binding_co return zsvsheet_proc_invoke_from_keypress(ctx->binding->proc_id, ctx->ch, ctx->subcommand_context); } -int zsvsheet_register_key_binding(struct zsvsheet_key_binding *binding) { if (zsvsheet_find_key_binding(binding->ch)) +int zsvsheet_register_key_binding(struct zsvsheet_key_binding *binding) { + if (zsvsheet_find_key_binding(binding->ch)) return EEXIST; /* Key bound already */ if (binding->proc_id != ZSVSHEET_PROC_INVALID && binding->handler == NULL) diff --git a/app/utils/cache.c b/app/utils/cache.c index ba03f885..982e7b6d 100644 --- a/app/utils/cache.c +++ b/app/utils/cache.c @@ -206,9 +206,8 @@ unsigned char *zsv_cache_path(const unsigned char *data_filepath, const unsigned return NULL; const unsigned char *last_slash = (void *)strrchr((void *)data_filepath, '/'); const unsigned char *last_backslash = (void *)strrchr((void *)data_filepath, '\\'); - const unsigned char *dir_end = (!last_slash && !last_backslash ? NULL - : last_backslash > last_slash ? last_backslash - : last_slash); + const unsigned char *dir_end = + (!last_slash && !last_backslash ? NULL : last_backslash > last_slash ? last_backslash : last_slash); char *s = NULL; char *filename_suffix = NULL; if (cache_filename) diff --git a/include/zsv/common.h b/include/zsv/common.h index 259ed407..0d80566e 100644 --- a/include/zsv/common.h +++ b/include/zsv/common.h @@ -27,7 +27,7 @@ enum zsv_status { zsv_status_row, zsv_status_done = 100 #ifdef ZSV_EXTRAS - , + , zsv_status_max_rows_read = 999 #endif }; diff --git a/include/zsv/utils/cache.h b/include/zsv/utils/cache.h index 6db6f3fd..251559fd 100644 --- a/include/zsv/utils/cache.h +++ b/include/zsv/utils/cache.h @@ -30,11 +30,7 @@ */ unsigned char *zsv_cache_path(const unsigned char *data_filepath, const unsigned char *cache_filename, char temp_file); -enum zsv_cache_type { - zsv_cache_type_property = 1, - zsv_cache_type_tag, - zsv_cache_type_overwrite -}; +enum zsv_cache_type { zsv_cache_type_property = 1, zsv_cache_type_tag, zsv_cache_type_overwrite }; unsigned char *zsv_cache_filepath(const unsigned char *data_filepath, enum zsv_cache_type type, char create_dir, char temp_file); diff --git a/include/zsv/utils/jq.h b/include/zsv/utils/jq.h index 3a238c2b..58131fe9 100644 --- a/include/zsv/utils/jq.h +++ b/include/zsv/utils/jq.h @@ -4,12 +4,7 @@ #include #include -enum zsv_jq_status { - zsv_jq_status_ok = 0, - zsv_jq_status_compile, - zsv_jq_status_memory, - zsv_jq_status_error -}; +enum zsv_jq_status { zsv_jq_status_ok = 0, zsv_jq_status_compile, zsv_jq_status_memory, zsv_jq_status_error }; size_t zsv_jq_fwrite1(void *restrict FILE_ptr, const void *restrict buff, size_t len); diff --git a/scripts/ci-run-clang-format.sh b/scripts/ci-run-clang-format.sh index 442ca9f9..9a37fce0 100755 --- a/scripts/ci-run-clang-format.sh +++ b/scripts/ci-run-clang-format.sh @@ -6,7 +6,7 @@ echo "[INF] Running $0" VERSION=$(clang-format --version | sed 's/^[^0-9]*//g' | sed 's/ .*$//g') MAJOR_VERSION=$(echo "$VERSION" | cut -d '.' -f1) -REQUIRED_VERSION="15" +REQUIRED_VERSION="10" if [ "$VERSION" = "" ]; then echo "[ERR] clang-format is not installed!" diff --git a/src/zsv_internal.c b/src/zsv_internal.c index 3fa392a1..b5aaf017 100644 --- a/src/zsv_internal.c +++ b/src/zsv_internal.c @@ -170,7 +170,7 @@ struct zsv_scanner { union { struct zsv_scan_delim_regs delim; struct zsv_scan_fixed_regs fixed; - } *regs; + } * regs; enum zsv_status stat; // last status unsigned char *buff; size_t bytes_read; From b2d400cb82ddc75168ae0a5767ce1442f730643d Mon Sep 17 00:00:00 2001 From: br1tney5pear5 Date: Mon, 16 Dec 2024 00:45:27 +0000 Subject: [PATCH 05/15] oops, commited a hack --- scripts/ci-run-clang-format.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci-run-clang-format.sh b/scripts/ci-run-clang-format.sh index 9a37fce0..442ca9f9 100755 --- a/scripts/ci-run-clang-format.sh +++ b/scripts/ci-run-clang-format.sh @@ -6,7 +6,7 @@ echo "[INF] Running $0" VERSION=$(clang-format --version | sed 's/^[^0-9]*//g' | sed 's/ .*$//g') MAJOR_VERSION=$(echo "$VERSION" | cut -d '.' -f1) -REQUIRED_VERSION="10" +REQUIRED_VERSION="15" if [ "$VERSION" = "" ]; then echo "[ERR] clang-format is not installed!" From 498ed45111779f6c05948a0a6893ce74866b2918 Mon Sep 17 00:00:00 2001 From: br1tney5pear5 Date: Mon, 16 Dec 2024 00:46:19 +0000 Subject: [PATCH 06/15] clang format again --- app/2db.c | 12 ++++++++++-- app/2tsv.c | 5 ++++- app/compare_unique_colname.c | 7 ++++--- app/flatten.c | 5 ++++- app/prop.c | 5 ++++- app/select-pull.c | 2 +- app/select.c | 2 +- app/utils/cache.c | 5 +++-- include/zsv/common.h | 2 +- include/zsv/utils/cache.h | 6 +++++- include/zsv/utils/jq.h | 7 ++++++- src/zsv_internal.c | 2 +- 12 files changed, 44 insertions(+), 16 deletions(-) diff --git a/app/2db.c b/app/2db.c index dc56f8d6..5e923513 100644 --- a/app/2db.c +++ b/app/2db.c @@ -24,9 +24,17 @@ #define ZSV_2DB_DEFAULT_TABLE_NAME "mytable" -enum zsv_2db_action { zsv_2db_action_create = 1, zsv_2db_action_append, zsv_2db_action_index }; +enum zsv_2db_action { + zsv_2db_action_create = 1, + zsv_2db_action_append, + zsv_2db_action_index +}; -enum zsv_2db_state { zsv_2db_state_header = 1, zsv_2db_state_data, zsv_2db_state_done }; +enum zsv_2db_state { + zsv_2db_state_header = 1, + zsv_2db_state_data, + zsv_2db_state_done +}; #define LQ_2DB_MAX_INDEXES 32 diff --git a/app/2tsv.c b/app/2tsv.c index f35c47ea..aadfa7b3 100644 --- a/app/2tsv.c +++ b/app/2tsv.c @@ -14,7 +14,10 @@ #include -enum zsv_2tsv_status { zsv_2tsv_status_ok = 0, zsv_2tsv_status_out_of_memory }; +enum zsv_2tsv_status { + zsv_2tsv_status_ok = 0, + zsv_2tsv_status_out_of_memory +}; #define ZSV_2TSV_BUFF_SIZE 65536 diff --git a/app/compare_unique_colname.c b/app/compare_unique_colname.c index a00a4a1a..c6123637 100644 --- a/app/compare_unique_colname.c +++ b/app/compare_unique_colname.c @@ -1,7 +1,8 @@ static int zsv_compare_unique_colname_cmp(zsv_compare_unique_colname *x, zsv_compare_unique_colname *y) { - return x->instance_num == y->instance_num - ? zsv_stricmp(x->name, y->name) - : x->instance_num > y->instance_num ? 1 : x->instance_num < y->instance_num ? -1 : 0; + return x->instance_num == y->instance_num ? zsv_stricmp(x->name, y->name) + : x->instance_num > y->instance_num ? 1 + : x->instance_num < y->instance_num ? -1 + : 0; } SGLIB_DEFINE_RBTREE_FUNCTIONS(zsv_compare_unique_colname, left, right, color, zsv_compare_unique_colname_cmp); diff --git a/app/flatten.c b/app/flatten.c index c6fa0d34..91ff8248 100644 --- a/app/flatten.c +++ b/app/flatten.c @@ -21,7 +21,10 @@ #include #include -enum flatten_agg_method { flatten_agg_method_none = 1, flatten_agg_method_array }; +enum flatten_agg_method { + flatten_agg_method_none = 1, + flatten_agg_method_array +}; struct flatten_column_name_and_ix { unsigned char *name; diff --git a/app/prop.c b/app/prop.c index c88ad583..848f6af9 100644 --- a/app/prop.c +++ b/app/prop.c @@ -659,7 +659,10 @@ static int zsv_prop_foreach_clean(struct zsv_foreach_dirent_handle *h, size_t de return err; } -enum zsv_prop_foreach_copy_mode { zsv_prop_foreach_copy_mode_check = 1, zsv_prop_foreach_copy_mode_copy }; +enum zsv_prop_foreach_copy_mode { + zsv_prop_foreach_copy_mode_check = 1, + zsv_prop_foreach_copy_mode_copy +}; struct zsv_prop_foreach_copy_ctx { struct zsv_dir_filter zsv_dir_filter; diff --git a/app/select-pull.c b/app/select-pull.c index a8677e81..2b2a5fe6 100644 --- a/app/select-pull.c +++ b/app/select-pull.c @@ -64,7 +64,7 @@ struct zsv_select_data { struct { // merge data: only used with --merge struct zsv_select_uint_list *indexes, **last_index; } merge; - } * out2in; // array of .output_cols_count length; out2in[x] = y where x = output ix, y = input info + } *out2in; // array of .output_cols_count length; out2in[x] = y where x = output ix, y = input info unsigned int output_cols_count; // total count of output columns diff --git a/app/select.c b/app/select.c index 15ed2001..698cd2b4 100644 --- a/app/select.c +++ b/app/select.c @@ -71,7 +71,7 @@ struct zsv_select_data { struct { // merge data: only used with --merge struct zsv_select_uint_list *indexes, **last_index; } merge; - } * out2in; // array of .output_cols_count length; out2in[x] = y where x = output ix, y = input info + } *out2in; // array of .output_cols_count length; out2in[x] = y where x = output ix, y = input info unsigned int output_cols_count; // total count of output columns diff --git a/app/utils/cache.c b/app/utils/cache.c index 982e7b6d..ba03f885 100644 --- a/app/utils/cache.c +++ b/app/utils/cache.c @@ -206,8 +206,9 @@ unsigned char *zsv_cache_path(const unsigned char *data_filepath, const unsigned return NULL; const unsigned char *last_slash = (void *)strrchr((void *)data_filepath, '/'); const unsigned char *last_backslash = (void *)strrchr((void *)data_filepath, '\\'); - const unsigned char *dir_end = - (!last_slash && !last_backslash ? NULL : last_backslash > last_slash ? last_backslash : last_slash); + const unsigned char *dir_end = (!last_slash && !last_backslash ? NULL + : last_backslash > last_slash ? last_backslash + : last_slash); char *s = NULL; char *filename_suffix = NULL; if (cache_filename) diff --git a/include/zsv/common.h b/include/zsv/common.h index 0d80566e..259ed407 100644 --- a/include/zsv/common.h +++ b/include/zsv/common.h @@ -27,7 +27,7 @@ enum zsv_status { zsv_status_row, zsv_status_done = 100 #ifdef ZSV_EXTRAS - , + , zsv_status_max_rows_read = 999 #endif }; diff --git a/include/zsv/utils/cache.h b/include/zsv/utils/cache.h index 251559fd..6db6f3fd 100644 --- a/include/zsv/utils/cache.h +++ b/include/zsv/utils/cache.h @@ -30,7 +30,11 @@ */ unsigned char *zsv_cache_path(const unsigned char *data_filepath, const unsigned char *cache_filename, char temp_file); -enum zsv_cache_type { zsv_cache_type_property = 1, zsv_cache_type_tag, zsv_cache_type_overwrite }; +enum zsv_cache_type { + zsv_cache_type_property = 1, + zsv_cache_type_tag, + zsv_cache_type_overwrite +}; unsigned char *zsv_cache_filepath(const unsigned char *data_filepath, enum zsv_cache_type type, char create_dir, char temp_file); diff --git a/include/zsv/utils/jq.h b/include/zsv/utils/jq.h index 58131fe9..3a238c2b 100644 --- a/include/zsv/utils/jq.h +++ b/include/zsv/utils/jq.h @@ -4,7 +4,12 @@ #include #include -enum zsv_jq_status { zsv_jq_status_ok = 0, zsv_jq_status_compile, zsv_jq_status_memory, zsv_jq_status_error }; +enum zsv_jq_status { + zsv_jq_status_ok = 0, + zsv_jq_status_compile, + zsv_jq_status_memory, + zsv_jq_status_error +}; size_t zsv_jq_fwrite1(void *restrict FILE_ptr, const void *restrict buff, size_t len); diff --git a/src/zsv_internal.c b/src/zsv_internal.c index b5aaf017..3fa392a1 100644 --- a/src/zsv_internal.c +++ b/src/zsv_internal.c @@ -170,7 +170,7 @@ struct zsv_scanner { union { struct zsv_scan_delim_regs delim; struct zsv_scan_fixed_regs fixed; - } * regs; + } *regs; enum zsv_status stat; // last status unsigned char *buff; size_t bytes_read; From 1934d34ad280c5cd9da4160f67991aae5e852202 Mon Sep 17 00:00:00 2001 From: br1tney5pear5 Date: Mon, 16 Dec 2024 21:57:22 +0000 Subject: [PATCH 07/15] fixed some warnings --- app/sheet.c | 9 ++++----- app/sheet/context-menu.c | 2 +- app/sheet/procedure.h | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/sheet.c b/app/sheet.c index 31abd165..9e80aa38 100644 --- a/app/sheet.c +++ b/app/sheet.c @@ -429,7 +429,6 @@ static zsvsheet_status zsvsheet_filter_handler(struct zsvsheet_proc_context *ctx struct zsvsheet_ui_buffer *current_ui_buffer = *state->display_info.ui_buffers.current; int prompt_footer_row = (int)(di->dimensions->rows - di->dimensions->footer_span); struct zsvsheet_buffer_info_internal binfo = zsvsheet_buffer_info_internal(current_ui_buffer); - int err; const char *filter; if (binfo.write_in_progress && !binfo.write_done) @@ -460,8 +459,8 @@ static zsvsheet_status zsvsheet_context_menu_filter_handler(struct zsvsheet_proc struct zsvsheet_sheet_context *state = (struct zsvsheet_sheet_context *)ctx->subcommand_context; struct zsvsheet_ui_buffer *current_ui_buffer = *(state->display_info.ui_buffers.current); - const char *contents = zsvsheet_screen_buffer_cell_display(current_ui_buffer->buffer, current_ui_buffer->cursor_row, - current_ui_buffer->cursor_col); + const char *contents = (const char *)zsvsheet_screen_buffer_cell_display( + current_ui_buffer->buffer, current_ui_buffer->cursor_row, current_ui_buffer->cursor_col); fprintf(stderr, "filtering for %s\n", contents); struct zsvsheet_proc_context context = { @@ -482,8 +481,8 @@ static zsvsheet_status zsvsheet_context_menu_open_link_handler(struct zsvsheet_p struct zsvsheet_sheet_context *state = (struct zsvsheet_sheet_context *)ctx->subcommand_context; struct zsvsheet_ui_buffer *current_ui_buffer = *(state->display_info.ui_buffers.current); - const char *contents = zsvsheet_screen_buffer_cell_display(current_ui_buffer->buffer, current_ui_buffer->cursor_row, - current_ui_buffer->cursor_col); + const char *contents = (const char *)zsvsheet_screen_buffer_cell_display( + current_ui_buffer->buffer, current_ui_buffer->cursor_row, current_ui_buffer->cursor_col); char command[256]; diff --git a/app/sheet/context-menu.c b/app/sheet/context-menu.c index e7034a09..dd0d511b 100644 --- a/app/sheet/context-menu.c +++ b/app/sheet/context-menu.c @@ -88,7 +88,7 @@ int context_menu_display(struct context_menu *menu, int row, int col, /* Make sure we don't overrun the screen horizontally */ col -= MAX(0, col + menu_width - (int)display_dims->columns); - if (row + menu_height > display_dims->rows - display_dims->footer_span - display_dims->header_span) + if (row + menu_height > (int)(display_dims->rows - display_dims->footer_span - display_dims->header_span)) row -= menu_height; else row += 1; /* Display the menu under the selected cell by default */ diff --git a/app/sheet/procedure.h b/app/sheet/procedure.h index 3cfae010..567c0728 100644 --- a/app/sheet/procedure.h +++ b/app/sheet/procedure.h @@ -3,7 +3,7 @@ #include #include -struct zsvsheet_context_menu_entry; +struct context_menu_entry; /* ID's of bulitin procedures, extensions can register more. * @@ -72,7 +72,7 @@ struct zsvsheet_proc_context { zsvsheet_proc_id_t id; } proc; struct { - struct zsvsheet_context_menu_entry *entry; + struct context_menu_entry *entry; } context_menu; } u; } invocation; From cf088c1b9bf3a5e205966d6dc995f76a4f81905c Mon Sep 17 00:00:00 2001 From: br1tney5pear5 Date: Mon, 16 Dec 2024 21:57:44 +0000 Subject: [PATCH 08/15] clang format --- app/sheet.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/sheet.c b/app/sheet.c index 9e80aa38..23bbab95 100644 --- a/app/sheet.c +++ b/app/sheet.c @@ -460,7 +460,7 @@ static zsvsheet_status zsvsheet_context_menu_filter_handler(struct zsvsheet_proc struct zsvsheet_sheet_context *state = (struct zsvsheet_sheet_context *)ctx->subcommand_context; struct zsvsheet_ui_buffer *current_ui_buffer = *(state->display_info.ui_buffers.current); const char *contents = (const char *)zsvsheet_screen_buffer_cell_display( - current_ui_buffer->buffer, current_ui_buffer->cursor_row, current_ui_buffer->cursor_col); + current_ui_buffer->buffer, current_ui_buffer->cursor_row, current_ui_buffer->cursor_col); fprintf(stderr, "filtering for %s\n", contents); struct zsvsheet_proc_context context = { @@ -482,7 +482,7 @@ static zsvsheet_status zsvsheet_context_menu_open_link_handler(struct zsvsheet_p struct zsvsheet_sheet_context *state = (struct zsvsheet_sheet_context *)ctx->subcommand_context; struct zsvsheet_ui_buffer *current_ui_buffer = *(state->display_info.ui_buffers.current); const char *contents = (const char *)zsvsheet_screen_buffer_cell_display( - current_ui_buffer->buffer, current_ui_buffer->cursor_row, current_ui_buffer->cursor_col); + current_ui_buffer->buffer, current_ui_buffer->cursor_row, current_ui_buffer->cursor_col); char command[256]; From f5c92d2cb9de2f1930a046ddb6c379b24fbc4787 Mon Sep 17 00:00:00 2001 From: br1tney5pear5 Date: Wed, 1 Jan 2025 21:48:55 +0000 Subject: [PATCH 09/15] added drill down context menu to pivot extension --- app/cli.c | 5 +- app/ext_example/mysheet_extension.c | 21 +++++- app/sheet.c | 75 +++---------------- app/sheet/context-menu.c | 9 +-- app/sheet/handlers.c | 2 +- app/sheet/handlers_internal.h | 11 ++- app/sheet/key-bindings.c | 2 +- app/sheet/key-bindings.h | 2 +- app/sheet/procedure.c | 2 +- app/test/Makefile | 24 ++++++ ...t-sheet-example-extension-context-menu.out | 25 +++++++ ...est-sheet-example-extension-drill-down.out | 25 +++++++ include/zsv/ext.h | 10 +++ include/zsv/ext/context-menu.h | 21 ++++++ {app/sheet => include/zsv/ext}/procedure.h | 0 include/zsv/ext/sheet.h | 3 + 16 files changed, 157 insertions(+), 80 deletions(-) create mode 100644 app/test/expected/test-sheet-example-extension-context-menu.out create mode 100644 app/test/expected/test-sheet-example-extension-drill-down.out create mode 100644 include/zsv/ext/context-menu.h rename {app/sheet => include/zsv/ext}/procedure.h (100%) diff --git a/app/cli.c b/app/cli.c index 40fb1b75..354cab28 100644 --- a/app/cli.c +++ b/app/cli.c @@ -26,7 +26,7 @@ #include "sheet/handlers_internal.h" #include "sheet/transformation.h" #endif -#include "sheet/procedure.h" +#include "../include/zsv/ext/procedure.h" #include "sheet/key-bindings.h" #include "sql_internal.h" @@ -425,6 +425,9 @@ static struct zsv_ext_callbacks *zsv_ext_callbacks_init(struct zsv_ext_callbacks e->ext_sheet_transformation_parser = zsvsheet_transformation_parser; e->ext_sheet_transformation_filename = zsvsheet_transformation_filename; e->ext_sheet_transformation_user_context = zsvsheet_transformation_user_context; + e->ext_sheet_open_context_menu = zsvsheet_ext_open_context_menu; + e->ext_sheet_context_menu_init = zsvsheet_ext_context_menu_init; + e->ext_sheet_context_menu_new_entry_func = zsvsheet_ext_context_menu_new_entry_func; #endif } return e; diff --git a/app/ext_example/mysheet_extension.c b/app/ext_example/mysheet_extension.c index 318be95b..aff52be3 100644 --- a/app/ext_example/mysheet_extension.c +++ b/app/ext_example/mysheet_extension.c @@ -12,6 +12,8 @@ #include "../external/sqlite3/sqlite3.h" #include #include +#include +#include #include #include #include @@ -206,13 +208,13 @@ static zsvsheet_status zsv_sqlite3_to_csv(zsvsheet_proc_context_t pctx, struct z return zst; } -// -zsvsheet_status pivot_drill_down(zsvsheet_proc_context_t ctx) { +zsvsheet_status context_menu_drill_down(zsvsheet_proc_context_t ctx) { enum zsvsheet_status zst = zsvsheet_status_ok; char result_buffer[256] = {0}; zsvsheet_buffer_t buff = zsv_cb.ext_sheet_buffer_current(ctx); struct pivot_data *pd; struct zsvsheet_rowcol rc; + if (zsv_cb.ext_sheet_buffer_get_ctx(buff, (void **)&pd) != zsv_ext_status_ok || zsv_cb.ext_sheet_buffer_get_selected_cell(buff, &rc) != zsvsheet_status_ok) { return zsvsheet_status_error; @@ -254,6 +256,18 @@ zsvsheet_status pivot_drill_down(zsvsheet_proc_context_t ctx) { return zst; } +zsvsheet_status pivot_open_menu(zsvsheet_proc_context_t ctx) { + char entry_name[64]; + struct context_menu menu; + if (zsv_cb.ext_sheet_context_menu_init(&menu)) + return zsvsheet_status_error; + snprintf(entry_name, sizeof(entry_name), "NIGGER"); + if (zsv_cb.ext_sheet_context_menu_new_entry_func(&menu, "Drill-down", context_menu_drill_down)) + return zsvsheet_status_error; + zsv_cb.ext_sheet_open_context_menu(ctx->subcommand_context, &menu); + return zsvsheet_status_ok; +} + /** * Here we define a custom command for the zsv `sheet` feature */ @@ -293,7 +307,7 @@ zsvsheet_status my_pivot_table_command_handler(zsvsheet_proc_context_t ctx) { zsvsheet_buffer_t buff = zsv_cb.ext_sheet_buffer_current(ctx); zsv_cb.ext_sheet_buffer_set_ctx(buff, pd, pivot_data_delete); zsv_cb.ext_sheet_buffer_set_cell_attrs(buff, get_cell_attrs); - zsv_cb.ext_sheet_buffer_on_newline(buff, pivot_drill_down); + zsv_cb.ext_sheet_buffer_on_newline(buff, pivot_open_menu); pd = NULL; // so that it isn't cleaned up below } } @@ -318,6 +332,7 @@ zsvsheet_status my_pivot_table_command_handler(zsvsheet_proc_context_t ctx) { enum zsv_ext_status zsv_ext_init(struct zsv_ext_callbacks *cb, zsv_execution_context ctx) { zsv_cb = *cb; + zsv_cb.ext_set_help(ctx, "Sample zsv sheet extension"); zsv_cb.ext_set_license(ctx, "Unlicense. See https://github.com/spdx/license-list-data/blob/master/text/Unlicense.txt"); diff --git a/app/sheet.c b/app/sheet.c index 23bbab95..ac914e41 100644 --- a/app/sheet.c +++ b/app/sheet.c @@ -453,78 +453,26 @@ static zsvsheet_status zsvsheet_filter_handler(struct zsvsheet_proc_context *ctx return zsvsheet_status_ok; } -static zsvsheet_status zsvsheet_context_menu_filter_handler(struct zsvsheet_proc_context *ctx) { - if (ctx->invocation.type != zsvsheet_proc_invocation_type_context_menu) - return zsvsheet_status_error; - - struct zsvsheet_sheet_context *state = (struct zsvsheet_sheet_context *)ctx->subcommand_context; - struct zsvsheet_ui_buffer *current_ui_buffer = *(state->display_info.ui_buffers.current); - const char *contents = (const char *)zsvsheet_screen_buffer_cell_display( - current_ui_buffer->buffer, current_ui_buffer->cursor_row, current_ui_buffer->cursor_col); - - fprintf(stderr, "filtering for %s\n", contents); - struct zsvsheet_proc_context context = { - .proc_id = zsvsheet_builtin_proc_filter, - .invocation.type = zsvsheet_proc_invocation_type_proc, - .invocation.interactive = false, - .invocation.u.proc.id = ctx->proc_id, - .subcommand_context = ctx->subcommand_context, - .num_params = 1, - .params[0].u.string = contents, - }; - return zsvsheet_proc_invoke(context.proc_id, &context); -} - -static zsvsheet_status zsvsheet_context_menu_open_link_handler(struct zsvsheet_proc_context *ctx) { - if (ctx->invocation.type != zsvsheet_proc_invocation_type_context_menu) - return zsvsheet_status_error; - - struct zsvsheet_sheet_context *state = (struct zsvsheet_sheet_context *)ctx->subcommand_context; - struct zsvsheet_ui_buffer *current_ui_buffer = *(state->display_info.ui_buffers.current); - const char *contents = (const char *)zsvsheet_screen_buffer_cell_display( - current_ui_buffer->buffer, current_ui_buffer->cursor_row, current_ui_buffer->cursor_col); - - char command[256]; - - /* Just an example, won't work on most platforms, escaping etc.... */ - snprintf(command, sizeof(command), "xdg-open '%s'", contents); - fprintf(stderr, "opening link '%s'...\n", contents); - fprintf(stderr, "%s\n", command); - - // system(command); - - return zsvsheet_status_ok; -} - -void zsvsheet_open_context_menu(struct zsvsheet_sheet_context *state) { - /* create context menu based on the cell contents/metadata */ +void zsvsheet_ext_open_context_menu(void *_state, const struct context_menu *menu) { + struct zsvsheet_sheet_context *state = (struct zsvsheet_sheet_context *)_state; struct zsvsheet_ui_buffer *current_ui_buffer = *(state->display_info.ui_buffers.current); struct zsvsheet_display_dimensions *ddims = state->display_info.dimensions; size_t cell_display_width = zsvsheet_cell_display_width(current_ui_buffer, ddims); - char entry_name[64]; - - context_menu_cleanup(&state->context_menu.menu); - if (context_menu_init(&state->context_menu.menu)) - return; - - snprintf(entry_name, sizeof(entry_name), "Filter for '%s'", - zsvsheet_screen_buffer_cell_display(current_ui_buffer->buffer, current_ui_buffer->cursor_row, - current_ui_buffer->cursor_col)); - if (context_menu_new_entry_func(&state->context_menu.menu, entry_name, zsvsheet_context_menu_filter_handler)) - return; - if (context_menu_new_entry_func(&state->context_menu.menu, "Open link...", zsvsheet_context_menu_open_link_handler)) - return; state->context_menu.row = current_ui_buffer->cursor_row; state->context_menu.col = current_ui_buffer->cursor_col * cell_display_width; + state->context_menu.menu = *menu; state->context_menu.active = true; -} -static zsvsheet_status zsvsheet_open_cell_context_menu_handler(struct zsvsheet_proc_context *ctx) { - struct zsvsheet_sheet_context *state = (struct zsvsheet_sheet_context *)ctx->subcommand_context; - zsvsheet_open_context_menu(state); zsvsheet_display_context_menu(state); - return zsvsheet_status_ok; +} + +int zsvsheet_ext_context_menu_init(struct context_menu *menu) { + return context_menu_init(menu); +} + +int zsvsheet_ext_context_menu_new_entry_func(struct context_menu *menu, const char *name, zsvsheet_proc_fn handler) { + return context_menu_new_entry_func(menu, name, handler); } static zsvsheet_status zsvsheet_subcommand_handler(struct zsvsheet_proc_context *ctx) { @@ -738,7 +686,6 @@ struct builtin_proc_desc { { zsvsheet_builtin_proc_open_file, "open", "Open a another CSV file", zsvsheet_open_file_handler }, { zsvsheet_builtin_proc_filter, "filter", "Hide rows that do not contain the specified text", zsvsheet_filter_handler }, { zsvsheet_builtin_proc_subcommand, "subcommand", "Editor subcommand", zsvsheet_subcommand_handler }, - { zsvsheet_builtin_proc_open_cell_context_menu, "open-cell-context-menu", "Open cell context menu", zsvsheet_open_cell_context_menu_handler }, { zsvsheet_builtin_proc_help, "help", "Display a list of actions and key-bindings", zsvsheet_help_handler }, { zsvsheet_builtin_proc_confirm, "confirm", "Confirm", zsvsheet_builtin_proc_handler }, { -1, NULL, NULL, NULL } diff --git a/app/sheet/context-menu.c b/app/sheet/context-menu.c index dd0d511b..07b9ce41 100644 --- a/app/sheet/context-menu.c +++ b/app/sheet/context-menu.c @@ -1,4 +1,5 @@ -#include "procedure.h" +#include "../include/zsv/ext/context-menu.h" +#include "../include/zsv/ext/procedure.h" #ifndef MIN #define MIN(A, B) ((A) < (B) ? (A) : (B)) @@ -20,12 +21,6 @@ struct context_menu_entry { uint8_t proc_ephemeral : 1; }; -struct context_menu { - struct context_menu_entry *entries; - struct context_menu_entry *last_entry; - struct context_menu_entry *selected_entry; -}; - int context_menu_init(struct context_menu *menu) { memset(menu, 0, sizeof(*menu)); return 0; diff --git a/app/sheet/handlers.c b/app/sheet/handlers.c index 6dc71c25..76eef011 100644 --- a/app/sheet/handlers.c +++ b/app/sheet/handlers.c @@ -1,5 +1,5 @@ #include "file.h" -#include "procedure.h" +#include "../include/zsv/ext/procedure.h" static void zsvsheet_key_handlers_delete(struct zsvsheet_key_data **root, struct zsvsheet_key_data ***nextp) { for (struct zsvsheet_key_data *next, *e = *root; e; e = next) { diff --git a/app/sheet/handlers_internal.h b/app/sheet/handlers_internal.h index dfbf5758..ac98fdc4 100644 --- a/app/sheet/handlers_internal.h +++ b/app/sheet/handlers_internal.h @@ -119,6 +119,15 @@ zsvsheet_status zsvsheet_register_command(int ch, const char *long_name, */ enum zsvsheet_status zsvsheet_push_transformation(zsvsheet_proc_context_t ctx, struct zsvsheet_buffer_transformation_opts opts); -#endif struct zsvsheet_buffer_data zsvsheet_buffer_info(zsvsheet_buffer_t buff); + +struct context_menu; + +int zsvsheet_ext_context_menu_init(struct context_menu *menu); + +int zsvsheet_ext_context_menu_new_entry_func(struct context_menu *menu, const char *name, zsvsheet_proc_fn handler); + +void zsvsheet_ext_open_context_menu(void *zsvsheet_sheet_context, const struct context_menu *menu); + +#endif diff --git a/app/sheet/key-bindings.c b/app/sheet/key-bindings.c index d54be2f0..d98dff40 100644 --- a/app/sheet/key-bindings.c +++ b/app/sheet/key-bindings.c @@ -1,4 +1,4 @@ -#include "procedure.h" +#include "../include/zsv/ext/procedure.h" #include "key-bindings.h" #include diff --git a/app/sheet/key-bindings.h b/app/sheet/key-bindings.h index 913afc65..4a217216 100644 --- a/app/sheet/key-bindings.h +++ b/app/sheet/key-bindings.h @@ -1,6 +1,6 @@ #ifndef ZSVSHEET_KEY_BINDINGS_H #define ZSVSHEET_KEY_BINDINGS_H -#include "procedure.h" +#include "../include/zsv/ext/procedure.h" enum zsvsheet_key { zsvsheet_key_unknown = 0, diff --git a/app/sheet/procedure.c b/app/sheet/procedure.c index bbf0c7cf..a8bdfe56 100644 --- a/app/sheet/procedure.c +++ b/app/sheet/procedure.c @@ -1,4 +1,4 @@ -#include "procedure.h" +#include "../include/zsv/ext/procedure.h" #if 0 #define proc_debug(...) fprintf(stderr, __VA_ARGS__) diff --git a/app/test/Makefile b/app/test/Makefile index 195503a2..86b243bc 100644 --- a/app/test/Makefile +++ b/app/test/Makefile @@ -813,3 +813,27 @@ benchmark-sheet-index: ${BUILD_DIR}/bin/zsv_sheet${EXE} ${TIMINGS_CSV} tmux send-keys -t $@ "G" && \ ${EXPECT} $@ && ${TEST_PASS} || ${TEST_FAIL}) +test-sheet-example-extension:\ + test-sheet-example-extension-context-menu test-sheet-example-extension-drill-down + +test-sheet-example-extension-context-menu: ${BUILD_DIR}/bin/cli${EXE} + ${TEST_INIT} + @echo 'set-option default-terminal "${TMUX_TERM}"' > ~/.tmux.conf + @${PREFIX} $< unregister mysheet || true + @${PREFIX} $< register mysheet + @tmux new-session -x 80 -y 25 -d -s "$@" "${PREFIX} $< sheet worldcitiespop_mil.csv" + @${PREFIX} $< unregister mysheet || true # unregister regardless of whether the test succeeds or not + @tmux send-keys -t $@ "v" "country" "Enter" + @tmux send-keys -t $@ "jjjj" "Enter" # go down a few rows and open menu + @${EXPECT} $@ && ${TEST_PASS} || ${TEST_FAIL} + +test-sheet-example-extension-drill-down: ${BUILD_DIR}/bin/cli${EXE} + ${TEST_INIT} + @echo 'set-option default-terminal "${TMUX_TERM}"' > ~/.tmux.conf + @${PREFIX} $< unregister mysheet || true + @${PREFIX} $< register mysheet + @tmux new-session -x 80 -y 25 -d -s "$@" "${PREFIX} $< sheet worldcitiespop_mil.csv" + @${PREFIX} $< unregister mysheet || true # unregister regardless of whether the test succeeds or not + @tmux send-keys -t $@ "v" "country" "Enter" + @tmux send-keys -t $@ "jjjj" "Enter" "Enter" # go down a few rows and open menu and drill down + @${EXPECT} $@ && ${TEST_PASS} || ${TEST_FAIL} diff --git a/app/test/expected/test-sheet-example-extension-context-menu.out b/app/test/expected/test-sheet-example-extension-context-menu.out new file mode 100644 index 00000000..13526957 --- /dev/null +++ b/app/test/expected/test-sheet-example-extension-context-menu.out @@ -0,0 +1,25 @@ +Row # value Count +1 ad 27 +2 ae 147 +3 af 27822 +4 ag 55 +5 ai 14 +* Drill-down al 4730 +7 am 896 +8 an 75 +9 ao 6170 +10 ar 2817 +11 at 4740 +12 au 3403 +13 aw 37 +14 az 3522 +15 ba 5076 +16 bb 165 +17 bd 8280 +18 be 5056 +19 bf 3248 +20 bg 6258 +21 bh 102 +22 bi 646 +23 bj 1331 +(building index) 5 diff --git a/app/test/expected/test-sheet-example-extension-drill-down.out b/app/test/expected/test-sheet-example-extension-drill-down.out new file mode 100644 index 00000000..05071db2 --- /dev/null +++ b/app/test/expected/test-sheet-example-extension-drill-down.out @@ -0,0 +1,25 @@ +Row # Country City AccentCit Region Populatio Latitude Longitude +89472 ai betty hil Betty Hil 00 18.216666 -63.0 +89474 ai cannifist Cannifist 00 18.233333 -63.01666 +89480 ai east end East End 00 18.233333 -63.0 +89485 ai little di Little Di 00 18.233333 -63.03333 +89488 ai long grou Long Grou 00 18.2 -63.05 +89490 ai lower sou Lower Sou 00 where cou 18.183333 -63.1 +89492 ai mount for Mount For 00 18.233333 -62.98333 +89494 ai north sid North Sid 00 18.216666 -63.05 +89496 ai saint mar Saint Mar 00 18.216666 -63.06666 +89502 ai the copse The Copse 00 18.216666 -62.98333 +89504 ai the fores The Fores 00 18.2 -63.03333 +89506 ai the valle The Valle 00 1379 18.216666 -63.05 +89509 ai welches h Welches H 00 18.233333 -63.01666 +89512 ai white hil White Hil 00 18.25 -63.0 + + + + + + + + + +(building index) 89472 diff --git a/include/zsv/ext.h b/include/zsv/ext.h index 8cf65d46..f3898d8a 100644 --- a/include/zsv/ext.h +++ b/include/zsv/ext.h @@ -18,6 +18,8 @@ #include "utils/sql.h" #include "utils/prop.h" #include "utils/writer.h" +#include "ext/procedure.h" +#include "ext/context-menu.h" /** * @file ext.h @@ -299,6 +301,14 @@ struct zsv_ext_callbacks { */ void *(*ext_sheet_transformation_user_context)(zsvsheet_transformation trn); + int (*ext_sheet_context_menu_init)(struct context_menu *menu); + + int (*ext_sheet_context_menu_new_entry_func)(struct context_menu *menu, const char *name, zsvsheet_proc_fn handler); + /* + * Open provided context menu at the current cell + */ + void (*ext_sheet_open_context_menu)(void *zsvsheet_sheet_context, const struct context_menu *menu); + /** * Get the parser from the context provided to a transformation row handler */ diff --git a/include/zsv/ext/context-menu.h b/include/zsv/ext/context-menu.h new file mode 100644 index 00000000..b5f85710 --- /dev/null +++ b/include/zsv/ext/context-menu.h @@ -0,0 +1,21 @@ +#ifndef _ZSVSHEET_CONTEXT_MENU_H_ +#define _ZSVSHEET_CONTEXT_MENU_H_ +#include "procedure.h" + +struct context_menu_entry; + +struct context_menu { + struct context_menu_entry *entries; + struct context_menu_entry *last_entry; + struct context_menu_entry *selected_entry; +}; + +int context_menu_init(struct context_menu *menu); + +int context_menu_new_entry(struct context_menu *menu, const char *name, zsvsheet_proc_id_t proc_id); + +int context_menu_new_entry_func(struct context_menu *menu, const char *name, zsvsheet_proc_fn handler); + +zsvsheet_status context_menu_confirm(struct context_menu *menu, void *subcommand_context); + +#endif /* _ZSVSHEET_CONTEXT_MENU_H_ */ diff --git a/app/sheet/procedure.h b/include/zsv/ext/procedure.h similarity index 100% rename from app/sheet/procedure.h rename to include/zsv/ext/procedure.h diff --git a/include/zsv/ext/sheet.h b/include/zsv/ext/sheet.h index f3e6b7e6..a08acb04 100644 --- a/include/zsv/ext/sheet.h +++ b/include/zsv/ext/sheet.h @@ -16,6 +16,9 @@ typedef enum zsvsheet_status { zsvsheet_status_busy, } zsvsheet_status; +struct zsvsheet_proc_context; +typedef zsvsheet_status (*zsvsheet_proc_fn)(struct zsvsheet_proc_context *ctx); + typedef struct zsvsheet_context *zsvsheet_context_t; typedef struct zsvsheet_subcommand_context *zsvsheet_subcommand_context_t; From ea323660bd75ed60ddae9d55a81e3edc150a6cec Mon Sep 17 00:00:00 2001 From: br1tney5pear5 Date: Wed, 1 Jan 2025 22:43:18 +0000 Subject: [PATCH 10/15] added the new tests to main run --- app/test/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/test/Makefile b/app/test/Makefile index 4bc632e5..dba6809f 100644 --- a/app/test/Makefile +++ b/app/test/Makefile @@ -626,7 +626,7 @@ test-sheet-cleanup: @rm -f tmux-*.log @tmux kill-server || printf '' -test-sheet-all: test-sheet-1 test-sheet-2 test-sheet-3 test-sheet-4 test-sheet-5 test-sheet-6 test-sheet-7 test-sheet-8 test-sheet-9 test-sheet-10 test-sheet-11 test-sheet-12 test-sheet-13 test-sheet-14 test-sheet-subcommand test-sheet-prop-cmd-opt +test-sheet-all: test-sheet-1 test-sheet-2 test-sheet-3 test-sheet-4 test-sheet-5 test-sheet-6 test-sheet-7 test-sheet-8 test-sheet-9 test-sheet-10 test-sheet-11 test-sheet-12 test-sheet-13 test-sheet-14 test-sheet-subcommand test-sheet-prop-cmd-opt test-sheet-example-extension @(for SESSION in $^; do ! tmux kill-session -t "$$SESSION" 2>/dev/null; done && ${TEST_PASS} || ${TEST_FAIL}) TMUX_TERM=xterm-256color From bd2604c1f8423121296f88d378c970c03b4a111b Mon Sep 17 00:00:00 2001 From: br1tney5pear5 Date: Wed, 1 Jan 2025 22:49:15 +0000 Subject: [PATCH 11/15] build fix --- app/test/Makefile | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/test/Makefile b/app/test/Makefile index dba6809f..43b85a28 100644 --- a/app/test/Makefile +++ b/app/test/Makefile @@ -829,24 +829,24 @@ benchmark-sheet-index: ${BUILD_DIR}/bin/zsv_sheet${EXE} ${TIMINGS_CSV} test-sheet-example-extension:\ test-sheet-example-extension-context-menu test-sheet-example-extension-drill-down -test-sheet-example-extension-context-menu: ${BUILD_DIR}/bin/cli${EXE} +test-sheet-example-extension-context-menu: ${BUILD_DIR}/bin/zsv_sheet${EXE} ${TEST_INIT} @echo 'set-option default-terminal "${TMUX_TERM}"' > ~/.tmux.conf - @${PREFIX} $< unregister mysheet || true - @${PREFIX} $< register mysheet - @tmux new-session -x 80 -y 25 -d -s "$@" "${PREFIX} $< sheet worldcitiespop_mil.csv" - @${PREFIX} $< unregister mysheet || true # unregister regardless of whether the test succeeds or not + @${PREFIX} ${BUILD_DIR}/bin/cli unregister mysheet || true + @${PREFIX} ${BUILD_DIR}/bin/cli register mysheet + @tmux new-session -x 80 -y 25 -d -s "$@" "${PREFIX} ${BUILD_DIR}/bin/cli sheet worldcitiespop_mil.csv" + @${PREFIX} ${BUILD_DIR}/bin/cli unregister mysheet || true # unregister regardless of whether the test succeeds or not @tmux send-keys -t $@ "v" "country" "Enter" @tmux send-keys -t $@ "jjjj" "Enter" # go down a few rows and open menu @${EXPECT} $@ && ${TEST_PASS} || ${TEST_FAIL} -test-sheet-example-extension-drill-down: ${BUILD_DIR}/bin/cli${EXE} +test-sheet-example-extension-drill-down: ${BUILD_DIR}/bin/zsv_sheet${EXE} ${TEST_INIT} @echo 'set-option default-terminal "${TMUX_TERM}"' > ~/.tmux.conf - @${PREFIX} $< unregister mysheet || true - @${PREFIX} $< register mysheet - @tmux new-session -x 80 -y 25 -d -s "$@" "${PREFIX} $< sheet worldcitiespop_mil.csv" - @${PREFIX} $< unregister mysheet || true # unregister regardless of whether the test succeeds or not + @${PREFIX} ${BUILD_DIR}/bin/cli unregister mysheet || true + @${PREFIX} ${BUILD_DIR}/bin/cli register mysheet + @tmux new-session -x 80 -y 25 -d -s "$@" "${PREFIX} ${BUILD_DIR}/bin/cli sheet worldcitiespop_mil.csv" + @${PREFIX} ${BUILD_DIR}/bin/cli unregister mysheet || true # unregister regardless of whether the test succeeds or not @tmux send-keys -t $@ "v" "country" "Enter" @tmux send-keys -t $@ "jjjj" "Enter" "Enter" # go down a few rows and open menu and drill down @${EXPECT} $@ && ${TEST_PASS} || ${TEST_FAIL} From 2a0c9e7b0cc7dbcfa280e375d560f4e74fa87325 Mon Sep 17 00:00:00 2001 From: br1tney5pear5 Date: Thu, 2 Jan 2025 10:40:36 +0000 Subject: [PATCH 12/15] moved extension tests to ext example --- app/ext_example/Makefile | 24 ++++++++++++++++- .../test-sheet-extension-context-menu.out} | 0 .../test-sheet-extension-drill-down.out} | 0 app/test/Makefile | 27 +------------------ 4 files changed, 24 insertions(+), 27 deletions(-) rename app/{test/expected/test-sheet-example-extension-context-menu.out => ext_example/test/expected/test-sheet-extension-context-menu.out} (100%) rename app/{test/expected/test-sheet-example-extension-drill-down.out => ext_example/test/expected/test-sheet-extension-drill-down.out} (100%) diff --git a/app/ext_example/Makefile b/app/ext_example/Makefile index ec7eb8fe..82e1e355 100644 --- a/app/ext_example/Makefile +++ b/app/ext_example/Makefile @@ -112,7 +112,7 @@ ${BUILD_DIR}/bin/cli: ${BUILD_DIR}/objs/utils/%.o: (cd .. && ${MAKE} CONFIGFILE=${CONFIGFILEPATH} CC=${CC} DEBUG=${DEBUG} $@ ) -TESTS=test-1 test-2 test-3 test-4 test-5 test-thirdparty +TESTS=test-1 test-2 test-3 test-4 test-5 test-thirdparty test-sheet-extension-context-menu test-sheet-extension-drill-down ifeq ($(ZSVSHEET_BUILD),1) TESTS+=test-sheet-extension-1 test-sheet-extension-2 endif @@ -198,6 +198,28 @@ test-thirdparty: test-%: ${CLI} ${TARGET} @${RUN_CLI} thirdparty >> /tmp/zsvext-$@.out @cmp /tmp/zsvext-$@.out test/expected/zsvext-$@.out && ${TEST_PASS} || ${TEST_FAIL} +test-sheet-extension-context-menu: ${CLI} ${TARGET} + ${TEST_INIT} + @echo 'set-option default-terminal "${TMUX_TERM}"' > ~/.tmux.conf + @${RUN_CLI} unregister mysheet 1>/dev/null || true + @${RUN_CLI} register mysheet 2>/dev/null + @tmux new-session -x 80 -y 25 -d -s "$@" "${RUN_CLI} sheet ../test/worldcitiespop_mil.csv" + @${RUN_CLI} unregister mysheet 1>/dev/null || true # unregister regardless of whether the test succeeds or not + @tmux send-keys -t $@ "v" "country" "Enter" + @tmux send-keys -t $@ "jjjj" "Enter" # go down a few rows and open menu + @${EXPECT} $@ && ${TEST_PASS} || ${TEST_FAIL} + +test-sheet-extension-drill-down: ${CLI} ${TARGET} + ${TEST_INIT} + @echo 'set-option default-terminal "${TMUX_TERM}"' > ~/.tmux.conf + @${RUN_CLI} unregister mysheet 1>/dev/null || true + @${RUN_CLI} register mysheet 2>/dev/null + @tmux new-session -x 80 -y 25 -d -s "$@" "${RUN_CLI} sheet ../test/worldcitiespop_mil.csv" + @${RUN_CLI} unregister mysheet 1>/dev/null || true # unregister regardless of whether the test succeeds or not + @tmux send-keys -t $@ "v" "country" "Enter" + @tmux send-keys -t $@ "jjjj" "Enter" "Enter" # go down a few rows and open menu and drill down + @${EXPECT} $@ && ${TEST_PASS} || ${TEST_FAIL} + clean: @rm -f ${TARGET} ${TARGET_SHEET} /tmp/zsvext-test*.out diff --git a/app/test/expected/test-sheet-example-extension-context-menu.out b/app/ext_example/test/expected/test-sheet-extension-context-menu.out similarity index 100% rename from app/test/expected/test-sheet-example-extension-context-menu.out rename to app/ext_example/test/expected/test-sheet-extension-context-menu.out diff --git a/app/test/expected/test-sheet-example-extension-drill-down.out b/app/ext_example/test/expected/test-sheet-extension-drill-down.out similarity index 100% rename from app/test/expected/test-sheet-example-extension-drill-down.out rename to app/ext_example/test/expected/test-sheet-extension-drill-down.out diff --git a/app/test/Makefile b/app/test/Makefile index 43b85a28..225c6aaa 100644 --- a/app/test/Makefile +++ b/app/test/Makefile @@ -626,7 +626,7 @@ test-sheet-cleanup: @rm -f tmux-*.log @tmux kill-server || printf '' -test-sheet-all: test-sheet-1 test-sheet-2 test-sheet-3 test-sheet-4 test-sheet-5 test-sheet-6 test-sheet-7 test-sheet-8 test-sheet-9 test-sheet-10 test-sheet-11 test-sheet-12 test-sheet-13 test-sheet-14 test-sheet-subcommand test-sheet-prop-cmd-opt test-sheet-example-extension +test-sheet-all: test-sheet-1 test-sheet-2 test-sheet-3 test-sheet-4 test-sheet-5 test-sheet-6 test-sheet-7 test-sheet-8 test-sheet-9 test-sheet-10 test-sheet-11 test-sheet-12 test-sheet-13 test-sheet-14 test-sheet-subcommand test-sheet-prop-cmd-opt @(for SESSION in $^; do ! tmux kill-session -t "$$SESSION" 2>/dev/null; done && ${TEST_PASS} || ${TEST_FAIL}) TMUX_TERM=xterm-256color @@ -825,28 +825,3 @@ benchmark-sheet-index: ${BUILD_DIR}/bin/zsv_sheet${EXE} ${TIMINGS_CSV} ${EXPECT} $@ indexed && \ tmux send-keys -t $@ "G" && \ ${EXPECT} $@ && ${TEST_PASS} || ${TEST_FAIL}) - -test-sheet-example-extension:\ - test-sheet-example-extension-context-menu test-sheet-example-extension-drill-down - -test-sheet-example-extension-context-menu: ${BUILD_DIR}/bin/zsv_sheet${EXE} - ${TEST_INIT} - @echo 'set-option default-terminal "${TMUX_TERM}"' > ~/.tmux.conf - @${PREFIX} ${BUILD_DIR}/bin/cli unregister mysheet || true - @${PREFIX} ${BUILD_DIR}/bin/cli register mysheet - @tmux new-session -x 80 -y 25 -d -s "$@" "${PREFIX} ${BUILD_DIR}/bin/cli sheet worldcitiespop_mil.csv" - @${PREFIX} ${BUILD_DIR}/bin/cli unregister mysheet || true # unregister regardless of whether the test succeeds or not - @tmux send-keys -t $@ "v" "country" "Enter" - @tmux send-keys -t $@ "jjjj" "Enter" # go down a few rows and open menu - @${EXPECT} $@ && ${TEST_PASS} || ${TEST_FAIL} - -test-sheet-example-extension-drill-down: ${BUILD_DIR}/bin/zsv_sheet${EXE} - ${TEST_INIT} - @echo 'set-option default-terminal "${TMUX_TERM}"' > ~/.tmux.conf - @${PREFIX} ${BUILD_DIR}/bin/cli unregister mysheet || true - @${PREFIX} ${BUILD_DIR}/bin/cli register mysheet - @tmux new-session -x 80 -y 25 -d -s "$@" "${PREFIX} ${BUILD_DIR}/bin/cli sheet worldcitiespop_mil.csv" - @${PREFIX} ${BUILD_DIR}/bin/cli unregister mysheet || true # unregister regardless of whether the test succeeds or not - @tmux send-keys -t $@ "v" "country" "Enter" - @tmux send-keys -t $@ "jjjj" "Enter" "Enter" # go down a few rows and open menu and drill down - @${EXPECT} $@ && ${TEST_PASS} || ${TEST_FAIL} From 968cd95a5f28911ab80877161c32d406331d18ef Mon Sep 17 00:00:00 2001 From: br1tney5pear5 Date: Thu, 2 Jan 2025 11:09:27 +0000 Subject: [PATCH 13/15] fix test --- app/ext_example/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/ext_example/Makefile b/app/ext_example/Makefile index 82e1e355..2b89648f 100644 --- a/app/ext_example/Makefile +++ b/app/ext_example/Makefile @@ -198,7 +198,7 @@ test-thirdparty: test-%: ${CLI} ${TARGET} @${RUN_CLI} thirdparty >> /tmp/zsvext-$@.out @cmp /tmp/zsvext-$@.out test/expected/zsvext-$@.out && ${TEST_PASS} || ${TEST_FAIL} -test-sheet-extension-context-menu: ${CLI} ${TARGET} +test-sheet-extension-context-menu: ${CLI} ${TARGET_SHEET} ../test/worldcitiespop_mil.csv ${TEST_INIT} @echo 'set-option default-terminal "${TMUX_TERM}"' > ~/.tmux.conf @${RUN_CLI} unregister mysheet 1>/dev/null || true @@ -209,7 +209,7 @@ test-sheet-extension-context-menu: ${CLI} ${TARGET} @tmux send-keys -t $@ "jjjj" "Enter" # go down a few rows and open menu @${EXPECT} $@ && ${TEST_PASS} || ${TEST_FAIL} -test-sheet-extension-drill-down: ${CLI} ${TARGET} +test-sheet-extension-drill-down: ${CLI} ${TARGET_SHEET} ../test/worldcitiespop_mil.csv ${TEST_INIT} @echo 'set-option default-terminal "${TMUX_TERM}"' > ~/.tmux.conf @${RUN_CLI} unregister mysheet 1>/dev/null || true From cd9558f5535a03a6d1831bff9f14e065ffcf66fd Mon Sep 17 00:00:00 2001 From: br1tney5pear5 Date: Thu, 2 Jan 2025 11:30:05 +0000 Subject: [PATCH 14/15] testing something --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6dbbba0b..e57870d8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ LABEL maintainer="Liquidaty" LABEL url="https://github.com/liquidaty/zsv" LABEL org.opencontainers.image.description="zsv: tabular data swiss-army knife CLI + world's fastest (simd) CSV parser" -RUN apk add bash gcc make musl-dev perl ncurses-dev ncurses-static tmux file sqlite curl zip +RUN apk add bash gcc make musl-dev perl ncurses-dev ncurses-static tmux file sqlite curl zip libjq-dev libutf8proc-dev WORKDIR /zsv COPY . . From 679d460dcaf7e09d6e0b537132aa88dbb2f780a8 Mon Sep 17 00:00:00 2001 From: br1tney5pear5 Date: Thu, 2 Jan 2025 11:33:37 +0000 Subject: [PATCH 15/15] Revert "testing something" This reverts commit cd9558f5535a03a6d1831bff9f14e065ffcf66fd. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e57870d8..6dbbba0b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ LABEL maintainer="Liquidaty" LABEL url="https://github.com/liquidaty/zsv" LABEL org.opencontainers.image.description="zsv: tabular data swiss-army knife CLI + world's fastest (simd) CSV parser" -RUN apk add bash gcc make musl-dev perl ncurses-dev ncurses-static tmux file sqlite curl zip libjq-dev libutf8proc-dev +RUN apk add bash gcc make musl-dev perl ncurses-dev ncurses-static tmux file sqlite curl zip WORKDIR /zsv COPY . .