2
3
4
5
6
7
9#define _XOPEN_SOURCE_EXTENDED 1
13#include <notcurses/notcurses.h>
19
20
25 uint y, x, ylen, xlen, maxy, maxx;
26 ncplane_cursor_yx(s->mplane[w], &y, &x);
27 ncplane_dim_yx(s->mplane[w], &maxy, &maxx);
30 ncplane_erase_region(s->mplane[w], y, x, ylen, xlen);
37 uint y, x, ylen, xlen, maxy, maxx;
38 ncplane_cursor_yx(s->mplane[w], &y, &x);
39 ncplane_dim_yx(s->mplane[w], &maxy, &maxx);
42 ncplane_erase_region(s->mplane[w], y, x, ylen, xlen);
45 ncplane_erase_region(s->mplane[w], y + 1, x = 0, ylen, maxx);
50
51
63 ncplane_putc_yx(s->mplane[w], -1, -1, &cell);
70 ncplane_putc_yx(s->mplane[w], y, x, &cell);
73int ui_draw_text(UiSurface *s, uint w, uint y, uint x,
const char *text) {
76 ncplane_putstr_yx(s->mplane[w], y, x, text);
79int ui_draw_text_n(UiSurface *s, uint w, uint y, uint x,
const char *text,
int m) {
82 ncplane_putnstr_yx(s->mplane[w], y, x, m, text);
89 strncpy(tmp_str, text, m);
91 for (
int i = l; i < m; i++) {
95 ncplane_putnstr_yx(s->mplane[w], y, x, m, tmp_str);
100int ui_mvwaddch(UiSurface *s, uint w, uint y, uint x,
const char c) {
105 ncplane_putc_yx(s->mplane[w], -1, -1, &cell);
111 ncplane_putstr(s->mplane[w], text);
117 ncplane_putnstr(s->mplane[w], m, text);
120int ui_mvwaddstr(UiSurface *s, uint w, uint y, uint x,
const char *text) {
123 ncplane_putstr_yx(s->mplane[w], y, x, text);
126int ui_mvwaddnstr(UiSurface *s, uint w, uint y, uint x,
const char *text,
int m) {
129 ncplane_putnstr_yx(s->mplane[w], y, x, m, text);
135 int l = strlen(text);
137 char *tmp_str = (
char *)malloc(m + 1);
140 strcpy(tmp_str, text);
141 for (
int i = l; i < (
int)m; i++) {
145 ncplane_putnstr_yx(s->mplane[w], y, x, m, tmp_str);
156 while (*wstr != L'\0')
157 ncplane_putwc_yx(s->mplane[w], -1, -1, *wstr++);
160int ui_mvwaddwstr(UiSurface *s, uint w, uint y, uint x,
const wchar_t *wstr) {
163 while (*wstr != L'\0')
164 ncplane_putwc_yx(s->mplane[w], y, x++, *wstr++);
172 while (*wstr != L'\0') {
173 width = wcwidth(*wstr);
176 if (cols + width > m)
178 ncplane_putwc_yx(s->mplane[w], -1, -1, *wstr++);
182int ui_mvwaddnwstr(UiSurface *s, uint w, uint y, uint x,
const wchar_t *wstr,
int m) {
187 while (*wstr != L'\0') {
188 width = wcwidth(*wstr);
191 if (cols + width > m)
193 ncplane_putwc_yx(s->mplane[w], y, x++, *wstr++);
194 cols += wcwidth(*wstr);
205 ncplane_putc(s->mplane[w], cell);
211 ncplane_putc_yx(s->mplane[w], y, x, cell);
218 ncplane_putc(s->mplane[w], cell++);
226 ncplane_putc(s->mplane[w], cell++);
234 ncplane_putc(s->mplane[w], cell++);
246 ncplane_putc(s->mplane[w], cell++);
252
253
int ui_waddnstr(UiSurface *s, uint w, const char *text, int m)
int ui_wadd_wch(UiSurface *s, uint w, const UiCell *cell)
int ui_draw_ch_yx(UiSurface *s, uint w, uint y, uint x, const char c)
int ui_wclrtobot(UiSurface *s, uint w)
int ui_mvwadd_wchstr(UiSurface *s, uint w, uint y, uint x, const UiCell *cell)
int ui_mvwaddnstr(UiSurface *s, uint w, uint y, uint x, const char *text, int m)
int ui_mvwaddstr(UiSurface *s, uint w, uint y, uint x, const char *text)
int ui_wadd_wchnstr(UiSurface *s, uint w, const UiCell *cell, uint m)
int ui_mvwaddnwstr(UiSurface *s, uint w, uint y, uint x, const wchar_t *wstr, int m)
int ui_draw_text_n(UiSurface *s, uint w, uint y, uint x, const char *text, int m)
int ui_mvwadd_wchnstr(UiSurface *s, uint w, uint y, uint x, const UiCell *cell, uint m)
int ui_mvwaddch(UiSurface *s, uint w, uint y, uint x, const char c)
int ui_draw_text(UiSurface *s, uint w, uint y, uint x, const char *text)
int ui_waddnwstr(UiSurface *s, uint w, const wchar_t *wstr, int m)
int ui_wmove(UiSurface *s, uint w, uint y, uint x)
int ui_draw_text_fill(UiSurface *s, uint w, uint y, uint x, const char *text, int m)
int ui_waddstr(UiSurface *s, uint w, const char *text)
int ui_wclrtoeol(UiSurface *s, uint w)
int ui_wadd_wchstr(UiSurface *s, uint w, const UiCell *cell)
#define DEFAULT_INITIALIZER(c)
int ui_mvwadd_wch(UiSurface *s, uint w, uint y, uint x, const UiCell *cell)
int ui_mvwaddwstr(UiSurface *s, uint w, uint y, uint x, const wchar_t *wstr)
int ui_mvwaddstr_fill(UiSurface *s, uint w, uint y, uint x, const char *str, int m)
int ui_draw_ch(UiSurface *s, uint w, const char c)
int ui_waddwstr(UiSurface *s, uint w, const wchar_t *wstr)
int mk_chimera(UiCell *cell, char c)
uint8_t gcluster_backstop