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 update 20241009 v2 #215

Merged
merged 4 commits into from
Oct 10, 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
17 changes: 5 additions & 12 deletions app/sheet.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#ifndef _XOPEN_SOURCE_EXTENDED
#define _XOPEN_SOURCE_EXTENDED
#endif
Expand Down Expand Up @@ -448,18 +450,9 @@ int ZSV_MAIN_FUNC(ZSV_COMMAND)(int argc, const char *argv[], struct zsv_opts *op
const char *display_cell(struct zsv_sheet_buffer *buff, size_t data_row, size_t data_col, int row, int col) {
char *str = (char *)zsv_sheet_buffer_cell_display(buff, data_row, data_col);
size_t len = str ? strlen(str) : 0;
if (len == 0 || has_multibyte_char(str, len < ZTV_CELL_DISPLAY_WIDTH ? len : ZTV_CELL_DISPLAY_WIDTH) == 0) {
// temporarily add a NULL delimiter
int ch = str[ZTV_CELL_DISPLAY_WIDTH - 1];
str[ZTV_CELL_DISPLAY_WIDTH - 1] = '\0'; // ensure a blank space between cells
mvprintw(row, col * ZTV_CELL_DISPLAY_WIDTH, "%-*s", ZTV_CELL_DISPLAY_WIDTH, str);
str[ZTV_CELL_DISPLAY_WIDTH - 1] = ch;
/*
mvprintw(row, col * ZTV_CELL_DISPLAY_WIDTH, "%-*.*s", ZTV_CELL_DISPLAY_WIDTH,
len < ZTV_CELL_DISPLAY_WIDTH ? len : ZTV_CELL_DISPLAY_WIDTH - 1,
str);
*/
} else {
if (len == 0 || has_multibyte_char(str, len < ZTV_CELL_DISPLAY_WIDTH ? len : ZTV_CELL_DISPLAY_WIDTH) == 0)
mvprintw(row, col * ZTV_CELL_DISPLAY_WIDTH, "%-*.*s", ZTV_CELL_DISPLAY_WIDTH, ZTV_CELL_DISPLAY_WIDTH - 1, str);
else {
size_t used_width;
int err = 0;
unsigned char *s = (unsigned char *)str;
Expand Down
6 changes: 1 addition & 5 deletions app/test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -559,13 +559,12 @@ test-compare: test-%: ${BUILD_DIR}/bin/zsv_%${EXE}
test-sheet: test-%: ${BUILD_DIR}/bin/zsv_%${EXE} worldcitiespop_mil.csv test-sheet-all

test-sheet-all: test-sheet-1 test-sheet-2 test-sheet-3 test-sheet-4
@(! tmux kill-session -t $@ 2>/dev/null && ${TEST_PASS} || ${TEST_FAIL})
@(for SESSION in $^; do ! tmux kill-session -t "$$SESSION" 2>/dev/null; done && ${TEST_PASS} || ${TEST_FAIL})

test-sheet-1: ${BUILD_DIR}/bin/zsv_sheet${EXE}
@${TEST_INIT}
@echo 'set-option default-terminal "tmux-256color"' > ~/.tmux.conf
@(tmux new-session -x 1000 -y 5 -d -s $@ "${PREFIX} $< worldcitiespop_mil.csv" && \
tmux set-window-option -t test-sheet prefix none && \
sleep 0.5 && \
tmux capture-pane -t $@ -p ${REDIRECT1} ${TMP_DIR}/[email protected] && \
tmux send-keys -t $@ "q" && \
Expand All @@ -574,7 +573,6 @@ test-sheet-1: ${BUILD_DIR}/bin/zsv_sheet${EXE}
test-sheet-2: ${BUILD_DIR}/bin/zsv_sheet${EXE}
@${TEST_INIT}
@(tmux new-session -x 1000 -y 5 -d -s $@ "${PREFIX} $< worldcitiespop_mil.csv" && \
tmux set-window-option -t test-sheet prefix none && \
sleep 0.5 && \
tmux send-keys -t $@ "C-F" && \
tmux capture-pane -t $@ -p ${REDIRECT1} ${TMP_DIR}/[email protected] && \
Expand All @@ -584,7 +582,6 @@ test-sheet-2: ${BUILD_DIR}/bin/zsv_sheet${EXE}
test-sheet-3: ${BUILD_DIR}/bin/zsv_sheet${EXE}
@${TEST_INIT}
@(tmux new-session -x 1000 -y 5 -d -s $@ "${PREFIX} $< worldcitiespop_mil.csv" && \
tmux set-window-option -t test-sheet prefix none && \
sleep 0.5 && \
tmux send-keys -t $@ "f" "sarmaj" Enter && \
sleep 0.5 && \
Expand All @@ -595,7 +592,6 @@ test-sheet-3: ${BUILD_DIR}/bin/zsv_sheet${EXE}
test-sheet-4: ${BUILD_DIR}/bin/zsv_sheet${EXE}
@${TEST_INIT}
@(tmux new-session -x 1000 -y 5 -d -s $@ "${PREFIX} $< worldcitiespop_mil.csv" && \
tmux set-window-option -t test-sheet prefix none && \
sleep 0.5 && \
tmux send-keys -t $@ "C-F" "C-F" "C-B" && \
tmux capture-pane -t $@ -p ${REDIRECT1} ${TMP_DIR}/[email protected] && \
Expand Down
5 changes: 0 additions & 5 deletions app/test/expected/test-sheet4.out

This file was deleted.