2021-03-08 09:03:26 +01:00
|
|
|
static int
|
|
|
|
issel(size_t id)
|
|
|
|
{
|
|
|
|
for (int i = 0;i < selidsize;i++)
|
|
|
|
if (selid[i] == id)
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
printsel(unsigned int state)
|
|
|
|
{
|
|
|
|
for (int i = 0;i < selidsize;i++)
|
2022-03-24 00:12:56 +01:00
|
|
|
if (selid[i] != -1 && (!sel || sel->id != selid[i])) {
|
2021-05-15 14:40:05 +02:00
|
|
|
#if PRINTINDEX_PATCH
|
2022-03-24 00:12:56 +01:00
|
|
|
if (print_index)
|
|
|
|
printf("%d\n", selid[i]);
|
|
|
|
else
|
2021-05-15 14:40:05 +02:00
|
|
|
#endif // PRINTINDEX_PATCH
|
2022-03-24 00:12:56 +01:00
|
|
|
puts(items[selid[i]].text);
|
|
|
|
}
|
|
|
|
if (sel && !(state & ShiftMask)) {
|
2021-05-15 14:40:05 +02:00
|
|
|
#if PRINTINDEX_PATCH
|
2022-03-24 00:12:56 +01:00
|
|
|
if (print_index)
|
|
|
|
printf("%d\n", sel->index);
|
|
|
|
else
|
2021-05-15 14:40:05 +02:00
|
|
|
#endif // PRINTINDEX_PATCH
|
2022-03-24 00:12:56 +01:00
|
|
|
puts(sel->text);
|
|
|
|
} else
|
2021-03-08 09:03:26 +01:00
|
|
|
puts(text);
|
2022-03-24 00:12:56 +01:00
|
|
|
|
2021-03-08 09:03:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2024-07-16 21:42:32 +02:00
|
|
|
selsel(void)
|
2021-03-08 09:03:26 +01:00
|
|
|
{
|
|
|
|
if (!sel)
|
|
|
|
return;
|
|
|
|
if (issel(sel->id)) {
|
|
|
|
for (int i = 0; i < selidsize; i++)
|
|
|
|
if (selid[i] == sel->id)
|
|
|
|
selid[i] = -1;
|
|
|
|
} else {
|
|
|
|
for (int i = 0; i < selidsize; i++)
|
|
|
|
if (selid[i] == -1) {
|
|
|
|
selid[i] = sel->id;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
selidsize++;
|
|
|
|
selid = realloc(selid, (selidsize + 1) * sizeof(int));
|
|
|
|
selid[selidsize - 1] = sel->id;
|
|
|
|
}
|
2024-07-16 21:42:32 +02:00
|
|
|
}
|