C-Menu
0.2.9
A User Interface Toolkit
Toggle main menu visibility
Loading...
Searching...
No Matches
pad_demo.c
Go to the documentation of this file.
1
#
define
_XOPEN_SOURCE_EXTENDED
1
2
#
define
_GNU_SOURCE
1
3
4
#
include
<
notcurses
/
notcurses
.
h
>
5
#
include
<
unistd
.
h
>
6
7
int
main
(
void
) {
8
// 1. Initialize Notcurses
9
struct
notcurses_options opts = {
10
.flags = NCOPTION_SUPPRESS_BANNERS,
11
};
12
struct
notcurses *nc = notcurses_init(&opts, NULL);
13
if
(!nc)
14
return
1;
15
16
struct
ncplane *stdn = notcurses_stdplane(nc);
17
unsigned
term_y, term_x;
18
ncplane_dim_yx(stdn, &term_y, &term_x);
19
20
struct
ncplane_options plane_opts = {
21
.y = 0,
22
.x = 0,
23
.rows = 100,
24
.cols = 200,
25
};
26
struct
ncplane *pad = ncplane_create(stdn, &plane_opts);
27
28
uint64_t channels = 0;
29
ncplane_set_fchannel(pad, 0x002244);
30
ncplane_set_bchannel(pad, 0x000000);
31
ncplane_set_base(pad,
" "
, 0, channels);
32
33
for
(
int
y = 0; y < 100; y += 5) {
34
for
(
int
x = 0; x < 200; x += 20) {
35
ncplane_printf_yx(pad, y, x,
"[Row %d, Col %d]"
, y, x);
36
}
37
}
38
39
for
(
int
i = 0; i <= 40; i++) {
40
ncplane_move_yx(pad, -i, -(i * 2));
41
notcurses_render(nc);
42
usleep(100000);
// 100ms delay
43
}
44
45
notcurses_stop(nc);
46
return
0;
47
}
48
49
/* Key Implementation Details
50
* Virtual Coordinates: The y and x positions in ncplane_options are relative to
51
* the parent plane (stdn).
52
* Negative Moving: To view lower or rightward sections of your large canvas,
53
* pass negative coordinates to ncplane_move_yx. This slides the canvas up or
54
* left behind the terminal viewport.
55
* Automatic Clipping: You do not need to calculate intersection windows like
56
* ncurses prefresh. Notcurses discards pixels outside the screen space
57
* automatically during notcurses_render.
58
*/
main
int main(int argc, char **argv)
Capture the current terminal settings for later restoration.
Definition
amort.c:30
ui
pad_demo.c
Generated by
1.17.0