[python] API conversions

pull/2333/head
nick black 3 years ago committed by nick black
parent d29813457b
commit c20e859a6d

@ -74,7 +74,7 @@ name: alpine-edge
steps:
- name: alpine-edge
image: dankamongmen/edge_builder:2021-08-05
image: dankamongmen/edge_builder:2021-11-08a
commands:
- export LANG=en_US.UTF-8
- export TERM=vt100

@ -1084,7 +1084,8 @@ ncplane_dim_x(const struct ncplane* n){
// ('celldimy', 'celldimx'), and the maximum displayable bitmap ('maxbmapy',
// 'maxbmapx'). If bitmaps are not supported, 'maxbmapy' and 'maxbmapx' will
// be 0. Any of the geometry arguments may be NULL.
void ncplane_pixelgeom(struct ncplane* n, int* restrict pxy, int* restrict pxx,
void ncplane_pixelgeom(struct ncplane* n,
unsigned* restrict pxy, unsigned* restrict pxx,
unsigned* restrict celldimy, unsigned* restrict celldimx,
unsigned* restrict maxbmapy, unsigned* restrict maxbmapx);

@ -103,8 +103,8 @@ class Ncplane:
return ret
def getDimensions(self):
y = ffi.new("int *")
x = ffi.new("int *")
y = ffi.new("unsigned int *")
x = ffi.new("unsigned int *")
lib.ncplane_dim_yx(self.n, y, x)
return (y[0], x[0])

@ -137,7 +137,7 @@ typedef struct ncplane_options {
**static inline unsigned ncplane_dim_x(const struct ncplane* ***n***);**
**void ncplane_cursor_yx(const struct ncplane* ***n***, int* restrict ***y***, int* restrict ***x***);**
**void ncplane_cursor_yx(const struct ncplane* ***n***, unsigned* restrict ***y***, unsigned* restrict ***x***);**
**void ncplane_translate(const struct ncplane* ***src***, const struct ncplane* ***dst***, int* restrict ***y***, int* restrict ***x***);**
@ -225,7 +225,7 @@ typedef struct ncplane_options {
**int ncplane_rotate_ccw(struct ncplane* ***n***);**
**void ncplane_pixelgeom(const struct notcurses* ***n***, int* restrict ***pxy***, int* restrict ***pxx***, unsigned* restrict ***celldimy***, unsigned* restrict ***celldimx***, unsigned* restrict ***maxbmapy***, unsigned* restrict ***maxbmapx***);**
**void ncplane_pixelgeom(const struct notcurses* ***n***, unsigned* restrict ***pxy***, unsigned* restrict ***pxx***, unsigned* restrict ***celldimy***, unsigned* restrict ***celldimx***, unsigned* restrict ***maxbmapy***, unsigned* restrict ***maxbmapx***);**
**int ncplane_set_name(struct ncplane* ***n***, const char* ***name***);**

@ -101,7 +101,7 @@ typedef struct ncvgeom {
**int ncvisual_resize_noninterpolative(struct ncvisual* ***n***, int ***rows***, int ***cols***);**
**int ncvisual_polyfill_yx(struct ncvisual* ***n***, unsigned ***y***, unsigned ***x***, uint32_t ***rgba***);**
**int ncvisual_polyfill_yx(struct ncvisual* ***n***, int ***y***, int ***x***, uint32_t ***rgba***);**
**int ncvisual_at_yx(const struct ncvisual* ***n***, unsigned ***y***, unsigned ***x***, uint32_t* ***pixel***);**

@ -69,17 +69,17 @@ namespace ncpp
return ::ncmetric (val, decimal, buf, omitdec, mult, uprefix);
}
static const char* qprefix (uintmax_t val, uintmax_t decimal, char *buf, int omitdec) noexcept
static const char* ncqprefix (uintmax_t val, uintmax_t decimal, char *buf, int omitdec) noexcept
{
return ::ncqprefix (val, decimal, buf, omitdec);
}
static const char* iprefix (uintmax_t val, uintmax_t decimal, char *buf, int omitdec) noexcept
static const char* nciprefix (uintmax_t val, uintmax_t decimal, char *buf, int omitdec) noexcept
{
return ::nciprefix (val, decimal, buf, omitdec);
}
static const char* bprefix (uintmax_t val, uintmax_t decimal, char *buf, int omitdec) noexcept
static const char* ncbprefix (uintmax_t val, uintmax_t decimal, char *buf, int omitdec) noexcept
{
return ::ncbprefix (val, decimal, buf, omitdec);
}

@ -323,12 +323,12 @@ namespace ncpp
get_dim (&rows, &cols);
}
int get_dim_x () const noexcept
unsigned get_dim_x () const noexcept
{
return ncplane_dim_x (plane);
}
int get_dim_y () const noexcept
unsigned get_dim_y () const noexcept
{
return ncplane_dim_y (plane);
}
@ -473,12 +473,12 @@ namespace ncpp
return error_guard (ncplane_cursor_move_yx (plane, y, x), -1);
}
void get_cursor_yx (int *y, int *x) const noexcept
void get_cursor_yx (unsigned *y, unsigned *x) const noexcept
{
ncplane_cursor_yx (plane, y, x);
}
void get_cursor_yx (int &y, int &x) const noexcept
void get_cursor_yx (unsigned &y, unsigned &x) const noexcept
{
get_cursor_yx (&y, &x);
}

@ -1223,7 +1223,8 @@ ncplane_dim_x(const struct ncplane* n){
// 'maxbmapx'). If bitmaps are not supported, or if there is no artificial
// limit on bitmap size, 'maxbmapy' and 'maxbmapx' will be 0. Any of the
// geometry arguments may be NULL.
API void ncplane_pixelgeom(const struct ncplane* n, int* RESTRICT pxy, int* RESTRICT pxx,
API void ncplane_pixelgeom(const struct ncplane* n,
unsigned* RESTRICT pxy, unsigned* RESTRICT pxx,
unsigned* RESTRICT celldimy, unsigned* RESTRICT celldimx,
unsigned* RESTRICT maxbmapy, unsigned* RESTRICT maxbmapx)
__attribute__ ((nonnull (1)));
@ -1862,7 +1863,7 @@ API void ncplane_home(struct ncplane* n)
__attribute__ ((nonnull (1)));
// Get the current position of the cursor within n. y and/or x may be NULL.
API void ncplane_cursor_yx(const struct ncplane* n, int* RESTRICT y, int* RESTRICT x)
API void ncplane_cursor_yx(const struct ncplane* n, unsigned* RESTRICT y, unsigned* RESTRICT x)
__attribute__ ((nonnull (1)));
// Get the current channels or attribute word for ncplane 'n'.
@ -2235,12 +2236,12 @@ API int ncplane_box(struct ncplane* n, const nccell* ul, const nccell* ur,
static inline int
ncplane_box_sized(struct ncplane* n, const nccell* ul, const nccell* ur,
const nccell* ll, const nccell* lr, const nccell* hline,
const nccell* vline, unsigned ylen, unsigned xlen,
const nccell* vline, unsigned ystop, unsigned xstop,
unsigned ctlword){
int y, x;
unsigned y, x;
ncplane_cursor_yx(n, &y, &x);
return ncplane_box(n, ul, ur, ll, lr, hline, vline, y + ylen - 1,
x + xlen - 1, ctlword);
return ncplane_box(n, ul, ur, ll, lr, hline, vline, y + ystop - 1,
x + xstop - 1, ctlword);
}
static inline int
@ -2716,7 +2717,7 @@ nccells_heavy_box(struct ncplane* n, uint16_t attr, uint64_t channels,
static inline int
ncplane_rounded_box(struct ncplane* n, uint16_t styles, uint64_t channels,
int ystop, int xstop, unsigned ctlword){
unsigned ystop, unsigned xstop, unsigned ctlword){
int ret = 0;
nccell ul = CELL_TRIVIAL_INITIALIZER, ur = CELL_TRIVIAL_INITIALIZER;
nccell ll = CELL_TRIVIAL_INITIALIZER, lr = CELL_TRIVIAL_INITIALIZER;
@ -2756,8 +2757,8 @@ ncplane_perimeter_rounded(struct ncplane* n, uint16_t stylemask,
static inline int
ncplane_rounded_box_sized(struct ncplane* n, uint16_t styles, uint64_t channels,
int ylen, int xlen, unsigned ctlword){
int y, x;
unsigned ylen, unsigned xlen, unsigned ctlword){
unsigned y, x;
ncplane_cursor_yx(n, &y, &x);
return ncplane_rounded_box(n, styles, channels, y + ylen - 1,
x + xlen - 1, ctlword);
@ -2769,13 +2770,13 @@ API int nccells_double_box(struct ncplane* n, uint16_t styles, uint64_t channels
static inline int
ncplane_double_box(struct ncplane* n, uint16_t styles, uint64_t channels,
int ystop, int xstop, unsigned ctlword){
unsigned ylen, unsigned xlen, unsigned ctlword){
int ret = 0;
nccell ul = CELL_TRIVIAL_INITIALIZER, ur = CELL_TRIVIAL_INITIALIZER;
nccell ll = CELL_TRIVIAL_INITIALIZER, lr = CELL_TRIVIAL_INITIALIZER;
nccell hl = CELL_TRIVIAL_INITIALIZER, vl = CELL_TRIVIAL_INITIALIZER;
if((ret = nccells_double_box(n, styles, channels, &ul, &ur, &ll, &lr, &hl, &vl)) == 0){
ret = ncplane_box(n, &ul, &ur, &ll, &lr, &hl, &vl, ystop, xstop, ctlword);
ret = ncplane_box(n, &ul, &ur, &ll, &lr, &hl, &vl, ylen, xlen, ctlword);
}
nccell_release(n, &ul); nccell_release(n, &ur);
nccell_release(n, &ll); nccell_release(n, &lr);
@ -2809,8 +2810,8 @@ ncplane_perimeter_double(struct ncplane* n, uint16_t stylemask,
static inline int
ncplane_double_box_sized(struct ncplane* n, uint16_t styles, uint64_t channels,
int ylen, int xlen, unsigned ctlword){
int y, x;
unsigned ylen, unsigned xlen, unsigned ctlword){
unsigned y, x;
ncplane_cursor_yx(n, &y, &x);
return ncplane_double_box(n, styles, channels, y + ylen - 1,
x + xlen - 1, ctlword);

@ -239,10 +239,10 @@ Notcurses_linesigs_enable(NotcursesObject *self, PyObject *Py_UNUSED(args))
static PyObject *
Notcurses_refresh(NotcursesObject *self, PyObject *Py_UNUSED(args))
{
int rows = 0, collumns = 0;
CHECK_NOTCURSES(notcurses_refresh(self->notcurses_ptr, &rows, &collumns));
unsigned rows = 0, columns = 0;
CHECK_NOTCURSES(notcurses_refresh(self->notcurses_ptr, &rows, &columns));
return Py_BuildValue("ii", rows, collumns);
return Py_BuildValue("II", rows, columns);
}
static PyObject *
@ -259,22 +259,22 @@ Notcurses_stdplane(NotcursesObject *self, PyObject *Py_UNUSED(args))
static PyObject *
Notcurses_stddim_yx(NotcursesObject *self, PyObject *Py_UNUSED(args))
{
int y = 0, x = 0;
unsigned y = 0, x = 0;
PyObject *new_object CLEANUP_PY_OBJ = NcPlane_Type.tp_alloc((PyTypeObject *)&NcPlane_Type, 0);
NcPlaneObject *new_plane = (NcPlaneObject *)new_object;
new_plane->ncplane_ptr = CHECK_NOTCURSES_PTR(notcurses_stddim_yx(self->notcurses_ptr, &y, &x));
Py_INCREF(new_object);
return Py_BuildValue("Oii", new_object, y, x);
return Py_BuildValue("OII", new_object, y, x);
}
static PyObject *
Notcurses_term_dim_yx(NotcursesObject *self, PyObject *Py_UNUSED(args))
{
int rows = 0, collumns = 0;
notcurses_term_dim_yx(self->notcurses_ptr, &rows, &collumns);
unsigned rows = 0, columns = 0;
notcurses_term_dim_yx(self->notcurses_ptr, &rows, &columns);
return Py_BuildValue("ii", rows, collumns);
return Py_BuildValue("II", rows, columns);
}
static PyObject *
@ -288,7 +288,7 @@ static PyObject *
Notcurses_pile_create(NotcursesObject *self, PyObject *args, PyObject *kwds)
{
int y = 0, x = 0;
int rows = 0, cols = 0;
unsigned rows = 0, cols = 0;
const char *name = NULL;
// TODO reseize callback
unsigned long long flags = 0;
@ -300,7 +300,7 @@ Notcurses_pile_create(NotcursesObject *self, PyObject *args, PyObject *kwds)
"flags",
"margin_b", "margin_r", NULL};
GNU_PY_CHECK_BOOL(PyArg_ParseTupleAndKeywords(args, kwds, "|iiiisKii", keywords,
GNU_PY_CHECK_BOOL(PyArg_ParseTupleAndKeywords(args, kwds, "|iiIIsKii", keywords,
&y, &x,
&rows, &cols,
&name,

@ -28,7 +28,7 @@ static PyObject *
Ncplane_create(NcPlaneObject *self, PyObject *args, PyObject *kwds)
{
int y = 0, x = 0;
int rows = 0, cols = 0;
unsigned rows = 0, cols = 0;
const char *name = NULL;
// TODO reseize callback
unsigned long long flags = 0;
@ -91,31 +91,31 @@ NcPlane_notcurses(NcPlaneObject *self, PyObject *Py_UNUSED(args))
static PyObject *
NcPlane_dim_yx(NcPlaneObject *self, PyObject *Py_UNUSED(args))
{
int y = 0, x = 0;
unsigned y = 0, x = 0;
ncplane_dim_yx(self->ncplane_ptr, &y, &x);
return Py_BuildValue("ii", y, x);
return Py_BuildValue("II", y, x);
}
static PyObject *
NcPlane_dim_x(NcPlaneObject *self, PyObject *Py_UNUSED(args))
{
return Py_BuildValue("i", ncplane_dim_x(self->ncplane_ptr));
return Py_BuildValue("I", ncplane_dim_x(self->ncplane_ptr));
}
static PyObject *
NcPlane_dim_y(NcPlaneObject *self, PyObject *Py_UNUSED(args))
{
return Py_BuildValue("i", ncplane_dim_y(self->ncplane_ptr));
return Py_BuildValue("I", ncplane_dim_y(self->ncplane_ptr));
}
static PyObject *
NcPlane_pixelgeom(NcPlaneObject *self, PyObject *Py_UNUSED(args))
{
int pxy = 0, pxx = 0, celldimy = 0, celldimx = 0, maxbmapy = 0, maxbmapx = 0;
unsigned pxy = 0, pxx = 0, celldimy = 0, celldimx = 0, maxbmapy = 0, maxbmapx = 0;
ncplane_pixelgeom(self->ncplane_ptr, &pxy, &pxx, &celldimy, &celldimx, &maxbmapy, &maxbmapx);
return Py_BuildValue("ii ii ii", pxy, pxx, celldimy, celldimx, maxbmapy, maxbmapx);
return Py_BuildValue("II II II", pxy, pxx, celldimy, celldimx, maxbmapy, maxbmapx);
}
static PyObject *
@ -477,11 +477,12 @@ NcPlane_at_yx_cell(NcPlaneObject *Py_UNUSED(self), PyObject *Py_UNUSED(args))
static PyObject *
NcPlane_contents(NcPlaneObject *self, PyObject *args, PyObject *kwds)
{
unsigned beg_y = 0, beg_x = 0, len_y = 0, len_x = 0;
int beg_y = 0, beg_x = 0;
unsigned len_y = 0, len_x = 0;
char *keywords[] = {"begy", "begx", "leny", "lenx", NULL};
GNU_PY_CHECK_BOOL(PyArg_ParseTupleAndKeywords(args, kwds, "II|II", keywords,
GNU_PY_CHECK_BOOL(PyArg_ParseTupleAndKeywords(args, kwds, "ii|II", keywords,
&beg_y, &beg_x,
&len_y, &len_x));
@ -546,11 +547,11 @@ NcPlane_home(NcPlaneObject *self, PyObject *Py_UNUSED(args))
static PyObject *
NcPlane_cursor_yx(NcPlaneObject *self, PyObject *Py_UNUSED(args))
{
int y = 0, x = 0;
unsigned y = 0, x = 0;
ncplane_cursor_yx(self->ncplane_ptr, &y, &x);
return Py_BuildValue("ii", y, x);
return Py_BuildValue("II", y, x);
}
static PyObject *
@ -818,101 +819,47 @@ NcPlane_polyfill_yx(NcPlaneObject *Py_UNUSED(self), PyObject *Py_UNUSED(args), P
static PyObject *
NcPlane_gradient(NcPlaneObject *self, PyObject *args, PyObject *kwds)
{
int y = -1, x = -1;
unsigned ylen = 0, xlen = 0;
const char *egc = NULL;
unsigned long stylemask = 0;
unsigned long long ul = 0, ur = 0, ll = 0, lr = 0;
int ystop = 0, xstop = 0;
char *keywords[] = {"egc",
char *keywords[] = {"y", "x", "ylen", "xlen", "egc",
"stylemask",
"ul", "ur", "ll", "lr",
"ystop", "xstop",
NULL};
GNU_PY_CHECK_BOOL(PyArg_ParseTupleAndKeywords(args, kwds, "skKKKKii", keywords,
&egc,
GNU_PY_CHECK_BOOL(PyArg_ParseTupleAndKeywords(args, kwds, "siiIIkKKKK", keywords,
&y, &x, &ylen, &xlen, &egc,
&stylemask,
&ul, &ur, &ll, &lr,
&ystop, &xstop));
&ul, &ur, &ll, &lr));
int cells_filled = CHECK_NOTCURSES(
ncplane_gradient(
self->ncplane_ptr, egc,
(uint32_t)stylemask,
(uint64_t)ul, (uint64_t)ur, (uint64_t)ll, (uint64_t)lr,
ystop, xstop));
return Py_BuildValue("i", cells_filled);
}
static PyObject *
NcPlane_highgradient(NcPlaneObject *self, PyObject *args, PyObject *kwds)
{
unsigned long ul = 0, ur = 0, ll = 0, lr = 0;
int ystop = 0, xstop = 0;
char *keywords[] = {"ul", "ur", "ll", "lr",
"ystop", "xstop",
NULL};
GNU_PY_CHECK_BOOL(PyArg_ParseTupleAndKeywords(args, kwds, "kkkkii", keywords,
&ul, &ur, &ll, &lr,
&ystop, &xstop));
int cells_filled = CHECK_NOTCURSES(
ncplane_highgradient(
self->ncplane_ptr,
(uint32_t)ul, (uint32_t)ur, (uint32_t)ll, (uint32_t)lr,
ystop, xstop));
return Py_BuildValue("i", cells_filled);
}
static PyObject *
NcPlane_gradient_sized(NcPlaneObject *self, PyObject *args, PyObject *kwds)
{
const char *egc = NULL;
unsigned long stylemask = 0;
unsigned long long ul = 0, ur = 0, ll = 0, lr = 0;
int ylen = 0, xlen = 0;
char *keywords[] = {"egc",
"stylemask",
"ul", "ur", "ll", "lr",
"ylen", "xlen",
NULL};
GNU_PY_CHECK_BOOL(PyArg_ParseTupleAndKeywords(args, kwds, "skKKKKii", keywords,
&egc,
&stylemask,
&ul, &ur, &ll, &lr,
&ylen, &xlen));
int cells_filled = CHECK_NOTCURSES(
ncplane_gradient_sized(
self->ncplane_ptr, egc,
(uint32_t)stylemask,
(uint64_t)ul, (uint64_t)ur, (uint64_t)ll, (uint64_t)lr,
ylen, xlen));
self->ncplane_ptr, y, x, ylen, xlen, egc,
(uint16_t)stylemask,
(uint64_t)ul, (uint64_t)ur, (uint64_t)ll, (uint64_t)lr));
return Py_BuildValue("i", cells_filled);
}
static PyObject *
NcPlane_highgradient_sized(NcPlaneObject *self, PyObject *args, PyObject *kwds)
NcPlane_gradient2x1(NcPlaneObject *self, PyObject *args, PyObject *kwds)
{
unsigned long ul = 0, ur = 0, ll = 0, lr = 0;
int ylen = 0, xlen = 0;
int y = -1, x = -1;
unsigned ylen = 0, xlen = 0;
char *keywords[] = {"ul", "ur", "ll", "lr",
"ylen", "xlen",
char *keywords[] = {"y", "x", "ylen", "xlen", "ul", "ur", "ll", "lr",
NULL};
GNU_PY_CHECK_BOOL(PyArg_ParseTupleAndKeywords(args, kwds, "kkkkii", keywords,
&ul, &ur, &ll, &lr,
&ylen, &xlen));
GNU_PY_CHECK_BOOL(PyArg_ParseTupleAndKeywords(args, kwds, "iiIIkkkk", keywords,
&y, &x, &ylen, &xlen,
&ul, &ur, &ll, &lr));
int cells_filled = CHECK_NOTCURSES(
ncplane_highgradient_sized(
self->ncplane_ptr,
(uint32_t)ul, (uint32_t)ur, (uint32_t)ll, (uint32_t)lr,
ylen, xlen));
ncplane_gradient2x1(
self->ncplane_ptr, y, x, ylen, xlen,
(uint32_t)ul, (uint32_t)ur, (uint32_t)ll, (uint32_t)lr));
return Py_BuildValue("i", cells_filled);
}
@ -920,14 +867,17 @@ NcPlane_highgradient_sized(NcPlaneObject *self, PyObject *args, PyObject *kwds)
static PyObject *
NcPlane_format(NcPlaneObject *self, PyObject *args)
{
int ystop = 0, xstop = 0;
int y = -1, x = -1;
unsigned ylen = 0, xlen = 0;
unsigned long stylemark = 0;
GNU_PY_CHECK_BOOL(PyArg_ParseTuple(args, "iik",
&ystop, &xstop,
GNU_PY_CHECK_BOOL(PyArg_ParseTuple(args, "iiIIk",
&y, &x, &ylen, &xlen,
&stylemark));
int cells_set = CHECK_NOTCURSES(ncplane_format(self->ncplane_ptr, ystop, xstop, (uint32_t)stylemark));
int cells_set = CHECK_NOTCURSES(ncplane_format(self->ncplane_ptr,
y, x, ylen, xlen,
(uint16_t)stylemark));
return Py_BuildValue("i", cells_set);
}
@ -935,7 +885,8 @@ NcPlane_format(NcPlaneObject *self, PyObject *args)
static PyObject *
NcPlane_stain(NcPlaneObject *self, PyObject *args, PyObject *kwds)
{
int ystop = 0, xstop = 0;
int x = -1, y = -1;
unsigned ylen = 0, xlen = 0;
unsigned long long ul = 0, ur = 0, ll = 0, lr = 0;
char *keywords[] = {
@ -943,14 +894,14 @@ NcPlane_stain(NcPlaneObject *self, PyObject *args, PyObject *kwds)
"ul", "ur", "ll", "lr",
NULL};
GNU_PY_CHECK_BOOL(PyArg_ParseTupleAndKeywords(args, kwds, "iiKKKK", keywords,
&ystop, &xstop,
GNU_PY_CHECK_BOOL(PyArg_ParseTupleAndKeywords(args, kwds, "iiIIKKKK", keywords,
&y, &x, &ylen, &xlen,
&ul, &ur, &ll, &lr));
int cells_set = CHECK_NOTCURSES(
ncplane_stain(
self->ncplane_ptr,
ystop, xstop,
y, x, ylen, xlen,
(uint64_t)ul, (uint64_t)ur, (uint64_t)ll, (uint64_t)lr));
return Py_BuildValue("i", cells_set);
@ -972,14 +923,15 @@ static PyObject *
NcPlane_mergedown(NcPlaneObject *self, PyObject *args, PyObject *kwds)
{
NcPlaneObject *dst_obj = NULL;
unsigned begsrcy = 0, begsrcx = 0, leny = 0, lenx = 0;
unsigned dsty = 0, dstx = 0;
int begsrcy = 0, begsrcx = 0;
unsigned leny = 0, lenx = 0;
int dsty = 0, dstx = 0;
char *keywords[] = {"dst",
"begsrcy", "begsrcx", "leny", "lenx",
"dsty", "dstx",
NULL};
GNU_PY_CHECK_BOOL(PyArg_ParseTupleAndKeywords(args, kwds, "O!IIIIII", keywords,
GNU_PY_CHECK_BOOL(PyArg_ParseTupleAndKeywords(args, kwds, "O!iiIIii", keywords,
&NcPlane_Type, &dst_obj,
&begsrcy, &begsrcx, &leny, &lenx,
&dsty, &dstx));
@ -1337,7 +1289,7 @@ NcPlane_perimeter_rounded(NcPlaneObject *self, PyObject *args, PyObject *kwds)
&channels,
&ctlword));
CHECK_NOTCURSES(ncplane_perimeter_rounded(self->ncplane_ptr, (uint32_t)stylemask, (uint64_t)channels, ctlword));
CHECK_NOTCURSES(ncplane_perimeter_rounded(self->ncplane_ptr, (uint16_t)stylemask, (uint64_t)channels, ctlword));
Py_RETURN_NONE;
}
@ -1347,7 +1299,7 @@ NcPlane_rounded_box_sized(NcPlaneObject *self, PyObject *args, PyObject *kwds)
{
unsigned long styles = 0;
unsigned long long channels = 0;
int ylen = 0, xlen = 0;
unsigned ylen = 0, xlen = 0;
unsigned int ctlword = 0;
char *keywords[] = {"styles",
@ -1358,14 +1310,14 @@ NcPlane_rounded_box_sized(NcPlaneObject *self, PyObject *args, PyObject *kwds)
GNU_PY_CHECK_BOOL(
PyArg_ParseTupleAndKeywords(
args, kwds, "kKiiI", keywords,
args, kwds, "kKIII", keywords,
&styles, &channels,
&ylen, &xlen,
&ctlword));
CHECK_NOTCURSES(ncplane_rounded_box_sized(
self->ncplane_ptr,
(uint32_t)styles,
(uint16_t)styles,
(uint64_t)channels,
ylen, xlen,
ctlword));
@ -1386,7 +1338,7 @@ NcPlane_double_box(NcPlaneObject *self, PyObject *args, PyObject *kwds)
{
unsigned long styles = 0;
unsigned long long channels = 0;
int ylen = 0, xlen = 0;
unsigned ylen = 0, xlen = 0;
unsigned int ctlword = 0;
char *keywords[] = {"styles",
@ -1397,14 +1349,14 @@ NcPlane_double_box(NcPlaneObject *self, PyObject *args, PyObject *kwds)
GNU_PY_CHECK_BOOL(
PyArg_ParseTupleAndKeywords(
args, kwds, "kKiiI", keywords,
args, kwds, "kKIII", keywords,
&styles, &channels,
&ylen, &xlen,
&ctlword));
CHECK_NOTCURSES(ncplane_double_box(
self->ncplane_ptr,
(uint32_t)styles,
(uint16_t)styles,
(uint64_t)channels,
ylen, xlen,
ctlword));
@ -1432,7 +1384,7 @@ NcPlane_perimeter_double(NcPlaneObject *self, PyObject *args, PyObject *kwds)
CHECK_NOTCURSES(ncplane_perimeter_double(
self->ncplane_ptr,
(uint32_t)styles,
(uint16_t)styles,
(uint64_t)channels,
ctlword));
@ -1445,7 +1397,7 @@ NcPlane_double_box_sized(NcPlaneObject *self, PyObject *args, PyObject *kwds)
unsigned long styles = 0;
unsigned long long channels = 0;
int ylen = 0, xlen = 0;
unsigned ylen = 0, xlen = 0;
unsigned int ctlword = 0;
char *keywords[] = {"styles",
@ -1456,14 +1408,14 @@ NcPlane_double_box_sized(NcPlaneObject *self, PyObject *args, PyObject *kwds)
GNU_PY_CHECK_BOOL(
PyArg_ParseTupleAndKeywords(
args, kwds, "kKiiI", keywords,
args, kwds, "kKIII", keywords,
&styles, &channels,
&ylen, &xlen,
&ctlword));
CHECK_NOTCURSES(ncplane_double_box_sized(
self->ncplane_ptr,
(uint32_t)styles,
(uint16_t)styles,
(uint64_t)channels,
ylen, xlen,
ctlword));
@ -1606,11 +1558,11 @@ NcPlane_qrcode(NcPlaneObject *self, PyObject *args)
GNU_PY_CHECK_BOOL(PyArg_ParseTuple(args, "s#", &data, &len));
int ymax = 0, xmax = 0;
unsigned ymax = 0, xmax = 0;
CHECK_NOTCURSES(ncplane_qrcode(self->ncplane_ptr, &ymax, &xmax, (void *)data, (size_t)len));
return Py_BuildValue("ii", &ymax, &xmax);
return Py_BuildValue("II", &ymax, &xmax);
}
static PyObject *
@ -1798,9 +1750,7 @@ static PyMethodDef NcPlane_methods[] = {
{"polyfill_yx", (void *)NcPlane_polyfill_yx, METH_VARARGS | METH_KEYWORDS, PyDoc_STR("Starting at the specified coordinate, if its glyph is different from that of is copied into it, and the original glyph is considered the fill target.")},
{"gradient", (void *)NcPlane_gradient, METH_VARARGS | METH_KEYWORDS, PyDoc_STR("Draw a gradient with its upper-left corner at the current cursor position.")},
{"highgradient", (void *)NcPlane_highgradient, METH_VARARGS | METH_KEYWORDS, PyDoc_STR("Do a high-resolution gradient using upper blocks and synced backgrounds.")},
{"gradient_sized", (void *)NcPlane_gradient_sized, METH_VARARGS | METH_KEYWORDS, PyDoc_STR("Draw a gradient with its upper-left corner at the current cursor position.")},
{"highgradient_sized", (void *)NcPlane_highgradient_sized, METH_VARARGS | METH_KEYWORDS, PyDoc_STR("NcPlane.gradent_sized() meets NcPlane.highgradient().")},
{"gradient2x1", (void *)NcPlane_gradient2x1, METH_VARARGS | METH_KEYWORDS, PyDoc_STR("NcPlane.gradent_sized() meets NcPlane.highgradient().")},
{"format", (PyCFunction)NcPlane_format, METH_VARARGS, PyDoc_STR("Set the given style throughout the specified region, keeping content and attributes unchanged. Returns the number of cells set.")},
{"stain", (void *)NcPlane_stain, METH_VARARGS | METH_KEYWORDS, PyDoc_STR("Set the given style throughout the specified region, keeping content and attributes unchanged. Returns the number of cells set.")},

@ -4,7 +4,7 @@
static int
reload_corners(struct ncplane* n, nccell* ul, nccell* ur, nccell* ll, nccell* lr){
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(n, &dimy, &dimx);
char* egc;
if( (egc = ncplane_at_yx(n, 1, dimx - 2, NULL, &ur->channels)) == NULL){
@ -94,24 +94,25 @@ move_ships(struct notcurses* nc, struct ship* ships, unsigned shipcount){
if(ships[s].n == NULL){
continue;
}
int yoff, xoff, ny, nx;
int yoff, xoff;
unsigned ny, nx;
ncplane_yx(ships[s].n, &yoff, &xoff);
ncplane_dim_yx(ships[s].n, &ny, &nx);
int dimy = ncplane_dim_y(stdn);
int dimx = ncplane_dim_x(stdn);
unsigned dimy = ncplane_dim_y(stdn);
unsigned dimx = ncplane_dim_x(stdn);
yoff += ships[s].vely;
xoff += ships[s].velx;
if(xoff <= 0){
xoff = 0;
ships[s].velx = -ships[s].velx;
}else if(xoff >= dimx - nx){
}else if((unsigned)xoff >= dimx - nx){
xoff = dimx - nx - 1;
ships[s].velx = -ships[s].velx;
}
if(yoff <= 1){
yoff = 2;
ships[s].vely = -ships[s].vely;
}else if(yoff >= dimy - ny){
}else if((unsigned)yoff >= dimy - ny){
yoff = dimy - ny - 1;
ships[s].vely = -ships[s].vely;
}
@ -128,7 +129,7 @@ get_ships(struct notcurses* nc, struct ship* ships, unsigned shipcount){
if(wmv == NULL){
return -1;
}
int cdimy, cdimx;
unsigned cdimy, cdimx;
ncplane_pixelgeom(notcurses_stdplane(nc), NULL, NULL, &cdimy, &cdimx, NULL, NULL);
if(ncvisual_resize(wmv, cdimy * SHIPHEIGHT, cdimx * SHIPWIDTH)){
ncvisual_destroy(wmv);
@ -162,7 +163,7 @@ get_ships(struct notcurses* nc, struct ship* ships, unsigned shipcount){
}
int box_demo(struct notcurses* nc){
int ylen, xlen;
unsigned ylen, xlen;
struct ncplane* n = notcurses_stddim_yx(nc, &ylen, &xlen);
ncplane_erase(n);
uint64_t transchan = 0;

@ -12,7 +12,7 @@ static int
chunli_draw(struct notcurses* nc, const char* ext, int count, const nccell* b){
chunli chuns[CHUNS];
char file[20];
int dimx, dimy;
unsigned dimx, dimy;
ncplane_dim_yx(notcurses_stdplane_const(nc), &dimy, &dimx);
struct timespec iterdelay;
timespec_div(&demodelay, 10, &iterdelay);
@ -31,7 +31,7 @@ chunli_draw(struct notcurses* nc, const char* ext, int count, const nccell* b){
return -1;
}
ncplane_set_base_cell(chuns[i].n, b);
int thisx, thisy;
unsigned thisx, thisy;
ncplane_dim_yx(chuns[i].n, &thisy, &thisx);
if(ncplane_move_yx(chuns[i].n, (dimy - thisy) / 2, (dimx - thisx) / 2)){
return -1;
@ -53,7 +53,8 @@ int chunli_demo(struct notcurses* nc){
}
struct timespec iterdelay;
timespec_div(&demodelay, 10, &iterdelay);
int ret, dimx, dimy;
int ret;
unsigned dimx, dimy;
ncplane_dim_yx(notcurses_stdplane_const(nc), &dimy, &dimx);
nccell b = CELL_TRIVIAL_INITIALIZER;
nccell_set_fg_alpha(&b, NCALPHA_TRANSPARENT);
@ -80,7 +81,7 @@ int chunli_demo(struct notcurses* nc){
return -1;
}
ncplane_set_base_cell(ncp, &b);
int thisx, thisy;
unsigned thisx, thisy;
ncplane_dim_yx(ncp, &thisy, &thisx);
if(ncplane_move_yx(ncp, (dimy - thisy) / 2, (dimx - thisx) / 2)){
return -1;

@ -49,7 +49,7 @@ dragonmayer(struct ncvisual* ncv, const char* str, int iters){
int dragon_demo(struct notcurses* nc){
done = false;
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* n = notcurses_stddim_yx(nc, &dimy, &dimx);
--dimy; // don't disturb the menu bar
// we use a Lindenmayer string rewriting system. the classic dragon curve

@ -55,7 +55,7 @@ zoom_map(struct notcurses* nc, const char* map, int* ret){
int xscale = geom.scalex;
//fprintf(stderr, "VHEIGHT: %d VWIDTH: %d scale: %d/%d\n", vheight, vwidth, yscale, xscale);
// we start at the lower left corner of the outzoomed map
int placey, placex; // dimensions of true display
unsigned placey, placex; // dimensions of true display
notcurses_term_dim_yx(nc, &placey, &placex);
float delty = 2 + yscale;
float deltx = 2 + xscale;
@ -166,7 +166,8 @@ eagles(struct notcurses* nc, struct ncplane* n){
const int height = 16;
const int width = 16;
struct eagle {
int yoff, xoff;
int yoff;
unsigned xoff;
struct ncplane* n;
} e[3];
for(size_t i = 0 ; i < sizeof(e) / sizeof(*e) ; ++i){
@ -199,7 +200,7 @@ eagles(struct notcurses* nc, struct ncplane* n){
e[i].yoff += rand() % (2 + i) - 1;
if(e[i].yoff < 0){
e[i].yoff = 0;
}else if(e[i].yoff + height >= truey){
}else if(e[i].yoff + height >= (int)truey){
e[i].yoff = truey - height - 1;
}
int scale = truex >= 80 ? truex / 80 : 1;

@ -28,7 +28,7 @@ drop_bricks(struct notcurses* nc, struct ncplane** arr, int arrcount){
if(rangee < arrcount){
int y;
ncplane_yx(arr[ranges], &y, NULL);
speeds[rangee - ranges] = y < stdy / 2 ? 1 : -1;
speeds[rangee - ranges] = y < (int)stdy / 2 ? 1 : -1;
++rangee;
}
}
@ -43,7 +43,7 @@ drop_bricks(struct notcurses* nc, struct ncplane** arr, int arrcount){
int x, y;
ncplane_yx(ncp, &y, &x);
if(felloff){
if(y + speeds[i] >= stdy || y + speeds[i] + ncplane_dim_y(ncp) < 0){
if(y + speeds[i] >= (int)stdy || y + speeds[i] + (int)ncplane_dim_y(ncp) < 0){
ncplane_destroy(ncp);
arr[ranges + i] = NULL;
if(ranges + i + 1 == rangee){
@ -153,8 +153,8 @@ int fission_demo(struct notcurses* nc){
goto err;
}
// copy the old content into this new ncplane
for(int usey = y ; usey < y + newy ; ++usey){
for(int usex = x ; usex < x + newx ; ++usex){
for(unsigned usey = y ; usey < y + newy ; ++usey){
for(unsigned usex = x ; usex < x + newx ; ++usex){
if(usemap[usey * dimx + usex]){
newx = usex - x;
ncplane_resize_simple(n, newy, newx);

@ -115,13 +115,13 @@ gridinv_demo(struct notcurses* nc, struct ncplane *n){
nccell ul, ll, cl, cr, lc, lr, ur, uc, cc;
prep_cells2(n, &ul, &uc, &ur, &cl, &cc, &cr, &ll, &lc, &lr);
for(int i = 0 ; i < 256 ; ++i){
int maxx, maxy;
unsigned maxx, maxy;
notcurses_term_dim_yx(nc, &maxy, &maxx);
int rs = 255 / maxx;
int gs = 255 / (maxx + maxy);
int bs = 255 / maxy;
int x = 0;
int y = 1;
unsigned x = 0;
unsigned y = 1;
// top line
cnccell_set_fg_rgb8(&ul, i / 2, i, i / 2);
cnccell_set_bg_rgb8(&ul, 255 - rs * x, 255 - gs * (x + y), 255 - bs * y);
@ -175,7 +175,7 @@ static int
gridswitch_demo(struct notcurses* nc, struct ncplane *n){
ncplane_erase(n);
int ret = 0;
int maxx, maxy;
unsigned maxx, maxy;
nccell ul, ll, cl, cr, lc, lr, ur, uc, cc;
prep_cells(n, &ul, &uc, &ur, &cl, &cc, &cr, &ll, &lc, &lr);
for(int i = 0 ; i < 256 ; ++i){
@ -183,8 +183,8 @@ gridswitch_demo(struct notcurses* nc, struct ncplane *n){
int rs = 256 / maxx;
int gs = 256 / (maxx + maxy);
int bs = 256 / maxy;
int x = 0;
int y = 1;
unsigned x = 0;
unsigned y = 1;
int bgr = i;
int bgg = 0x80;
int bgb = i;

@ -5,7 +5,7 @@ static int centercols;
static int
animate(struct notcurses* nc, struct ncplane* ncp, void* curry){
int* flipmode = curry;
int rows, cols;
unsigned rows, cols;
ncplane_dim_yx(ncp, &rows, &cols);
const bool smallscreen = rows < 26;
const int row1 = rows - 10 + smallscreen;

@ -26613,7 +26613,7 @@ int jungle_demo(struct notcurses* nc){
nccell c = CELL_TRIVIAL_INITIALIZER;
nccell_load(n, &c, "\xe2\x96\x80"); // upper half block
for(size_t y = 0 ; y < ORIGHEIGHT ; y += (yiter * 2)){
int targy = yoff + y / (yiter * 2);
unsigned targy = yoff + y / (yiter * 2);
if(targy < dimy / 2){
if(ncplane_cursor_move_yx(n, targy, xoff)){
return -1;

@ -3811,11 +3811,12 @@ int mojibake_demo(struct notcurses* nc){
do{
unsigned u = topmost;
do{
int y, x, leny, lenx;
int y, x;
ncplane_yx(planes[u], &y, &x);
if(y >= dimy){
if(y >= (int)dimy){
break;
}
unsigned leny, lenx;
ncplane_dim_yx(planes[u], &leny, &lenx);
if(y == 2){
if(leny > 1){

@ -154,7 +154,7 @@ int normal_demo(struct notcurses* nc){
if(!notcurses_canutf8(nc)){
return 0;
}
int dy, dx;
unsigned dy, dx;
int r = -1;
struct ncplane* nstd = notcurses_stddim_yx(nc, &dy, &dx);
ncplane_erase(nstd);
@ -175,13 +175,13 @@ int normal_demo(struct notcurses* nc){
if(!rgba){
goto err;
}
for(int off = 0 ; off < dy * dx ; ++off){
for(unsigned off = 0 ; off < dy * dx ; ++off){
rgba[off] = 0xff000000;
}
unsigned y;
if(dy / geom.scaley % 2){
y = dy / geom.scaley + 1;
for(int x = 0 ; x < dx ; ++x){
for(unsigned x = 0 ; x < dx ; ++x){
if(mcell(offset(rgba, y, x, dx), y, x, dy / geom.scaley, dx)){
goto err;
}
@ -190,7 +190,7 @@ int normal_demo(struct notcurses* nc){
struct timespec scaled;
timespec_div(&demodelay, dy, &scaled);
for(y = 0 ; y <= dy / 2 ; ++y){
for(int x = 0 ; x < dx ; ++x){
for(unsigned x = 0 ; x < dx ; ++x){
if(mcell(offset(rgba, dy / 2 - y, x, dx), dy / 2 - y, x, dy, dx)){
goto err;
}

@ -6,7 +6,7 @@ int qrcode_demo(struct notcurses* nc){
}
#ifdef USE_QRCODEGEN
char data[128];
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane *stdn = notcurses_stddim_yx(nc, &dimy, &dimx);
ncplane_erase(stdn);
struct ncplane* n = ncplane_dup(stdn, NULL);

@ -107,7 +107,7 @@ fill_chunk(struct ncplane* n, int idx){
ncchannel_set_rgb8(&ur, g, b, r);
ncchannel_set_rgb8(&ll, b, r, g);
int ret = 0;
if(ncplane_highgradient_sized(n, ul, ur, ll, lr, maxy, maxx) <= 0){
if(ncplane_gradient2x1(n, -1, -1, 0, 0, ul, ur, ll, lr) <= 0){
ret = -1;
}
ret |= ncplane_double_box(n, 0, channels, maxy - 1, maxx - 1, 0);
@ -134,7 +134,7 @@ draw_bounding_box(struct ncplane* n, int yoff, int xoff, int chunky, int chunkx)
// make a bunch of boxes with gradients and use them to play a sliding puzzle.
int sliding_puzzle_demo(struct notcurses* nc){
int ret = -1, z;
int maxx, maxy;
unsigned maxx, maxy;
struct ncplane* n = notcurses_stddim_yx(nc, &maxy, &maxx);
int chunky, chunkx;
// want at least 2x2 for each sliding chunk

@ -468,7 +468,7 @@ int witherworm_demo(struct notcurses* nc){
const int start = starts[i];
int step = steps[i];
nccell_init(&c);
int y, x;
unsigned y, x;
unsigned maxy, maxx;
ncplane_dim_yx(n, &maxy, &maxx); // might resize
int rgb = start;
@ -489,11 +489,11 @@ int witherworm_demo(struct notcurses* nc){
if(ncplane_set_fg_rgb8(n, ncchannel_r(rgb), ncchannel_g(rgb), ncchannel_b(rgb))){
return -1;
}
if(x >= (int)maxx){
if(x >= maxx){
x = 0;
++y;
}
if(y >= (int)maxy){
if(y >= maxy){
break;
}
wchar_t wcs;
@ -509,7 +509,7 @@ int witherworm_demo(struct notcurses* nc){
}
int ulen = 0;
int r;
if(wcwidth(wcs) <= (int)maxx - x){
if(wcwidth(wcs) <= (int)(maxx - x)){
if((r = ncplane_putegc(n, &(*s)[idx], &ulen)) <= 0){
if(ulen < 0){
return -1;
@ -529,7 +529,7 @@ int witherworm_demo(struct notcurses* nc){
++egcs_out;
}
rgb += step;
}while(y < (int)maxy);
}while(y < maxy);
struct ncplane* math = mathplane(nc);
if(math == NULL){
return -1;

@ -404,7 +404,7 @@ static int
infoplane_notcurses(struct notcurses* nc, const fetched_info* fi, int planeheight){
const int planewidth = 72;
unsigned dimy;
int y;
unsigned y;
struct ncplane* std = notcurses_stddim_yx(nc, &dimy, NULL);
ncplane_cursor_yx(std, &y, NULL);
struct ncplane_options nopts = {
@ -589,7 +589,7 @@ display_thread(void* vmarshal){
ncv = ncvisual_from_file(m->dinfo->logofile);
}
if(ncv){
int y;
unsigned y;
ncplane_cursor_yx(notcurses_stdplane_const(m->nc), &y, NULL);
bool pixeling = false;
if(notcurses_check_pixel_support(m->nc) >= 1){

@ -92,7 +92,7 @@ braille_viz(struct ncplane* n, wchar_t l, const wchar_t* egcs, wchar_t r,
static void
finish_line(struct ncplane* n){
int x;
unsigned x;
ncplane_cursor_yx(n, NULL, &x);
while(x++ < 80){
ncplane_putchar(n, ' ');
@ -147,7 +147,7 @@ emoji_viz(struct ncplane* n){
}
}
}
int x;
unsigned x;
ncplane_cursor_yx(n, NULL, &x);
while(x++ < 80){
ncplane_putchar(n, ' ');
@ -312,7 +312,7 @@ unicodedumper(struct ncplane* n, const char* indent){
ncplane_putchar(n, '\n');
}
emoji_viz(n);
int y, x;
unsigned y, x;
ncplane_cursor_yx(n, &y, &x);
uint64_t ur = NCCHANNELS_INITIALIZER(0xff, 0xff, 0xff, 0x1B, 0xd8, 0x8E);
uint64_t lr = NCCHANNELS_INITIALIZER(0xff, 0xff, 0xff, 0xdB, 0x18, 0x8E);
@ -340,7 +340,7 @@ display_logo(struct ncplane* n, const char* path){
ncvisual_destroy(ncv);
return -1;
}
int y;
unsigned y;
ncplane_cursor_yx(n, &y, NULL);
struct ncvisual_options vopts = {
.n = n,

@ -349,9 +349,9 @@ int input_demo(ncpp::NotCurses* nc) {
n->printf("Unicode: [0x%08x] '%lc'", r, (wchar_t)r);
}
}
int x;
unsigned x;
n->get_cursor_yx(nullptr, &x);
for(int i = x ; i < n->get_dim_x() ; ++i){
for(unsigned i = x ; i < n->get_dim_x() ; ++i){
n->putc(' ');
}
if(!dim_rows(n)){

@ -636,7 +636,7 @@ int ncplane_qrcode(ncplane* n, unsigned* ymax, unsigned* xmax, const void* data,
return -1;
}
#else
int ncplane_qrcode(ncplane* n, int* ymax, int* xmax, const void* data, size_t len){
int ncplane_qrcode(ncplane* n, unsigned* ymax, unsigned* xmax, const void* data, size_t len){
(void)n;
(void)ymax;
(void)xmax;

@ -47,7 +47,7 @@ puttext_advance_line(ncplane* n){
// * C < dimx: ++y, x = 0
static int
puttext_line(ncplane* n, ncalign_e align, const char* text, size_t* bytes){
int cursx; // current cursor location
unsigned cursx; // current cursor location
ncplane_cursor_yx(n, NULL, &cursx);
const int dimx = ncplane_dim_x(n);
const int avail = dimx - cursx - 1;

@ -77,6 +77,9 @@ const char* ncnmetric(uintmax_t val, size_t s, uintmax_t decimal,
sprintfed = snprintf(buf, s, "%.2f%lc", (double)val / dv,
(wint_t)prefixes[consumed - 1]);
}
if(sprintfed < 0){
return NULL;
}
if(uprefix){
if((size_t)sprintfed < s){
buf[sprintfed] = uprefix;
@ -102,6 +105,9 @@ const char* ncnmetric(uintmax_t val, size_t s, uintmax_t decimal,
sprintfed = snprintf(buf, s, "%.2f", (double)val / decimal);
}
}
if(sprintfed < 0){
return NULL;
}
if(consumed && uprefix){
if((size_t)sprintfed < s){
buf[sprintfed] = uprefix;
@ -113,5 +119,5 @@ const char* ncnmetric(uintmax_t val, size_t s, uintmax_t decimal,
const char *ncmetric(uintmax_t val, uintmax_t decimal, char *buf, int omitdec,
uintmax_t mult, int uprefix){
return ncnmetric(val, SIZE_MAX, decimal, buf, omitdec, mult, uprefix);
return ncnmetric(val, INT_MAX, decimal, buf, omitdec, mult, uprefix);
}

@ -1548,7 +1548,7 @@ int ncplane_move_family_below(ncplane* restrict n, ncplane* restrict bpoint){
return 0;
}
void ncplane_cursor_yx(const ncplane* n, int* y, int* x){
void ncplane_cursor_yx(const ncplane* n, unsigned* y, unsigned* x){
if(y){
*y = n->y;
}
@ -1983,7 +1983,7 @@ int ncplane_vline_interp(ncplane* n, const nccell* c, unsigned len,
int deltbr = (br2 - br1) / ((int)len + 1);
int deltbg = (bg2 - bg1) / ((int)len + 1);
int deltbb = (bb2 - bb1) / ((int)len + 1);
int ypos, xpos;
unsigned ypos, xpos;
unsigned ret;
ncplane_cursor_yx(n, &ypos, &xpos);
nccell dupc = CELL_TRIVIAL_INITIALIZER;
@ -2026,21 +2026,21 @@ int ncplane_box(ncplane* n, const nccell* ul, const nccell* ur,
const nccell* ll, const nccell* lr, const nccell* hl,
const nccell* vl, unsigned ystop, unsigned xstop,
unsigned ctlword){
int yoff, xoff;
unsigned yoff, xoff;
ncplane_cursor_yx(n, &yoff, &xoff);
// must be at least 2x2, with its upper-left corner at the current cursor
if(ystop < (unsigned)yoff + 1){
if(ystop < yoff + 1){
logerror("ystop (%u) insufficient for yoff (%d)\n", ystop, yoff);
return -1;
}
if(xstop < (unsigned)xoff + 1){
if(xstop < xoff + 1){
logerror("xstop (%u) insufficient for xoff (%d)\n", xstop, xoff);
return -1;
}
unsigned ymax, xmax;
ncplane_dim_yx(n, &ymax, &xmax);
// must be within the ncplane
if(xstop >= (unsigned)xmax || ystop >= (unsigned)ymax){
if(xstop >= xmax || ystop >= ymax){
logerror("Boundary (%ux%u) beyond plane (%dx%d)\n", ystop, xstop, ymax, xmax);
return -1;
}
@ -3179,7 +3179,7 @@ int ncstrwidth_valid(const char* egcs, int* validbytes, int* validwidth){
return *validwidth;
}
void ncplane_pixelgeom(const ncplane* n, int* RESTRICT pxy, int* RESTRICT pxx,
void ncplane_pixelgeom(const ncplane* n, unsigned* RESTRICT pxy, unsigned* RESTRICT pxx,
unsigned* RESTRICT celldimy, unsigned* RESTRICT celldimx,
unsigned* RESTRICT maxbmapy, unsigned* RESTRICT maxbmapx){
notcurses* nc = ncplane_notcurses(n);

@ -60,7 +60,7 @@ auto main(int argc, const char** argv) -> int {
struct ncplane* tplane = ncplane_above(ncp);
ncplane_dim_yx(tplane, &tgeomy, &tgeomx);
ncplane_dim_yx(ncp, &vgeomy, &vgeomx);
(*n)->printf(0, 0, "Scroll: %c Cursor: 000/000 Viewgeom: %03d/%03d Textgeom: %03d/%03d",
(*n)->printf(0, 0, "Scroll: %c Cursor: 000/000 Viewgeom: %03u/%03u Textgeom: %03u/%03u",
horscroll ? '+' : '-', vgeomy, vgeomx, tgeomy, tgeomx);
nc.render();
while(nc.get(true, &ni) != (char32_t)-1){
@ -72,11 +72,11 @@ auto main(int argc, const char** argv) -> int {
}else if((ni.ctrl && ni.id == 'D') || ni.id == NCKEY_ENTER){
break;
}else if(ncreader_offer_input(nr, &ni)){
int ncpy, ncpx;
unsigned ncpy, ncpx;
ncplane_cursor_yx(ncp, &ncpy, &ncpx);
ncplane_dim_yx(tplane, &tgeomy, &tgeomx);
ncplane_dim_yx(ncp, &vgeomy, &vgeomx);
(*n)->printf(0, 0, "Scroll: %c Cursor: %03d/%03d Viewgeom: %03d/%03d Textgeom: %03d/%03d",
(*n)->printf(0, 0, "Scroll: %c Cursor: %03u/%03u Viewgeom: %03u/%03u Textgeom: %03u/%03u",
horscroll ? '+' : '-', ncpy, ncpx, vgeomy, vgeomx, tgeomy, tgeomx);
nc.render();
}

@ -16,7 +16,7 @@ class TabletCtx {
lines(rand() % 5 + 3),
rgb(rand() % 0x1000000),
idx(++class_idx) {}
int getLines() const {
unsigned getLines() const {
return lines;
}
void addLine() {
@ -51,7 +51,7 @@ int tabletfxn(struct nctablet* _t, bool cliptop __attribute__ ((unused))){
p->release(c);
p->set_bg_rgb(0xffffff);
p->set_fg_rgb(0x000000);
int ret = tctx->getLines();
unsigned ret = tctx->getLines();
if(ret > p->get_dim_y()){
ret = p->get_dim_y();
}

@ -147,7 +147,7 @@ auto lang_and_term() -> void {
}
unsigned dimy, dimx;
notcurses_stddim_yx(nc, &dimy, &dimx);
std::cout << "Detected geometry: " << dimx << 'x' << dimy << std::endl;
std::cout << "Detected cell geometry: " << dimx << 'x' << dimy << std::endl;
notcurses_stop(nc);
if(dimx < 50 || dimy < 24){ // minimum assumed geometry
std::cerr << "Terminal was too small for tests (minimum 50x24)" << std::endl;

@ -282,7 +282,7 @@ TEST_CASE("Media") {
}
// do a pixel video with a different plane for each frame
SUBCASE("LoadVideoPixelScaleDifferentPlanes") {
SUBCASE("LoadVideoPixelStretchDifferentPlanes") {
if(notcurses_check_pixel_support(nc_) > 0){
if(notcurses_canopen_videos(nc_)){
unsigned dimy, dimx;
@ -296,10 +296,12 @@ TEST_CASE("Media") {
}
CHECK(0 == ret);
struct ncvisual_options opts{};
opts.scaling = NCSCALE_SCALE;
opts.scaling = NCSCALE_STRETCH;
opts.blitter = NCBLIT_PIXEL;
REQUIRE(ncvisual_blit(nc_, ncv, &opts));
auto n = ncvisual_blit(nc_, ncv, &opts);
REQUIRE(nullptr != n);
CHECK(0 == notcurses_render(nc_));
CHECK(0 == ncplane_destroy(n));
}
ncvisual_destroy(ncv);
}

@ -30,7 +30,7 @@ TEST_CASE("Plane") {
// Starting position ought be 0, 0 (the origin)
SUBCASE("StdPlanePosition") {
int x, y;
unsigned x, y;
ncplane_cursor_yx(n_, &y, &x);
CHECK(0 == x);
CHECK(0 == y);
@ -51,7 +51,7 @@ TEST_CASE("Plane") {
unsigned cols, rows;
notcurses_term_dim_yx(nc_, &rows, &cols);
CHECK(0 == ncplane_cursor_move_yx(n_, 0, 0));
int x, y;
unsigned x, y;
ncplane_cursor_yx(n_, &y, &x);
CHECK(y == 0);
CHECK(x == 0);
@ -108,7 +108,7 @@ TEST_CASE("Plane") {
nccell c = CELL_CHAR_INITIALIZER('a');
CHECK(0 < ncplane_putc_yx(n_, 0, 0, &c));
CHECK(0 == strcmp("a", ncplane_at_yx(n_, 0, 0, nullptr, nullptr)));
int y, x;
unsigned y, x;
ncplane_cursor_yx(n_, &y, &x);
CHECK(0 == y);
CHECK(1 == x);
@ -128,7 +128,7 @@ TEST_CASE("Plane") {
nccell c{};
CHECK(strlen(cchar) == nccell_load(n_, &c, cchar));
CHECK(0 < ncplane_putc(n_, &c));
int x, y;
unsigned x, y;
ncplane_cursor_yx(n_, &y, &x);
CHECK(0 == y);
CHECK(1 == x);
@ -140,7 +140,7 @@ TEST_CASE("Plane") {
const wchar_t* w = L"";
int sbytes = 0;
CHECK(0 < ncplane_putwegc(n_, w, &sbytes));
int x, y;
unsigned x, y;
ncplane_cursor_yx(n_, &y, &x);
CHECK(0 == y);
CHECK(1 == x);
@ -157,7 +157,7 @@ TEST_CASE("Plane") {
int wrote = ncplane_putstr(n_, *s);
CHECK(ncstrwidth(*s) == wrote);
}
int x, y;
unsigned x, y;
ncplane_cursor_yx(n_, &y, &x);
CHECK(2 == y);
CHECK(10 <= x);
@ -174,7 +174,7 @@ TEST_CASE("Plane") {
int wrote = ncplane_putwstr(n_, *s);
CHECK(0 < wrote);
}
int x, y;
unsigned x, y;
ncplane_cursor_yx(n_, &y, &x);
CHECK(2 == y);
CHECK(10 <= x);
@ -190,7 +190,7 @@ TEST_CASE("Plane") {
CHECK(!ncplane_set_scrolling(n_, true));
int wrote = ncplane_putwstr(n_, e);
CHECK(0 < wrote);
int x, y;
unsigned x, y;
ncplane_cursor_yx(n_, &y, &x);
CHECK_LE(0, y);
CHECK(1 <= x); // FIXME tighten in on this
@ -207,7 +207,7 @@ TEST_CASE("Plane") {
for(unsigned yidx = 0 ; yidx < y ; ++yidx){
CHECK(0 == ncplane_cursor_move_yx(n_, yidx, 1));
CHECK(x - 2 == ncplane_hline(n_, &c, x - 2));
int posx, posy;
unsigned posx, posy;
ncplane_cursor_yx(n_, &posy, &posx);
CHECK(yidx == posy);
CHECK(x - 1 == posx);
@ -226,7 +226,7 @@ TEST_CASE("Plane") {
for(unsigned xidx = 1 ; xidx < x - 1 ; ++xidx){
CHECK(0 == ncplane_cursor_move_yx(n_, 1, xidx));
CHECK(y - 2 == ncplane_vline(n_, &c, y - 2));
int posx, posy;
unsigned posx, posy;
ncplane_cursor_yx(n_, &posy, &posx);
CHECK(y - 2 == posy);
CHECK(xidx == posx - 1);
@ -592,7 +592,7 @@ TEST_CASE("Plane") {
ncplane_dim_yx(n_, &dimy, &dimx);
REQUIRE(0 == ncplane_cursor_move_yx(n_, 1, dimx - strlen(STR2)));
REQUIRE(0 < ncplane_putstr(n_, STR2));
int y, x;
unsigned y, x;
ncplane_cursor_yx(n_, &y, &x);
REQUIRE(1 == y);
REQUIRE(dimx == x);
@ -630,7 +630,7 @@ TEST_CASE("Plane") {
ncplane_dim_yx(n_, &dimy, &dimx);
REQUIRE(0 == ncplane_cursor_move_yx(n_, 1, dimx - mbstowcs(nullptr, STR2, 0)));
REQUIRE(0 < ncplane_putstr(n_, STR2));
int y, x;
unsigned y, x;
ncplane_cursor_yx(n_, &y, &x);
REQUIRE(1 == y);
REQUIRE(dimx == x);
@ -657,7 +657,7 @@ TEST_CASE("Plane") {
const char STR3[] = "da chronic lives";
ncplane_set_styles(n_, NCSTYLE_BOLD);
REQUIRE(0 < ncplane_putstr_yx(n_, 0, 0, STR1));
int y, x;
unsigned y, x;
ncplane_cursor_yx(n_, &y, &x);
CHECK(0 == ncplane_cursor_move_yx(n_, y + 1, x - strlen(STR2)));
ncplane_on_styles(n_, NCSTYLE_ITALIC);
@ -667,7 +667,7 @@ TEST_CASE("Plane") {
REQUIRE(0 < ncplane_putstr(n_, STR3));
ncplane_off_styles(n_, NCSTYLE_ITALIC);
CHECK(0 == notcurses_render(nc_));
int newx;
unsigned newx;
ncplane_cursor_yx(n_, &y, &newx);
CHECK(newx == x);
nccell testcell = CELL_TRIVIAL_INITIALIZER;
@ -1084,7 +1084,7 @@ TEST_CASE("Plane") {
REQUIRE(nullptr != n);
CHECK(false == ncplane_set_scrolling(n, true));
uint64_t channels = NCCHANNELS_INITIALIZER(0, 0xff, 0, 0xff, 0, 0xff);
int y, x;
unsigned y, x;
CHECK(1 == ncplane_set_base(n, " ", 0, channels));
CHECK(0 == notcurses_render(nc_));
for(unsigned i = 0 ; i < ncplane_dim_y(n) ; ++i){

@ -35,8 +35,10 @@ TEST_CASE("Rotate") {
CHECK(0 == notcurses_stop(nc_));
return;
}
unsigned dimy, dimx;
struct ncplane* n_ = notcurses_stddim_yx(nc_, &dimy, &dimx);
unsigned udimy, udimx;
struct ncplane* n_ = notcurses_stddim_yx(nc_, &udimy, &udimx);
int dimy = udimy;
int dimx = udimx;
REQUIRE(n_);
uint64_t ul, ur, ll, lr;

@ -32,7 +32,7 @@ TEST_CASE("Scrolling") {
CHECK(!ncplane_set_scrolling(n, false));
// try to write 40 EGCs; it ought fail after 20
CHECK(-20 == ncplane_putstr(n, "0123456789012345678901234567890123456789"));
int y, x;
unsigned y, x;
ncplane_cursor_yx(n, &y, &x);
CHECK(0 == y);
CHECK(20 == x);
@ -81,7 +81,7 @@ TEST_CASE("Scrolling") {
struct ncplane* n = ncplane_create(n_, &nopts);
REQUIRE(n);
CHECK(20 == ncplane_putstr(n, "01234567890123456789"));
int y, x;
unsigned y, x;
ncplane_cursor_yx(n, &y, &x);
CHECK(0 == y);
CHECK(20 == x);
@ -119,7 +119,7 @@ TEST_CASE("Scrolling") {
CHECK(0 > ret);
}
}
int y, x;
unsigned y, x;
ncplane_cursor_yx(n, &y, &x);
CHECK(0 == y);
CHECK(20 == x);
@ -177,7 +177,7 @@ TEST_CASE("Scrolling") {
CHECK(!ncplane_set_scrolling(n, true));
CHECK(40 == ncplane_putstr(n, out)); // fill up the plane w/ numbers
CHECK(0 == notcurses_render(nc_));
int y, x;
unsigned y, x;
ncplane_cursor_yx(n, &y, &x);
CHECK(1 == y);
CHECK(20 == x);

@ -196,7 +196,7 @@ TEST_CASE("Sixels") {
//print_bmap(rgbold, newn->sprite->pixy, newn->sprite->pixx);
CHECK(0 == notcurses_render(nc_));
struct ncplane_options nopts = {
.y = ncplane_dim_y(newn) * 3 / 4,
.y = (int)ncplane_dim_y(newn) * 3 / 4,
.x = 0,
.rows = ncplane_dim_y(newn) / 4,
.cols = ncplane_dim_x(newn) / 2,

@ -21,7 +21,7 @@ TEST_CASE("Wide") {
const char* w = "\u5168";
int sbytes = 0;
CHECK(0 < ncplane_putegc(n_, w, &sbytes));
int x, y;
unsigned x, y;
ncplane_cursor_yx(n_, &y, &x);
CHECK(0 == y);
CHECK(2 == x);
@ -35,7 +35,7 @@ TEST_CASE("Wide") {
unsigned dimx;
ncplane_dim_yx(n_, nullptr, &dimx);
CHECK(0 < ncplane_putegc_yx(n_, 0, dimx - 3, w, &sbytes));
int x, y;
unsigned x, y;
ncplane_cursor_yx(n_, &y, &x);
CHECK(0 == y);
CHECK(dimx - 1 == x);
@ -57,7 +57,7 @@ TEST_CASE("Wide") {
// now it ought be rejected
CHECK(0 > ncplane_putegc_yx(n_, 0, dimx - 1, w, &sbytes));
// cursor ought remain where it was
int y, x;
unsigned y, x;
ncplane_cursor_yx(n_, &y, &x);
CHECK(0 == y);
CHECK(dimx - 1 == x);
@ -116,7 +116,7 @@ TEST_CASE("Wide") {
int sbytes = 0;
CHECK(0 < ncplane_putegc_yx(n_, 0, 1, wbashed, &sbytes));
CHECK(0 < ncplane_putchar_yx(n_, 1, 1, bashed));
int x, y;
unsigned x, y;
ncplane_cursor_yx(n_, &y, &x);
CHECK(1 == y);
CHECK(2 == x);
@ -148,7 +148,7 @@ TEST_CASE("Wide") {
CHECK(0 < cols1);
int cols2 = ncplane_putegc_yx(n_, 0, 1, w, &sbytes);
CHECK(0 < cols2);
int x, y;
unsigned x, y;
ncplane_cursor_yx(n_, &y, &x);
CHECK(0 == y);
CHECK(1 + cols2 == x);
@ -175,7 +175,7 @@ TEST_CASE("Wide") {
CHECK(0 < ncplane_putegc_yx(n_, 0, 2, wbashedr, &sbytes));
CHECK(1 == ncplane_putchar_yx(n_, 0, 1, *cc));
CHECK(1 == ncplane_putchar_yx(n_, 0, 2, *cc));
int x, y;
unsigned x, y;
ncplane_cursor_yx(n_, &y, &x);
CHECK(0 == y);
CHECK(3 == x);
@ -205,7 +205,7 @@ TEST_CASE("Wide") {
CHECK(0 < ncplane_putegc_yx(n_, 0, 0, wsafel, &sbytes));
CHECK(0 < ncplane_putegc_yx(n_, 0, 3, wsafer, &sbytes));
CHECK(1 == ncplane_putchar_yx(n_, 0, 2, *cc));
int x, y;
unsigned x, y;
ncplane_cursor_yx(n_, &y, &x);
CHECK(0 == y);
CHECK(3 == x);
@ -301,11 +301,12 @@ TEST_CASE("Wide") {
char* egc;
// print two wide glyphs on the standard plane
int y, x;
ncplane_yx(n_, &y, &x);
CHECK(0 == y);
CHECK(0 == x);
int py, px;
ncplane_yx(n_, &py, &px);
CHECK(0 == py);
CHECK(0 == px);
CHECK(2 == ncplane_putstr(n_, "\xe5\x85\xa8")); // \u5168 (全)
unsigned y, x;
ncplane_cursor_yx(n_, &y, &x);
CHECK(0 == y);
CHECK(2 == x);

@ -12,7 +12,8 @@ bool InvalidMove() { // a bit wasteful, but pieces are tiny
curpiece_->release(c);
int transy = dy, transx = x; // need game area coordinates via translation
curpiece_->translate(*board_, &transy, &transx);
if(transy < 0 || transy >= board_->get_dim_y() || transx < 0 || transx >= board_->get_dim_x()){
if(transy < 0 || (unsigned)transy >= board_->get_dim_y()
|| transx < 0 || (unsigned)transx >= board_->get_dim_x()){
return true;
}
board_->get_at(transy, transx, &b);

Loading…
Cancel
Save