1use std::os::raw::c_char;
2use std::os::raw::c_int;
3
4#[repr(C)]
5pub enum Name {
6 UNKNOWN = 0,
7 ARC,
8 ARROW,
9 ARROW2,
10 ARROW3,
11 BALLOON,
12 BALLOON2,
13 BOUNCE,
14 BOUNCINGBALL,
15 BOUNCINGBAR,
16 BOXBOUNCE,
17 BOXBOUNCE2,
18 CHRISTMAS,
19 CIRCLE,
20 CIRCLEHALVES,
21 CIRCLEQUARTERS,
22 CLOCK,
23 DOTS,
24 DOTS10,
25 DOTS11,
26 DOTS12,
27 DOTS2,
28 DOTS3,
29 DOTS4,
30 DOTS5,
31 DOTS6,
32 DOTS7,
33 DOTS8,
34 DOTS9,
35 DQPB,
36 EARTH,
37 FLIP,
38 GRENADE,
39 GROWHORIZONTAL,
40 GROWVERTICAL,
41 HAMBURGER,
42 HEARTS,
43 LAYER,
44 LINE,
45 LINE2,
46 MONKEY,
47 MOON,
48 NOISE,
49 PIPE,
50 POINT,
51 PONG,
52 RUNNER,
53 SHARK,
54 SIMPLEDOTS,
55 SIMPLEDOTSSCROLLING,
56 SMILEY,
57 SQUARECORNERS,
58 SQUISH,
59 STAR,
60 STAR2,
61 TOGGLE,
62 TOGGLE10,
63 TOGGLE11,
64 TOGGLE12,
65 TOGGLE13,
66 TOGGLE2,
67 TOGGLE3,
68 TOGGLE4,
69 TOGGLE5,
70 TOGGLE6,
71 TOGGLE7,
72 TOGGLE8,
73 TOGGLE9,
74 TRIANGLE,
75 WEATHER,
76}
77
78#[repr(C)]
79struct spinner_t {
80 name: Name,
81 interval: c_int,
82 frames_length: c_int,
83 frames: *mut *mut c_char
84}
85
86#[repr(C)]
87struct wow_t;
88
89#[allow(warnings)]
90extern "C" {
91 fn wow_init(s: *mut spinner_t, text: *const c_char) -> *mut wow_t;
92 fn wow_persist(wow: *mut wow_t);
93 fn wow_persist_with(wow: *mut wow_t, s: *mut spinner_t, text: *const c_char);
94 fn wow_spinner(wow: *mut wow_t, s: *mut spinner_t);
95 fn wow_start(wow: *mut wow_t);
96 fn wow_stop(wow: *mut wow_t);
97 fn wow_text(wow: *mut wow_t, text: *const c_char);
98 fn spin_get(name: Name) -> *mut spinner_t;
99 fn wow_clean(wow: *mut wow_t);
100 fn spinner_clean(s: *mut spinner_t);
101}
102
103pub struct Spinner {
104 spinner: *mut spinner_t
105}
106
107impl Drop for Spinner {
108 fn drop(&mut self) {
109 unsafe {
110 spinner_clean(self.spinner);
111 }
112 }
113}
114
115impl Spinner {
116 pub fn new(name: Name) -> Self {
117 unsafe {
118 let res = spin_get(name);
119 Self {
120 spinner: res
121 }
122 }
123 }
124}
125
126pub struct Wow {
127 wow: *mut wow_t
128}
129
130impl Drop for Wow {
131 fn drop(&mut self) {
132 unsafe {
133 wow_clean(self.wow);
134 }
135 }
136}
137
138impl Wow {
139 pub fn new(s: &Spinner,text: &str) -> Self {
140 unsafe {
141 let res = wow_init(s.spinner, text.as_ptr() as *const i8);
142 Self {
143 wow: res
144 }
145 }
146 }
147
148 pub fn persist(&self) {
149 unsafe {
150 wow_persist(self.wow);
151 }
152 }
153 pub fn persist_with(&self, s: &Spinner, text: &str) {
154 unsafe {
155 wow_persist_with(self.wow, s.spinner, text.as_ptr() as *const i8);
156 }
157 }
158 pub fn spinner(&self, s: &Spinner) {
159 unsafe {
160 wow_spinner(self.wow, s.spinner);
161 }
162 }
163 pub fn start(&self) {
164 unsafe {
165 wow_start(self.wow);
166 }
167 }
168 pub fn stop(&self) {
169 unsafe {
170 wow_stop(self.wow);
171 }
172 }
173 pub fn text(&self, text: &str) {
174 unsafe {
175 wow_text(self.wow, text.as_ptr() as *const i8);
176 }
177 }
178}