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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
use core::ptr::{null, null_mut};
use crate::{
cstring, NcCapabilities, NcChannels, NcComponent, NcDim, NcDirect, NcInput, NcIntResult, NcRgb,
NcTime,
};
#[inline]
pub fn ncdirect_cantruecolor(ncd: &NcDirect) -> bool {
ncdirect_capabilities(ncd).rgb
}
#[inline]
pub fn ncdirect_canchangecolor(ncd: &NcDirect) -> bool {
crate::nccapability_canchangecolor(&ncdirect_capabilities(ncd))
}
#[inline]
pub fn ncdirect_canfade(ncd: &NcDirect) -> bool {
ncdirect_canchangecolor(ncd) || ncdirect_cantruecolor(ncd)
}
#[inline]
pub fn ncdirect_canopen_videos(_ncd: &NcDirect) -> bool {
unsafe { crate::notcurses_canopen_videos(null()) }
}
#[inline]
pub fn ncdirect_canhalfblock(ncd: &NcDirect) -> bool {
unsafe { crate::ncdirect_canutf8(ncd) }
}
#[inline]
pub fn ncdirect_canquadrant(ncd: &NcDirect) -> bool {
(unsafe { crate::ncdirect_canutf8(ncd) }) && ncdirect_capabilities(ncd).quadrants
}
#[inline]
pub fn ncdirect_cansextant(ncd: &NcDirect) -> bool {
(unsafe { crate::ncdirect_canutf8(ncd) }) && ncdirect_capabilities(ncd).sextants
}
#[inline]
pub fn ncdirect_canbraille(_ncd: &NcDirect) -> bool {
unsafe { crate::notcurses_canbraille(null()) }
}
#[inline]
pub fn ncdirect_capabilities(ncd: &NcDirect) -> NcCapabilities {
unsafe { *crate::bindings::ffi::ncdirect_capabilities(ncd) }
}
#[inline]
pub fn ncdirect_getc_blocking(ncd: &mut NcDirect, input: &mut NcInput) -> char {
unsafe { core::char::from_u32_unchecked(crate::ncdirect_getc(ncd, null(), null_mut(), input)) }
}
#[inline]
pub fn ncdirect_getc_nblock(ncd: &mut NcDirect, input: &mut NcInput) -> char {
unsafe {
let ts = NcTime::new();
core::char::from_u32_unchecked(crate::ncdirect_getc(ncd, &ts, null_mut(), input))
}
}
#[inline]
pub fn ncdirect_set_fg_rgb8(
ncd: &mut NcDirect,
red: NcComponent,
green: NcComponent,
blue: NcComponent,
) -> NcIntResult {
let rgb = (red as NcRgb) << 16 | (green as NcRgb) << 8 | blue as NcRgb;
unsafe { crate::ncdirect_set_fg_rgb(ncd, rgb) }
}
#[inline]
pub fn ncdirect_set_bg_rgb8(
ncd: &mut NcDirect,
red: NcComponent,
green: NcComponent,
blue: NcComponent,
) -> NcIntResult {
let rgb = (red as NcRgb) << 16 | (green as NcRgb) << 8 | blue as NcRgb;
unsafe { crate::ncdirect_set_bg_rgb(ncd, rgb) }
}
#[inline]
pub fn ncdirect_hline_interp(
ncd: &mut NcDirect,
egc: &str,
len: NcDim,
h1: NcChannels,
h2: NcChannels,
) -> NcIntResult {
#[cfg(any(target_arch = "armv7l", target_arch = "i686"))]
let egc_ptr = cstring![egc] as *const i8;
#[cfg(not(any(target_arch = "armv7l", target_arch = "i686")))]
let egc_ptr = cstring![egc];
unsafe { crate::bindings::ffi::ncdirect_hline_interp(ncd, egc_ptr, len as i32, h1, h2) }
}
#[inline]
pub fn ncdirect_vline_interp(
ncd: &mut NcDirect,
egc: &str,
len: NcDim,
h1: NcChannels,
h2: NcChannels,
) -> NcIntResult {
#[cfg(any(target_arch = "armv7l", target_arch = "i686"))]
let egc_ptr = cstring![egc] as *const i8;
#[cfg(not(any(target_arch = "armv7l", target_arch = "i686")))]
let egc_ptr = cstring![egc];
unsafe { crate::bindings::ffi::ncdirect_vline_interp(ncd, egc_ptr, len as i32, h1, h2) }
}