Refactor personInfo function: update parameters to include person list, enhance memory handling, and improve user interaction in TUI.
This commit is contained in:
@@ -255,20 +255,20 @@ void personListing(list_t *person_list, int terminal_x, int terminal_y)
|
||||
int idx = 0, row = 2;
|
||||
while (current && row < win_height)
|
||||
{
|
||||
if (current->user.uuid)
|
||||
if (idx >= offset && row < win_height - 1)
|
||||
{
|
||||
if (idx == highlight)
|
||||
wattron(personlisting, COLOR_PAIR(2));
|
||||
mvwprintw(personlisting, row, 2, "%-10hu %-20s %-20s %s",
|
||||
current->user.uuid,
|
||||
current->user.surname,
|
||||
current->user.name,
|
||||
current->user.available ? "Yes " : "No ");
|
||||
if (idx == highlight)
|
||||
wattroff(personlisting, COLOR_PAIR(2));
|
||||
row++;
|
||||
}
|
||||
|
||||
if (idx >= offset && row < win_height - 1)
|
||||
{
|
||||
if (idx == highlight)
|
||||
wattron(personlisting, COLOR_PAIR(2));
|
||||
mvwprintw(personlisting, row, 2, "%-10hu %-20s %-20s %s",
|
||||
current->user.uuid,
|
||||
current->user.surname,
|
||||
current->user.name,
|
||||
current->user.available ? "Yes " : "No ");
|
||||
if (idx == highlight)
|
||||
wattroff(personlisting, COLOR_PAIR(2));
|
||||
row++;
|
||||
}
|
||||
idx++;
|
||||
current = current->next;
|
||||
}
|
||||
@@ -278,7 +278,7 @@ void personListing(list_t *person_list, int terminal_x, int terminal_y)
|
||||
keyboard_input = wgetch(personlisting);
|
||||
if (keyboard_input == KEY_UP)
|
||||
{
|
||||
if (highlight > 1)
|
||||
if (highlight > 0)
|
||||
{
|
||||
highlight--;
|
||||
if (highlight < offset)
|
||||
@@ -303,7 +303,7 @@ void personListing(list_t *person_list, int terminal_x, int terminal_y)
|
||||
selected = selected->next;
|
||||
idx++;
|
||||
}
|
||||
personInfo(selected, terminal_x, terminal_y);
|
||||
personInfo(person_list, selected, terminal_x, terminal_y);
|
||||
}
|
||||
else if (keyboard_input == 27 || keyboard_input == 'q')
|
||||
{
|
||||
@@ -460,10 +460,10 @@ void personSearch(list_t *person_list, int terminal_x, int terminal_y)
|
||||
}
|
||||
}
|
||||
|
||||
void personInfo(node_t *_person, int terminal_x, int terminal_y)
|
||||
void personInfo(list_t *_list, node_t *_person, int terminal_x, int terminal_y)
|
||||
{
|
||||
int win_height = 14;
|
||||
int win_width = 50;
|
||||
int win_width = 60;
|
||||
int start_y = (terminal_y - win_height) / 2;
|
||||
int start_x = (terminal_x - win_width) / 2;
|
||||
|
||||
@@ -483,7 +483,7 @@ void personInfo(node_t *_person, int terminal_x, int terminal_y)
|
||||
wattroff(personinfodialog, COLOR_PAIR(6));
|
||||
keypad(personinfodialog, TRUE);
|
||||
|
||||
char buttons[2][20] = {"<Print to file...>", "<Back>"};
|
||||
char buttons[3][20] = {"<Print to file...>", "<Add Time Event>", "<Back>"};
|
||||
char prompts[6][32] = {"Name", "Surname", "Department", "Last time event", "Total time", "Available"};
|
||||
|
||||
char keyboard_input;
|
||||
@@ -520,7 +520,7 @@ void personInfo(node_t *_person, int terminal_x, int terminal_y)
|
||||
|
||||
wrefresh(personinfodialog);
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
if (highlight == i)
|
||||
wattron(personinfodialog, COLOR_PAIR(2));
|
||||
@@ -541,8 +541,12 @@ void personInfo(node_t *_person, int terminal_x, int terminal_y)
|
||||
|
||||
if (keyboard_input == '\t')
|
||||
{
|
||||
highlight = !highlight;
|
||||
if (highlight != 2)
|
||||
highlight++;
|
||||
else
|
||||
highlight = 1;
|
||||
}
|
||||
|
||||
else if (keyboard_input == '\n')
|
||||
{
|
||||
if (highlight == 0)
|
||||
@@ -550,6 +554,10 @@ void personInfo(node_t *_person, int terminal_x, int terminal_y)
|
||||
exportPersonInfo(_person);
|
||||
}
|
||||
else if (highlight == 1)
|
||||
{
|
||||
addTimeEvent(_person, _list);
|
||||
}
|
||||
else if (highlight == 2)
|
||||
{
|
||||
delwin(personinfodialog);
|
||||
touchwin(stdscr);
|
||||
|
||||
Reference in New Issue
Block a user