From 85398018f86932363623387b5a0417bf63db2db9 Mon Sep 17 00:00:00 2001 From: Louie S Date: Thu, 4 May 2023 16:18:46 -0700 Subject: Rewrite handle_args function using getopt library --- src/draw.c | 76 ++++++++++++++++++++++++++++++++++++++------------------------ 1 file changed, 47 insertions(+), 29 deletions(-) diff --git a/src/draw.c b/src/draw.c index 03c53bf..61e0a93 100644 --- a/src/draw.c +++ b/src/draw.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -54,6 +55,11 @@ int main(int argc, char **argv){ srand(time(NULL)); flags_set = handle_args(argc, argv, &cfg_path); + //exit if args could not be interpreted (i.e., --config with no argument) + if(flags_set == NULL) { + print_help(argv[0]); + return 1; + } if(flags_set[1]) return(0); //exit if help flag was passed if(flags_set[2]) freopen("/dev/null", "w", stdout); //turn off output if quiet flag was passed if(!flags_set[0]) strcpy(cfg_path, find_config()); //find_config if not config flag was passed @@ -62,13 +68,13 @@ int main(int argc, char **argv){ //read the contents of the cfg file; print help message if invalid if(!cfg_interp(cfg_path)){ print_help(argv[0]); - return 0; + return 1; } //Remove Empty Groups from the Array clean_groups(); g = get_groups(); //retrieve results of cfg_interp - g_count = get_gcount(g); //retrieve number of groups in g (only do this after removing empty groups) + g_count = get_gcount(); //retrieve number of groups in g (only do this after removing empty groups) //check that there are is at least one valid group if(g_count == 0){ @@ -186,31 +192,43 @@ bool *handle_args(int argc, char **argv, char **cfg_path){ // 1 -> -h|--help // 2 -> -q|--quiet + int opt = 0; + struct option long_options[] = { + {"config", required_argument, NULL, 'c'}, + {"help", no_argument, NULL, 'h'}, + {"quiet", no_argument, NULL, 'q'}, + {0, 0, 0, 0} + }; bool *flags_set = calloc(FLAG_COUNT, sizeof(bool)); - int i; - - for(i = 1; i < argc; ++i){ - //-c - if(!strcmp(argv[i], "-c") || !strcmp(argv[i], "--config")){ - ++i; - if(i < argc){ - strcpy(*cfg_path, argv[i]); + int i = 0; + + while(opt != -1){ + opt = getopt_long(argc, argv, "c:hq", long_options, &i); + switch(opt){ + case 0: + printf("Unknown long option '%s'", long_options[i].name); + if(optarg) + printf(" with arg '%s'", optarg); + printf("\n"); + break; + case 'c': + strcpy(*cfg_path, optarg); flags_set[0] = true; - } - continue; - } - - //-h - if(!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")){ - print_help(argv[0]); - flags_set[1] = true; - break; //break rather than continue; program will quit if a help message is requested - } - - //-q - if(!strcmp(argv[i], "-q") || !strcmp(argv[i], "--quiet")){ - flags_set[2] = true; - continue; + break; + case 'h': + print_help(argv[0]); + flags_set[1] = true; + opt = -1; // break out of the while loop + break; + case 'q': + flags_set[2] = true; + break; + case '?': + return NULL; // error parsing arguments + case -1: + break; // don't print unknown option message if at the end of the list + default: + printf("Unknown short option: '%c'\n", opt); } } @@ -218,12 +236,12 @@ bool *handle_args(int argc, char **argv, char **cfg_path){ } void print_help(char *exec_name){ - printf("Usage: %s [OPTION] [FILE]\n", exec_name); + printf("Usage: %s [OPTION]\n", exec_name); printf("Draw an Ncurses Menu to Launch Media from\n\n"); - printf(" -c, --config Specify a configuration file path\n"); - printf(" -h, --help Print this help message\n"); - printf(" -q, --quiet Suppress stdout messages\n"); + printf(" -c, --config=FILE Specify a configuration file path\n"); + printf(" -h, --help Print this help message\n"); + printf(" -q, --quiet Suppress stdout messages\n"); } void update_display(bool resize){ -- cgit From 14a6e82cc82e8c1802c0d468c6b32553d56099a6 Mon Sep 17 00:00:00 2001 From: Louie S Date: Tue, 9 May 2023 17:20:31 -0700 Subject: Don't check for windres on unix builds --- configure | 10 +++++++--- configure.ac | 12 ++++++++---- src/windows/.deps/terminal_media_launcher-cache.Po | 1 + src/windows/.deps/terminal_media_launcher-draw.Po | 1 + src/windows/.deps/terminal_media_launcher-read_cfg.Po | 1 + 5 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 src/windows/.deps/terminal_media_launcher-cache.Po create mode 100644 src/windows/.deps/terminal_media_launcher-draw.Po create mode 100644 src/windows/.deps/terminal_media_launcher-read_cfg.Po diff --git a/configure b/configure index 538dda3..1df7536 100755 --- a/configure +++ b/configure @@ -5755,7 +5755,8 @@ if test "${enable_embed_icon+set}" = set; then : fi if test "x$embed_icon" = "xyes"; then - if test -n "$ac_tool_prefix"; then + if test "x$build_windows" = "xyes"; then + if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}windres", so it can be a program name with args. set dummy ${ac_tool_prefix}windres; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 @@ -5847,11 +5848,14 @@ else WINDRES="$ac_cv_prog_WINDRES" fi - if ${WINDRES:+false} :; then : + if ${WINDRES:+false} :; then : { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Cannot embed icon" >&5 $as_echo "$as_me: WARNING: Cannot embed icon" >&2;} - embed_icon=no + embed_icon=no fi + else + embed_icon=no + fi fi if test "$embed_icon" = "yes"; then EMBED_ICON_TRUE= diff --git a/configure.ac b/configure.ac index 78ee96c..bb8e8e8 100644 --- a/configure.ac +++ b/configure.ac @@ -59,10 +59,14 @@ AC_ARG_ENABLE([embed_icon], [embed icon in windows executable (default is yes)])], [embed_icon=no]) if test "x$embed_icon" = "xyes"; then - AC_CHECK_TOOL([WINDRES], [windres]) - AS_VAR_IF([WINDRES], [], - [AC_MSG_WARN([Cannot embed icon]) - embed_icon=no]) + if test "x$build_windows" = "xyes"; then + AC_CHECK_TOOL([WINDRES], [windres]) + AS_VAR_IF([WINDRES], [], + [AC_MSG_WARN([Cannot embed icon]) + embed_icon=no]) + else + embed_icon=no + fi fi AM_CONDITIONAL([EMBED_ICON], [test "$embed_icon" = "yes"]) diff --git a/src/windows/.deps/terminal_media_launcher-cache.Po b/src/windows/.deps/terminal_media_launcher-cache.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/src/windows/.deps/terminal_media_launcher-cache.Po @@ -0,0 +1 @@ +# dummy diff --git a/src/windows/.deps/terminal_media_launcher-draw.Po b/src/windows/.deps/terminal_media_launcher-draw.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/src/windows/.deps/terminal_media_launcher-draw.Po @@ -0,0 +1 @@ +# dummy diff --git a/src/windows/.deps/terminal_media_launcher-read_cfg.Po b/src/windows/.deps/terminal_media_launcher-read_cfg.Po new file mode 100644 index 0000000..9ce06a8 --- /dev/null +++ b/src/windows/.deps/terminal_media_launcher-read_cfg.Po @@ -0,0 +1 @@ +# dummy -- cgit From 2a790c9b633f72a1b0a106fc72d7587aa08d4bcb Mon Sep 17 00:00:00 2001 From: Louie S Date: Tue, 9 May 2023 18:39:36 -0700 Subject: Change how e_hover and e_offset are managed; cache e_hover and e_offset as array --- src/cache.c | 31 +++++++++++++++++++------------ src/draw.c | 47 +++++++++++++++++++++++++---------------------- src/include/cache.h | 4 ++-- src/include/draw.h | 2 +- src/windows/draw.c | 2 +- 5 files changed, 48 insertions(+), 38 deletions(-) diff --git a/src/cache.c b/src/cache.c index 60a0fa6..599879d 100644 --- a/src/cache.c +++ b/src/cache.c @@ -9,10 +9,11 @@ #include "include/cache.h" #include "include/read_cfg.h" -void save_to_cache(int g_hover, int e_hover, int true_hover, char *cfg_name){ +void save_to_cache(int g_count, int g_hover, int *e_hover, int *e_offset, int true_hover, char *cfg_name){ FILE *fp; struct stat cfg_stat; //for determining last modification time of file char *path = get_cache_path(true); + int i; //ensure get_cache_path() did not return NULL if(path == NULL) return; @@ -30,20 +31,26 @@ void save_to_cache(int g_hover, int e_hover, int true_hover, char *cfg_name){ //write to file fwrite(cfg_name, sizeof(char), BUF_LEN, fp); fwrite(&cfg_stat.st_mtime, sizeof(long int), 1, fp); + fwrite(&g_count, sizeof(int), 1, fp); fwrite(&g_hover, sizeof(int), 1, fp); - fwrite(&e_hover, sizeof(int), 1, fp); + for(i = 0; i < g_count; ++i){ + fwrite(&(e_hover[i]), sizeof(int), 1, fp); + fwrite(&(e_offset[i]), sizeof(int), 1, fp); + } fwrite(&true_hover, sizeof(int), 1, fp); fclose(fp); return; } -void load_cache(int *g_hover, int *e_hover, int *true_hover, char *new_cfg_name){ +void load_cache(int g_count, int *g_hover, int **e_hover, int **e_offset, int *true_hover, char *new_cfg_name){ FILE *fp; char *path = get_cache_path(false); char saved_cfg_name[BUF_LEN]; long int saved_cfg_mtime; struct stat new_cfg_stat; + int saved_g_count; + int i; //ensure get_cache_path() did not return NULL if(path == NULL) return; @@ -61,15 +68,15 @@ void load_cache(int *g_hover, int *e_hover, int *true_hover, char *new_cfg_name) stat(new_cfg_name, &new_cfg_stat); if(!(strcmp(saved_cfg_name, new_cfg_name)) && saved_cfg_mtime >= new_cfg_stat.st_mtime){ - fread(g_hover, sizeof(int), 1, fp); - fread(e_hover, sizeof(int), 1, fp); - fread(true_hover, sizeof(int), 1, fp); - } - - else{ - *g_hover = 0; - *e_hover = 0; - *true_hover = 0; + fread(&saved_g_count, sizeof(int), 1, fp); + if(saved_g_count == g_count){ + fread(g_hover, sizeof(int), 1, fp); + for(i = 0; i < g_count; ++i){ + fread(&(*e_hover)[i], sizeof(int), 1, fp); + fread(&(*e_offset)[i], sizeof(int), 1, fp); + } + fread(true_hover, sizeof(int), 1, fp); + } } fclose(fp); diff --git a/src/draw.c b/src/draw.c index 61e0a93..7078760 100644 --- a/src/draw.c +++ b/src/draw.c @@ -33,15 +33,15 @@ int locateChar(char input); WINDOW *group_win = NULL; WINDOW *entry_win = NULL; WINDOW *info_win = NULL; -int g_hover; -int e_hover; -int true_hover; //0 = hovering on groups, 1 = hovering on entries +int g_hover = 0; +int *e_hover; +int true_hover = 0; //0 = hovering on groups, 1 = hovering on entries GROUP **g; ENTRY **e; int g_count; int e_count; int g_offset = 0; -int e_offset = 0; +int *e_offset; int main(int argc, char **argv){ bool *flags_set = NULL; @@ -82,8 +82,12 @@ int main(int argc, char **argv){ exit(0); } + //initialize e_hover to track hover on each group + e_hover = calloc(g_count, sizeof(int)); + e_offset = calloc(g_count, sizeof(int)); + //load cached data - load_cache(&g_hover, &e_hover, &true_hover, cfg_path); + load_cache(g_count, &g_hover, &e_hover, &e_offset, &true_hover, cfg_path); //reopen stdout for drawing menu freopen("/dev/tty", "w", stdout); @@ -109,7 +113,7 @@ int main(int argc, char **argv){ //update highlighting for loaded location if(true_hover){ - i = e_hover; + i = e_hover[g_hover]; true_hover = 0; trav_col(g_hover); switch_col(); @@ -131,11 +135,11 @@ int main(int argc, char **argv){ break; case KEY_DOWN: - trav_col((true_hover ? e_hover : g_hover)+1); + trav_col((true_hover ? e_hover[g_hover] : g_hover)+1); break; case KEY_UP: - trav_col((true_hover ? e_hover : g_hover)-1); + trav_col((true_hover ? e_hover[g_hover] : g_hover)-1); break; case KEY_PPAGE: @@ -160,7 +164,7 @@ int main(int argc, char **argv){ case 10: //enter key //create a green highlight over the launched entry - mvwchgat(entry_win, 1+e_hover-e_offset, 1, entry_win->_maxx-1, A_DIM, 3, NULL); + mvwchgat(entry_win, 1+e_hover[g_hover]-e_offset[g_hover], 1, entry_win->_maxx-1, A_DIM, 3, NULL); wrefresh(entry_win); launch(); @@ -181,7 +185,7 @@ int main(int argc, char **argv){ endwin(); //save position data to cache - save_to_cache(g_hover, e_hover, true_hover, cfg_path); + save_to_cache(g_count, g_hover, e_hover, e_offset, true_hover, cfg_path); return 0; } @@ -312,7 +316,7 @@ void fill_col(int mode){ int i; WINDOW *col = (mode ? entry_win : group_win); int count = (mode ? e_count : g_count); - int offset = (mode ? e_offset : g_offset); + int offset = (mode ? e_offset[g_hover] : g_offset); int max_len = col->_maxx-1; //longest possible string length that can be displayed in the window int ycoord = 1; int max_y = HEIGHT-(6+GAP_SIZE); @@ -406,7 +410,7 @@ void update_col(int mode, int hl_where, bool resize){ e = get_entries(get_ghead(g[g_hover]), e_count); fill_col(1); if(!resize) mvwchgat(entry_win, y_hl, 1, entry_win->_maxx-1, A_DIM, 1, NULL); - else mvwchgat(entry_win, 1+e_hover-e_offset, 1, entry_win->_maxx-1, A_DIM, (true_hover ? 2 : 1), NULL); + else mvwchgat(entry_win, 1+e_hover[g_hover]-e_offset[g_hover], 1, entry_win->_maxx-1, A_DIM, (true_hover ? 2 : 1), NULL); break; default: @@ -429,11 +433,11 @@ void switch_col(){ true_hover = (true_hover+1) % 2; if(true_hover){ mvwchgat(group_win, 1+g_hover, 1, group_win->_maxx-1, A_DIM, 1, NULL); //adjust group light - mvwchgat(entry_win, 1+e_hover, 1, entry_win->_maxx-1, A_DIM, 2, NULL); //adjust entry light + mvwchgat(entry_win, 1+e_hover[g_hover], 1, entry_win->_maxx-1, A_DIM, 2, NULL); //adjust entry light } else{ mvwchgat(group_win, 1+g_hover, 1, group_win->_maxx-1, A_DIM, 2, NULL); //adjust group light - mvwchgat(entry_win, 1+e_hover, 1, entry_win->_maxx-1, A_DIM, 1, NULL); //adjust entry light + mvwchgat(entry_win, 1+e_hover[g_hover], 1, entry_win->_maxx-1, A_DIM, 1, NULL); //adjust entry light } move(3, (WIDTH/4)+10); @@ -443,8 +447,8 @@ void switch_col(){ } void trav_col(int new_i){ - int *focus = (true_hover ? &e_hover : &g_hover); //make it easy to know which column we are looking at - int *offset = (true_hover ? &e_offset : &g_offset); + int *focus = (true_hover ? &(e_hover[g_hover]) : &g_hover); //make it easy to know which column we are looking at + int *offset = (true_hover ? &(e_offset[g_hover]) : &g_offset); int count = (true_hover ? e_count : g_count); int max_hl = HEIGHT-(3+GAP_SIZE); //for some reason, this works int min_hl = 5; @@ -455,7 +459,7 @@ void trav_col(int new_i){ if(new_i >= count) new_i = count-1; //reset previously highlighted entry and group, change focus - mvwchgat(entry_win, 1+e_hover-e_offset, 1, entry_win->_maxx-1, A_NORMAL, 0, NULL); + mvwchgat(entry_win, 1+e_hover[g_hover]-e_offset[g_hover], 1, entry_win->_maxx-1, A_NORMAL, 0, NULL); mvwchgat(group_win, 1+g_hover-g_offset, 1, group_win->_maxx-1, A_NORMAL, 0, NULL); *focus = new_i; @@ -473,12 +477,11 @@ void trav_col(int new_i){ if(oob_flag > 0) (true_hover ? update_col(1, oob_flag-1, false) : update_col(0, oob_flag-1, false)); //highlight newly hovered upon entry/group - mvwchgat(entry_win, 1+e_hover-e_offset, 1, entry_win->_maxx-1, A_DIM, (true_hover ? 2 : 1), NULL); + mvwchgat(entry_win, 1+e_hover[g_hover]-e_offset[g_hover], 1, entry_win->_maxx-1, A_DIM, (true_hover ? 2 : 1), NULL); mvwchgat(group_win, 1+g_hover-g_offset, 1, group_win->_maxx-1, A_DIM, (true_hover ? 1 : 2), NULL); if(!true_hover){ //a little extra work regarding group hover - e_offset = 0; + e_offset[g_hover] = 0; update_col(1, 1, false); - e_hover = 0; } wrefresh(group_win); @@ -488,7 +491,7 @@ void trav_col(int new_i){ } int locateChar(char input){ - int location = (true_hover ? e_hover : g_hover); + int location = (true_hover ? e_hover[g_hover] : g_hover); bool fold_case = get_case_sensitivity(); char first_char; int i; @@ -523,7 +526,7 @@ int locateChar(char input){ char *get_launch(){ char *program = get_gprog(g[g_hover]); char *flags = get_gflags(g[g_hover]); - char *path = get_epath(e[e_hover]); + char *path = get_epath(e[e_hover[g_hover]]); bool quotes = get_gquotes(g[g_hover]); char *full_command = malloc(sizeof(char) * BUF_LEN); diff --git a/src/include/cache.h b/src/include/cache.h index 0f5a6c4..894e4e1 100644 --- a/src/include/cache.h +++ b/src/include/cache.h @@ -1,9 +1,9 @@ #ifndef CACHE_H #define CACHE_H -void save_to_cache(int g_hover, int e_hover, int true_hover, char *cfg_name); +void save_to_cache(int g_count, int g_hover, int *e_hover, int *e_offset, int true_hover, char *cfg_name); -void load_cache(int *g_hover, int *e_hover, int *true_hover, char *new_cfg_name); +void load_cache(int g_count, int *g_hover, int **e_hover, int **e_offset, int *true_hover, char *new_cfg_name); char *get_cache_path(bool create); diff --git a/src/include/draw.h b/src/include/draw.h index 0a6baba..387ced3 100644 --- a/src/include/draw.h +++ b/src/include/draw.h @@ -6,7 +6,7 @@ #define BUF_LEN 1024 extern int g_hover; -extern int e_hover; +extern int *e_hover; extern struct group **g; extern struct entry **e; diff --git a/src/windows/draw.c b/src/windows/draw.c index 28bef68..3b06b9f 100644 --- a/src/windows/draw.c +++ b/src/windows/draw.c @@ -8,7 +8,7 @@ void launch(){ char *program = get_gprog(g[g_hover]); char *flags = get_gflags(g[g_hover]); - char *path = get_epath(e[e_hover]); + char *path = get_epath(e[e_hover[g_hover]]); bool quotes = get_gquotes(g[g_hover]); char file[BUF_LEN]; char params[BUF_LEN]; -- cgit From 3a1962deeb9975f7e175d0e06b88725b7d79ecc8 Mon Sep 17 00:00:00 2001 From: Louie S Date: Tue, 9 May 2023 21:02:01 -0700 Subject: Remove some drawing glitches --- src/draw.c | 50 +++++++++++++++++++++++++++----------------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/src/draw.c b/src/draw.c index 7078760..fa5965a 100644 --- a/src/draw.c +++ b/src/draw.c @@ -25,7 +25,7 @@ void draw_title(); void draw_win(WINDOW *new, char *title); void fill_col(int mode); //0 = GROUP, 1 = ENTRY char *trim_name(char *name, char *path, int max_len); -void update_col(int mode, int hl_where, bool resize); //0 = last, 1 = first; 0 = GROUP, 1 = ENTRY, 2 = INFO +void update_col(int mode, int y_hl, bool resize); //mode: 0 = GROUP, 1 = ENTRY, 2 = INFO void switch_col(); void trav_col(int new_i); int locateChar(char input); @@ -112,14 +112,12 @@ int main(int argc, char **argv){ update_display(false); //update highlighting for loaded location - if(true_hover){ - i = e_hover[g_hover]; - true_hover = 0; - trav_col(g_hover); - switch_col(); - trav_col(i); - } - else trav_col(g_hover); + i = true_hover; + true_hover = 0; + trav_col(g_hover); + switch_col(); + trav_col(e_hover[g_hover]); + true_hover = i; update_display(true); //drawing is done, now run a while loop to receive input (ESC ends this loop) @@ -269,12 +267,12 @@ void update_display(bool resize){ draw_win(group_win, "GROUP"); draw_win(entry_win, "ENTRY"); draw_win(info_win, "INFO"); - update_col(0, 1, resize); + update_col(0, group_win->_maxy-1, resize); //start with hover on the first group, draw the entries from the selected group, true_hover is over the groups (rather than the entries) (do update after first draw, only after subsequent (resize) updates) if(resize){ - update_col(1, 1, resize); - update_col(2, 0, resize); + update_col(1, entry_win->_maxy-1, resize); + update_col(2, 1, resize); } curs_set(0); //hide the cursor //move(3, (WIDTH/4)+10); @@ -353,7 +351,7 @@ char *trim_name(char *name, char *path, int max_len){ return name; } -void update_col(int mode, int hl_where, bool resize){ +void update_col(int mode, int y_hl, bool resize){ //mode 0 = group //mode 1 = entry //mode 2 = info @@ -361,7 +359,6 @@ void update_col(int mode, int hl_where, bool resize){ WINDOW *col; char *name; int name_len; - int y_hl; char *execution; switch(mode){ @@ -388,8 +385,6 @@ void update_col(int mode, int hl_where, bool resize){ return; } - y_hl = (hl_where ? 1 : col->_maxy-1); - //reset the column window (including reboxing and redrawing the title) wclear(col); box(col, 0, 0); @@ -432,12 +427,12 @@ void update_col(int mode, int hl_where, bool resize){ void switch_col(){ true_hover = (true_hover+1) % 2; if(true_hover){ - mvwchgat(group_win, 1+g_hover, 1, group_win->_maxx-1, A_DIM, 1, NULL); //adjust group light - mvwchgat(entry_win, 1+e_hover[g_hover], 1, entry_win->_maxx-1, A_DIM, 2, NULL); //adjust entry light + mvwchgat(group_win, 1+g_hover-g_offset, 1, group_win->_maxx-1, A_DIM, 1, NULL); //adjust group light + mvwchgat(entry_win, 1+e_hover[g_hover]-e_offset[g_hover], 1, entry_win->_maxx-1, A_DIM, 2, NULL); //adjust entry light } else{ - mvwchgat(group_win, 1+g_hover, 1, group_win->_maxx-1, A_DIM, 2, NULL); //adjust group light - mvwchgat(entry_win, 1+e_hover[g_hover], 1, entry_win->_maxx-1, A_DIM, 1, NULL); //adjust entry light + mvwchgat(group_win, 1+g_hover-g_offset, 1, group_win->_maxx-1, A_DIM, 2, NULL); //adjust group light + mvwchgat(entry_win, 1+e_hover[g_hover]-e_offset[g_hover], 1, entry_win->_maxx-1, A_DIM, 1, NULL); //adjust entry light } move(3, (WIDTH/4)+10); @@ -474,19 +469,28 @@ void trav_col(int new_i){ oob_flag = 2; } - if(oob_flag > 0) (true_hover ? update_col(1, oob_flag-1, false) : update_col(0, oob_flag-1, false)); + // rewrite to not rely on oob_flag semantics + //if(oob_flag > 0) (true_hover ? update_col(1, oob_flag-1, false) : update_col(0, oob_flag-1, false)); + if(oob_flag > 0){ + if(true_hover){ + update_col(1, (oob_flag == 1 ? entry_win->_maxy-1 : 1), false); + } + else{ + update_col(0, (oob_flag == 1 ? entry_win->_maxy-1 : 1), false); + } + } //highlight newly hovered upon entry/group mvwchgat(entry_win, 1+e_hover[g_hover]-e_offset[g_hover], 1, entry_win->_maxx-1, A_DIM, (true_hover ? 2 : 1), NULL); mvwchgat(group_win, 1+g_hover-g_offset, 1, group_win->_maxx-1, A_DIM, (true_hover ? 1 : 2), NULL); if(!true_hover){ //a little extra work regarding group hover e_offset[g_hover] = 0; - update_col(1, 1, false); + update_col(1, e_hover[g_hover]+1, false); } wrefresh(group_win); wrefresh(entry_win); - update_col(2, 0, false); + update_col(2, 1, false); return; } -- cgit From 5683ccf3a01d8d97b08f8ecbf656a3d92f9737ef Mon Sep 17 00:00:00 2001 From: Louie S Date: Tue, 9 May 2023 21:36:50 -0700 Subject: Fixed graphical issues pertaining to remembering e_hovers --- src/draw.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/draw.c b/src/draw.c index fa5965a..9bb982f 100644 --- a/src/draw.c +++ b/src/draw.c @@ -469,8 +469,6 @@ void trav_col(int new_i){ oob_flag = 2; } - // rewrite to not rely on oob_flag semantics - //if(oob_flag > 0) (true_hover ? update_col(1, oob_flag-1, false) : update_col(0, oob_flag-1, false)); if(oob_flag > 0){ if(true_hover){ update_col(1, (oob_flag == 1 ? entry_win->_maxy-1 : 1), false); @@ -484,8 +482,7 @@ void trav_col(int new_i){ mvwchgat(entry_win, 1+e_hover[g_hover]-e_offset[g_hover], 1, entry_win->_maxx-1, A_DIM, (true_hover ? 2 : 1), NULL); mvwchgat(group_win, 1+g_hover-g_offset, 1, group_win->_maxx-1, A_DIM, (true_hover ? 1 : 2), NULL); if(!true_hover){ //a little extra work regarding group hover - e_offset[g_hover] = 0; - update_col(1, e_hover[g_hover]+1, false); + update_col(1, e_hover[g_hover]+1, true); } wrefresh(group_win); -- cgit