C-Menu 0.2.9
A User Interface Toolkit
Loading...
Searching...
No Matches
ui_notcurses_draw.c File Reference

NotCurses UI backend — drawing functions. More...

#include "ui_backend.h"
#include "ui_notcurses_internal.h"
#include <notcurses/notcurses.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for ui_notcurses_draw.c:

Go to the source code of this file.

Macros

#define _GNU_SOURCE
#define _XOPEN_SOURCE_EXTENDED   1

Functions

int mk_chimera (UiCell *cell, char c)
 create a cell with specified character, using background cell style and channels
struct ncvisual * ui_display_image (struct notcurses *nc, UiMultiMedia *mm, const char *image_file, int y, int x, int begy, int begx)
 display an image on the terminal using NotCurses
int ui_draw_ch (UiSurface *s, ss_t w, char c)
 on specified window, at current location, add character
int ui_draw_ch_yx (UiSurface *s, ss_t w, uint y, uint x, char c)
 on specified window, move to y, x, add character
int ui_draw_text (UiSurface *s, ss_t w, uint y, uint x, const char *text)
 on specified window, move to y, x, add string
int ui_draw_text_fill (UiSurface *s, ss_t w, uint y, uint x, const char *text, int m)
 on specified window, move to y, x, add string, at most m columns, fill with spaces if text is shorter than m
int ui_draw_text_n (UiSurface *s, ss_t w, uint y, uint x, const char *text, int m)
 on specified window, move to y, x, add string, at most m columns
int ui_mvwadd_wch (UiSurface *s, ss_t w, uint y, uint x, const UiCell *cell)
 on specified window, move to y, x, add cell
int ui_mvwadd_wchnstr (UiSurface *s, ss_t w, uint y, uint x, const UiCell *cell, uint m)
 on specified window, move to y, x, add cell string, at most m columns
int ui_mvwadd_wchstr (UiSurface *s, ss_t w, uint y, uint x, const UiCell *cell)
 on specified window, move to y, x, add cell string
int ui_mvwaddch (UiSurface *s, ss_t w, uint y, uint x, const char c)
 on specified window, move to y, x, add character
int ui_mvwaddnstr (UiSurface *s, ss_t w, uint y, uint x, const char *text, int m)
 on specified window, move to y, x, add string, at most m columns
int ui_mvwaddnwstr (UiSurface *s, ss_t w, uint y, uint x, const wchar_t *wstr, int m)
 on specified window, move to y, x, add string, at most m columns
int ui_mvwaddstr (UiSurface *s, ss_t w, uint y, uint x, const char *text)
 on specified window, move to y, x, add string
int ui_mvwaddstr_fill (UiSurface *s, ss_t w, uint y, uint x, const char *text, int m)
 on specified window, move to y, x, add string, at most m columns, fill with spaces if text is shorter than m
int ui_mvwaddwstr (UiSurface *s, ss_t w, uint y, uint x, const wchar_t *wstr)
 on specified window, move to y, x, add wchar_t string
void ui_restore_wins ()
 Restore the state of all windows in the UI. This function refreshes the standard screen and all surface windows, ensuring that their contents are displayed correctly.
int ui_wadd_wch (UiSurface *s, ss_t w, const UiCell *cell)
 on specified window, at current location, add cell
int ui_wadd_wchnstr (UiSurface *s, ss_t w, const UiCell *cell, uint m)
 on specified window, add cell string, at most m columns
int ui_wadd_wchstr (UiSurface *s, ss_t w, const UiCell *cell)
 on specified window, at current location, add cell string
int ui_waddch (UiSurface *s, ss_t w, const char c)
 on specified window, at current location, add character
int ui_waddnstr (UiSurface *s, ss_t w, const char *text, int m)
 on specified window, at current location, add string, at most m columns
int ui_waddnwstr (UiSurface *s, ss_t w, const wchar_t *wstr, int m)
 on specified window, at current location, add wchar_t string, at most m columns
int ui_waddstr (UiSurface *s, ss_t w, const char *text)
 on specified window, at current location, add string
int ui_waddwstr (UiSurface *s, ss_t w, const wchar_t *wstr)
 on specified window, at current location, add wchar_t string
int ui_wclrtobot (UiSurface *s, ss_t w)
 clear from current cursor position to bottom of window
int ui_wclrtoeol (UiSurface *s, ss_t w)
 clear the window from the current cursor position to the end of the window

Detailed Description

NotCurses UI backend — drawing functions.

Implements the drawing operations declared in ui_backend.h using the NotCurses API.

Definition in file ui_notcurses_draw.c.

Macro Definition Documentation

◆ _GNU_SOURCE

#define _GNU_SOURCE

Definition at line 8 of file ui_notcurses_draw.c.

◆ _XOPEN_SOURCE_EXTENDED

#define _XOPEN_SOURCE_EXTENDED   1

Definition at line 9 of file ui_notcurses_draw.c.

Function Documentation

◆ mk_chimera()

int mk_chimera ( UiCell * cell,
char c )

create a cell with specified character, using background cell style and channels

Parameters
cellpointer to UiCell
ccharacter
Returns
0 on success, -1 on error

Definition at line 66 of file ui_notcurses_draw.c.

66 {
67 cell->gcluster = c;
68 cell->gcluster_backstop = 0;
69 cell->stylemask = bkgd_cell.stylemask;
70 cell->channels = bkgd_cell.channels;
71 return 0;
72}
UiCell bkgd_cell
uint16_t stylemask
Definition ui_backend.h:389
uint64_t channels
Definition ui_backend.h:406
char gcluster_backstop
Definition ui_backend.h:387
uint32_t gcluster
Definition ui_backend.h:381

◆ ui_display_image()

struct ncvisual * ui_display_image ( struct notcurses * nc,
UiMultiMedia * mm,
const char * image_file,
int y,
int x,
int begy,
int begx )

display an image on the terminal using NotCurses

Parameters
ncNotCurses context
mmUiMultiMedia structure to hold the image and surface
image_filepath to the image file
yheight of the image display area (or -1 for full height)
xwidth of the image display area (or -1 for full width)
begystarting row for the image display area (or -1 for top)
begxstarting column for the image display area (or -1 for left)
Returns
pointer to the ncvisual structure on success, nullptr on error

Definition at line 466 of file ui_notcurses_draw.c.

466 {
467 struct ncplane *stdn = notcurses_stdplane(nc);
468 unsigned term_rows, term_cols;
469 ncplane_dim_yx(stdn, &term_rows, &term_cols);
470 mm->ncv = ncvisual_from_file(image_file);
471 if (!mm->ncv) {
472 fprintf(stderr, "Error: Could not load image file.\n");
473 return nullptr;
474 }
475 struct ncvgeom geom;
476 if (ncvisual_geom(nc, mm->ncv, NULL, &geom) < 0) {
477 ncvisual_destroy(mm->ncv);
478 return nullptr;
479 }
480 if (begy == -1)
481 begy = 0;
482 if (begx == -1)
483 begx = 0;
484 if (y == -1)
485 y = (int)term_rows - begy;
486 if (x == -1)
487 x = (int)term_cols - begx;
488 if (begy + y > (int)term_rows)
489 y = (int)term_rows - begy;
490 if (begx + x > (int)term_cols)
491 x = (int)term_cols - begx;
492 int max_rows = y - 2;
493 int max_cols = x - 2;
494 if (max_rows <= 0) {
495 ncvisual_destroy(mm->ncv);
496 return nullptr;
497 }
498 struct ncvisual_options vopts_calc = {
499 .scaling = NCSCALE_SCALE_HIRES,
500 .blitter = NCBLIT_PIXEL,
501 };
502 struct ncplane_options nopts = {
503 .y = begy,
504 .x = x,
505 .rows = max_rows,
506 .cols = max_cols,
507 };
508 struct ncplane *tmp_bound_plane = ncplane_create(stdn, &nopts);
509 if (!tmp_bound_plane) {
510 ncvisual_destroy(mm->ncv);
511 return nullptr;
512 }
513 vopts_calc.n = tmp_bound_plane;
514 if (ncvisual_geom(nc, mm->ncv, &vopts_calc, &geom) < 0) {
515 ncplane_destroy(tmp_bound_plane);
516 ncvisual_destroy(mm->ncv);
517 return nullptr;
518 }
519 unsigned rows = geom.rcelly;
520 unsigned cols = geom.rcellx;
521 // dimensions
522 ncplane_destroy(tmp_bound_plane);
523 mm->sfc = ui_surface_box(stdsfc, BOX, rows + 2, cols + 2, begy, 0, image_file);
524 ui_surface_addwin(mm->sfc, WIN, BOX, rows, cols, 1, 1);
525 struct ncvisual_options vopts = {
526 .n = mm->sfc->mplane[WIN],
527 .scaling = NCSCALE_SCALE_HIRES,
528 .blitter = NCBLIT_PIXEL,
529 };
530 ncvisual_blit(nc, mm->ncv, &vopts);
531 notcurses_render(nc);
532 return mm->ncv;
533}
int ui_surface_addwin(UiSurface *s, ss_t w, uint p, uint lines, uint cols, uint y, uint x)
Add a new window to the specified UiSurface.
Definition ui_ncurses.c:395
UiSurface * ui_surface_box(UiSurface *parent, uint p, uint lines, uint cols, uint y, uint x, const char *title)
Create a new UI surface with a border box and optional title.
Definition ui_ncurses.c:288
UiSurface * stdsfc
Definition ui_ncurses.c:46
struct ncplane * mplane[SUB_SFC_MAX]
Definition ui_backend.h:351
NcVisual * ncv
Definition ui_backend.h:776
UiSurface * sfc
Definition ui_backend.h:777

References UiMultiMedia::ncv, UiMultiMedia::sfc, stdsfc, ui_surface_addwin(), and ui_surface_box().

Here is the call graph for this function:

◆ ui_draw_ch()

int ui_draw_ch ( UiSurface * s,
ss_t w,
char c )

on specified window, at current location, add character

Draw a character in a surface window.

Parameters
ssurface
wwindow
ccharacter
Returns
0 on success, -1 on error

Definition at line 79 of file ui_notcurses_draw.c.

79 {
80 if (!s || !c)
81 return -1;
82 nccell cell = CELL_INITIALIZER(c, s->meta[w].bkgd_cell.stylemask, s->meta[w].bkgd_cell.channels);
83 ncplane_putc_yx(s->mplane[w], -1, -1, &cell);
84 return 0;
85}
#define CELL_INITIALIZER(c, s, chan)
Definition ui_backend.h:434
struct nccell bkgd_cell
Definition ui_backend.h:332
struct UiSurfaceMeta meta[SUB_SFC_MAX]
Definition ui_backend.h:354

◆ ui_draw_ch_yx()

int ui_draw_ch_yx ( UiSurface * s,
ss_t w,
uint y,
uint x,
char c )

on specified window, move to y, x, add character

Draw a character at a specific position in a surface window.

Parameters
ssurface
wwindow
yrow
xcolumn
ccharacter
Returns
0 on success, -1 on error

Definition at line 94 of file ui_notcurses_draw.c.

94 {
95 if (!s || !c)
96 return -1;
97 nccell cell = CELL_INITIALIZER(c, s->meta[w].bkgd_cell.stylemask, s->meta[w].bkgd_cell.channels);
98 ncplane_putc_yx(s->mplane[w], y, x, &cell);
99 return 0;
100}

Referenced by menu_cmd_processor().

Here is the caller graph for this function:

◆ ui_draw_text()

int ui_draw_text ( UiSurface * s,
ss_t w,
uint y,
uint x,
const char * text )

on specified window, move to y, x, add string

Parameters
ssurface
wwindow
yrow
xcolumn
textstring
Returns
0 on success, -1 on error

Definition at line 109 of file ui_notcurses_draw.c.

109 {
110 if (!s || !text)
111 return -1;
112 ncplane_putstr_yx(s->mplane[w], y, x, text);
113 return 0;
114}

Referenced by ui_action_disposition(), ui_answer_yn(), ui_display_error(), ui_perror(), ui_timeout_prompt(), and ui_update_timeout_prompt().

Here is the caller graph for this function:

◆ ui_draw_text_fill()

int ui_draw_text_fill ( UiSurface * s,
ss_t w,
uint y,
uint x,
const char * text,
int m )

on specified window, move to y, x, add string, at most m columns, fill with spaces if text is shorter than m

Draw a text string at a specific position in a surface window, filling the remaining space with spaces if the string is shorter than n.

Parameters
ssurface
wwindow
yrow
xcolumn
textstring
mmaximum number of columns to write
Returns
0 on success, -1 on error

Definition at line 139 of file ui_notcurses_draw.c.

139 {
140 if (!s || !text)
141 return -1;
142 char tmp_str[MAXLEN];
143 strncpy(tmp_str, text, m);
144 int l = strlen(text);
145 for (int i = l; i < m; i++) {
146 tmp_str[i] = ' ';
147 }
148 tmp_str[m] = '\0';
149 ncplane_putnstr_yx(s->mplane[w], y, x, m, tmp_str);
150 ui_render();
151 return 0;
152}
void ui_render()
Render the UI by updating panels and refreshing the display.
Definition ui_ncurses.c:884
#define MAXLEN
Definition curskeys.c:15

References ui_render().

Referenced by menu_cmd_processor(), and menu_engine().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_draw_text_n()

int ui_draw_text_n ( UiSurface * s,
ss_t w,
uint y,
uint x,
const char * text,
int m )

on specified window, move to y, x, add string, at most m columns

Draw a text string at a specific position in a surface window.

Parameters
ssurface
wwindow
yrow
xcolumn
textstring
mmaximum number of columns to write
Returns
0 on success, -1 on error

Definition at line 124 of file ui_notcurses_draw.c.

124 {
125 if (!s || !text)
126 return -1;
127 ncplane_putnstr_yx(s->mplane[w], y, x, m, text);
128 return 0;
129}

◆ ui_mvwadd_wch()

int ui_mvwadd_wch ( UiSurface * s,
ss_t w,
uint y,
uint x,
const UiCell * cell )

on specified window, move to y, x, add cell

Parameters
ssurface
wwindow
yrow
xcolumn
cellcell string
Returns
0 on success, -1 on error

Definition at line 363 of file ui_notcurses_draw.c.

363 {
364 if (!s)
365 return -1;
366 ncplane_putc_yx(s->mplane[w], y, x, cell);
367 return 0;
368}

◆ ui_mvwadd_wchnstr()

int ui_mvwadd_wchnstr ( UiSurface * s,
ss_t w,
uint y,
uint x,
const UiCell * cell,
uint m )

on specified window, move to y, x, add cell string, at most m columns

Parameters
ssurface
wwindow
yrow
xcolumn
cellcell string
mmaximum number of columns to write
Returns
0 on success, -1 on error

Definition at line 430 of file ui_notcurses_draw.c.

430 {
431 if (!s)
432 return -1;
433 ui_wmove(s, w, y, x);
434 uint cols = 0;
435 while (cell->gcluster != 0 && cols < m) {
436 ncplane_putc(s->mplane[w], cell);
437 cols += cell->width;
438 cell++;
439 }
440 return 0;
441}
int ui_wmove(UiSurface *s, ss_t w, uint y, uint x)
Move the cursor to a specified position within a UiSurface.
Definition ui_ncurses.c:653
uint8_t width
Definition ui_backend.h:388

References ui_wmove().

Here is the call graph for this function:

◆ ui_mvwadd_wchstr()

int ui_mvwadd_wchstr ( UiSurface * s,
ss_t w,
uint y,
uint x,
const UiCell * cell )

on specified window, move to y, x, add cell string

Parameters
ssurface
wwindow
yrow
xcolumn
cellcell string
Returns
0 on success, -1 on error

Definition at line 393 of file ui_notcurses_draw.c.

393 {
394 if (!s)
395 return -1;
396 ui_wmove(s, w, y, x);
397 while (cell->gcluster != 0) {
398 ncplane_putc(s->mplane[w], cell);
399 cell++;
400 }
401 return 0;
402}

References ui_wmove().

Here is the call graph for this function:

◆ ui_mvwaddch()

int ui_mvwaddch ( UiSurface * s,
ss_t w,
uint y,
uint x,
const char c )

on specified window, move to y, x, add character

Parameters
ssurface
wwindow
yrow
xcolumn
ccharacter
Returns
0 on success, -1 on error

Definition at line 175 of file ui_notcurses_draw.c.

175 {
176 if (!s || !c)
177 return -1;
178 nccell cell = CELL_INITIALIZER(c, s->meta[w].bkgd_cell.stylemask, s->meta[w].bkgd_cell.channels);
179 ncplane_putc_yx(s->mplane[w], y, x, &cell);
180 return 0;
181}

◆ ui_mvwaddnstr()

int ui_mvwaddnstr ( UiSurface * s,
ss_t w,
uint y,
uint x,
const char * text,
int m )

on specified window, move to y, x, add string, at most m columns

Parameters
ssurface
wwindow
yrow
xcolumn
textstring
mmaximum number of columns to write
Returns
0 on success, -1 on error

Definition at line 230 of file ui_notcurses_draw.c.

230 {
231 if (!s || !text)
232 return -1;
233 ncplane_putnstr_yx(s->mplane[w], y, x, m, text);
234 return 0;
235}

◆ ui_mvwaddnwstr()

int ui_mvwaddnwstr ( UiSurface * s,
ss_t w,
uint y,
uint x,
const wchar_t * wstr,
int m )

on specified window, move to y, x, add string, at most m columns

Parameters
ssurface
wwindow
yrow
xcolumn
wchar_tstring
mmaximum number of columns to write
Returns
0 on success, -1 on error

Definition at line 324 of file ui_notcurses_draw.c.

324 {
325 if (!s || !wstr)
326 return -1;
327 int cols = 0;
328 int width;
329 while (*wstr != L'\0') {
330 width = wcwidth(*wstr);
331 if (width < 0)
332 width = 0;
333 if (cols + width > m)
334 break;
335 ncplane_putwc_yx(s->mplane[w], y, x++, *wstr++);
336 cols += wcwidth(*wstr);
337 }
338 return 0;
339}

◆ ui_mvwaddstr()

int ui_mvwaddstr ( UiSurface * s,
ss_t w,
uint y,
uint x,
const char * text )

on specified window, move to y, x, add string

Parameters
ssurface
wwindow
yrow
xcolumn
textstring
Returns
0 on success, -1 on error

Definition at line 215 of file ui_notcurses_draw.c.

215 {
216 if (!s || !text)
217 return -1;
218 ncplane_putstr_yx(s->mplane[w], y, x, text);
219 return 0;
220}

◆ ui_mvwaddstr_fill()

int ui_mvwaddstr_fill ( UiSurface * s,
ss_t w,
uint y,
uint x,
const char * text,
int m )

on specified window, move to y, x, add string, at most m columns, fill with spaces if text is shorter than m

Parameters
ssurface
wwindow
yrow
xcolumn
textstring
mmaximum number of columns to write
Returns
0 on success, -1 on error

Definition at line 245 of file ui_notcurses_draw.c.

245 {
246 if (!s || !text)
247 return -1;
248 int l = strlen(text);
249 if (l <= m) {
250 char *tmp_str = (char *)malloc(m + 1);
251 if (!tmp_str)
252 return -1;
253 strcpy(tmp_str, text);
254 for (int i = l; i < (int)m; i++) {
255 tmp_str[i] = ' ';
256 }
257 tmp_str[m] = '\0';
258 ncplane_putnstr_yx(s->mplane[w], y, x, m, tmp_str);
259 free(tmp_str);
260 }
261 return 0;
262}

◆ ui_mvwaddwstr()

int ui_mvwaddwstr ( UiSurface * s,
ss_t w,
uint y,
uint x,
const wchar_t * wstr )

on specified window, move to y, x, add wchar_t string

Parameters
ssurface
wwindow
wchar_tstring
Returns
0 on success, -1 on error

Definition at line 285 of file ui_notcurses_draw.c.

285 {
286 if (!s || !wstr)
287 return -1;
288 while (*wstr != L'\0')
289 ncplane_putwc_yx(s->mplane[w], y, x++, *wstr++);
290 return 0;
291}

◆ ui_restore_wins()

void ui_restore_wins ( )

Restore the state of all windows in the UI. This function refreshes the standard screen and all surface windows, ensuring that their contents are displayed correctly.

Definition at line 445 of file ui_notcurses_draw.c.

445 {
446 // for (int s = 0; s <= sfc_ptr; s++) {
447 // for (int w = 0; w < 8; w++)
448 // if (ui_surface[s]->mplane[w] != nullptr)
449 // touchwin(ui_surface[s]->mplane[w]);
450 // }
451 // ui_render(ui);
452}

References sfc_ptr, SUB_SFC_MAX, ui_render(), and ui_surface.

Referenced by enter_file_spec(), exec_objects(), fork_exec(), form_exec_receiver(), full_screen_shell(), menu_cmd_processor(), menu_engine(), view_cmd_processor(), view_init_input(), and write_view_buffer().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ui_wadd_wch()

int ui_wadd_wch ( UiSurface * s,
ss_t w,
const UiCell * cell )

on specified window, at current location, add cell

Parameters
ssurface
wwindow
cellcell string
Returns
0 on success, -1 on error

Definition at line 349 of file ui_notcurses_draw.c.

349 {
350 if (!s)
351 return -1;
352 ncplane_putc(s->mplane[w], cell);
353 return 0;
354}

◆ ui_wadd_wchnstr()

int ui_wadd_wchnstr ( UiSurface * s,
ss_t w,
const UiCell * cell,
uint m )

on specified window, add cell string, at most m columns

Parameters
ssurface
wwindow
cellcell string
mmaximum number of columns to write
Returns
0 on success, -1 on error

Definition at line 410 of file ui_notcurses_draw.c.

410 {
411 if (!s)
412 return -1;
413 uint cols = 0;
414 while (cell->gcluster != 0 && cols < m) {
415 ncplane_putc(s->mplane[w], cell);
416 cols += cell->width;
417 cell++;
418 }
419 return 0;
420}

◆ ui_wadd_wchstr()

int ui_wadd_wchstr ( UiSurface * s,
ss_t w,
const UiCell * cell )

on specified window, at current location, add cell string

Parameters
ssurface
wwindow
cellcell string
Returns
0 on success, -1 on error

Definition at line 376 of file ui_notcurses_draw.c.

376 {
377 if (!s)
378 return -1;
379 while (cell->gcluster != 0) {
380 ncplane_putc(s->mplane[w], cell);
381 cell++;
382 }
383 return 0;
384}

◆ ui_waddch()

int ui_waddch ( UiSurface * s,
ss_t w,
const char c )

on specified window, at current location, add character

Parameters
ssurface
wwindow
ccharacter
Returns
0 on success, -1 on error

Definition at line 160 of file ui_notcurses_draw.c.

160 {
161 if (!s || !c)
162 return -1;
163 nccell cell = CELL_INITIALIZER(c, s->meta[w].bkgd_cell.stylemask, s->meta[w].bkgd_cell.channels);
164 ncplane_putc_yx(s->mplane[w], -1, -1, &cell);
165 return 0;
166}

◆ ui_waddnstr()

int ui_waddnstr ( UiSurface * s,
ss_t w,
const char * text,
int m )

on specified window, at current location, add string, at most m columns

Parameters
ssurface
wwindow
textstring
mmaximum number of columns to write
Returns
0 on success, -1 on error

Definition at line 201 of file ui_notcurses_draw.c.

201 {
202 if (!s || !text)
203 return -1;
204 ncplane_putnstr(s->mplane[w], m, text);
205 return 0;
206}

◆ ui_waddnwstr()

int ui_waddnwstr ( UiSurface * s,
ss_t w,
const wchar_t * wstr,
int m )

on specified window, at current location, add wchar_t string, at most m columns

Parameters
ssurface
wwindow
wchar_tstring
mmaximum number of columns to write
Returns
0 on success, -1 on error

Definition at line 300 of file ui_notcurses_draw.c.

300 {
301 if (!s || !wstr)
302 return -1;
303 int cols = 0;
304 int width;
305 while (*wstr != L'\0') {
306 width = wcwidth(*wstr);
307 if (width < 0)
308 width = 0;
309 if (cols + width > m)
310 break;
311 ncplane_putwc_yx(s->mplane[w], -1, -1, *wstr++);
312 }
313 return 0;
314}

◆ ui_waddstr()

int ui_waddstr ( UiSurface * s,
ss_t w,
const char * text )

on specified window, at current location, add string

Parameters
ssurface
wwindow
textstring
Returns
0 on success, -1 on error

Definition at line 188 of file ui_notcurses_draw.c.

188 {
189 if (!s || !text)
190 return -1;
191 ncplane_putstr(s->mplane[w], text);
192 return 0;
193}

◆ ui_waddwstr()

int ui_waddwstr ( UiSurface * s,
ss_t w,
const wchar_t * wstr )

on specified window, at current location, add wchar_t string

Parameters
ssurface
wwindow
wchar_tstring
Returns
0 on success, -1 on error

Definition at line 272 of file ui_notcurses_draw.c.

272 {
273 if (!s || !wstr)
274 return -1;
275 while (*wstr != L'\0')
276 ncplane_putwc_yx(s->mplane[w], -1, -1, *wstr++);
277 return 0;
278}

◆ ui_wclrtobot()

int ui_wclrtobot ( UiSurface * s,
ss_t w )

clear from current cursor position to bottom of window

Set the style of a surface window.

Parameters
ssurface
wwindow
Returns
0 on success, -1 on error

Definition at line 42 of file ui_notcurses_draw.c.

42 {
43 if (!s)
44 return -1;
45 uint y, x, ylen, xlen, maxy, maxx;
46 ncplane_cursor_yx(s->mplane[w], &y, &x);
47 ncplane_dim_yx(s->mplane[w], &maxy, &maxx);
48 xlen = maxx - x;
49 ylen = 1;
50 ncplane_erase_region(s->mplane[w], y, x, ylen, xlen);
51 ylen = maxy - y - 1;
52 xlen = maxx;
53 ncplane_erase_region(s->mplane[w], y + 1, x = 0, ylen, maxx);
54 return 0;
55}

Referenced by display_line_eod(), scroll_next(), scroll_prev(), and search().

Here is the caller graph for this function:

◆ ui_wclrtoeol()

int ui_wclrtoeol ( UiSurface * s,
ss_t w )

clear the window from the current cursor position to the end of the window

Clear to the end of the line in a surface window.

Parameters
ssurface
wwindow
Returns
0 on success, -1 on error

Definition at line 26 of file ui_notcurses_draw.c.

26 {
27 if (!s)
28 return -1;
29 uint y, x, ylen, xlen, maxy, maxx;
30 ncplane_cursor_yx(s->mplane[w], &y, &x);
31 ncplane_dim_yx(s->mplane[w], &maxy, &maxx);
32 xlen = maxx - x;
33 ylen = 1;
34 ncplane_erase_region(s->mplane[w], y, x, ylen, xlen);
35 return 0;
36}

Referenced by cf_accept(), display_line(), display_prompt(), display_split_line(), form_post(), get_cmd_arg(), get_cmd_char(), pick_engine(), picker(), ui_display_chyron(), and ui_update_timeout_prompt().

Here is the caller graph for this function: