summaryrefslogtreecommitdiff
path: root/src/draw.c
diff options
context:
space:
mode:
authorLouie Shprung <lshprung@tutanota.com>2024-08-13 21:06:03 -0400
committerLouie Shprung <lshprung@tutanota.com>2024-08-13 21:06:03 -0400
commitb5dd0df1808429a3c0ed1f86256962512b8273f5 (patch)
tree51c145097dfbf3a730bd60cbc6c516962712ee18 /src/draw.c
parent4e68f637300c0e360d49f8f672d0675d42da0d1f (diff)
Working implementation for lua config
Diffstat (limited to 'src/draw.c')
-rw-r--r--src/draw.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/draw.c b/src/draw.c
index 1775329..99b1a74 100644
--- a/src/draw.c
+++ b/src/draw.c
@@ -1,3 +1,4 @@
+#include <assert.h>
#include <getopt.h>
#include <stdbool.h>
#include <stdio.h>
@@ -40,7 +41,6 @@ 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 g_offset = 0;
int *e_offset;
@@ -74,6 +74,10 @@ int main(int argc, char **argv){
print_help(argv[0]);
return 1;
}
+ // DEBUG
+ //for(i = 0; i < g_count; ++i) {
+ // group_debug(g[i]);
+ //}
/*
//Remove Empty Groups from the Array
@@ -335,6 +339,7 @@ void fill_col(int mode){
//mode 1 = entry
int i;
+ ENTRY **entries = get_gentries(g[g_hover]);
WINDOW *col = (mode ? entry_win : group_win);
int count = (mode ? get_ecount(g[g_hover]) : g_count);
int offset = (mode ? e_offset[g_hover] : g_offset);
@@ -343,15 +348,12 @@ void fill_col(int mode){
int max_y = HEIGHT-(6+GAP_SIZE);
char *name;
- mvwprintw(col, 0, 0, "i: %d\n", offset);
- if(offset < 0) offset = 0;
-
for(i = 0+offset; i < count; i++){
if(ycoord >= max_y) break; //reached the bottom of the terminal window, stop drawing
- name = (mode ? get_ename(e[i]) : get_gname(g[i]));
+ name = (mode ? get_ename(entries[i]) : get_gname(g[i]));
//the name is too long, take the group to the trimming function
- if(strlen(name) > max_len) name = trim_name(name, (mode ? get_epath(e[i]) : get_gname(g[i])), max_len);
+ if(strlen(name) > max_len) name = trim_name(name, (mode ? get_epath(entries[i]) : get_gname(g[i])), max_len);
wmove(col, ycoord, 1);
wprintw(col, "%s", name);
ycoord++;
@@ -427,7 +429,6 @@ void update_col(int mode, int y_hl, bool resize){
break;
case 1:
- e = get_gentries(g[g_hover]);
fill_col(1);
if(!resize) mvwchgat(entry_win, y_hl, 1, getmaxx(entry_win)-2, A_DIM, 1, NULL);
else mvwchgat(entry_win, 1+e_hover[g_hover]-e_offset[g_hover], 1, getmaxx(entry_win)-2, A_DIM, (true_hover ? 2 : 1), NULL);
@@ -483,7 +484,6 @@ void trav_col(int new_i){
mvwchgat(group_win, 1+g_hover-g_offset, 1, getmaxx(group_win)-2, A_NORMAL, 0, NULL);
*focus = new_i;
-
//check offsets relating to new highlight, make sure highlight did not go oob
while(*focus-*offset+5 > max_hl){
(*offset)++;
@@ -517,6 +517,7 @@ void trav_col(int new_i){
}
int locateChar(char input){
+ ENTRY **entries = get_gentries(g[g_hover]);
int location = (true_hover ? e_hover[g_hover] : g_hover);
bool fold_case = get_case_sensitivity();
char first_char;
@@ -526,7 +527,7 @@ int locateChar(char input){
if(true_hover){ //hovering on entries
for(i = location+1; i < get_ecount(g[g_hover]); i++){
- first_char = get_ename(e[i])[0];
+ first_char = get_ename(entries[i])[0];
if(fold_case && first_char >= 97 && first_char <= 122) first_char -= 32;
if(input == first_char){
location = i;
@@ -550,13 +551,12 @@ int locateChar(char input){
}
char *get_launch(){
+ ENTRY **entries = get_gentries(g[g_hover]);
char *program = get_gprog(g[g_hover]);
char *flags = get_gflags(g[g_hover]);
- char *path = get_epath(e[e_hover[g_hover]]);
+ char *path = get_epath(entries[e_hover[g_hover]]);
bool quotes = false;
- char *full_command = malloc(sizeof(char) * BUF_LEN);
-
- full_command[0] = '\0';
+ char *full_command = calloc(BUF_LEN, sizeof(char));
//if the entry is an executable file (doesn't have a launcher)
if(!(strcmp(program, "./"))){