forked from uoaerg/wavemon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
about_scr.c
76 lines (68 loc) · 2.06 KB
/
about_scr.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* wavemon - a wireless network monitoring application
*
* Copyright (c) 2001-2002 Jan Morgenstern <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "wavemon.h"
/* GLOBALS */
static WINDOW *w_about;
static char *about_lines[] = {
PACKAGE_NAME " - status monitor for wireless network devices",
"version " PACKAGE_VERSION,
"",
"original by jan morgenstern <[email protected]>",
"distributed under the GNU general public license v3",
"",
PACKAGE_URL
};
static int *linecd[ARRAY_SIZE(about_lines)];
void scr_about_init(void)
{
w_about = newwin_title(0, WAV_HEIGHT, "About", false);
for (size_t i = 0; i < ARRAY_SIZE(about_lines); i++) {
linecd[i] = malloc(strlen(about_lines[i]) * sizeof(int));
for (size_t j = 0; j < strlen(about_lines[i]); j++)
linecd[i][j] = (rand() / (float)RAND_MAX) * 120 + 60;
}
}
int scr_about_loop(WINDOW *w_menu)
{
char buf[0x100];
size_t i, j;
for (i = 0; i < ARRAY_SIZE(about_lines); i++) {
for (j = 0; j < strlen(about_lines[i]); j++) {
if (linecd[i][j] > 60) {
buf[j] = ' ';
linecd[i][j]--;
} else if (linecd[i][j]) {
buf[j] = (rand() / (float)RAND_MAX) * 54 + 65;
linecd[i][j]--;
} else {
buf[j] = about_lines[i][j];
}
}
buf[j] = '\0';
waddstr_center(w_about, (WAV_HEIGHT - ARRAY_SIZE(about_lines))/2 + i, buf);
}
wrefresh(w_about);
return wgetch(w_menu);
}
void scr_about_fini(void)
{
delwin(w_about);
for (size_t i = 0; i < ARRAY_SIZE(about_lines); i++)
free(linecd[i]);
}