9 if(ncplane_set_widget(
n->ncp,
NULL,
NULL) == 0){
22 ncreader_destroy_internal(
n);
43 .
y = -ncplane_dim_y(
n),
44 .x = -ncplane_dim_x(
n),
45 .rows = ncplane_dim_y(
n),
46 .cols = ncplane_dim_x(
n),
63 if(ncplane_set_widget(
n, nr, (
void(*)(
void*))ncreader_destroy_internal)){
91 assert(
n->textarea->lenx >=
n->ncp->lenx);
92 assert(
n->textarea->leny >=
n->ncp->leny);
93 for(
unsigned y = 0 ;
y <
n->ncp->leny ; ++
y){
94 const unsigned texty =
y;
95 for(
unsigned x = 0 ;
x <
n->ncp->lenx ; ++
x){
96 const unsigned textx =
x +
n->xproject;
97 const nccell* src = &
n->textarea->fb[nfbcellidx(
n->textarea, texty, textx)];
98 nccell* dst = &
n->ncp->fb[nfbcellidx(
n->ncp,
y,
x)];
100 if(cellcmp_and_dupfar(&
n->ncp->pool, dst,
n->textarea, src) < 0){
116 int viewx =
n->ncp->x;
117 int textx =
n->textarea->x;
126 viewx =
n->ncp->lenx - 1;
128 textx =
n->textarea->lenx - 1;
129 n->xproject =
n->textarea->x -
n->ncp->x;
153 unsigned textx =
n->textarea->x;
154 unsigned y =
n->ncp->y;
155 unsigned viewx =
n->ncp->x;
157 if(textx >=
n->textarea->lenx - 1){
160 if(
y >=
n->textarea->leny - 1){
171 if(viewx >=
n->ncp->lenx - 1){
203 unsigned y =
n->ncp->y;
204 if(
y >=
n->textarea->leny - 1){
222 if(
n->textarea->x >=
n->textarea->lenx -
cols){
224 if(ncplane_resize_simple(
n->textarea,
n->textarea->leny,
n->textarea->lenx +
cols)){
229 }
else if(
n->ncp->x >=
n->ncp->lenx){
233 if(ncplane_putegc(
n->textarea,
egc,
NULL) < 0){
236 if(ncplane_putegc(
n->ncp,
egc,
NULL) < 0){
239 if(
n->textarea->x >=
n->textarea->lenx -
cols){
241 n->textarea->x =
n->textarea->lenx -
cols;
244 if(
n->ncp->x >=
n->ncp->lenx -
cols){
245 n->ncp->x =
n->ncp->lenx -
cols;
253 int x =
n->textarea->x;
254 int y =
n->textarea->y;
255 if(
n->textarea->x == 0){
257 y =
n->textarea->y - 1;
258 x =
n->textarea->lenx - 1;
271is_egc_wordbreak(
ncplane* textarea){
278 memset(&mbstate, 0,
sizeof(mbstate));
279 size_t s = mbrtowc(&w,
egc, MB_CUR_MAX, &mbstate);
281 if(s == (
size_t)-1 || s == (
size_t)-2){
300 while(
n->textarea->x){
307 while(
n->textarea->x < ncplane_dim_x(
n->textarea) - 1){
314 while(
n->textarea->x){
319 while(
n->textarea->x){
323 if(is_egc_wordbreak(
n->textarea)){
342 while(
n->textarea->x){
346 if(is_egc_wordbreak(
n->textarea)){
352 while(
n->textarea->x < ncplane_dim_x(
n->textarea) - 1){
356 if(is_egc_wordbreak(
n->textarea)){
375 if(ncinput_ctrl_p(ni) && !
n->no_cmd_keys){
376 return ncreader_ctrl_input(
n, ni);
377 }
else if(ncinput_alt_p(ni) && !
n->no_cmd_keys){
378 return ncreader_alt_input(
n, ni);
380 if(ncinput_alt_p(ni) || ncinput_ctrl_p(ni)){
384 return do_backspace(
n);
400 }
else if(nckey_synthesized_p(ni->
id)){
405 unsigned char egc[5]={0};
#define logerror(fmt,...)
int ncplane_cursor_move_yx(ncplane *n, int y, int x)
char * ncplane_contents(ncplane *nc, int begy, int begx, unsigned leny, unsigned lenx)
ncplane * notcurses_stdplane(notcurses *nc)
void ncplane_set_channels(ncplane *n, uint64_t channels)
int notcurses_ucs32_to_utf8(const uint32_t *ucs32, unsigned ucs32count, unsigned char *resultbuf, size_t buflen)
void ncplane_set_styles(ncplane *n, unsigned stylebits)
int ncplane_destroy(ncplane *ncp)
char * ncplane_at_yx(const ncplane *n, int y, int x, uint16_t *stylemask, uint64_t *channels)
int ncplane_putegc_yx(ncplane *n, int y, int x, const char *gclust, size_t *sbytes)
int ncstrwidth(const char *egcs, int *validbytes, int *validwidth)
notcurses * ncplane_notcurses(const ncplane *n)
ncplane * ncplane_create(ncplane *n, const ncplane_options *nopts)
void ncplane_erase(ncplane *n)
const struct ncplane_options * opts
#define NCREADER_OPTION_NOCMDKEYS
#define NCREADER_OPTION_HORSCROLL
#define NCREADER_OPTION_CURSOR
int ncreader_move_up(ncreader *n)
int ncreader_move_down(ncreader *n)
ncreader * ncreader_create(ncplane *n, const ncreader_options *opts)
int ncreader_write_egc(ncreader *n, const char *egc)
char * ncreader_contents(const ncreader *n)
void ncreader_destroy(ncreader *n, char **contents)
ncplane * ncreader_plane(ncreader *n)
int ncreader_clear(ncreader *n)
int ncreader_move_right(ncreader *n)
bool ncreader_offer_input(ncreader *n, const ncinput *ni)
int ncreader_move_left(ncreader *n)
int notcurses_cursor_enable(notcurses *nc, int y, int x)
int notcurses_cursor_disable(notcurses *nc)