mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-16 00:13:00 +00:00
ncreader_create: accept const options #403
This commit is contained in:
parent
7683973ee4
commit
d174431187
@ -2756,7 +2756,7 @@ API int ncsubproc_destroy(struct ncsubproc* n);
|
|||||||
// is (version * 4 + 17) columns wide, and ⌈version * 4 + 17 / 2⌉ rows tall. If
|
// is (version * 4 + 17) columns wide, and ⌈version * 4 + 17 / 2⌉ rows tall. If
|
||||||
// maxversion is not zero, it plays a hard limit on the QR code size. Though the
|
// maxversion is not zero, it plays a hard limit on the QR code size. Though the
|
||||||
// max version of current QR codes is 40, greater values are allowed, for
|
// max version of current QR codes is 40, greater values are allowed, for
|
||||||
// future compatability (provide 0 for no artificail bound).
|
// future compatability (provide 0 for no artificial bound).
|
||||||
API int ncplane_qrcode(struct ncplane* n, int maxversion, const void* data, size_t len);
|
API int ncplane_qrcode(struct ncplane* n, int maxversion, const void* data, size_t len);
|
||||||
|
|
||||||
// Promote an ncplane 'n' to an ncvisual. The plane should not be associated
|
// Promote an ncplane 'n' to an ncvisual. The plane should not be associated
|
||||||
@ -2782,7 +2782,7 @@ typedef struct ncreader_options {
|
|||||||
// supporting readline keybindings. 'rows' and 'cols' both must be negative.
|
// supporting readline keybindings. 'rows' and 'cols' both must be negative.
|
||||||
// there are no restrictions on 'y' or 'x'. creates its own plane.
|
// there are no restrictions on 'y' or 'x'. creates its own plane.
|
||||||
API struct ncreader* ncreader_create(struct notcurses* nc, int y, int x,
|
API struct ncreader* ncreader_create(struct notcurses* nc, int y, int x,
|
||||||
ncreader_options* opts);
|
const ncreader_options* opts);
|
||||||
|
|
||||||
// empty the ncreader of any user input, and home the cursor.
|
// empty the ncreader of any user input, and home the cursor.
|
||||||
API int ncreader_clear(struct ncreader* n);
|
API int ncreader_clear(struct ncreader* n);
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
|
||||||
ncreader* ncreader_create(notcurses* nc, int y, int x, ncreader_options* opts){
|
ncreader* ncreader_create(notcurses* nc, int y, int x, const ncreader_options* opts){
|
||||||
if(opts->physrows <= 0 || opts->physcols <= 0){
|
if(opts->physrows <= 0 || opts->physcols <= 0){
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
if(opts->egc == NULL){
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
ncreader* nr = malloc(sizeof(*nr));
|
ncreader* nr = malloc(sizeof(*nr));
|
||||||
if(nr){
|
if(nr){
|
||||||
nr->ncp = ncplane_new(nc, opts->physrows, opts->physcols, y, x, NULL);
|
nr->ncp = ncplane_new(nc, opts->physrows, opts->physcols, y, x, NULL);
|
||||||
@ -11,6 +14,10 @@ ncreader* ncreader_create(notcurses* nc, int y, int x, ncreader_options* opts){
|
|||||||
free(nr);
|
free(nr);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
if(ncplane_set_base(nr->ncp, opts->egc, opts->eattrword, opts->echannels) <= 0){
|
||||||
|
ncreader_destroy(nr);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
// FIXME
|
// FIXME
|
||||||
}
|
}
|
||||||
return nr;
|
return nr;
|
||||||
|
@ -31,12 +31,16 @@ TEST_CASE("Readers") {
|
|||||||
CHECK(!nr);
|
CHECK(!nr);
|
||||||
}
|
}
|
||||||
|
|
||||||
SUBCASE("ReaderLifecycle") {
|
SUBCASE("ReaderRender") {
|
||||||
ncreader_options opts{};
|
ncreader_options opts{};
|
||||||
opts.physrows = 1;
|
opts.physrows = 1;
|
||||||
opts.physcols = dimx / 2;
|
opts.physcols = dimx / 2;
|
||||||
|
opts.egc = strdup("▒");
|
||||||
auto nr = ncreader_create(nc_, 0, 0, &opts);
|
auto nr = ncreader_create(nc_, 0, 0, &opts);
|
||||||
REQUIRE(nullptr != nr);
|
REQUIRE(nullptr != nr);
|
||||||
|
CHECK(0 == notcurses_render(nc_));
|
||||||
|
CHECK(0 < ncplane_set_base(n_, opts.egc, opts.eattrword, opts.echannels));
|
||||||
|
sleep(5);
|
||||||
ncreader_destroy(nr);
|
ncreader_destroy(nr);
|
||||||
CHECK(0 == notcurses_render(nc_));
|
CHECK(0 == notcurses_render(nc_));
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user