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
|
#include "vui.h"
int x = 0, y = 0;
int main(void) {
vui_init();
int x = 0, y = 0;
int scroll_x = 0, scroll_y = 0;
for (;;) {
static int last_left = 0;
int left = (COLS - (72 < COLS ? 72 : COLS - 2)) >> 1;
int right = COLS - left;
int top = 5;
int bottom = LINES - 5;
//vui_fill(' ', FG_WHITE | BG_BLUE);
//vui_fill_rect(' ', FG_BLACK | BG_BLACK, left + 2, top + 1, right - left, bottom - top);
//vui_fill_rect(' ', FG_BLACK | BG_WHITE, left, top, right - left, bottom - top);
if (y < top) { scroll_y = top - y; }
if (y > bottom) { scroll_y = bottom - y; }
scroll_x += left - last_left;
last_left = left;
int sdx = scroll_x > 0 ? 1 : (scroll_x < 0 ? -1 : 0);
sdx = scroll_x;
int sdy = scroll_y > 0 ? 1 : (scroll_y < 0 ? -1 : 0);
vui_scroll(sdx, sdy);
x += sdx;
y += sdy;
scroll_x -= sdx;
scroll_y -= sdy;
vui_blit();
int animating = !!scroll_x || !!scroll_y;
if (animating && !vui_wait_for_input(50)) continue;
VuiKey c = vui_key();
if (c == KEY_INVALID || c == KEY_ESC) goto done;
if (x >= right) {
x = left;
y += 2;
}
static unsigned i = 0;
i++;
int tx = x + vui_aprintf(x, y - 1, (i & 1 ? FG_WHITE : FG_CYAN) | BG_BLACK, "%02X", c);
vui_chra(x++, y, c < 0x20 || c > KEY_UTF8_MAX || c == 0x7f ? 0xfffd : c, FG_BYELLOW | BG_BLUE);
while (x < tx) vui_chra(x++, y, ' ', FG_BYELLOW | BG_BLUE);
}
done:
vui_fini();
return 0;
}
|