From e71d1bcbae0775ec756f3de98b5c255df3e90243 Mon Sep 17 00:00:00 2001 From: Louie S Date: Sat, 17 Feb 2024 10:42:57 -0500 Subject: Use getmax. instead of directly accessing member --- src/draw.c | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) (limited to 'src/draw.c') diff --git a/src/draw.c b/src/draw.c index 2a6e74f..894f6f2 100644 --- a/src/draw.c +++ b/src/draw.c @@ -162,7 +162,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[g_hover]-e_offset[g_hover], 1, entry_win->_maxx-1, A_DIM, 3, NULL); + mvwchgat(entry_win, 1+e_hover[g_hover]-e_offset[g_hover], 1, getmaxx(entry_win)-1, A_DIM, 3, NULL); wrefresh(entry_win); launch(); @@ -267,11 +267,11 @@ void update_display(bool resize){ draw_win(group_win, "GROUP"); draw_win(entry_win, "ENTRY"); draw_win(info_win, "INFO"); - update_col(0, group_win->_maxy-1, resize); + update_col(0, getmaxy(group_win)-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, entry_win->_maxy-1, resize); + update_col(1, getmaxy(entry_win)-1, resize); update_col(2, 1, resize); } curs_set(0); //hide the cursor @@ -299,7 +299,7 @@ void draw_win(WINDOW *new, char *title){ box(new, 0, 0); attron(A_UNDERLINE); - wmove(new, 0, (new->_maxx - title_len)/2); + wmove(new, 0, (getmaxx(new) - title_len)/2); wprintw(new, "%s", title); attroff(A_UNDERLINE); wrefresh(new); @@ -315,7 +315,7 @@ void fill_col(int mode){ WINDOW *col = (mode ? entry_win : group_win); int count = (mode ? e_count : g_count); 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 max_len = getmaxx(col)-1; //longest possible string length that can be displayed in the window int ycoord = 1; int max_y = HEIGHT-(6+GAP_SIZE); char *name; @@ -388,7 +388,7 @@ void update_col(int mode, int y_hl, bool resize){ //reset the column window (including reboxing and redrawing the title) wclear(col); box(col, 0, 0); - wmove(col, 0, (col->_maxx - name_len)/2); + wmove(col, 0, (getmaxx(col) - name_len)/2); wprintw(col, "%s", name); wrefresh(col); @@ -396,25 +396,25 @@ void update_col(int mode, int y_hl, bool resize){ switch(mode){ case 0: fill_col(0); - if(!resize) mvwchgat(group_win, y_hl, 1, group_win->_maxx-1, A_DIM, 2, NULL); - else mvwchgat(group_win, 1+g_hover-g_offset, 1, group_win->_maxx-1, A_DIM, (true_hover ? 1 : 2), NULL); + if(!resize) mvwchgat(group_win, y_hl, 1, getmaxx(group_win)-1, A_DIM, 2, NULL); + else mvwchgat(group_win, 1+g_hover-g_offset, 1, getmaxx(group_win)-1, A_DIM, (true_hover ? 1 : 2), NULL); break; case 1: e_count = get_ecount(g[g_hover]); 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[g_hover]-e_offset[g_hover], 1, entry_win->_maxx-1, A_DIM, (true_hover ? 2 : 1), NULL); + if(!resize) mvwchgat(entry_win, y_hl, 1, getmaxx(entry_win)-1, A_DIM, 1, NULL); + else mvwchgat(entry_win, 1+e_hover[g_hover]-e_offset[g_hover], 1, getmaxx(entry_win)-1, A_DIM, (true_hover ? 2 : 1), NULL); break; default: execution = get_launch(); - if(strlen(execution) >= info_win->_maxx){ - execution[info_win->_maxx - 1] = '\0'; - execution[info_win->_maxx - 2] = '.'; - execution[info_win->_maxx - 3] = '.'; - execution[info_win->_maxx - 4] = '.'; + if(strlen(execution) >= getmaxx(info_win)){ + execution[getmaxx(info_win) - 1] = '\0'; + execution[getmaxx(info_win) - 2] = '.'; + execution[getmaxx(info_win) - 3] = '.'; + execution[getmaxx(info_win) - 4] = '.'; } mvwprintw(info_win, 1, 1, "%s", execution); @@ -427,12 +427,12 @@ void update_col(int mode, int y_hl, bool resize){ void switch_col(){ true_hover = (true_hover+1) % 2; if(true_hover){ - 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 + mvwchgat(group_win, 1+g_hover-g_offset, 1, getmaxx(group_win)-1, A_DIM, 1, NULL); //adjust group light + mvwchgat(entry_win, 1+e_hover[g_hover]-e_offset[g_hover], 1, getmaxx(entry_win)-1, A_DIM, 2, NULL); //adjust entry light } else{ - 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 + mvwchgat(group_win, 1+g_hover-g_offset, 1, getmaxx(group_win)-1, A_DIM, 2, NULL); //adjust group light + mvwchgat(entry_win, 1+e_hover[g_hover]-e_offset[g_hover], 1, getmaxx(entry_win)-1, A_DIM, 1, NULL); //adjust entry light } move(3, (WIDTH/4)+10); @@ -454,8 +454,8 @@ 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[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); + mvwchgat(entry_win, 1+e_hover[g_hover]-e_offset[g_hover], 1, getmaxx(entry_win)-1, A_NORMAL, 0, NULL); + mvwchgat(group_win, 1+g_hover-g_offset, 1, getmaxx(group_win)-1, A_NORMAL, 0, NULL); *focus = new_i; @@ -471,16 +471,16 @@ void trav_col(int new_i){ if(oob_flag > 0){ if(true_hover){ - update_col(1, (oob_flag == 1 ? entry_win->_maxy-1 : 1), false); + update_col(1, (oob_flag == 1 ? getmaxy(entry_win)-1 : 1), false); } else{ - update_col(0, (oob_flag == 1 ? entry_win->_maxy-1 : 1), false); + update_col(0, (oob_flag == 1 ? getmaxy(entry_win)-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); + mvwchgat(entry_win, 1+e_hover[g_hover]-e_offset[g_hover], 1, getmaxx(entry_win)-1, A_DIM, (true_hover ? 2 : 1), NULL); + mvwchgat(group_win, 1+g_hover-g_offset, 1, getmaxx(group_win)-1, A_DIM, (true_hover ? 1 : 2), NULL); if(!true_hover){ //a little extra work regarding group hover update_col(1, e_hover[g_hover]+1, true); } -- cgit