unsigned geometries

pull/2333/head
nick black 3 years ago committed by nick black
parent 332bf71642
commit 83ff2cfe5a

@ -128,8 +128,8 @@ add_compile_options(-fno-signed-zeros -fno-trapping-math -fassociative-math)
add_compile_options(-fno-math-errno -freciprocal-math -funsafe-math-optimizations)
add_compile_options(-fexceptions -fstrict-aliasing)
if(${USE_ASAN})
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
add_compile_options(-fsanitize=undefined)
add_link_options(-fsanitize=undefined)
endif()
endif()

@ -28,7 +28,13 @@ rearrangements of Notcurses.
which all used -1. A length of zero passed to line-drawing functions is
now an error. Several line-drawing functions now reliably return errors
as opposed to short successes. Dimensions of 0 to `ncplane_mergedown()`
now mean "everything".
now mean "everything". Almost all coordinates now accept -1 to indicate the
current cursor position in that dimension. `ncplane_highgradient()` has
been deprecated in favor of the new `ncplane_gradient2x1()`, which takes
origin coordinates. `ncplane_format()` and `ncplane_stain()` now take
origin coordinates. All now interpret their `unsigned` argument as
lengths rather than closing coordinates, observing the same semantics as
outlined above.
* `ncvisual_geom()` has been introduced, using the `ncvgeom` struct
introduced for direct mode. This allows complete statement of geometry
for an `ncvisual`. It replaces `ncvisual_blitter_geom()`, which has been

@ -230,7 +230,7 @@ int ncpile_render_to_file(struct ncplane* p, FILE* fp);
// Retrieve the contents of the specified cell as last rendered. The EGC is
// returned, or NULL on error. This EGC must be free()d by the caller. The
// styles and channels are written to 'attrword' and 'channels', respectively.
char* notcurses_at_yx(struct notcurses* nc, int yoff, int xoff,
char* notcurses_at_yx(struct notcurses* nc, unsigned yoff, unsigned xoff,
uint16_t* styles, uint64_t* channels);
```
@ -248,14 +248,14 @@ const struct ncplane* notcurses_stdplane_const(const struct notcurses* nc);
// notcurses_stdplane(), plus free bonus dimensions written to non-NULL y/x!
static inline struct ncplane*
notcurses_stddim_yx(struct notcurses* nc, int* restrict y, int* restrict x){
notcurses_stddim_yx(struct notcurses* nc, unsigned* restrict y, unsigned* restrict x){
struct ncplane* s = notcurses_stdplane(nc); // can't fail
ncplane_dim_yx(s, y, x); // accepts NULL
return s;
}
static inline const struct ncplane*
notcurses_stddim_yx_const(const struct notcurses* nc, int* restrict y, int* restrict x){
notcurses_stddim_yx_const(const struct notcurses* nc, unsigned* restrict y, unsigned* restrict x){
const struct ncplane* s = notcurses_stdplane_const(nc); // can't fail
ncplane_dim_yx(s, y, x); // accepts NULL
return s;
@ -279,8 +279,8 @@ struct ncplane* notcurses_bottom(struct notcurses* n);
// Return our current idea of the terminal dimensions in rows and cols.
static inline void
notcurses_term_dim_yx(const struct notcurses* n, int* restrict rows,
int* restrict cols){
notcurses_term_dim_yx(const struct notcurses* n, unsigned* restrict rows,
unsigned* restrict cols){
ncplane_dim_yx(notcurses_stdplane_const(n), rows, cols);
}
@ -289,7 +289,7 @@ notcurses_term_dim_yx(const struct notcurses* n, int* restrict rows,
// primarily useful if the screen is externally corrupted, or if an
// NCKEY_RESIZE event has been read and you're not yet ready to render. The
// current screen geometry is returned in 'y' and 'x', if they are not NULL.
int notcurses_refresh(struct notcurses* n, int* restrict y, int* restrict x);
int notcurses_refresh(struct notcurses* n, unsigned* restrict y, unsigned* restrict x);
// Enable or disable the terminal's cursor, if supported, placing it at
// 'y', 'x'. Immediate effect (no need for a call to notcurses_render()).
@ -498,7 +498,7 @@ int ncdirect_cursor_down(struct ncdirect* nc, int num);
// Get the cursor position, when supported. This requires writing to the
// terminal, and then reading from it. If the terminal doesn't reply, or
// doesn't reply in a way we understand, the results might be deleterious.
int ncdirect_cursor_yx(struct ncdirect* n, int* y, int* x);
int ncdirect_cursor_yx(struct ncdirect* n, unsigned* y, unsigned* x);
// Push or pop the cursor location to the terminal's stack. The depth of this
// stack, and indeed its existence, is terminal-dependent.
@ -919,17 +919,17 @@ struct ncplane* ncplane_dup(struct ncplane* n, void* opaque);
// Merge the ncplane 'src' down onto the ncplane 'dst'. This is most rigorously
// defined as "write to 'dst' the frame that would be rendered were the entire
// stack made up only of the specified subregion of 'src' and, below it, the
// subregion of 'dst' having the specified origin. Merging is independent of
// subregion of 'dst' having the specified origin. Supply -1 to indicate the
// current cursor position in the relevant dimension. Merging is independent of
// the position of 'src' viz 'dst' on the z-axis. It is an error to define a
// subregion that is not entirely contained within 'src'. It is an error to
// define a target origin such that the projected subregion is not entirely
// contained within 'dst'. Behavior is undefined if 'src' and 'dst' are
// equivalent. 'dst' is modified, but 'src' remains unchanged. Neither 'src'
// nor 'dst' may have sprixels. Lengths of 0 mean "everything left".
int ncplane_mergedown(struct ncplane* restrict src, struct ncplane* restrict dst,
unsigned begsrcy, unsigned begsrcx,
unsigned leny, unsigned lenx,
unsigned dsty, unsigned dstx);
int ncplane_mergedown(struct ncplane* RESTRICT src, struct ncplane* RESTRICT dst,
int begsrcy, int begsrcx, unsigned leny, unsigned lenx,
int dsty, int dstx);
// Merge the entirety of 'src' down onto the ncplane 'dst'. If 'src' does not
// intersect with 'dst', 'dst' will not be changed, but it is not an error.
@ -1064,16 +1064,16 @@ int ncplane_abs_y(const struct ncplane* n);
int ncplane_abs_x(const struct ncplane* n);
// Return the dimensions of this ncplane.
void ncplane_dim_yx(struct ncplane* n, int* restrict rows, int* restrict cols);
void ncplane_dim_yx(struct ncplane* n, unsigned* restrict rows, unsigned* restrict cols);
static inline int
static inline unsigned
ncplane_dim_y(const struct ncplane* n){
int dimy;
ncplane_dim_yx(n, &dimy, NULL);
return dimy;
}
static inline int
static inline unsigned
ncplane_dim_x(const struct ncplane* n){
int dimx;
ncplane_dim_yx(n, NULL, &dimx);
@ -1085,8 +1085,8 @@ ncplane_dim_x(const struct ncplane* n){
// '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,
int* restrict celldimy, int* restrict celldimx,
int* restrict maxbmapy, int* restrict maxbmapx);
unsigned* restrict celldimy, unsigned* restrict celldimx,
unsigned* restrict maxbmapy, unsigned* restrict maxbmapx);
// provided a coordinate relative to the origin of 'src', map it to the same
// absolute coordinate relative to the origin of 'dst'. either or both of 'y'
@ -1232,7 +1232,8 @@ uint32_t* ncplane_as_rgba(const struct ncplane* n, ncblitter_e blit,
// 'n'. Start at the plane's 'begy'x'begx' coordinate (which must lie on the
// plane), continuing for 'leny'x'lenx' cells. Either or both of 'leny' and
// 'lenx' can be specified as 0 to go through the boundary of the plane.
char* ncplane_contents(const struct ncplane* nc, unsigned begy, unsigned begx,
// -1 can be specified for 'begx'/'begy' to use the current cursor location.
char* ncplane_contents(const struct ncplane* nc, int begy, int begx,
unsigned leny, unsigned lenx);
// Manipulate the opaque user pointer associated with this plane.
@ -1641,10 +1642,12 @@ Similarly, areas can be filled with a cell.
// target. We do the same to all cardinally-connected cells having this same
// fill target. Returns the number of cells polyfilled. An invalid initial y, x
// is an error. Returns the number of cells filled, or -1 on error.
int ncplane_polyfill_yx(struct ncplane* n, int y, int x, const nccell* c);
int ncplane_polyfill_yx(struct ncplane* n, unsigned y, unsigned x, const nccell* c);
// Draw a gradient with its upper-left corner at the current cursor position,
// stopping at 'ystop'x'xstop'. The glyph composed of 'egc' and 'styles' is
// Draw a gradient with its upper-left corner at the position specified by 'y'/'x',
// where -1 means the current cursor position in that dimension. The area is
// specified by 'ylen'/'xlen', where 0 means "everything remaining below or
// to the right, respectively." The glyph composed of 'egc' and 'styles' is
// used for all cells. The channels specified by 'ul', 'ur', 'll', and 'lr'
// are composed into foreground and background gradients. To do a vertical
// gradient, 'ul' ought equal 'ur' and 'll' ought equal 'lr'. To do a
@ -1652,40 +1655,38 @@ int ncplane_polyfill_yx(struct ncplane* n, int y, int x, const nccell* c);
// color everything the same, all four channels should be equivalent. The
// resulting alpha values are equal to incoming alpha values. Returns the
// number of cells filled on success, or -1 on failure.
int ncplane_gradient(struct ncplane* n, const char* egc, uint32_t styles,
uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr,
int ystop, int xstop);
// Draw a gradient with its upper-left corner at the current cursor position,
// having dimensions 'ylen'x'xlen'. See ncplane_gradient for more information.
static inline int
ncplane_gradient_sized(struct ncplane* n, const char* egc, uint32_t styles,
uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr,
int ylen, int xlen){
int y, x;
ncplane_cursor_yx(n, &y, &x);
return ncplane_gradient(n, egc, styles, ul, ur, ll, lr, y + ylen - 1, x + xlen - 1);
}
int ncplane_gradient(struct ncplane* n, int y, int x, unsigned ylen,
unsigned xlen, const char* egc, uint16_t styles,
uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr);
// Do a high-resolution gradient using upper blocks and synced backgrounds.
// This doubles the number of vertical gradations, but restricts you to
// half blocks (appearing to be full blocks). Returns the number of cells
// filled on success, or -1 on error.
int ncplane_highgradient(struct ncplane* n, uint32_t ul, uint32_t ur,
uint32_t ll, uint32_t lr, int ystop, int xstop);
// ncplane_gradent_sized() meets ncplane_highgradient().
int ncplane_highgradient_sized(struct ncplane* n, uint32_t ul, uint32_t ur,
uint32_t ll, uint32_t lr, int ylen, int xlen);
int ncplane_gradient2x1(struct ncplane* n, int y, int x, unsigned ylen,
unsigned xlen, uint32_t ul, uint32_t ur,
uint32_t ll, uint32_t lr);
// Set the given style throughout the specified region, keeping content and
// channels unchanged. Returns the number of cells set, or -1 on failure.
int ncplane_format(struct ncplane* n, int ystop, int xstop, uint32_t styles);
// channels unchanged. The upper left corner is at 'x', 'y', and -1 may be
// specified to indicate the cursor's position in that dimension. The area
// is specified by 'xlen', 'ylen', and 0 may be specified to indicate everything
// remaining to the right and below, respectively. It is an error for any
// coordinate to be outside the plane. Returns the number of cells set,
// or -1 on failure.
API int ncplane_format(struct ncplane* n, int y, int x, unsigned ylen,
unsigned xlen, uint16_t stylemask);
// Set the given channels throughout the specified region, keeping content and
// attributes unchanged. Returns the number of cells set, or -1 on failure.
int ncplane_stain(struct ncplane* n, int ystop, int xstop,
uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr);
// channels unchanged. The upper left corner is at 'x', 'y', and -1 may be
// specified to indicate the cursor's position in that dimension. The area
// is specified by 'xlen', 'ylen', and 0 may be specified to indicate everything
// remaining to the right and below, respectively. It is an error for any
// coordinate to be outside the plane. Returns the number of cells set,
// or -1 on failure.
API int ncplane_stain(struct ncplane* n, int y, int x, unsigned ylen,
unsigned xlen, uint64_t ul, uint64_t ur,
uint64_t ll, uint64_t lr);
```
My 14 year-old self would never forgive me if we didn't have sweet palette
@ -3328,15 +3329,15 @@ it was built up:
// blitters actually supported by this environment. if no ncvisual was
// supplied, only cdimy/cdimx are filled in.
typedef struct ncvgeom {
int pixy, pixx; // true pixel geometry of ncvisual data
int cdimy, cdimx; // terminal cell geometry when this was calculated
int rpixy, rpixx; // rendered pixel geometry (per visual_options)
int rcelly, rcellx; // rendered cell geometry (per visual_options)
int scaley, scalex; // pixels per filled cell (scale == c for bitmaps)
int maxpixely, maxpixelx; // only defined for NCBLIT_PIXEL
int begy, begx; // upper-left corner of used section
int leny, lenx; // geometry of used section
ncblitter_e blitter;// blitter that will be used
unsigned pixy, pixx; // true pixel geometry of ncvisual data
unsigned cdimy, cdimx; // terminal cell geometry when this was calculated
unsigned rpixy, rpixx; // rendered pixel geometry (per visual_options)
unsigned rcelly, rcellx; // rendered cell geometry (per visual_options)
unsigned scaley, scalex; // pixels per filled cell (scale == c for bitmaps)
unsigned begy, begx; // upper-left corner of used section
unsigned leny, lenx; // geometry of used section
unsigned maxpixely, maxpixelx; // only defined for NCBLIT_PIXEL
ncblitter_e blitter; // blitter that will be used
} ncvgeom;
// all-purpose ncvisual geometry solver. one or both of 'nc' and 'n' must be
@ -3360,13 +3361,15 @@ int ncvisual_resize(struct ncvisual* n, int rows, int cols);
int ncvisual_resize_noninterpolative(struct ncvisual* n, int rows, int cols);
// Polyfill at the specified location within the ncvisual 'n', using 'rgba'.
int ncvisual_polyfill_yx(struct ncvisual* n, int y, int x, uint32_t rgba);
int ncvisual_polyfill_yx(struct ncvisual* n, unsigned y, unsigned x, uint32_t rgba);
// Get the specified pixel from the specified ncvisual.
int ncvisual_at_yx(const struct ncvisual* n, int y, int x, uint32_t* pixel);
int ncvisual_at_yx(const struct ncvisual* n, unsigned y, unsigned x,
uint32_t* pixel);
// Set the specified pixel in the specified ncvisual.
int ncvisual_set_yx(const struct ncvisual* n, int y, int x, uint32_t pixel);
int ncvisual_set_yx(const struct ncvisual* n, unsigned y, unsigned x,
uint32_t pixel);
// If a subtitle ought be displayed at this time, return a new plane (bound
// to 'parent' containing the subtitle, which might be text or graphics

@ -74,7 +74,7 @@ terminal, and will refuse to run in anything smaller than 80x24.
**-V**|**--version**: Print the program name and version, and exit with success.
***demospec***: Select which demos to run, and what order to run them in. The
default is **ixetunchmdbkywgarvlsfjqzo**. See above for a list of demos.
default is **ixetunchmdbkywjgarvlsfqzo**. See above for a list of demos.
Default margins are all 0, and thus the full screen will be rendered. Using
**-m**, margins can be supplied. Provide a single number to set all four margins

@ -38,9 +38,9 @@ notcurses_direct - minimal notcurses instances for styling text
**int ncdirect_set_bg_palindex(struct ncdirect* ***nc***, int ***pidx***);**
**int ncdirect_dim_x(const struct ncdirect* ***nc***);**
**unsigned ncdirect_dim_x(const struct ncdirect* ***nc***);**
**int ncdirect_dim_y(const struct ncdirect* ***nc***);**
**unsigned ncdirect_dim_y(const struct ncdirect* ***nc***);**
**unsigned ncdirect_supported_styles(const struct ncdirect* ***nc***);**
@ -58,6 +58,8 @@ notcurses_direct - minimal notcurses instances for styling text
**int ncdirect_cursor_move_yx(struct ncdirect* ***n***, int ***y***, int ***x***);**
**int ncdirect_cursor_yx(struct ncdirect* ***n***, unsigned* ***y***, unsigned* ***x***);**
**int ncdirect_cursor_enable(struct ncdirect* ***nc***);**
**int ncdirect_cursor_disable(struct ncdirect* ***nc***);**

@ -51,32 +51,54 @@ notcurses_lines - operations on lines and boxes
**static inline int ncplane_double_box_sized(struct ncplane* ***n***, uint32_t ***styles***, uint64_t ***channels***, int ***ylen***, int ***xlen***, unsigned ***ctlword***);**
**int ncplane_polyfill_yx(struct ncplane* ***n***, int ***y***, int ***x***, const nccell* ***c***);**
**int ncplane_polyfill_yx(struct ncplane* ***n***, unsigned ***y***, unsigned ***x***, const nccell* ***c***);**
**int ncplane_gradient(struct ncplane* ***n***, const char* ***egc***, uint32_t ***stylemask***, uint64_t ***ul***, uint64_t ***ur***, uint64_t ***ll***, uint64_t ***lr***, int ***ystop***, int ***xstop***);**
**int ncplane_gradient(struct ncplane* ***n***, int ***y***, int ***x***, unsigned ***ylen***, unsigned ***xlen***, const char* ***egc***, uint16_t ***stylemask***, uint64_t ***ul***, uint64_t ***ur***, uint64_t ***ll***, uint64_t ***lr***);**
**static inline int ncplane_gradient_sized(struct ncplane* ***n***, const char* ***egc***, uint32_t ***stylemask***, uint64_t ***ul***, uint64_t ***ur***, uint64_t ***ll***, uint64_t ***lr***, int ***ylen***, int ***xlen***);**
**int ncplane_highgradient2x1(struct ncplane* ***n***, int ***y***, int ***x***, unsigned ***ylen***, unsigned ***xlen***, uint16_t ***ul***, uint32_t ***ur***, uint32_t ***ll***, uint32_t ***lr***);**
**int ncplane_highgradient(struct ncplane* ***n***, uint32_t ***ul***, uint32_t ***ur***, uint32_t ***ll***, uint32_t ***lr***, int ***ystop***, int ***xstop***);**
**int ncplane_format(struct ncplane* ***n***, int ***y***, int ***x***, unsigned ***ylen***, unsigned ***xlen***, uint16_t ***stylemask***);**
**int ncplane_highgradient_sized(struct ncplane* ***n***, uint32_t ***ul***, uint32_t ***ur***, uint32_t ***ll***, uint32_t ***lr***, int ***ylen***, int ***xlen***);**
**int ncplane_stain(struct ncplane* ***n***, int ***y***, int ***x***, unsigned ***ylen***, unsigned ***xlen***, uint64_t ***ul***, uint64_t ***ur***, uint64_t ***ll***, uint64_t ***lr***);**
**int ncplane_format(struct ncplane* ***n***, int ***ystop***, int ***xstop***, uint32_t ***stylemask***);**
# DESCRIPTION
**int ncplane_stain(struct ncplane* ***n***, int ***ystop***, int ***xstop***, uint64_t ***ul***, uint64_t ***ur***, uint64_t ***ll***, uint64_t ***lr***);**
**ncplane_polyfill_yx** starts at the specified ***y*** and ***x*** (provide
-1 to use the cursor's position in the relevant dimension). The cell at
these coordinates is replaced with ***c***. All connected cells having the
same content as this original cell are replaced with ***c***, recursively.
Two cells are connected if they are vertical or horizontal neighbors of one
another.
# DESCRIPTION
**ncplane_gradient** replaces all glyphs in the specified area with
***egc***, and colors them with the specified gradient. All content
within the specified area is destroyed.
**ncplane_gradient2x1** draws a high-definition gradient in the specified
area. It will return an error if UTF8 is not being used. The gradient is
drawn using the UPPER HALF BLOCK glyph, with two vertical steps and one
horizontal step in each cell. Since cells are often about twice as tall as
they are wide, this tends to result in very even color differences. All
content within the specified area is destroyed.
**ncplane_format** sets the attributes of every cell in the region having its
upper-left corner at the cursor's current position, and its lower-right corner
at **ystop**, **xstop**.
upper-left corner at ***y*** and ***x*** (provide -1 to use the cursor's
position in the relevant dimension), and its area defined by ***ylen*** and
***xlen*** (provide 0 to use all remaining area to the right and below,
respectively). Channels and glyphs will be unaffected.
**ncplane_stain** works the same way, but sets channels. Standard linear
interpolation is applied between the provided corner channels. Glyphs
and their attributes will be unaffected.
Box- and line-drawing is unaffected by a plane's scrolling status.
# RETURN VALUES
**ncplane_format** returns -1 if either **ystop** or **xstop** is less than the
current equivalent position, otherwise 0.
**ncplane_format**, **ncplane_stain**, **ncplane_gradient**,
**ncplane_gradient2x1**, and **ncplane_polyfill_yx** return -1 if
any coordinates are outside the plane, and otherwise the number of cells
affected.
**ncplane_hline_interp**, **ncplane_hline**, **ncplane_vline_interp**, and
**ncplane_vline** all return the number of glyphs drawn on success, or -1

@ -125,17 +125,17 @@ typedef struct ncplane_options {
**uint32_t* ncplane_as_rgba(const struct ncplane* ***nc***, ncblitter_e ***blit***, unsigned ***begy***, unsigned ***begx***, unsigned ***leny***, unsigned ***lenx***, unsigned* ***pxdimy***, unsigned* ***pxdimx***);**
**char* ncplane_contents(const struct ncplane* ***nc***, unsigned ***begy***, unsigned ***begx***, unsigned ***leny***, unsigned ***lenx***);**
**char* ncplane_contents(const struct ncplane* ***nc***, int ***begy***, int ***begx***, unsigned ***leny***, unsigned ***lenx***);**
**void* ncplane_set_userptr(struct ncplane* ***n***, void* ***opaque***);**
**void* ncplane_userptr(struct ncplane* ***n***);**
**void ncplane_dim_yx(const struct ncplane* ***n***, int* restrict ***rows***, int* restrict ***cols***);**
**void ncplane_dim_yx(const struct ncplane* ***n***, unsigned* restrict ***rows***, unsigned* restrict ***cols***);**
**static inline int ncplane_dim_y(const struct ncplane* ***n***);**
**static inline unsigned ncplane_dim_y(const struct ncplane* ***n***);**
**static inline int ncplane_dim_x(const struct ncplane* ***n***);**
**static inline unsigned ncplane_dim_x(const struct ncplane* ***n***);**
**void ncplane_cursor_yx(const struct ncplane* ***n***, int* restrict ***y***, int* restrict ***x***);**
@ -205,7 +205,7 @@ typedef struct ncplane_options {
**void notcurses_drop_planes(struct notcurses* ***nc***);**
**int ncplane_mergedown(struct ncplane* ***src***, struct ncplane* ***dst***, unsigned ***begsrcy***, unsigned ***begsrcx***, unsigned ***leny***, unsigned ***lenx***, unsigned ***dsty***, unsigned ***dstx***);**
**int ncplane_mergedown(struct ncplane* ***src***, struct ncplane* ***dst***, int ***begsrcy***, int ***begsrcx***, unsigned ***leny***, unsigned ***lenx***, int ***dsty***, int ***dstx***);**
**int ncplane_mergedown_simple(struct ncplane* restrict ***src***, struct ncplane* restrict ***dst***);**
@ -225,7 +225,7 @@ typedef struct ncplane_options {
**int ncplane_rotate_ccw(struct ncplane* ***n***);**
**void ncplane_pixelgeom(struct notcurses* ***n***, int* restrict ***pxy***, int* restrict ***pxx***, int* restrict ***celldimy***, int* restrict ***celldimx***, int* restrict ***maxbmapy***, int* restrict ***maxbmapx***);**
**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***);**
**int ncplane_set_name(struct ncplane* ***n***, const char* ***name***);**

@ -10,7 +10,7 @@ notcurses_refresh - redraw an externally-damaged display
**#include <notcurses/notcurses.h>**
**int notcurses_refresh(const struct notcurses* ***nc***, int* restrict ***rows***, int* restrict ***cols***);**
**int notcurses_refresh(const struct notcurses* ***nc***, unsigned* restrict ***rows***, unsigned* restrict ***cols***);**
# DESCRIPTION

@ -16,7 +16,7 @@ notcurses_render - sync the physical display to a virtual pile
**int notcurses_render(struct notcurses* ***nc***);**
**char* notcurses_at_yx(struct notcurses* ***nc***, int ***yoff***, int ***xoff***, uint16_t* ***styles***, uint64_t* ***channels***);**
**char* notcurses_at_yx(struct notcurses* ***nc***, unsigned ***yoff***, unsigned ***xoff***, uint16_t* ***styles***, uint64_t* ***channels***);**
**int ncpile_render_to_file(struct ncplane* ***p***, FILE* ***fp***);**

@ -14,9 +14,9 @@ notcurses_stdplane - acquire the standard ncplane
**const struct ncplane* notcurses_stdplane_const(const struct notcurses* ***nc***);**
**static inline struct ncplane* notcurses_stddim_yx(struct notcurses* ***nc***, int* restrict ***y***, int* restrict ***x***);**
**static inline struct ncplane* notcurses_stddim_yx(struct notcurses* ***nc***, unsigned* restrict ***y***, unsigned* restrict ***x***);**
**static inline const struct ncplane* notcurses_stddim_yx_const(const struct notcurses* ***nc***, int* restrict ***y***, int* restrict ***x***);**
**static inline const struct ncplane* notcurses_stddim_yx_const(const struct notcurses* ***nc***, unsigned* restrict ***y***, unsigned* restrict ***x***);**
**int notcurses_enter_alternate_screen(struct notcurses* ***nc***);**

@ -53,15 +53,15 @@ struct ncvisual_options {
typedef int (*streamcb)(struct notcurses*, struct ncvisual*, void*);
typedef struct ncvgeom {
int pixy, pixx; // true pixel geometry of ncvisual data
int cdimy, cdimx; // terminal cell geometry when this was calculated
int rpixy, rpixx; // rendered pixel geometry (per visual_options)
int rcelly, rcellx; // rendered cell geometry (per visual_options)
int scaley, scalex; // pixels per filled cell (scale == c for bitmaps)
int maxpixely, maxpixelx; // only defined for NCBLIT_PIXEL
int begy, begx; // upper-left corner of used section
int leny, lenx; // geometry of used section
ncblitter_e blitter;// blitter that will be used
unsigned pixy, pixx; // true pixel geometry of ncvisual data
unsigned cdimy, cdimx; // terminal cell geometry when this was calculated
unsigned rpixy, rpixx; // rendered pixel geometry (per visual_options)
unsigned rcelly, rcellx; // rendered cell geometry (per visual_options)
unsigned scaley, scalex; // pixels per filled cell (scale == c for bitmaps)
unsigned begy, begx; // upper-left corner of used section
unsigned leny, lenx; // geometry of used section
unsigned maxpixely, maxpixelx; // only defined for NCBLIT_PIXEL
ncblitter_e blitter;i // blitter that will be used
} ncvgeom;
```
@ -101,11 +101,11 @@ typedef struct ncvgeom {
**int ncvisual_resize_noninterpolative(struct ncvisual* ***n***, int ***rows***, int ***cols***);**
**int ncvisual_polyfill_yx(struct ncvisual* ***n***, int ***y***, int ***x***, uint32_t ***rgba***);**
**int ncvisual_polyfill_yx(struct ncvisual* ***n***, unsigned ***y***, unsigned ***x***, uint32_t ***rgba***);**
**int ncvisual_at_yx(const struct ncvisual* ***n***, int ***y***, int ***x***, uint32_t* ***pixel***);**
**int ncvisual_at_yx(const struct ncvisual* ***n***, unsigned ***y***, unsigned ***x***, uint32_t* ***pixel***);**
**int ncvisual_set_yx(const struct ncvisual* ***n***, int ***y***, int ***x***, uint32_t ***pixel***);**
**int ncvisual_set_yx(const struct ncvisual* ***n***, unsigned ***y***, unsigned ***x***, uint32_t ***pixel***);**
**struct ncplane* ncvisual_subtitle_plane(struct ncplane* ***parent***, const struct ncvisual* ***ncv***);**

@ -75,14 +75,14 @@ namespace ncpp
return error_guard (ncdirect_set_bg_palindex (direct, pidx), -1);
}
int get_dim_x () const NOEXCEPT_MAYBE
unsigned get_dim_x () const NOEXCEPT_MAYBE
{
return error_guard<int> (ncdirect_dim_x (direct), -1);
return ncdirect_dim_x (direct);
}
int get_dim_y () const NOEXCEPT_MAYBE
unsigned get_dim_y () const NOEXCEPT_MAYBE
{
return error_guard<int> (ncdirect_dim_y (direct), -1);
return ncdirect_dim_y (direct);
}
unsigned get_palette_size () const noexcept
@ -140,12 +140,12 @@ namespace ncpp
return error_guard (ncdirect_cursor_disable (direct), -1);
}
void get_cursor_yx (int *y, int *x) const noexcept
void get_cursor_yx (unsigned *y, unsigned *x) const noexcept
{
ncdirect_cursor_yx (direct, 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);
}

@ -200,22 +200,22 @@ namespace ncpp
return error_guard (notcurses_render (nc), -1);
}
void get_term_dim (int *rows, int *cols) const noexcept
void get_term_dim (unsigned *rows, unsigned *cols) const noexcept
{
notcurses_term_dim_yx (nc, rows, cols);
}
void get_term_dim (int &rows, int &cols) const noexcept
void get_term_dim (unsigned &rows, unsigned &cols) const noexcept
{
get_term_dim (&rows, &cols);
}
bool refresh (int* rows, int* cols) const NOEXCEPT_MAYBE
bool refresh (unsigned* rows, unsigned* cols) const NOEXCEPT_MAYBE
{
return error_guard (notcurses_refresh (nc, rows, cols), -1);
}
bool refresh (int& rows, int& cols) const NOEXCEPT_MAYBE
bool refresh (unsigned& rows, unsigned& cols) const NOEXCEPT_MAYBE
{
return refresh (&rows, &cols);
}
@ -308,7 +308,7 @@ namespace ncpp
return new Plane (notcurses_stdplane (nc), true);
}
Plane* get_stdplane (int *y, int *x)
Plane* get_stdplane (unsigned *y, unsigned *x)
{
if (y == nullptr)
throw invalid_argument ("'y' must be a valid pointer");
@ -318,7 +318,7 @@ namespace ncpp
return get_stdplane (*y, *x);
}
Plane* get_stdplane (int &y, int &x) noexcept
Plane* get_stdplane (unsigned &y, unsigned &x) noexcept
{
return new Plane (notcurses_stddim_yx (nc, &y, &x));
}

@ -80,7 +80,7 @@ namespace ncpp
plane = create_plane (n, rows, cols, yoff, xoff, opaque);
}
explicit Plane (int rows, int cols, int yoff, int xoff, void *opaque = nullptr, NotCurses *ncinst = nullptr)
explicit Plane (unsigned rows, unsigned cols, int yoff, int xoff, void *opaque = nullptr, NotCurses *ncinst = nullptr)
: Root (ncinst)
{
ncplane_options nopts = {
@ -213,24 +213,14 @@ namespace ncpp
return error_guard (ncplane_pulse (plane, ts, fader, curry), -1);
}
int gradient (const char* egc, uint16_t stylemask, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr, int ystop, int xstop) const NOEXCEPT_MAYBE
int gradient (int y, int x, unsigned ylen, unsigned xlen, const char* egc, uint16_t stylemask, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr) const NOEXCEPT_MAYBE
{
return error_guard<int> (ncplane_gradient (plane, egc, stylemask, ul, ur, ll, lr, ystop, xstop), -1);
return error_guard<int> (ncplane_gradient (plane, y, x, ylen, xlen, egc, stylemask, ul, ur, ll, lr), -1);
}
int gradient_sized (const char* egc, uint16_t stylemask, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr, int ylen, int xlen) const NOEXCEPT_MAYBE
int gradient2x1 (int y, int x, unsigned ylen, unsigned xlen, uint32_t ul, uint32_t ur, uint32_t ll, uint32_t lr) const NOEXCEPT_MAYBE
{
return error_guard<int> (ncplane_gradient_sized (plane, egc, stylemask, ul, ur, ll, lr, ylen, xlen), -1);
}
int high_gradient (uint32_t ul, uint32_t ur, uint32_t ll, uint32_t lr, int ylen, int xlen) const NOEXCEPT_MAYBE
{
return error_guard<int> (ncplane_highgradient (plane, ul, ur, ll, lr, ylen, xlen), -1);
}
int high_gradient_sized (uint32_t ul, uint32_t ur, uint32_t ll, uint32_t lr, int ylen, int xlen) const NOEXCEPT_MAYBE
{
return error_guard<int> (ncplane_highgradient_sized (plane, ul, ur, ll, lr, ylen, xlen), -1);
return error_guard<int> (ncplane_gradient2x1 (plane, y, x, ylen, xlen, ul, ur, ll, lr), -1);
}
void greyscale () const noexcept
@ -323,12 +313,12 @@ namespace ncpp
return error_guard<int> (ncplane_valign (plane, static_cast<ncalign_e>(align), r), INT_MAX);
}
void get_dim (int *rows, int *cols) const noexcept
void get_dim (unsigned *rows, unsigned *cols) const noexcept
{
ncplane_dim_yx (plane, rows, cols);
}
void get_dim (int &rows, int &cols) const noexcept
void get_dim (unsigned &rows, unsigned &cols) const noexcept
{
get_dim (&rows, &cols);
}
@ -457,7 +447,7 @@ namespace ncpp
return mergedown (&dst, begsrcy, begsrcx, leny, lenx, dsty, dstx);
}
bool mergedown (Plane *dst, unsigned begsrcy, unsigned begsrcx, unsigned leny, unsigned lenx, unsigned dsty, unsigned dstx) const
bool mergedown (Plane *dst, int begsrcy, int begsrcx, unsigned leny, unsigned lenx, int dsty, int dstx) const
{
if (plane == dst->plane)
throw invalid_argument ("'dst' must refer to a different plane than the one this method is called on");
@ -958,14 +948,14 @@ namespace ncpp
ncplane_off_styles (plane, static_cast<unsigned>(styles));
}
int format (int ystop, int xstop, uint16_t stylemask) const NOEXCEPT_MAYBE
int format (int y, int x, unsigned ylen, unsigned xlen, uint16_t stylemask) const NOEXCEPT_MAYBE
{
return error_guard<int> (ncplane_format (plane, ystop, xstop, stylemask), -1);
return error_guard<int> (ncplane_format (plane, y, x, ylen, xlen, stylemask), -1);
}
int stain (int ystop, int xstop, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr) const NOEXCEPT_MAYBE
int stain (int y, int x, unsigned ylen, unsigned xlen, uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr) const NOEXCEPT_MAYBE
{
return error_guard<int> (ncplane_stain (plane, ystop, xstop, ul, ur, ll, lr), -1);
return error_guard<int> (ncplane_stain (plane, y, x, ylen, xlen, ul, ur, ll, lr), -1);
}
Plane* get_below () const noexcept
@ -1301,7 +1291,7 @@ namespace ncpp
static void unmap_plane (Plane *p) noexcept;
private:
ncplane* create_plane (const Plane &n, int rows, int cols, int yoff, int xoff, void *opaque)
ncplane* create_plane (const Plane &n, unsigned rows, unsigned cols, int yoff, int xoff, void *opaque)
{
ncplane_options nopts = {
.y = yoff,
@ -1318,7 +1308,7 @@ namespace ncpp
return create_plane (n, nopts);
}
ncplane* create_plane (Plane &n, int rows, int cols, int yoff, NCAlign align, void *opaque)
ncplane* create_plane (Plane &n, unsigned rows, unsigned cols, int yoff, NCAlign align, void *opaque)
{
ncplane_options nopts = {
yoff,

@ -194,14 +194,15 @@ ncdirect_bg_default(struct ncdirect* nc){
}
// Get the current number of columns/rows.
API int ncdirect_dim_x(struct ncdirect* nc) __attribute__ ((nonnull (1)));
API int ncdirect_dim_y(struct ncdirect* nc) __attribute__ ((nonnull (1)));
API unsigned ncdirect_dim_x(struct ncdirect* nc) __attribute__ ((nonnull (1)));
API unsigned ncdirect_dim_y(struct ncdirect* nc) __attribute__ ((nonnull (1)));
// Returns a 16-bit bitmask of supported curses-style attributes
// (NCSTYLE_UNDERLINE, NCSTYLE_BOLD, etc.) The attribute is only
// indicated as supported if the terminal can support it together with color.
// For more information, see the "ncv" capability in terminfo(5).
API unsigned ncdirect_supported_styles(const struct ncdirect* nc);
API unsigned ncdirect_supported_styles(const struct ncdirect* nc)
__attribute__ ((nonnull (1)));
// ncplane_styles_*() analogues
API int ncdirect_set_styles(struct ncdirect* n, unsigned stylebits)
@ -240,7 +241,7 @@ API int ncdirect_cursor_down(struct ncdirect* nc, int num)
// Get the cursor position, when supported. This requires writing to the
// terminal, and then reading from it. If the terminal doesn't reply, or
// doesn't reply in a way we understand, the results might be deleterious.
API int ncdirect_cursor_yx(struct ncdirect* n, int* y, int* x)
API int ncdirect_cursor_yx(struct ncdirect* n, unsigned* y, unsigned* x)
__attribute__ ((nonnull (1)));
// Push or pop the cursor location to the terminal's stack. The depth of this

@ -532,7 +532,7 @@ static inline uint64_t
ncchannels_set_fg_default(uint64_t* channels){
uint32_t channel = ncchannels_fchannel(*channels);
ncchannel_set_default(&channel);
*channels = ((uint64_t)channel << 32llu) | (*channels & 0xffffffffllu);
ncchannels_set_fchannel(channels, channel);
return *channels;
}
@ -781,7 +781,7 @@ nccell_extended_gcluster(const struct ncplane* n, const nccell* c);
// return the number of columns occupied by 'c'. see ncstrwidth() for an
// equivalent for multiple EGCs.
static inline int
static inline unsigned
nccell_cols(const nccell* c){
return c->width ? c->width : 1;
}
@ -1169,7 +1169,7 @@ API int notcurses_linesigs_enable(struct notcurses* n)
// primarily useful if the screen is externally corrupted, or if an
// NCKEY_RESIZE event has been read and you're not yet ready to render. The
// current screen geometry is returned in 'y' and 'x', if they are not NULL.
API int notcurses_refresh(struct notcurses* n, int* RESTRICT y, int* RESTRICT x)
API int notcurses_refresh(struct notcurses* n, unsigned* RESTRICT y, unsigned* RESTRICT x)
__attribute__ ((nonnull (1)));
// Extract the Notcurses context to which this plane is attached.
@ -1180,7 +1180,7 @@ API const struct notcurses* ncplane_notcurses_const(const struct ncplane* n)
__attribute__ ((nonnull (1)));
// Return the dimensions of this ncplane. y or x may be NULL.
API void ncplane_dim_yx(const struct ncplane* n, int* RESTRICT y, int* RESTRICT x)
API void ncplane_dim_yx(const struct ncplane* n, unsigned* RESTRICT y, unsigned* RESTRICT x)
__attribute__ ((nonnull (1)));
// Get a reference to the standard plane (one matching our current idea of the
@ -1191,53 +1191,53 @@ API const struct ncplane* notcurses_stdplane_const(const struct notcurses* nc);
// notcurses_stdplane(), plus free bonus dimensions written to non-NULL y/x!
static inline struct ncplane*
notcurses_stddim_yx(struct notcurses* nc, int* RESTRICT y, int* RESTRICT x){
notcurses_stddim_yx(struct notcurses* nc, unsigned* RESTRICT y, unsigned* RESTRICT x){
struct ncplane* s = notcurses_stdplane(nc); // can't fail
ncplane_dim_yx(s, y, x); // accepts NULL
return s;
}
static inline const struct ncplane*
notcurses_stddim_yx_const(const struct notcurses* nc, int* RESTRICT y, int* RESTRICT x){
notcurses_stddim_yx_const(const struct notcurses* nc, unsigned* RESTRICT y, unsigned* RESTRICT x){
const struct ncplane* s = notcurses_stdplane_const(nc); // can't fail
ncplane_dim_yx(s, y, x); // accepts NULL
return s;
}
static inline int
static inline unsigned
ncplane_dim_y(const struct ncplane* n){
int dimy;
unsigned dimy;
ncplane_dim_yx(n, &dimy, NULL);
return dimy;
}
static inline int
static inline unsigned
ncplane_dim_x(const struct ncplane* n){
int dimx;
unsigned dimx;
ncplane_dim_yx(n, NULL, &dimx);
return dimx;
}
// Retrieve pixel geometry for the display region ('pxy', 'pxx'), each cell
// ('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. These results are
// invalidated by a terminal resize.
// '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,
int* RESTRICT celldimy, int* RESTRICT celldimx,
int* RESTRICT maxbmapy, int* RESTRICT maxbmapx)
unsigned* RESTRICT celldimy, unsigned* RESTRICT celldimx,
unsigned* RESTRICT maxbmapy, unsigned* RESTRICT maxbmapx)
__attribute__ ((nonnull (1)));
// Return our current idea of the terminal dimensions in rows and cols.
static inline void
notcurses_term_dim_yx(const struct notcurses* n, int* RESTRICT rows, int* RESTRICT cols){
notcurses_term_dim_yx(const struct notcurses* n, unsigned* RESTRICT rows, unsigned* RESTRICT cols){
ncplane_dim_yx(notcurses_stdplane_const(n), rows, cols);
}
// Retrieve the contents of the specified cell as last rendered. Returns the EGC
// or NULL on error. This EGC must be free()d by the caller. The stylemask and
// channels are written to 'stylemask' and 'channels', respectively.
API char* notcurses_at_yx(struct notcurses* nc, int yoff, int xoff,
API char* notcurses_at_yx(struct notcurses* nc, unsigned yoff, unsigned xoff,
uint16_t* stylemask, uint64_t* channels)
__attribute__ ((nonnull (1)));
@ -1260,8 +1260,8 @@ API char* notcurses_at_yx(struct notcurses* nc, int yoff, int xoff,
typedef struct ncplane_options {
int y; // vertical placement relative to parent plane
int x; // horizontal placement relative to parent plane
int rows; // rows, must be positive (unless NCPLANE_OPTION_MARGINALIZED)
int cols; // columns, must be positive (unless NCPLANE_OPTION_MARGINALIZED)
unsigned rows; // rows, must be >0 unless NCPLANE_OPTION_MARGINALIZED
unsigned cols; // columns, must be >0 unless NCPLANE_OPTION_MARGINALIZED
void* userptr; // user curry, may be NULL
const char* name; // name (used only for debugging), may be NULL
int (*resizecb)(struct ncplane*); // callback when parent is resized
@ -1603,10 +1603,10 @@ API int ncplane_resize(struct ncplane* n, int keepy, int keepx,
// shrinking in some dimension). Keep the origin where it is.
static inline int
ncplane_resize_simple(struct ncplane* n, unsigned ylen, unsigned xlen){
int oldy, oldx;
unsigned oldy, oldx;
ncplane_dim_yx(n, &oldy, &oldx); // current dimensions of 'n'
unsigned keepleny = (unsigned)oldy > ylen ? ylen : (unsigned)oldy;
unsigned keeplenx = (unsigned)oldx > xlen ? xlen : (unsigned)oldx;
unsigned keepleny = oldy > ylen ? ylen : oldy;
unsigned keeplenx = oldx > xlen ? xlen : oldx;
return ncplane_resize(n, 0, 0, keepleny, keeplenx, 0, 0, ylen, xlen);
}
@ -1783,7 +1783,8 @@ API int ncplane_at_yx_cell(struct ncplane* n, int y, int x, nccell* c);
// 'n'. Start at the plane's 'begy'x'begx' coordinate (which must lie on the
// plane), continuing for 'leny'x'lenx' cells. Either or both of 'leny' and
// 'lenx' can be specified as 0 to go through the boundary of the plane.
API char* ncplane_contents(struct ncplane* n, unsigned begy, unsigned begx,
// -1 can be specified for 'begx'/'begy' to use the current cursor location.
API char* ncplane_contents(struct ncplane* n, int begy, int begx,
unsigned leny, unsigned lenx);
// Manipulate the opaque user pointer associated with this plane.
@ -2249,7 +2250,7 @@ ncplane_perimeter(struct ncplane* n, const nccell* ul, const nccell* ur,
if(ncplane_cursor_move_yx(n, 0, 0)){
return -1;
}
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(n, &dimy, &dimx);
return ncplane_box_sized(n, ul, ur, ll, lr, hline, vline, dimy, dimx, ctlword);
}
@ -2259,10 +2260,13 @@ ncplane_perimeter(struct ncplane* n, const nccell* ul, const nccell* ur,
// target. We do the same to all cardinally-connected cells having this same
// fill target. Returns the number of cells polyfilled. An invalid initial y, x
// is an error. Returns the number of cells filled, or -1 on error.
API int ncplane_polyfill_yx(struct ncplane* n, int y, int x, const nccell* c);
API int ncplane_polyfill_yx(struct ncplane* n, int y, int x, const nccell* c)
__attribute__ ((nonnull (1, 4)));
// Draw a gradient with its upper-left corner at the current cursor position,
// stopping at 'ystop'x'xstop'. The glyph composed of 'egc' and 'stylemask' is
// Draw a gradient with its upper-left corner at the position specified by 'y'/'x',
// where -1 means the current cursor position in that dimension. The area is
// specified by 'ylen'/'xlen', where 0 means "everything remaining below or
// to the right, respectively." The glyph composed of 'egc' and 'styles' is
// used for all cells. The channels specified by 'ul', 'ur', 'll', and 'lr'
// are composed into foreground and background gradients. To do a vertical
// gradient, 'ul' ought equal 'ur' and 'll' ought equal 'lr'. To do a
@ -2270,7 +2274,6 @@ API int ncplane_polyfill_yx(struct ncplane* n, int y, int x, const nccell* c);
// color everything the same, all four channels should be equivalent. The
// resulting alpha values are equal to incoming alpha values. Returns the
// number of cells filled on success, or -1 on failure.
//
// Palette-indexed color is not supported.
//
// Preconditions for gradient operations (error otherwise):
@ -2280,44 +2283,40 @@ API int ncplane_polyfill_yx(struct ncplane* n, int y, int x, const nccell* c);
// 1x1: all four colors must be the same
// 1xN: both top and both bottom colors must be the same (vertical gradient)
// Nx1: both left and both right colors must be the same (horizontal gradient)
API int ncplane_gradient(struct ncplane* n, const char* egc, uint32_t stylemask,
uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr,
int ystop, int xstop);
API int ncplane_gradient(struct ncplane* n, int y, int x, unsigned ylen,
unsigned xlen, const char* egc, uint16_t styles,
uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr)
__attribute__ ((nonnull (1, 6)));
// Do a high-resolution gradient using upper blocks and synced backgrounds.
// This doubles the number of vertical gradations, but restricts you to
// half blocks (appearing to be full blocks). Returns the number of cells
// filled on success, or -1 on error.
API int ncplane_highgradient(struct ncplane* n, uint32_t ul, uint32_t ur,
uint32_t ll, uint32_t lr, int ystop, int xstop);
// Draw a gradient with its upper-left corner at the current cursor position,
// having dimensions 'ylen'x'xlen'. See ncplane_gradient for more information.
static inline int
ncplane_gradient_sized(struct ncplane* n, const char* egc, uint32_t stylemask,
uint64_t ul, uint64_t ur, uint64_t ll, uint64_t lr,
int ylen, int xlen){
if(ylen < 1 || xlen < 1){
return -1;
}
int y, x;
ncplane_cursor_yx(n, &y, &x);
return ncplane_gradient(n, egc, stylemask, ul, ur, ll, lr,
y + ylen - 1, x + xlen - 1);
}
// ncplane_gradent_sized() meets ncplane_highgradient().
API int ncplane_highgradient_sized(struct ncplane* n, uint32_t ul, uint32_t ur,
uint32_t ll, uint32_t lr, int ylen, int xlen);
API int ncplane_gradient2x1(struct ncplane* n, int y, int x, unsigned ylen,
unsigned xlen, uint32_t ul, uint32_t ur,
uint32_t ll, uint32_t lr)
__attribute__ ((nonnull (1)));
// Set the given style throughout the specified region, keeping content and
// channels unchanged. Returns the number of cells set, or -1 on failure.
API int ncplane_format(struct ncplane* n, int ystop, int xstop, uint32_t stylemask);
// channels unchanged. The upper left corner is at 'x', 'y', and -1 may be
// specified to indicate the cursor's position in that dimension. The lower
// right corner is specified by 'xstop', 'ystop'. It is an error for any
// coordinate to be outside the plane. Returns the number of cells set,
// or -1 on failure.
API int ncplane_format(struct ncplane* n, int y, int x, unsigned ystop,
unsigned xstop, uint16_t stylemask)
__attribute__ ((nonnull (1)));
// Set the given channels throughout the specified region, keeping content and
// attributes unchanged. Returns the number of cells set, or -1 on failure.
API int ncplane_stain(struct ncplane* n, int ystop, int xstop, uint64_t ul,
uint64_t ur, uint64_t ll, uint64_t lr);
// attributes unchanged. The upper left corner is at 'x', 'y', and -1 may be
// specified to indicate the cursor's position in that dimension. The lower
// right corner is specified by 'xstop', 'ystop'. It is an error for any
// coordinate to be outside the plane. Returns the number of cells set,
// or -1 on failure.
API int ncplane_stain(struct ncplane* n, int y, int x, unsigned ystop,
unsigned xstop, uint64_t ul, uint64_t ur,
uint64_t ll, uint64_t lr)
__attribute__ ((nonnull (1)));
// Merge the entirety of 'src' down onto the ncplane 'dst'. If 'src' does not
// intersect with 'dst', 'dst' will not be changed, but it is not an error.
@ -2328,7 +2327,8 @@ API int ncplane_mergedown_simple(struct ncplane* RESTRICT src,
// Merge the ncplane 'src' down onto the ncplane 'dst'. This is most rigorously
// defined as "write to 'dst' the frame that would be rendered were the entire
// stack made up only of the specified subregion of 'src' and, below it, the
// subregion of 'dst' having the specified origin. Merging is independent of
// subregion of 'dst' having the specified origin. Supply -1 to indicate the
// current cursor position in the relevant dimension. Merging is independent of
// the position of 'src' viz 'dst' on the z-axis. It is an error to define a
// subregion that is not entirely contained within 'src'. It is an error to
// define a target origin such that the projected subregion is not entirely
@ -2337,9 +2337,9 @@ API int ncplane_mergedown_simple(struct ncplane* RESTRICT src,
// nor 'dst' may have sprixels. Lengths of 0 mean "everything left".
API int ncplane_mergedown(struct ncplane* RESTRICT src,
struct ncplane* RESTRICT dst,
unsigned begsrcy, unsigned begsrcx,
int begsrcy, int begsrcx,
unsigned leny, unsigned lenx,
unsigned dsty, unsigned dstx)
int dsty, int dstx)
__attribute__ ((nonnull (1, 2)));
// Erase every cell in the ncplane (each cell is initialized to the null glyph
@ -2614,37 +2614,44 @@ typedef int (*fadecb)(struct notcurses* nc, struct ncplane* n,
// modification (if the terminal uses a palette, our ability to fade planes is
// limited, and affected by the complexity of the rest of the screen).
API int ncplane_fadeout(struct ncplane* n, const struct timespec* ts,
fadecb fader, void* curry);
fadecb fader, void* curry)
__attribute__ ((nonnull (1)));
// Fade the ncplane in over the specified time. Load the ncplane with the
// target cells without rendering, then call this function. When it's done, the
// ncplane will have reached the target levels, starting from zeroes.
API int ncplane_fadein(struct ncplane* n, const struct timespec* ts,
fadecb fader, void* curry);
fadecb fader, void* curry)
__attribute__ ((nonnull (1)));
// Rather than the simple ncplane_fade{in/out}(), ncfadectx_setup() can be
// paired with a loop over ncplane_fade{in/out}_iteration() + ncfadectx_free().
API struct ncfadectx* ncfadectx_setup(struct ncplane* n);
API ALLOC struct ncfadectx* ncfadectx_setup(struct ncplane* n)
__attribute__ ((nonnull (1)));
// Return the number of iterations through which 'nctx' will fade.
API int ncfadectx_iterations(const struct ncfadectx* nctx);
API int ncfadectx_iterations(const struct ncfadectx* nctx)
__attribute__ ((nonnull (1)));
// Fade out through 'iter' iterations, where
// 'iter' < 'ncfadectx_iterations(nctx)'.
API int ncplane_fadeout_iteration(struct ncplane* n, struct ncfadectx* nctx,
int iter, fadecb fader, void* curry);
int iter, fadecb fader, void* curry)
__attribute__ ((nonnull (1, 2)));
// Fade in through 'iter' iterations, where
// 'iter' < 'ncfadectx_iterations(nctx)'.
API int ncplane_fadein_iteration(struct ncplane* n, struct ncfadectx* nctx,
int iter, fadecb fader, void* curry);
int iter, fadecb fader, void* curry)
__attribute__ ((nonnull (1, 2)));
// Pulse the plane in and out until the callback returns non-zero, relying on
// the callback 'fader' to initiate rendering. 'ts' defines the half-period
// (i.e. the transition from black to full brightness, or back again). Proper
// use involves preparing (but not rendering) an ncplane, then calling
// ncplane_pulse(), which will fade in from black to the specified colors.
API int ncplane_pulse(struct ncplane* n, const struct timespec* ts, fadecb fader, void* curry);
API int ncplane_pulse(struct ncplane* n, const struct timespec* ts, fadecb fader, void* curry)
__attribute__ ((nonnull (1)));
// Release the resources associated with 'nctx'.
API void ncfadectx_free(struct ncfadectx* nctx);
@ -2729,7 +2736,7 @@ ncplane_perimeter_rounded(struct ncplane* n, uint32_t stylemask,
if(ncplane_cursor_move_yx(n, 0, 0)){
return -1;
}
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(n, &dimy, &dimx);
nccell ul = CELL_TRIVIAL_INITIALIZER;
nccell ur = CELL_TRIVIAL_INITIALIZER;
@ -2782,7 +2789,7 @@ ncplane_perimeter_double(struct ncplane* n, uint32_t stylemask,
if(ncplane_cursor_move_yx(n, 0, 0)){
return -1;
}
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(n, &dimy, &dimx);
nccell ul = CELL_TRIVIAL_INITIALIZER;
nccell ur = CELL_TRIVIAL_INITIALIZER;
@ -2894,8 +2901,8 @@ struct ncvisual_options {
// pass an origin of 0, 0 and a size of 0, 0 (or the true height and width).
// these numbers are all in terms of ncvisual pixels. negative values are
// prohibited.
int begy, begx; // origin of rendered section
int leny, lenx; // size of rendered section
unsigned begy, begx; // origin of rendered section
unsigned leny, lenx; // size of rendered section
// use NCBLIT_DEFAULT if you don't care, an appropriate blitter will be
// chosen for your terminal, given your scaling. NCBLIT_PIXEL is never
// chosen for NCBLIT_DEFAULT.
@ -2927,15 +2934,15 @@ struct ncvisual_options {
// blitters actually supported by this environment. if no ncvisual was
// supplied, only cdimy/cdimx are filled in.
typedef struct ncvgeom {
int pixy, pixx; // true pixel geometry of ncvisual data
int cdimy, cdimx; // terminal cell geometry when this was calculated
int rpixy, rpixx; // rendered pixel geometry (per visual_options)
int rcelly, rcellx; // rendered cell geometry (per visual_options)
int scaley, scalex; // pixels per filled cell (scale == c for bitmaps)
int maxpixely, maxpixelx; // only defined for NCBLIT_PIXEL
int begy, begx; // upper-left corner of used section
int leny, lenx; // geometry of used section
ncblitter_e blitter;// blitter that will be used
unsigned pixy, pixx; // true pixel geometry of ncvisual data
unsigned cdimy, cdimx; // terminal cell geometry when this was calculated
unsigned rpixy, rpixx; // rendered pixel geometry (per visual_options)
unsigned rcelly, rcellx; // rendered cell geometry (per visual_options)
unsigned scaley, scalex; // pixels per filled cell (scale == c for bitmaps)
unsigned begy, begx; // upper-left corner of used section
unsigned leny, lenx; // geometry of used section
unsigned maxpixely, maxpixelx; // only defined for NCBLIT_PIXEL
ncblitter_e blitter; // blitter that will be used
} ncvgeom;
// all-purpose ncvisual geometry solver. one or both of 'nc' and 'n' must be
@ -2979,15 +2986,17 @@ API int ncvisual_resize_noninterpolative(struct ncvisual* n, int rows, int cols)
__attribute__ ((nonnull (1)));
// Polyfill at the specified location within the ncvisual 'n', using 'rgba'.
API int ncvisual_polyfill_yx(struct ncvisual* n, int y, int x, uint32_t rgba)
API int ncvisual_polyfill_yx(struct ncvisual* n, unsigned y, unsigned x, uint32_t rgba)
__attribute__ ((nonnull (1)));
// Get the specified pixel from the specified ncvisual.
API int ncvisual_at_yx(const struct ncvisual* n, int y, int x, uint32_t* pixel)
API int ncvisual_at_yx(const struct ncvisual* n, unsigned y, unsigned x,
uint32_t* pixel)
__attribute__ ((nonnull (1, 4)));
// Set the specified pixel in the specified ncvisual.
API int ncvisual_set_yx(const struct ncvisual* n, int y, int x, uint32_t pixel)
API int ncvisual_set_yx(const struct ncvisual* n, unsigned y, unsigned x,
uint32_t pixel)
__attribute__ ((nonnull (1)));
// Render the decoded frame according to the provided options (which may be
@ -3068,7 +3077,8 @@ API ALLOC struct ncplane* ncvisual_subtitle_plane(struct ncplane* parent,
// - otherwise NCBLIT_3x2
// NCBLIT_2x2 and NCBLIT_3x2 both distort the original aspect ratio, thus
// NCBLIT_2x1 is used outside of NCSCALE_STRETCH.
API ncblitter_e ncvisual_media_defblitter(const struct notcurses* nc, ncscale_e scale);
API ncblitter_e ncvisual_media_defblitter(const struct notcurses* nc, ncscale_e scale)
__attribute__ ((nonnull (1)));
// Called for each frame rendered from 'ncv'. If anything but 0 is returned,
// the streaming operation ceases immediately, and that value is propagated out.
@ -3080,7 +3090,8 @@ typedef int (*ncstreamcb)(struct ncvisual*, struct ncvisual_options*,
// If you'd like subtitles to be decoded, provide an ncplane as the curry. If the
// curry is NULL, subtitles will not be displayed.
API int ncvisual_simple_streamer(struct ncvisual* ncv, struct ncvisual_options* vopts,
const struct timespec* tspec, void* curry);
const struct timespec* tspec, void* curry)
__attribute__ ((nonnull (1)));
// Stream the entirety of the media, according to its own timing. Blocking,
// obviously. streamer may be NULL; it is otherwise called for each frame, and
@ -3093,7 +3104,8 @@ API int ncvisual_simple_streamer(struct ncvisual* ncv, struct ncvisual_options*
// supply 'timescale' less than or equal to 0.
API int ncvisual_stream(struct notcurses* nc, struct ncvisual* ncv,
float timescale, ncstreamcb streamer,
const struct ncvisual_options* vopts, void* curry);
const struct ncvisual_options* vopts, void* curry)
__attribute__ ((nonnull (1, 2)));
// Blit a flat array 'data' of RGBA 32-bit values to the ncplane 'vopts->n',
// which mustn't be NULL. the blit begins at 'vopts->y' and 'vopts->x' relative
@ -3103,20 +3115,24 @@ API int ncvisual_stream(struct notcurses* nc, struct ncvisual* ncv,
// 'leny'x'lenx' fields from 'vopts'. Returns the number of pixels blitted, or
// -1 on error.
API int ncblit_rgba(const void* data, int linesize,
const struct ncvisual_options* vopts);
const struct ncvisual_options* vopts)
__attribute__ ((nonnull (1)));
// Same as ncblit_rgba(), but for BGRx.
API int ncblit_bgrx(const void* data, int linesize,
const struct ncvisual_options* vopts);
const struct ncvisual_options* vopts)
__attribute__ ((nonnull (1)));
// Supply an alpha value [0..255] to be applied throughout.
API int ncblit_rgb_packed(const void* data, int linesize,
const struct ncvisual_options* vopts, int alpha);
const struct ncvisual_options* vopts, int alpha)
__attribute__ ((nonnull (1)));
// Supply an alpha value [0..255] to be applied throughout. linesize must be
// a multiple of 4 for this RGBx data.
API int ncblit_rgb_loose(const void* data, int linesize,
const struct ncvisual_options* vopts, int alpha);
const struct ncvisual_options* vopts, int alpha)
__attribute__ ((nonnull (1)));
// The ncpixel API facilitates direct management of the pixels within an
// ncvisual (ncvisuals keep a backing store of 32-bit RGBA pixels, and render
@ -3393,17 +3409,21 @@ bprefix(uintmax_t val, uintmax_t decimal, char* buf, int omitdec){
// 'y', 'x'. Immediate effect (no need for a call to notcurses_render()).
// It is an error if 'y', 'x' lies outside the standard plane. Can be
// called while already visible to move the cursor.
API int notcurses_cursor_enable(struct notcurses* nc, int y, int x);
API int notcurses_cursor_enable(struct notcurses* nc, int y, int x)
__attribute__ ((nonnull (1)));
// Get the current location of the terminal's cursor, whether visible or not.
API int notcurses_cursor_yx(struct notcurses* nc, int* y, int* x);
API int notcurses_cursor_yx(struct notcurses* nc, int* y, int* x)
__attribute__ ((nonnull (1)));
// Disable the hardware cursor. It is an error to call this while the
// cursor is already disabled.
API int notcurses_cursor_disable(struct notcurses* nc);
API int notcurses_cursor_disable(struct notcurses* nc)
__attribute__ ((nonnull (1)));
// Convert the plane's content to greyscale.
API void ncplane_greyscale(struct ncplane* n);
API void ncplane_greyscale(struct ncplane* n)
__attribute__ ((nonnull (1)));
// ╭──────────────────────────╮
// │This is the primary header│
@ -3455,15 +3475,19 @@ API int ncselector_additem(struct ncselector* n, const struct ncselector_item* i
API int ncselector_delitem(struct ncselector* n, const char* item);
// Return reference to the selected option, or NULL if there are no items.
API const char* ncselector_selected(const struct ncselector* n);
API const char* ncselector_selected(const struct ncselector* n)
__attribute__ ((nonnull (1)));
// Return a reference to the ncselector's underlying ncplane.
API struct ncplane* ncselector_plane(struct ncselector* n);
API struct ncplane* ncselector_plane(struct ncselector* n)
__attribute__ ((nonnull (1)));
// Move up or down in the list. A reference to the newly-selected item is
// returned, or NULL if there are no items in the list.
API const char* ncselector_previtem(struct ncselector* n);
API const char* ncselector_nextitem(struct ncselector* n);
API const char* ncselector_previtem(struct ncselector* n)
__attribute__ ((nonnull (1)));
API const char* ncselector_nextitem(struct ncselector* n)
__attribute__ ((nonnull (1)));
// Offer the input to the ncselector. If it's relevant, this function returns
// true, and the input ought not be processed further. If it's irrelevant to
@ -4258,6 +4282,10 @@ API int notcurses_mouse_enable(struct notcurses* n)
API int notcurses_mouse_disable(struct notcurses* n)
__attribute__ ((nonnull (1))) __attribute__ ((deprecated));
API int ncplane_highgradient_sized(struct ncplane* n, uint32_t ul, uint32_t ur,
uint32_t ll, uint32_t lr, int ylen, int xlen)
__attribute__ ((deprecated));
#undef API
#undef ALLOC

@ -191,7 +191,7 @@ drawcycles(struct ncplane* std, struct ncprogbar* left, struct ncprogbar* right,
static int
animate(struct notcurses* nc, struct ncprogbar* left, struct ncprogbar* right){
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* std = notcurses_stddim_yx(nc, &dimy, &dimx);
int headx = -1;
int heady = -1;
@ -254,10 +254,11 @@ animate(struct notcurses* nc, struct ncprogbar* left, struct ncprogbar* right){
static int
make_pbars(struct ncplane* column, struct ncprogbar** left, struct ncprogbar** right){
int dimy, dimx, coly, colx, colposy, colposx;
unsigned dimy, dimx, coly, colx;
struct notcurses* nc = ncplane_notcurses(column);
notcurses_stddim_yx(nc, &dimy, &dimx);
ncplane_dim_yx(column, &coly, &colx);
int colposy, colposx;
ncplane_yx(column, &colposy, &colposx);
ncplane_options opts = {
.x = colposx / 4 * -3,
@ -297,7 +298,7 @@ int animate_demo(struct notcurses* nc){
if(!notcurses_canutf8(nc)){
return 0;
}
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* n = notcurses_stddim_yx(nc, &dimy, &dimx);
ncplane_erase(n);
ncplane_home(n);
@ -306,18 +307,18 @@ int animate_demo(struct notcurses* nc){
ncchannel_set_rgb8(&tr, 0, 0xff, 0);
ncchannel_set_rgb8(&bl, 0, 0, 0xff);
ncchannel_set_rgb8(&br, 0, 0xff, 0xff);
if(ncplane_highgradient(n, tl, tr, bl, br, dimy - 1, dimx - 1) < 0){
if(ncplane_gradient2x1(n, -1, -1, 0, 0, tl, tr, bl, br) < 0){
return -1;
}
ncplane_set_fg_rgb(n, 0xf0f0a0);
ncplane_set_bg_rgb(n, 0);
int width = 40;
unsigned width = 40;
if(width > dimx - 8){
if((width = dimx - 8) <= 0){
return -1;
}
}
int height = 40;
unsigned height = 40;
if(height >= dimy - 4){
if((height = dimy - 5) <= 0){
return -1;

@ -21,7 +21,7 @@ static int democount;
static demoresult* results;
static char *datadir = NOTCURSES_SHARE;
static const char DEFAULT_DEMO[] = "ixetunchmdbkywgarvlsfjqzo";
static const char DEFAULT_DEMO[] = "ixetunchmdbkywjgarvlsfqzo";
atomic_bool interrupted = ATOMIC_VAR_INIT(false);
// checked following demos, whether aborted, failed, or otherwise
@ -388,6 +388,7 @@ static int
summary_table(struct notcurses* nc, const char* spec, bool canimage, bool canvideo){
notcurses_leave_alternate_screen(nc);
struct ncplane* n = notcurses_stdplane(nc);
ncplane_set_bg_default(n);
ncplane_set_scrolling(n, true);
bool failed = false;
uint64_t totalbytes = 0;
@ -530,7 +531,7 @@ int main(int argc, char** argv){
notcurses_mice_enable(nc, NCMICE_BUTTON_EVENT | NCMICE_DRAG_EVENT);
const bool canimage = notcurses_canopen_images(nc);
const bool canvideo = notcurses_canopen_videos(nc);
int dimx, dimy;
unsigned dimx, dimy;
ncplane_dim_yx(notcurses_stdplane(nc), &dimy, &dimx);
if(input_dispatcher(nc)){
goto err;

@ -6,7 +6,7 @@ drop_bricks(struct notcurses* nc, struct ncplane** arr, int arrcount){
if(arrcount == 0 || arr == NULL){
return -1;
}
int stdy, stdx;
unsigned stdy, stdx;
notcurses_term_dim_yx(nc, &stdy, &stdx);
// an erase+render cycle ought not change the screen, as we duplicated it
struct timespec iterdelay;
@ -104,7 +104,7 @@ shuffle_in(struct ncplane** arr, int count, struct ncplane* n){
// you played yourself https://genius.com/De-la-soul-fallin-lyrics
int fission_demo(struct notcurses* nc){
struct ncplane* npl = NULL;
int dimx, dimy;
unsigned dimx, dimy;
struct ncplane* stdn = notcurses_stddim_yx(nc, &dimy, &dimx);
size_t usesize = sizeof(bool) * dimy * dimx;
bool* usemap = malloc(usesize);
@ -126,8 +126,8 @@ int fission_demo(struct notcurses* nc){
// * newy/newx: actual geometry of current brick
// * usey/usex:
ncplane_greyscale(stdn);
for(int y = 1 ; y < dimy ; ++y){
int x = 0;
for(unsigned y = 1 ; y < dimy ; ++y){
unsigned x = 0;
while(x < dimx){
if(usemap[y * dimx + x]){ // skip if we've already been copied
++x;

@ -256,7 +256,7 @@ int grid_demo(struct notcurses* nc){
int ret = 0;
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);

@ -86,7 +86,7 @@ debug_toggle(struct notcurses* nc){
debug = NULL;
return;
}
int dimy, dimx;
unsigned dimy, dimx;
notcurses_term_dim_yx(nc, &dimy, &dimx);
fbuf f;
if(fbuf_init_small(&f)){
@ -123,7 +123,7 @@ debug_toggle(struct notcurses* nc){
return;
}
fbuf_free(&f);
for(int y = 0 ; y < ncplane_dim_y(n) ; ++y){
for(unsigned y = 0 ; y < ncplane_dim_y(n) ; ++y){
nccell c = CELL_TRIVIAL_INITIALIZER;
nccell_set_fg_alpha(&c, NCALPHA_TRANSPARENT);
nccell_set_bg_alpha(&c, NCALPHA_TRANSPARENT);
@ -144,7 +144,7 @@ about_toggle(struct notcurses* nc){
}
const int ABOUT_ROWS = 9;
const int ABOUT_COLS = 40;
int dimy;
unsigned dimy;
notcurses_term_dim_yx(nc, &dimy, NULL);
ncplane_options nopts = {
.y = 3,
@ -410,7 +410,7 @@ struct ncplane* hud_create(struct notcurses* nc){
if(hud){
return NULL;
}
int dimx, dimy;
unsigned dimx, dimy;
notcurses_term_dim_yx(nc, &dimy, &dimx);
struct ncplane_options nopts = {
// FPS graph is 6 rows tall; we want one row above it
@ -632,7 +632,7 @@ int demo_render(struct notcurses* nc){
int fpsgraph_init(struct notcurses* nc){
const int PLOTHEIGHT = 6;
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* stdn = notcurses_stddim_yx(nc, &dimy, &dimx);
ncplane_options nopts = {
.y = NCALIGN_BOTTOM,

@ -64,7 +64,7 @@ greatscott(struct notcurses* nc, int dimx){
}
static struct ncplane*
orcashow(struct notcurses* nc, int dimy, int dimx){
orcashow(struct notcurses* nc, unsigned dimy, unsigned dimx){
char* path = find_data("natasha-blur.png");
if(path == NULL){
return NULL;
@ -134,7 +134,7 @@ int intro(struct notcurses* nc){
ncchannel_set_rgb8(&cclr, 0, 0, 0xff);
// we use full block rather+fg than space+bg to conflict less with the menu
ncplane_cursor_move_yx(ncp, 2, 1);
if(ncplane_highgradient_sized(ncp, ccul, ccur, ccll, cclr, rows - 3, cols - 2) <= 0){
if(ncplane_gradient2x1(ncp, -1, -1, rows - 3, cols - 2, ccul, ccur, ccll, cclr) <= 0){
return -1;
}
nccell c = CELL_TRIVIAL_INITIALIZER;
@ -168,7 +168,9 @@ int intro(struct notcurses* nc){
if(ncplane_cursor_move_yx(ncp, 5, (cols - centercols) / 2 + 1)){
return -1;
}
if(ncplane_gradient(ncp, "Δ", 0, cul, cur, cll, clr, rows - 8, cols / 2 + centercols / 2 - 1) <= 0){
if(ncplane_gradient(ncp, -1, -1, rows - 8 - 5,
cols / 2 + centercols / 2 - 1 - ((cols - centercols) / 2 + 1),
"Δ", 0, cul, cur, cll, clr) <= 0){
return -1;
}
nccell_set_fg_rgb(&lr, 0xff0000); nccell_set_bg_rgb(&lr, 0x002000);

@ -26601,7 +26601,7 @@ int jungle_demo(struct notcurses* nc){
if(out < ORIGWIDTH * ORIGHEIGHT){ // uh-oh
return -1;
}
int dimx, dimy;
unsigned dimx, dimy;
struct ncplane* n = notcurses_stddim_yx(nc, &dimy, &dimx);
// FIXME rewrite all of this using modern ncvisual, sheesh
dimy *= 2; // use half blocks

@ -3687,7 +3687,7 @@ int mojibake_demo(struct notcurses* nc){
if(!notcurses_canutf8(nc)){
return 0;
}
int dimy;
unsigned dimy;
struct ncplane* std = notcurses_stddim_yx(nc, &dimy, NULL);
ncplane_greyscale(std);
struct ncplane* title = maketitle(std);
@ -3714,7 +3714,7 @@ int mojibake_demo(struct notcurses* nc){
makegroup(title, dimy + 1, face_costume, "face-costume"),
makegroup(title, dimy + 1, cat_face, "cat-face"),
makegroup(title, dimy + 1, monkey_face, "monkey-face"),
makegroup(title, dimy + 1, emotion, "emotion"),
//makegroup(title, dimy + 1, emotion, "emotion"),
makegroup(title, dimy + 1, hand_fingers_open, "hand-fingers-open"),
makegroup(title, dimy + 1, hand_fingers_partial, "hand-fingers-partial"),
makegroup(title, dimy + 1, hand_single_finger, "hand-single-finger"),

@ -231,7 +231,7 @@ int normal_demo(struct notcurses* nc){
ncchannels_set_fg_rgb8(&bl, 0xff, 0, 0xff);
ncchannels_set_fg_rgb8(&br, 0, 0, 0);
ncplane_dim_yx(n, &dy, &dx);
if(ncplane_stain(n, dy - 1, dx - 1, tl, tr, bl, br) < 0){
if(ncplane_stain(n, -1, -1, dy - 1, dx - 1, tl, tr, bl, br) < 0){
goto err;
}
DEMO_RENDER(nc);

@ -58,7 +58,6 @@ videothread(void* vnc){
.scaling = NCSCALE_STRETCH,
.n = ncp,
.y = 1,
.flags = NCVISUAL_OPTION_ADDALPHA,
};
int three = 3;
if(ncvisual_blit(nc, ncv, &ovopts) == NULL){
@ -186,7 +185,7 @@ outro_message(struct notcurses* nc, int* rows, int* cols){
}
int outro(struct notcurses* nc){
int rows, cols;
unsigned rows, cols;
struct ncplane* ncp = notcurses_stddim_yx(nc, &rows, &cols);
ncplane_erase(ncp);
struct ncvisual* chncv = NULL;

@ -94,7 +94,7 @@ static int
fill_chunk(struct ncplane* n, int idx){
const int hidx = idx % CHUNKS_HORZ;
const int vidx = idx / CHUNKS_HORZ;
int maxy, maxx;
unsigned maxy, maxx;
ncplane_dim_yx(n, &maxy, &maxx);
uint64_t channels = 0;
int r = 64 + hidx * 10;

@ -174,7 +174,7 @@ int view_demo(struct notcurses* nc){
return 0;
}
memset(&marsh, 0, sizeof(marsh));
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* nstd = notcurses_stddim_yx(nc, &dimy, &dimx);
int ret = view_images(nc, nstd, dimy, dimx);
if(ret){

@ -145,7 +145,7 @@ int yield_demo(struct notcurses* nc){
if(!notcurses_canopen_images(nc)){
return 0;
}
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* std = notcurses_stddim_yx(nc, &dimy, &dimx);
// in sixel-based implementation, if we redraw each cycle, the underlying
// material will be redrawn, taking time. erasing won't eliminate the

@ -233,7 +233,8 @@ selector_run(struct notcurses* nc, struct ncplane* p, struct ncselector* selecto
"NCSelector allows a single option to be selected from a list.\n"
"NCFdplane streams a file descriptor, while NCSubproc spawns a subprocess and streams its output.\n";
int titers = get_word_count(text);
int ret = 0, dimy, dimx;
int ret = 0;
unsigned dimy, dimx;
ncplane_dim_yx(notcurses_stdplane(nc), &dimy, &dimx);
const int centery = (dimy - ncplane_dim_y(p)) / 2;
int ry, rx, sy, sx;
@ -307,7 +308,8 @@ mselector_run(struct notcurses* nc, struct ncplane* p, struct ncmultiselector* m
"Widgets can be controlled with the keyboard and/or mouse. "
"They are implemented atop ncplanes, and these planes can be manipulated like all others.";
const int titers = get_word_count(text);
int ret = 0, dimy, dimx;
int ret = 0;
unsigned dimy, dimx;
ncplane_dim_yx(notcurses_stdplane(nc), &dimy, &dimx);
const int centery = (dimy - ncplane_dim_y(p)) / 2;
int ry, rx, sy, sx;
@ -376,7 +378,7 @@ mselector_run(struct notcurses* nc, struct ncplane* p, struct ncmultiselector* m
static int
reader_demo(struct notcurses* nc){
int ret = -1;
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* std = notcurses_stddim_yx(nc, &dimy, &dimx);
const int READER_COLS = 64;
const int READER_ROWS = 8;

@ -365,7 +365,7 @@ drawpalette(struct notcurses* nc){
if(psize > 256){
psize = 256;
}
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* n = notcurses_stddim_yx(nc, &dimy, &dimx);
if(dimx < 64){
return -1;
@ -380,7 +380,7 @@ drawpalette(struct notcurses* nc){
if(ncplane_cursor_move_yx(n, -1, (dimx - toshow) / 2)){
return -1;
}
for(int x = (dimx - 64) / 2 ; x < dimx / 2 + 32 ; ++x){
for(unsigned x = (dimx - 64) / 2 ; x < dimx / 2 + 32 ; ++x){
const int truex = x - (dimx - 64) / 2;
if(y * 64 + truex >= psize){
break;
@ -403,7 +403,7 @@ drawpalette(struct notcurses* nc){
static int
infoplane_notcurses(struct notcurses* nc, const fetched_info* fi, int planeheight){
const int planewidth = 72;
int dimy;
unsigned dimy;
int y;
struct ncplane* std = notcurses_stddim_yx(nc, &dimy, NULL);
ncplane_cursor_yx(std, &y, NULL);
@ -552,7 +552,7 @@ neologo_present(struct notcurses* nc, const char* nlogo){
maxlinelen = collen;
}
}
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* n = notcurses_stddim_yx(nc, &dimy, &dimx);
const int leftpad = (dimx - maxlinelen) / 2;
for(int i = 0 ; i < linecount ; ++i){

@ -319,7 +319,7 @@ unicodedumper(struct ncplane* n, const char* indent){
uint64_t ul = NCCHANNELS_INITIALIZER(0xff, 0xff, 0xff, 0x19, 0x19, 0x70);
uint64_t ll = NCCHANNELS_INITIALIZER(0xff, 0xff, 0xff, 0x19, 0x19, 0x70);
ncplane_cursor_move_yx(n, y - 15, 0);
ncplane_stain(n, y - 1, 79, ul, ur, ll, lr);
ncplane_stain(n, -1, -1, y - 1, 79, ul, ur, ll, lr);
ncplane_set_styles(n, NCSTYLE_BOLD | NCSTYLE_ITALIC);
ncplane_cursor_move_yx(n, y - 12, 54);
wviz(n, L"🯁🯂🯃https://notcurses.com");
@ -330,7 +330,7 @@ unicodedumper(struct ncplane* n, const char* indent){
static int
display_logo(struct ncplane* n, const char* path){
int cpixy, cpixx;
unsigned cpixy, cpixx;
ncplane_pixelgeom(n, NULL, NULL, &cpixy, &cpixx, NULL, NULL);
struct ncvisual* ncv = ncvisual_from_file(path);
if(ncv == NULL){
@ -480,7 +480,7 @@ int main(int argc, const char** argv){
// so that we know whether we're talking to gpm
notcurses_mice_enable(nc, NCMICE_ALL_EVENTS);
const char indent[] = "";
int dimx;
unsigned dimx;
struct ncplane* stdn = notcurses_stddim_yx(nc, NULL, &dimx);
if(dimx < 80){
ncplane_set_fg_rgb(stdn, 0xff5349);

@ -26,8 +26,8 @@ using namespace ncpp;
std::mutex mtx;
uint64_t start;
static int dimy, dimx;
std::atomic<bool> done;
static unsigned dimy, dimx;
static struct ncuplot* plot;
// return the string version of a special composed key
@ -185,10 +185,9 @@ char32_t printutf8(char32_t kp){
// older text, and thus clearly indicate the current output.
static bool
dim_rows(const Plane* n){
int y, x;
Cell c;
for(y = 0 ; y < dimy ; ++y){
for(x = 0 ; x < dimx ; ++x){
for(unsigned y = 0 ; y < dimy ; ++y){
for(unsigned x = 0 ; x < dimx ; ++x){
if(n->get_at(y, x, &c) < 0){
n->release(c);
return false;
@ -255,10 +254,10 @@ int input_demo(ncpp::NotCurses* nc) {
constexpr auto PLOTWIDTH = 56;
auto n = nc->get_stdplane(&dimy, &dimx);
// FIXME no ncpp wrapper for Plane::pixelgeom?
int celldimx, maxbmapx;
unsigned celldimx, maxbmapx;
ncplane_pixelgeom(*n, nullptr, nullptr, nullptr, &celldimx, nullptr, &maxbmapx);
struct ncplane_options nopts = {
.y = dimy - PLOTHEIGHT - 1,
.y = static_cast<int>(dimy) - PLOTHEIGHT - 1,
.x = NCALIGN_CENTER,
.rows = PLOTHEIGHT,
.cols = PLOTWIDTH,
@ -297,7 +296,7 @@ int input_demo(ncpp::NotCurses* nc) {
ncuplot_destroy(plot);
return -1;
}
int y = 0;
unsigned y = 0;
std::deque<wchar_t> cells;
char32_t r;
done = false;

@ -67,24 +67,18 @@ tria_blit_ascii(ncplane* nc, int linesize, const void* data,
int leny, int lenx, const blitterargs* bargs){
//fprintf(stderr, "ASCII %d X %d @ %d X %d (%p) place: %d X %d\n", leny, lenx, bargs->begy, bargs->begx, data, bargs->u.cell.placey, bargs->u.cell.placex);
const bool blendcolors = bargs->flags & NCVISUAL_OPTION_BLEND;
int dimy, dimx, x, y;
unsigned dimy, dimx, x, y;
int total = 0; // number of cells written
ncplane_dim_yx(nc, &dimy, &dimx);
// FIXME not going to necessarily be safe on all architectures hrmmm
const unsigned char* dat = data;
int visy = bargs->begy;
for(y = bargs->u.cell.placey ; visy < (bargs->begy + leny) && y < dimy ; ++y, ++visy){
if(y < 0){
continue;
}
if(ncplane_cursor_move_yx(nc, y, bargs->u.cell.placex < 0 ? 0 : bargs->u.cell.placex)){
return -1;
}
int visx = bargs->begx;
for(x = bargs->u.cell.placex ; visx < (bargs->begx + lenx) && x < dimx ; ++x, ++visx){
if(x < 0){
continue;
}
const unsigned char* rgbbase_up = dat + (linesize * visy) + (visx * 4);
//fprintf(stderr, "[%04d/%04d] lsize: %d %02x %02x %02x %02x\n", y, x, linesize, rgbbase_up[0], rgbbase_up[1], rgbbase_up[2], rgbbase_up[3]);
nccell* c = ncplane_cell_ref_yx(nc, y, x);
@ -122,24 +116,18 @@ tria_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx,
const bool blendcolors = bargs->flags & NCVISUAL_OPTION_BLEND;
//fprintf(stderr, "HALF %d X %d @ %d X %d (%p) place: %d X %d\n", leny, lenx, bargs->begy, bargs->begx, data, bargs->u.cell.placey, bargs->u.cell.placex);
uint32_t transcolor = bargs->transcolor;
int dimy, dimx, x, y;
unsigned dimy, dimx, x, y;
int total = 0; // number of cells written
ncplane_dim_yx(nc, &dimy, &dimx);
// FIXME not going to necessarily be safe on all architectures hrmmm
const unsigned char* dat = data;
int visy = bargs->begy;
for(y = bargs->u.cell.placey ; visy < (bargs->begy + leny) && y < dimy ; ++y, visy += 2){
if(y < 0){
continue;
}
if(ncplane_cursor_move_yx(nc, y, bargs->u.cell.placex < 0 ? 0 : bargs->u.cell.placex)){
return -1;
}
int visx = bargs->begx;
for(x = bargs->u.cell.placex ; visx < (bargs->begx + lenx) && x < dimx ; ++x, ++visx){
if(x < 0){
continue;
}
const unsigned char* rgbbase_up = dat + (linesize * visy) + (visx * 4);
const unsigned char* rgbbase_down = zeroes;
if(visy < bargs->begy + leny - 1){
@ -453,7 +441,7 @@ quadrant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx,
const blitterargs* bargs){
const unsigned nointerpolate = bargs->flags & NCVISUAL_OPTION_NOINTERPOLATE;
const bool blendcolors = bargs->flags & NCVISUAL_OPTION_BLEND;
int dimy, dimx, x, y;
unsigned dimy, dimx, x, y;
int total = 0; // number of cells written
ncplane_dim_yx(nc, &dimy, &dimx);
//fprintf(stderr, "quadblitter %dx%d -> %d/%d+%d/%d\n", leny, lenx, dimy, dimx, bargs->u.cell.placey, bargs->u.cell.placex);
@ -461,17 +449,11 @@ quadrant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx,
const unsigned char* dat = data;
int visy = bargs->begy;
for(y = bargs->u.cell.placey ; visy < (bargs->begy + leny) && y < dimy ; ++y, visy += 2){
if(y < 0){
continue;
}
if(ncplane_cursor_move_yx(nc, y, bargs->u.cell.placex < 0 ? 0 : bargs->u.cell.placex)){
return -1;
}
int visx = bargs->begx;
for(x = bargs->u.cell.placex ; visx < (bargs->begx + lenx) && x < dimx ; ++x, visx += 2){
if(x < 0){
continue;
}
const unsigned char* rgbbase_tl = dat + (linesize * visy) + (visx * 4);
const unsigned char* rgbbase_tr = zeroes;
const unsigned char* rgbbase_bl = zeroes;
@ -674,24 +656,18 @@ sextant_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx,
const blitterargs* bargs){
const unsigned nointerpolate = bargs->flags & NCVISUAL_OPTION_NOINTERPOLATE;
const bool blendcolors = bargs->flags & NCVISUAL_OPTION_BLEND;
int dimy, dimx, x, y;
unsigned dimy, dimx, x, y;
int total = 0; // number of cells written
ncplane_dim_yx(nc, &dimy, &dimx);
//fprintf(stderr, "sexblitter %dx%d -> %d/%d+%d/%d\n", leny, lenx, dimy, dimx, bargs->u.cell.placey, bargs->u.cell.placex);
const unsigned char* dat = data;
int visy = bargs->begy;
for(y = bargs->u.cell.placey ; visy < (bargs->begy + leny) && y < dimy ; ++y, visy += 3){
if(y < 0){
continue;
}
if(ncplane_cursor_move_yx(nc, y, bargs->u.cell.placex < 0 ? 0 : bargs->u.cell.placex)){
return -1;
}
int visx = bargs->begx;
for(x = bargs->u.cell.placex ; visx < (bargs->begx + lenx) && x < dimx ; ++x, visx += 2){
if(x < 0){
continue;
}
uint32_t rgbas[6] = { 0, 0, 0, 0, 0, 0 };
memcpy(&rgbas[0], (dat + (linesize * visy) + (visx * 4)), sizeof(*rgbas));
if(visx < bargs->begx + lenx - 1){
@ -748,24 +724,18 @@ static inline int
braille_blit(ncplane* nc, int linesize, const void* data, int leny, int lenx,
const blitterargs* bargs){
const bool blendcolors = bargs->flags & NCVISUAL_OPTION_BLEND;
int dimy, dimx, x, y;
unsigned dimy, dimx, x, y;
int total = 0; // number of cells written
ncplane_dim_yx(nc, &dimy, &dimx);
// FIXME not going to necessarily be safe on all architectures hrmmm
const unsigned char* dat = data;
int visy = bargs->begy;
for(y = bargs->u.cell.placey ; visy < (bargs->begy + leny) && y < dimy ; ++y, visy += 4){
if(y < 0){
continue;
}
if(ncplane_cursor_move_yx(nc, y, bargs->u.cell.placex < 0 ? 0 : bargs->u.cell.placex)){
return -1;
}
int visx = bargs->begx;
for(x = bargs->u.cell.placex ; visx < (bargs->begx + lenx) && x < dimx ; ++x, visx += 2){
if(x < 0){
continue;
}
const uint32_t* rgbbase_l0 = (const uint32_t*)(dat + (linesize * visy) + (visx * 4));
const uint32_t* rgbbase_r0 = &zeroes32;
const uint32_t* rgbbase_l1 = &zeroes32;

@ -144,8 +144,8 @@ int ncdirect_clear(ncdirect* nc){
return -1;
}
int ncdirect_dim_x(ncdirect* nc){
int x;
unsigned ncdirect_dim_x(ncdirect* nc){
unsigned x;
if(nc->tcache.ttyfd >= 0){
if(update_term_dimensions(NULL, &x, &nc->tcache, 0) == 0){
return x;
@ -153,11 +153,11 @@ int ncdirect_dim_x(ncdirect* nc){
}else{
return 80; // lol
}
return -1;
return 0;
}
int ncdirect_dim_y(ncdirect* nc){
int y;
unsigned ncdirect_dim_y(ncdirect* nc){
unsigned y;
if(nc->tcache.ttyfd >= 0){
if(update_term_dimensions(&y, NULL, &nc->tcache, 0) == 0){
return y;
@ -165,7 +165,7 @@ int ncdirect_dim_y(ncdirect* nc){
}else{
return 24; // lol
}
return -1;
return 0;
}
int ncdirect_cursor_enable(ncdirect* nc){
@ -185,12 +185,12 @@ int ncdirect_cursor_disable(ncdirect* nc){
}
static int
cursor_yx_get(ncdirect* n, const char* u7, int* y, int* x){
cursor_yx_get(ncdirect* n, const char* u7, unsigned* y, unsigned* x){
struct inputctx* ictx = n->tcache.ictx;
if(ncdirect_flush(n)){
return -1;
}
int fakey, fakex;
unsigned fakey, fakex;
if(y == NULL){
y = &fakey;
}
@ -198,7 +198,7 @@ cursor_yx_get(ncdirect* n, const char* u7, int* y, int* x){
x = &fakex;
}
get_cursor_location(ictx, u7, y, x);
loginfo("cursor at y=%d x=%d\n", *y, *x);
loginfo("cursor at y=%u x=%u\n", *y, *x);
return 0;
}
@ -215,9 +215,11 @@ int ncdirect_cursor_move_yx(ncdirect* n, int y, int x){
if(hpa){
return term_emit(tiparm(hpa, x), n->ttyfp, false);
}else if(n->tcache.ttyfd >= 0 && u7){
if(cursor_yx_get(n, u7, &y, NULL)){
unsigned yprime;
if(cursor_yx_get(n, u7, &yprime, NULL)){
return -1;
}
y = yprime;
}else{
y = 0;
}
@ -225,9 +227,11 @@ int ncdirect_cursor_move_yx(ncdirect* n, int y, int x){
if(!vpa){
return term_emit(tiparm(vpa, y), n->ttyfp, false);
}else if(n->tcache.ttyfd >= 0 && u7){
if(cursor_yx_get(n, u7, NULL, &x)){
unsigned xprime;
if(cursor_yx_get(n, u7, NULL, &xprime)){
return -1;
}
x = xprime;
}else{
x = 0;
}
@ -362,7 +366,7 @@ detect_cursor_inversion_wrapper(ncdirect* n, const char* u7, int* y, int* x){
// no terminfo capability for this. dangerous--it involves writing controls to
// the terminal, and then reading a response.
int ncdirect_cursor_yx(ncdirect* n, int* y, int* x){
int ncdirect_cursor_yx(ncdirect* n, unsigned* y, unsigned* x){
// this is only meaningful for real terminals
if(n->tcache.ttyfd < 0){
return -1;
@ -372,7 +376,7 @@ int ncdirect_cursor_yx(ncdirect* n, int* y, int* x){
fprintf(stderr, "Terminal doesn't support cursor reporting\n");
return -1;
}
int yval, xval;
unsigned yval, xval;
if(!y){
y = &yval;
}
@ -417,10 +421,10 @@ ncdirect_align(struct ncdirect* n, ncalign_e align, int c){
// y is an out-only param, indicating the location where drawing started
static int
ncdirect_dump_sprixel(ncdirect* n, const ncplane* np, int xoff, int* y, fbuf* f){
int dimy, dimx;
ncdirect_dump_sprixel(ncdirect* n, const ncplane* np, int xoff, unsigned* y, fbuf* f){
unsigned dimy, dimx;
ncplane_dim_yx(np, &dimy, &dimx);
const int toty = ncdirect_dim_y(n);
const unsigned toty = ncdirect_dim_y(n);
// flush our FILE*, as we're about to use UNIX I/O (since we can't rely on
// stdio to transfer large amounts at once).
if(ncdirect_flush(n)){
@ -431,9 +435,10 @@ ncdirect_dump_sprixel(ncdirect* n, const ncplane* np, int xoff, int* y, fbuf* f)
}
if(toty - dimy < *y){
int scrolls = *y - 1;
*y = toty - dimy;
if(*y < 0){
if(toty <= dimy){
*y = 0;
}else{
*y = toty - dimy;
}
scrolls -= *y;
// perform our scrolling outside of the fbuf framework, as we need it
@ -504,16 +509,16 @@ ncdirect_set_fg_default_f(ncdirect* nc, fbuf* f){
static int
ncdirect_dump_cellplane(ncdirect* n, const ncplane* np, fbuf* f, int xoff){
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(np, &dimy, &dimx);
const int toty = ncdirect_dim_y(n);
const unsigned toty = ncdirect_dim_y(n);
// save the existing style and colors
const bool fgdefault = ncdirect_fg_default_p(n);
const bool bgdefault = ncdirect_bg_default_p(n);
const uint32_t fgrgb = ncchannels_fg_rgb(n->channels);
const uint32_t bgrgb = ncchannels_bg_rgb(n->channels);
for(int y = 0 ; y < dimy ; ++y){
for(int x = 0 ; x < dimx ; ++x){
for(unsigned y = 0 ; y < dimy ; ++y){
for(unsigned x = 0 ; x < dimx ; ++x){
uint16_t stylemask;
uint64_t channels;
char* egc = ncplane_at_yx(np, y, x, &stylemask, &channels);
@ -580,7 +585,7 @@ ncdirect_dump_plane(ncdirect* n, const ncplane* np, int xoff){
return -1;
}
if(np->sprite){
int y;
unsigned y;
if(ncdirect_dump_sprixel(n, np, xoff, &y, &f)){
fbuf_free(&f);
return -1;
@ -628,10 +633,6 @@ ncdirect_render_visual(ncdirect* n, ncvisual* ncv,
if(!vopts){
vopts = &defvopts;
}
if(vopts->leny < 0 || vopts->lenx < 0){
fprintf(stderr, "Invalid render geometry %d/%d\n", vopts->leny, vopts->lenx);
return NULL;
}
//fprintf(stderr, "OUR DATA: %p rows/cols: %d/%d outsize: %d/%d %d/%d\n", ncv->data, ncv->pixy, ncv->pixx, dimy, dimx, ymax, xmax);
//fprintf(stderr, "render %d/%d to scaling: %d\n", ncv->pixy, ncv->pixx, vopts->scaling);
const struct blitset* bset = rgba_blitter_low(&n->tcache, vopts->scaling,
@ -640,11 +641,11 @@ ncdirect_render_visual(ncdirect* n, ncvisual* ncv,
if(!bset){
return NULL;
}
int ymax = vopts->leny / bset->height;
int xmax = vopts->lenx / bset->width;
unsigned ymax = vopts->leny / bset->height;
unsigned xmax = vopts->lenx / bset->width;
unsigned dimy = vopts->leny > 0 ? ymax : ncdirect_dim_y(n);
unsigned dimx = vopts->lenx > 0 ? xmax : ncdirect_dim_x(n);
int disprows, dispcols, outy;
unsigned disprows, dispcols, outy;
if(vopts->scaling != NCSCALE_NONE && vopts->scaling != NCSCALE_NONE_HIRES){
if(bset->geom != NCBLIT_PIXEL){
dispcols = dimx * encoding_x_scale(&n->tcache, bset);
@ -964,12 +965,12 @@ char* ncdirect_readline(ncdirect* n, const char* prompt){
}
int dimx = ncdirect_dim_x(n);
// FIXME what if we're reading from redirected input, not a terminal?
int y, xstart;
unsigned y, xstart;
if(cursor_yx_get(n, u7, &y, &xstart)){
return NULL;
}
int tline = y;
int bline = y;
unsigned bline = y;
wchar_t* str;
int wspace = BUFSIZ / sizeof(*str);
if((str = malloc(wspace * sizeof(*str))) == NULL){
@ -980,7 +981,7 @@ char* ncdirect_readline(ncdirect* n, const char* prompt){
str[wused++] = L'\0';
ncinput ni;
uint32_t id;
int oldx = xstart;
unsigned oldx = xstart;
while((id = ncdirect_getc_blocking(n, &ni)) != (uint32_t)-1){
if(ni.evtype == NCTYPE_RELEASE){
continue;
@ -1040,7 +1041,7 @@ char* ncdirect_readline(ncdirect* n, const char* prompt){
str[wused - 1] = L'\0';
}
// FIXME check modifiers
int x;
unsigned x;
if(cursor_yx_get(n, u7, &y, &x)){
break;
}
@ -1521,7 +1522,7 @@ int ncdirect_stream(ncdirect* n, const char* filename, ncstreamcb streamer,
}
// starting position *after displaying one frame* so as to effect any
// necessary scrolling.
int y = -1, x = -1;
unsigned y = 0, x = 0;
int lastid = -1;
int thisid = -1;
do{
@ -1587,7 +1588,8 @@ ncdirectv* ncdirectf_render(ncdirect* n, ncdirectf* frame, const struct ncvisual
int ncdirectf_geom(ncdirect* n, ncdirectf* frame,
const struct ncvisual_options* vopts, ncvgeom* geom){
const struct blitset* bset;
int disppxy, disppxx, outy, outx, placey, placex;
unsigned disppxy, disppxx, outy, outx;
int placey, placex;
return ncvisual_geom_inner(&n->tcache, frame, vopts, geom, &bset,
&disppxy, &disppxx, &outy, &outx,
&placey, &placex);

@ -3,8 +3,8 @@
#include "internal.h"
typedef struct ncfadectx {
int rows; // number of rows when allocated
int cols; // number of columns when allocated
unsigned rows; // number of rows when allocated
unsigned cols; // number of columns when allocated
int maxsteps; // maximum number of iterations
unsigned maxr, maxg, maxb; // maxima across foreground channels
unsigned maxbr, maxbg, maxbb; // maxima across background channels
@ -32,9 +32,9 @@ alloc_ncplane_palette(ncplane* n, ncfadectx* pp, const struct timespec* ts){
pp->maxbr = pp->maxbg = pp->maxbb = 0;
unsigned r, g, b, br, bg, bb;
uint64_t channels;
int y, x;
unsigned y;
for(y = 0 ; y < pp->rows ; ++y){
for(x = 0 ; x < pp->cols ; ++x){
for(unsigned x = 0 ; x < pp->cols ; ++x){
channels = n->fb[nfbcellidx(n, y, x)].channels;
pp->channels[y * pp->cols + x] = channels;
ncchannels_fg_rgb8(channels, &r, &g, &b);
@ -108,13 +108,13 @@ alloc_ncplane_palette(ncplane* n, ncfadectx* pp, const struct timespec* ts){
int ncplane_fadein_iteration(ncplane* n, ncfadectx* nctx, int iter,
fadecb fader, void* curry){
int y, x;
// each time through, we need look each cell back up, due to the
// possibility of a resize event :/
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(n, &dimy, &dimx);
unsigned y;
for(y = 0 ; y < nctx->rows && y < dimy ; ++y){
for(x = 0 ; x < nctx->cols && x < dimx; ++x){
for(unsigned x = 0 ; x < nctx->cols && x < dimx; ++x){
unsigned r, g, b;
ncchannels_fg_rgb8(nctx->channels[nctx->cols * y + x], &r, &g, &b);
unsigned br, bg, bb;
@ -175,13 +175,13 @@ int ncplane_fadeout_iteration(ncplane* n, ncfadectx* nctx, int iter,
fadecb fader, void* curry){
unsigned br, bg, bb;
unsigned r, g, b;
int y, x;
// each time through, we need look each cell back up, due to the
// possibility of a resize event :/
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(n, &dimy, &dimx);
unsigned y;
for(y = 0 ; y < nctx->rows && y < dimy ; ++y){
for(x = 0 ; x < nctx->cols && x < dimx; ++x){
for(unsigned x = 0 ; x < nctx->cols && x < dimx; ++x){
nccell* c = &n->fb[dimx * y + x];
if(!nccell_fg_default_p(c)){
ncchannels_fg_rgb8(nctx->channels[nctx->cols * y + x], &r, &g, &b);

@ -1,8 +1,8 @@
#include "internal.h"
void ncplane_greyscale(ncplane *n){
for(int y = 0 ; y < n->leny ; ++y){
for(int x = 0 ; x < n->lenx ; ++x){
for(unsigned y = 0 ; y < n->leny ; ++y){
for(unsigned x = 0 ; x < n->lenx ; ++x){
nccell* c = &n->fb[nfbcellidx(n, y, x)];
unsigned r, g, b;
nccell_fg_rgb8(c, &r, &g, &b);
@ -20,11 +20,8 @@ void ncplane_greyscale(ncplane *n){
// success. so a return of 0 means there's no work to be done here, and N means
// we did some work here, filling everything we could reach. out-of-plane is 0.
static int
ncplane_polyfill_recurse(ncplane* n, int y, int x, const nccell* c, const char* filltarg){
if(y >= n->leny || x >= n->lenx){
return 0; // not fillable
}
if(y < 0 || x < 0){
ncplane_polyfill_recurse(ncplane* n, unsigned y, unsigned x, const nccell* c, const char* filltarg){
if(y >= (unsigned)n->leny || x >= (unsigned)n->lenx){
return 0; // not fillable
}
nccell* cur = &n->fb[nfbcellidx(n, y, x)];
@ -38,18 +35,22 @@ ncplane_polyfill_recurse(ncplane* n, int y, int x, const nccell* c, const char*
}
int r, ret = 1;
//fprintf(stderr, "blooming from %d/%d ret: %d\n", y, x, ret);
if((r = ncplane_polyfill_recurse(n, y - 1, x, c, filltarg)) < 0){
return -1;
if(y){
if((r = ncplane_polyfill_recurse(n, y - 1, x, c, filltarg)) < 0){
return -1;
}
ret += r;
}
ret += r;
if((r = ncplane_polyfill_recurse(n, y + 1, x, c, filltarg)) < 0){
return -1;
}
ret += r;
if((r = ncplane_polyfill_recurse(n, y, x - 1, c, filltarg)) < 0){
return -1;
if(x){
if((r = ncplane_polyfill_recurse(n, y, x - 1, c, filltarg)) < 0){
return -1;
}
ret += r;
}
ret += r;
if((r = ncplane_polyfill_recurse(n, y, x + 1, c, filltarg)) < 0){
return -1;
}
@ -57,32 +58,42 @@ ncplane_polyfill_recurse(ncplane* n, int y, int x, const nccell* c, const char*
return ret;
}
// at the initial step only, invalid y, x is an error, so explicitly check.
int ncplane_polyfill_yx(ncplane* n, int y, int x, const nccell* c){
// at the initial step only, invalid ystart, xstart is an error, so explicitly check.
int ncplane_polyfill_yx(ncplane* n, int ystart, int xstart, const nccell* c){
int ret = -1;
if(y < n->leny && x < n->lenx){
if(y >= 0 && x >= 0){
if(y >= n->leny || x >= n->lenx){
return -1; // not fillable
}
if(y < 0 || x < 0){
return -1; // not fillable
}
const nccell* cur = &n->fb[nfbcellidx(n, y, x)];
const char* targ = nccell_extended_gcluster(n, cur);
const char* fillegc = nccell_extended_gcluster(n, c);
//fprintf(stderr, "checking %d/%d (%s) for [%s]\n", y, x, targ, fillegc);
if(strcmp(fillegc, targ) == 0){
return 0;
}
// we need an external copy of this, since we'll be writing to it on
// the first call into ncplane_polyfill_recurse()
char* targcopy = strdup(targ);
if(targcopy){
ret = ncplane_polyfill_recurse(n, y, x, c, targcopy);
free(targcopy);
}
if(ystart < 0){
if(ystart != -1){
logerror("invalid ystart: %d\n", ystart);
return -1;
}
ystart = n->y;
}
unsigned y = ystart;
if(xstart < 0){
if(xstart != -1){
logerror("invalid xstart: %d\n", xstart);
return -1;
}
xstart = n->x;
}
unsigned x = xstart;
if(y >= n->leny || x >= n->lenx){
logerror("invalid start: %u/%u (%u/%u)\n", y, x, n->leny, n->lenx);
return -1;
}
const nccell* cur = &n->fb[nfbcellidx(n, y, x)];
const char* targ = nccell_extended_gcluster(n, cur);
const char* fillegc = nccell_extended_gcluster(n, c);
//fprintf(stderr, "checking %d/%d (%s) for [%s]\n", y, x, targ, fillegc);
if(strcmp(fillegc, targ) == 0){
return 0;
}
// we need an external copy of this, since we'll be writing to it on
// the first call into ncplane_polyfill_recurse()
char* targcopy = strdup(targ);
if(targcopy){
ret = ncplane_polyfill_recurse(n, y, x, c, targcopy);
free(targcopy);
}
return ret;
}
@ -93,16 +104,19 @@ check_gradient_channel_args(uint32_t ul, uint32_t ur, uint32_t bl, uint32_t br){
ncchannel_default_p(bl) || ncchannel_default_p(br)){
if(!(ncchannel_default_p(ul) && ncchannel_default_p(ur) &&
ncchannel_default_p(bl) && ncchannel_default_p(br))){
logerror("some (not all) channels were defaults\n");
return true;
}
}
if(ncchannel_alpha(ul) != ncchannel_alpha(ur) ||
ncchannel_alpha(ur) != ncchannel_alpha(bl) ||
ncchannel_alpha(bl) != ncchannel_alpha(br)){
logerror("channel alphas didn't match\n");
return true;
}
if(ncchannel_palindex_p(ul) || ncchannel_palindex_p(bl) ||
ncchannel_palindex_p(br) || ncchannel_palindex_p(ur)){
logerror("can't blend palette-indexed color\n");
return true;
}
return false;
@ -127,11 +141,75 @@ bool check_gradient_args(uint64_t ul, uint64_t ur, uint64_t bl, uint64_t br){
return false;
}
// takes a signed starting coordinate (where -1 indicates the cursor's
// position), and an unsigned vector (where 0 indicates "everything
// remaining", i.e. to the right and below). returns 0 iff everything
// is valid and on the plane, filling in 'ystart'/'xstart' with the
// (non-negative) starting coordinates and 'ylen'/'xlen with the
// (positive) dimensions of the affected area.
static int
check_geometry_args(const ncplane* n, int y, int x,
unsigned* ylen, unsigned* xlen,
unsigned* ystart, unsigned* xstart){
// handle the special -1 case for y/x, and reject other negatives
if(y < 0){
if(y != -1){
logerror("invalid y: %d\n", y);
return -1;
}
y = n->y;
}
if(x < 0){
if(x != -1){
logerror("invalid x: %d\n", x);
return -1;
}
x = n->x;
}
// y and x are both now definitely positive, but might be off-plane.
// lock in y and x as ystart and xstart for unsigned comparisons.
*ystart = y;
*xstart = x;
unsigned ymax, xmax;
ncplane_dim_yx(n, &ymax, &xmax);
if(*ystart >= ymax || *xstart >= xmax){
logerror("invalid starting coordinates: %u/%u\n", *ystart, *xstart);
return -1;
}
// handle the special 0 case for ylen/xlen
if(*ylen == 0){
*ylen = ymax - *ystart;
}
if(*xlen == 0){
*xlen = xmax - *xstart;
}
// ensure ylen/xlen are on-plane
if(*ylen > ymax){
logerror("ylen > dimy %u > %u\n", *ylen, ymax);
return -1;
}
if(*xlen > xmax){
logerror("xlen > dimx %u > %u\n", *xlen, xmax);
return -1;
}
// ensure x + xlen and y + ylen are on-plane, without overflow
if(ymax - *ylen < *ystart){
logerror("y + ylen > ymax %u + %u > %u\n", *ystart, *ylen, ymax);
return -1;
}
if(xmax - *xlen < *xstart){
logerror("x + xlen > xmax %u + %u > %u\n", *xstart, *xlen, xmax);
return -1;
}
return 0;
}
// calculate both channels of a gradient at a particular point, knowing that
// we're using double halfblocks, into `c`->channels.
static inline void
calc_highgradient(nccell* c, uint32_t ul, uint32_t ur, uint32_t ll,
uint32_t lr, int y, int x, int ylen, int xlen){
uint32_t lr, unsigned y, unsigned x,
unsigned ylen, unsigned xlen){
if(!ncchannel_default_p(ul)){
cell_set_fchannel(c, calc_gradient_channel(ul, ur, ll, lr,
y * 2, x, ylen, xlen));
@ -143,159 +221,116 @@ calc_highgradient(nccell* c, uint32_t ul, uint32_t ur, uint32_t ll,
}
}
int ncplane_highgradient(ncplane* n, uint32_t ul, uint32_t ur,
uint32_t ll, uint32_t lr, int ystop, int xstop){
int ncplane_gradient2x1(ncplane* n, int y, int x, unsigned ylen, unsigned xlen,
uint32_t ul, uint32_t ur, uint32_t ll, uint32_t lr){
if(!notcurses_canutf8(ncplane_notcurses(n))){
logerror("Highdef gradients require UTF8\n");
logerror("highdef gradients require utf8\n");
return -1;
}
if(check_gradient_channel_args(ul, ur, ll, lr)){
logerror("Invalid highdef gradient channels\n");
return -1;
}
int yoff, xoff, ymax, xmax;
ncplane_cursor_yx(n, &yoff, &xoff);
// must be at least 1x1, with its upper-left corner at the current cursor
if(ystop < yoff){
return -1;
}
if(xstop < xoff){
return -1;
}
ncplane_dim_yx(n, &ymax, &xmax);
// must be within the ncplane
if(xstop >= xmax || ystop >= ymax){
unsigned ystart, xstart;
if(check_geometry_args(n, y, x, &ylen, &xlen, &ystart, &xstart)){
return -1;
}
const int xlen = xstop - xoff + 1;
const int ylen = (ystop - yoff + 1) * 2;
if(xlen == 1){
if(ul != ur || ll != lr){
logerror("horizontal channel variation in single column\n");
return -1;
}
}
int total = 0;
for(int y = yoff ; y <= ystop ; ++y){
for(int x = xoff ; x <= xstop ; ++x){
nccell* targc = ncplane_cell_ref_yx(n, y, x);
for(unsigned yy = ystart ; yy < ystart + ylen ; ++yy){
for(unsigned xx = xstart ; xx < xstart + xlen ; ++xx){
nccell* targc = ncplane_cell_ref_yx(n, yy, xx);
targc->channels = 0;
if(pool_blit_direct(&n->pool, targc, "", strlen(""), 1) <= 0){
return -1;
}
calc_highgradient(targc, ul, ur, ll, lr, y - yoff, x - xoff, ylen, xlen);
calc_highgradient(targc, ul, ur, ll, lr, yy - ystart, xx - xstart, ylen, xlen);
++total;
}
}
return total;
}
// FIXME remove in abi3
int ncplane_highgradient_sized(ncplane* n, uint32_t ul, uint32_t ur,
uint32_t ll, uint32_t lr, int ylen, int xlen){
if(ylen < 1 || xlen < 1){
return -1;
}
int y, x;
if(!notcurses_canutf8(ncplane_notcurses_const(n))){
// this works because the uin32_ts we pass in will be promoted to uint64_ts
// via extension, and the space will employ the background. mwahh!
return ncplane_gradient_sized(n, " ", 0, ul, ur, ll, lr, ylen, xlen);
return ncplane_gradient(n, -1, -1, ylen, xlen, " ", 0, ul, ur, ll, lr);
}
ncplane_cursor_yx(n, &y, &x);
return ncplane_highgradient(n, ul, ur, ll, lr, y + ylen - 1, x + xlen - 1);
return ncplane_gradient2x1(n, -1, -1, ylen, xlen, ul, ur, ll, lr);
}
int ncplane_gradient(ncplane* n, const char* egc, uint32_t stylemask,
uint64_t ul, uint64_t ur, uint64_t bl, uint64_t br,
int ystop, int xstop){
int ncplane_gradient(ncplane* n, int y, int x, unsigned ylen, unsigned xlen,
const char* egc, uint16_t stylemask,
uint64_t ul, uint64_t ur, uint64_t bl, uint64_t br){
if(check_gradient_args(ul, ur, bl, br)){
logerror("Illegal gradient inputs\n");
return -1;
}
if(egc == NULL){
unsigned ystart, xstart;
if(check_geometry_args(n, y, x, &ylen, &xlen, &ystart, &xstart)){
return -1;
}
int yoff, xoff, ymax, xmax;
ncplane_cursor_yx(n, &yoff, &xoff);
// must be at least 1x1, with its upper-left corner at the current cursor
if(ystop < yoff){
logerror("Ystop %d < yoff %d\n", ystop, yoff);
return -1;
}
if(xstop < xoff){
logerror("Xstop %d < xoff %d\n", xstop, xoff);
return -1;
}
ncplane_dim_yx(n, &ymax, &xmax);
// must be within the ncplane
if(xstop >= xmax || ystop >= ymax){
return -1;
}
const int xlen = xstop - xoff + 1;
const int ylen = ystop - yoff + 1;
if(ylen == 1){
if(xlen == 1){
if(ul != ur || ur != br || br != bl){
logerror("channel variation in 1x1 area\n");
return -1;
}
}else{
if(ul != bl || ur != br){
logerror("vertical channel variation in single row\n");
return -1;
}
}
}else if(xlen == 1){
if(ul != ur || bl != br){
logerror("horizontal channel variation in single column\n");
return -1;
}
}
int total = 0;
for(int y = yoff ; y <= ystop ; ++y){
for(int x = xoff ; x <= xstop ; ++x){
nccell* targc = ncplane_cell_ref_yx(n, y, x);
for(unsigned yy = ystart ; yy < ystart + ylen ; ++yy){
for(unsigned xx = xstart ; xx < xstart + xlen ; ++xx){
nccell* targc = ncplane_cell_ref_yx(n, yy, xx);
targc->channels = 0;
if(nccell_load(n, targc, egc) < 0){
return -1;
}
targc->stylemask = stylemask;
calc_gradient_channels(&targc->channels, ul, ur, bl, br,
y - yoff, x - xoff, ylen, xlen);
yy - ystart, xx - xstart, ylen, xlen);
++total;
}
}
return total;
}
int ncplane_stain(ncplane* n, int ystop, int xstop,
int ncplane_stain(ncplane* n, int y, int x, unsigned ylen, unsigned xlen,
uint64_t tl, uint64_t tr, uint64_t bl, uint64_t br){
// Can't use default or palette-indexed colors in a gradient
if(check_gradient_args(tl, tr, bl, br)){
logerror("Illegal staining inputs\n");
return -1;
}
int yoff, xoff, ymax, xmax;
ncplane_cursor_yx(n, &yoff, &xoff);
// must be at least 1x1, with its upper-left corner at the current cursor
if(ystop < yoff){
logerror("Ystop %d < yoff %d\n", ystop, yoff);
return -1;
}
if(xstop < xoff){
logerror("Xstop %d < xoff %d\n", xstop, xoff);
unsigned ystart, xstart;
if(check_geometry_args(n, y, x, &ylen, &xlen, &ystart, &xstart)){
return -1;
}
ncplane_dim_yx(n, &ymax, &xmax);
// must be within the ncplane
if(xstop >= xmax || ystop >= ymax){
return -1;
}
const int xlen = xstop - xoff + 1;
const int ylen = ystop - yoff + 1;
int total = 0;
for(int y = yoff ; y <= ystop ; ++y){
for(int x = xoff ; x <= xstop ; ++x){
nccell* targc = ncplane_cell_ref_yx(n, y, x);
for(unsigned yy = ystart ; yy < ystart + ylen ; ++yy){
for(unsigned xx = xstart ; xx < xstart + xlen ; ++xx){
nccell* targc = ncplane_cell_ref_yx(n, yy, xx);
if(targc->gcluster){
calc_gradient_channels(&targc->channels, tl, tr, bl, br,
y - yoff, x - xoff, ylen, xlen);
yy - ystart, xx - xstart, ylen, xlen);
}
++total;
}
@ -303,25 +338,16 @@ int ncplane_stain(ncplane* n, int ystop, int xstop,
return total;
}
int ncplane_format(ncplane* n, int ystop, int xstop, uint32_t stylemask){
int yoff, xoff, ymax, xmax;
ncplane_cursor_yx(n, &yoff, &xoff);
// must be at least 1x1, with its upper-left corner at the current cursor
if(ystop < yoff){
return -1;
}
if(xstop < xoff){
return -1;
}
ncplane_dim_yx(n, &ymax, &xmax);
// must be within the ncplane
if(xstop >= xmax || ystop >= ymax){
int ncplane_format(ncplane* n, int y, int x, unsigned ylen,
unsigned xlen, uint16_t stylemask){
unsigned ystart, xstart;
if(check_geometry_args(n, y, x, &ylen, &xlen, &ystart, &xstart)){
return -1;
}
int total = 0;
for(int y = yoff ; y < ystop + 1 ; ++y){
for(int x = xoff ; x < xstop + 1 ; ++x){
nccell* targc = ncplane_cell_ref_yx(n, y, x);
for(unsigned yy = ystart ; yy < ystart + ylen ; ++yy){
for(unsigned xx = xstart ; xx < xstart + xlen ; ++xx){
nccell* targc = ncplane_cell_ref_yx(n, yy, xx);
targc->stylemask = stylemask;
++total;
}
@ -459,12 +485,12 @@ rotate_2x1_ccw(ncplane* src, ncplane* dst, int srcy, int srcx, int dsty, int dst
// copy 'newp' into 'n' after resizing 'n' to match 'newp'
static int
rotate_merge(ncplane* n, ncplane* newp){
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(newp, &dimy, &dimx);
int ret = ncplane_resize(n, 0, 0, 0, 0, 0, 0, dimy, dimx);
if(ret == 0){
for(int y = 0 ; y < dimy ; ++y){
for(int x = 0 ; x < dimx ; ++x){
for(unsigned y = 0 ; y < dimy ; ++y){
for(unsigned x = 0 ; x < dimx ; ++x){
const nccell* src = &newp->fb[fbcellidx(y, dimx, x)];
nccell* targ = &n->fb[fbcellidx(y, dimx, x)];
if(cell_duplicate_far(&n->pool, targ, newp, src) < 0){
@ -481,7 +507,7 @@ static ncplane*
rotate_plane(ncplane* n){
int absy, absx;
ncplane_yx(n, &absy, &absx);
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(n, &dimy, &dimx);
if(dimx % 2 != 0){
return NULL;
@ -505,7 +531,7 @@ int ncplane_rotate_cw(ncplane* n){
if(newp == NULL){
return -1;
}
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(n, &dimy, &dimx);
int centy, centx;
ncplane_center_abs(n, &centy, &centx);
@ -515,9 +541,9 @@ int ncplane_rotate_cw(ncplane* n){
// the top two leftmost cells. work from the bottom up on the source, so we
// can copy to the top row from the left to the right.
int targx, targy = 0;
for(int x = 0 ; x < dimx ; x += 2){
for(unsigned x = 0 ; x < dimx ; x += 2){
targx = 0;
for(int y = dimy - 1 ; y >= 0 ; --y){
for(int y = (int)dimy - 1 ; y >= 0 ; --y){
if(rotate_2x1_cw(n, newp, y, x, targy, targx)){
ncplane_destroy(newp);
return -1;
@ -536,15 +562,16 @@ int ncplane_rotate_ccw(ncplane* n){
if(newp == NULL){
return -1;
}
int dimy, dimx, targdimy, targdimx;
unsigned dimy, dimx, targdimy, targdimx;
ncplane_dim_yx(n, &dimy, &dimx);
ncplane_dim_yx(newp, &targdimy, &targdimx);
int x = dimx - 2, y;
int x = (int)dimx - 2;
int y;
// Each row of the target plane is taken from a column of the source plane.
// As the target row grows (down), the source column shrinks (moves left).
for(int targy = 0 ; targy < targdimy ; ++targy){
for(unsigned targy = 0 ; targy < targdimy ; ++targy){
y = 0;
for(int targx = 0 ; targx < targdimx ; targx += 2){
for(unsigned targx = 0 ; targx < targdimx ; targx += 2){
if(rotate_2x1_ccw(n, newp, y, x, targy, targx)){
ncplane_destroy(newp);
return -1;

@ -2212,7 +2212,7 @@ uint32_t ncdirect_getc(ncdirect* nc, const struct timespec *ts,
return ncdirect_get(nc, ts, ni);
}
int get_cursor_location(inputctx* ictx, const char* u7, int* y, int* x){
int get_cursor_location(inputctx* ictx, const char* u7, unsigned* y, unsigned* x){
pthread_mutex_lock(&ictx->clock);
while(ictx->cvalid == 0){
if(tty_emit(u7, ictx->ti->ttyfd)){

@ -82,7 +82,7 @@ struct initial_responses {
struct initial_responses* inputlayer_get_responses(struct inputctx* ictx)
__attribute__ ((nonnull (1)));
int get_cursor_location(struct inputctx* ictx, const char* u7, int* y, int* x)
int get_cursor_location(struct inputctx* ictx, const char* u7, unsigned* y, unsigned* x)
__attribute__ ((nonnull (1, 2)));
#ifdef __cplusplus

@ -81,7 +81,7 @@ typedef struct ncplane {
int absx, absy; // origin of the plane relative to the pile's origin
// also used as left and top margin on resize by
// ncplane_resize_marginalized()
int lenx, leny; // size of the plane, [0..len{x,y}) is addressable
unsigned lenx, leny; // size of the plane, [0..len{x,y}) is addressable
egcpool pool; // attached storage pool for UTF-8 EGCs
uint64_t channels; // works the same way as cells
@ -294,7 +294,7 @@ typedef struct ncpile {
struct notcurses* nc; // notcurses context
struct ncpile *prev, *next; // circular list
size_t crenderlen; // size of crender vector
int dimy, dimx; // rows and cols at time of render
unsigned dimy, dimx; // rows and cols at time of last render
int scrolls; // how many real lines need be scrolled at raster
sprixel* sprixelcache; // list of sprixels
} ncpile;
@ -317,8 +317,8 @@ typedef struct notcurses {
ncpile* last_pile;
egcpool pool; // egcpool for lastframe
int lfdimx; // dimensions of lastframe, unchanged by screen resize
int lfdimy; // lfdimx/lfdimy are 0 until first rasterization
unsigned lfdimx; // dimensions of lastframe, unchanged by screen resize
unsigned lfdimy; // lfdimx/lfdimy are 0 until first rasterization
int cursory; // desired cursor placement according to user.
int cursorx; // -1 is don't-care, otherwise moved here after each render.
@ -555,7 +555,7 @@ pool_extended_gcluster(const egcpool* pool, const nccell* c){
}
static inline nccell*
ncplane_cell_ref_yx(const ncplane* n, int y, int x){
ncplane_cell_ref_yx(const ncplane* n, unsigned y, unsigned x){
return &n->fb[nfbcellidx(n, y, x)];
}
@ -568,12 +568,12 @@ cell_debug(const egcpool* p, const nccell* c){
static inline void
plane_debug(const ncplane* n, bool details){
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(n, &dimy, &dimx);
fprintf(stderr, "p: %p dim: %d/%d poolsize: %d\n", n, dimy, dimx, n->pool.poolsize);
if(details){
for(int y = 0 ; y < 1 ; ++y){
for(int x = 0 ; x < 10 ; ++x){
for(unsigned y = 0 ; y < 1 ; ++y){
for(unsigned x = 0 ; x < 10 ; ++x){
const nccell* c = &n->fb[fbcellidx(y, dimx, x)];
fprintf(stderr, "[%03d/%03d] ", y, x);
cell_debug(&n->pool, c);
@ -764,7 +764,7 @@ sprite_rebuild(const notcurses* nc, sprixel* s, int ycell, int xcell){
// happy fact: common reported values for maximum sixel height are 256, 1024,
// and 4096...not a single goddamn one of which is divisible by six. augh.
static inline void
clamp_to_sixelmax(const tinfo* t, int* y, int* x, int* outy, ncscale_e scaling){
clamp_to_sixelmax(const tinfo* t, unsigned* y, unsigned* x, unsigned* outy, ncscale_e scaling){
if(t->sixel_maxy && *y > t->sixel_maxy){
*y = t->sixel_maxy;
}
@ -869,7 +869,7 @@ int ncplane_resize_internal(ncplane* n, int keepy, int keepx,
int yoff, int xoff,
unsigned ylen, unsigned xlen);
int update_term_dimensions(int* rows, int* cols, tinfo* tcache, int margin_b);
int update_term_dimensions(unsigned* rows, unsigned* cols, tinfo* tcache, int margin_b);
ALLOC static inline void*
memdup(const void* src, size_t len){
@ -935,7 +935,7 @@ int ncvisual_bounding_box(const struct ncvisual* ncv, int* leny, int* lenx,
// steps / 2 is to work around truncate-towards-zero).
static int
calc_gradient_component(unsigned tl, unsigned tr, unsigned bl, unsigned br,
int y, int x, int ylen, int xlen){
unsigned y, unsigned x, unsigned ylen, unsigned xlen){
const int avm = (ylen - 1) - y;
const int ahm = (xlen - 1) - x;
if(xlen < 2){
@ -958,7 +958,7 @@ calc_gradient_component(unsigned tl, unsigned tr, unsigned bl, unsigned br,
// calculate one of the channels of a gradient at a particular point.
static inline uint32_t
calc_gradient_channel(uint32_t ul, uint32_t ur, uint32_t ll, uint32_t lr,
int y, int x, int ylen, int xlen){
unsigned y, unsigned x, unsigned ylen, unsigned xlen){
uint32_t chan = 0;
ncchannel_set_rgb8_clipped(&chan,
calc_gradient_component(ncchannel_r(ul), ncchannel_r(ur),
@ -978,8 +978,8 @@ calc_gradient_channel(uint32_t ul, uint32_t ur, uint32_t ll, uint32_t lr,
// into `channels'. x and y ought be the location within the gradient.
static inline void
calc_gradient_channels(uint64_t* channels, uint64_t ul, uint64_t ur,
uint64_t ll, uint64_t lr, int y, int x,
int ylen, int xlen){
uint64_t ll, uint64_t lr, unsigned y, unsigned x,
unsigned ylen, unsigned xlen){
if(!ncchannels_fg_default_p(ul)){
ncchannels_set_fchannel(channels,
calc_gradient_channel(ncchannels_fchannel(ul),
@ -1548,7 +1548,8 @@ rgba_blit_dispatch(ncplane* nc, const struct blitset* bset,
int ncvisual_geom_inner(const tinfo* ti, const struct ncvisual* n,
const struct ncvisual_options* vopts, ncvgeom* geom,
const struct blitset** bset,
int* disppxy, int* disppxx, int* outy, int* outx,
unsigned* disppxy, unsigned* disppxx,
unsigned* outy, unsigned* outx,
int* placey, int* placex);
static inline const struct blitset*

@ -718,10 +718,10 @@ destroy_deflator(unsigned animated, z_stream* zctx, int pixy, int pixx){
static int
finalize_multiframe_selfref(sprixel* s, fbuf* f){
int prewiped = 0;
for(int y = 0 ; y < s->dimy ; ++y){
for(int x = 0 ; x < s->dimx ; ++x){
int tyxidx = y * s->dimx + x;
int state = s->n->tam[tyxidx].state;
for(unsigned y = 0 ; y < s->dimy ; ++y){
for(unsigned x = 0 ; x < s->dimx ; ++x){
unsigned tyxidx = y * s->dimx + x;
unsigned state = s->n->tam[tyxidx].state;
if(state >= SPRIXCELL_ANNIHILATED){
if(kitty_blit_wipe_selfref(s, f, y, x)){
return -1;
@ -730,7 +730,7 @@ finalize_multiframe_selfref(sprixel* s, fbuf* f){
}
}
}
loginfo("transitively wiped %d/%d\n", prewiped, s->dimy * s->dimx);
loginfo("transitively wiped %d/%u\n", prewiped, s->dimy * s->dimx);
return 0;
}
@ -1126,8 +1126,8 @@ int kitty_remove(int id, fbuf* f){
// damages cells underneath the graphic which were OPAQUE
int kitty_scrub(const ncpile* p, sprixel* s){
//fprintf(stderr, "FROM: %d/%d state: %d s->n: %p\n", s->movedfromy, s->movedfromx, s->invalidated, s->n);
for(int yy = s->movedfromy ; yy < s->movedfromy + s->dimy && yy < p->dimy ; ++yy){
for(int xx = s->movedfromx ; xx < s->movedfromx + s->dimx && xx < p->dimx ; ++xx){
for(unsigned yy = s->movedfromy ; yy < s->movedfromy + s->dimy && yy < p->dimy ; ++yy){
for(unsigned xx = s->movedfromx ; xx < s->movedfromx + s->dimx && xx < p->dimx ; ++xx){
const int ridx = yy * p->dimx + xx;
assert(0 <= ridx);
struct crender *r = &p->crender[ridx];

@ -12,7 +12,7 @@ typedef struct ncmenu_int_item {
typedef struct ncmenu_int_section {
char* name; // utf-8 c string
int itemcount;
unsigned itemcount;
ncmenu_int_item* items; // items, NULL iff itemcount == 0
ncinput shortcut; // shortcut, will be underlined if present in name
int xoff; // column offset from beginning of menu bar
@ -62,7 +62,7 @@ mbstr_find_codepoint(const char* s, uint32_t cp, int* col){
static void
free_menu_section(ncmenu_int_section* ms){
for(int i = 0 ; i < ms->itemcount ; ++i){
for(unsigned i = 0 ; i < ms->itemcount ; ++i){
free(ms->items[i].desc);
free(ms->items[i].shortdesc);
}
@ -188,7 +188,7 @@ dup_menu_section(ncmenu_int_section* dst, const struct ncmenu_section* src){
// Duplicates all menu sections in opts, adding their length to '*totalwidth'.
static int
dup_menu_sections(ncmenu* ncm, const ncmenu_options* opts, int* totalwidth, int* totalheight){
dup_menu_sections(ncmenu* ncm, const ncmenu_options* opts, unsigned* totalwidth, unsigned* totalheight){
if(opts->sectioncount == 0){
return -1;
}
@ -197,9 +197,9 @@ dup_menu_sections(ncmenu* ncm, const ncmenu_options* opts, int* totalwidth, int*
return -1;
}
bool rightaligned = false; // can only right-align once. twice is error.
int maxheight = 0;
int maxwidth = *totalwidth;
int xoff = 2;
unsigned maxheight = 0;
unsigned maxwidth = *totalwidth;
unsigned xoff = 2;
int i;
for(i = 0 ; i < opts->sectioncount ; ++i){
if(opts->sections[i].name){
@ -294,9 +294,9 @@ section_x(const ncmenu* ncm, int x){
static int
write_header(ncmenu* ncm){
ncplane_set_channels(ncm->ncp, ncm->headerchannels);
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(ncm->ncp, &dimy, &dimx);
int xoff = 0; // 2-column margin on left
unsigned xoff = 0; // 2-column margin on left
int ypos = ncm->bottom ? dimy - 1 : 0;
if(ncplane_cursor_move_yx(ncm->ncp, ypos, 0)){
return -1;
@ -385,12 +385,12 @@ ncmenu* ncmenu_create(ncplane* n, const ncmenu_options* opts){
if(opts->flags >= (NCMENU_OPTION_HIDING << 1u)){
logwarn("Provided unsupported flags %016" PRIx64 "\n", opts->flags);
}
int totalheight = 1;
int totalwidth = 2; // start with two-character margin on the left
unsigned totalheight = 1;
unsigned totalwidth = 2; // start with two-character margin on the left
ncmenu* ret = malloc(sizeof(*ret));
ret->sectioncount = opts->sectioncount;
ret->sections = NULL;
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(n, &dimy, &dimx);
if(ret){
ret->bottom = !!(opts->flags & NCMENU_OPTION_BOTTOM);
@ -461,13 +461,13 @@ int ncmenu_unroll(ncmenu* n, int sectionidx){
return -1;
}
n->unrolledsection = sectionidx;
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(n->ncp, &dimy, &dimx);
const int height = section_height(n, sectionidx);
const int width = section_width(n, sectionidx);
int xpos = n->sections[sectionidx].xoff < 0 ?
dimx + (n->sections[sectionidx].xoff - 2) : n->sections[sectionidx].xoff;
if(xpos + width >= dimx){
(int)dimx + (n->sections[sectionidx].xoff - 2) : n->sections[sectionidx].xoff;
if(xpos + width >= (int)dimx){
xpos = dimx - (width + 2);
}
int ypos = n->bottom ? dimy - height - 1 : 1;
@ -478,7 +478,7 @@ int ncmenu_unroll(ncmenu* n, int sectionidx){
return -1;
}
const ncmenu_int_section* sec = &n->sections[sectionidx];
for(int i = 0 ; i < sec->itemcount ; ++i){
for(unsigned i = 0 ; i < sec->itemcount ; ++i){
++ypos;
if(sec->items[i].desc){
// FIXME the user ought be able to configure the disabled channel
@ -487,8 +487,10 @@ int ncmenu_unroll(ncmenu* n, int sectionidx){
}else{
ncplane_set_channels(n->ncp, n->disablechannels);
}
if(i == sec->itemselected){
ncplane_set_channels(n->ncp, ncchannels_reverse(ncplane_channels(n->ncp)));
if(sec->itemselected >= 0){
if(i == (unsigned)sec->itemselected){
ncplane_set_channels(n->ncp, ncchannels_reverse(ncplane_channels(n->ncp)));
}
}
ncplane_set_styles(n->ncp, 0);
int cols = ncplane_putstr_yx(n->ncp, ypos, xpos + 1, sec->items[i].desc);
@ -585,7 +587,7 @@ int ncmenu_nextitem(ncmenu* n){
ncmenu_int_section* sec = &n->sections[n->unrolledsection];
// FIXME probably best to detect cycles
do{
if(++sec->itemselected == sec->itemcount){
if((unsigned)++sec->itemselected == sec->itemcount){
sec->itemselected = 0;
}
}while(!sec->items[sec->itemselected].desc || sec->items[sec->itemselected].disabled);
@ -628,10 +630,10 @@ const char* ncmenu_mouse_selected(const ncmenu* n, const ncinput* click,
if(click->evtype != NCTYPE_RELEASE){
return NULL;
}
int y, x, dimy, dimx;
struct ncplane* nc = n->ncp;
y = click->y;
x = click->x;
int y = click->y;
int x = click->x;
unsigned dimy, dimx;
ncplane_dim_yx(nc, &dimy, &dimx);
if(!ncplane_translate_abs(nc, &y, &x)){
return NULL;
@ -645,7 +647,7 @@ const char* ncmenu_mouse_selected(const ncmenu* n, const ncinput* click,
return NULL;
}
const struct ncmenu_int_section* sec = &n->sections[n->unrolledsection];
if(y < 2 || y - 2 >= sec->itemcount){
if(y < 2 || (unsigned)y - 2 >= sec->itemcount){
return NULL;
}
const int itemidx = y - 2;
@ -659,14 +661,15 @@ bool ncmenu_offer_input(ncmenu* n, const ncinput* nc){
// we can't actually select menu items in this function, since we need to
// invoke an arbitrary function as a result.
if(nc->id == NCKEY_BUTTON1 && nc->evtype == NCTYPE_RELEASE){
int y, x, dimy, dimx;
int y, x;
y = nc->y;
x = nc->x;
unsigned dimy, dimx;
ncplane_dim_yx(n->ncp, &dimy, &dimx);
if(!ncplane_translate_abs(n->ncp, &y, &x)){
return false;
}
if(y != (n->bottom ? dimy - 1 : 0)){
if(y != (n->bottom ? (int)dimy - 1 : 0)){
return false;
}
int i = section_x(n, x);
@ -726,7 +729,7 @@ int ncmenu_item_set_status(ncmenu* n, const char* section, const char* item,
for(int si = 0 ; si < n->sectioncount ; ++si){
struct ncmenu_int_section* sec = &n->sections[si];
if(strcmp(sec->name, section) == 0){
for(int ii = 0 ; ii < sec->itemcount ; ++ii){
for(unsigned ii = 0 ; ii < sec->itemcount ; ++ii){
struct ncmenu_int_item* i = &sec->items[ii];
if(strcmp(i->desc, item) == 0){
const bool changed = i->disabled == enabled;

@ -241,7 +241,7 @@ int ncplane_at_yx_cell(ncplane* n, int y, int x, nccell* c){
return -1;
}
void ncplane_dim_yx(const ncplane* n, int* rows, int* cols){
void ncplane_dim_yx(const ncplane* n, unsigned* rows, unsigned* cols){
if(rows){
*rows = n->leny;
}
@ -252,7 +252,7 @@ void ncplane_dim_yx(const ncplane* n, int* rows, int* cols){
// anyone calling this needs ensure the ncplane's framebuffer is updated
// to reflect changes in geometry. also called at startup for standard plane.
int update_term_dimensions(int* rows, int* cols, tinfo* tcache, int margin_b){
int update_term_dimensions(unsigned* rows, unsigned* cols, tinfo* tcache, int margin_b){
// if we're not a real tty, we presumably haven't changed geometry, return
if(tcache->ttyfd < 0){
if(rows){
@ -267,7 +267,7 @@ int update_term_dimensions(int* rows, int* cols, tinfo* tcache, int margin_b){
}
return 0;
}
int rowsafe, colsafe;
unsigned rowsafe, colsafe;
if(rows == NULL){
rows = &rowsafe;
}
@ -601,25 +601,25 @@ void ncplane_home(ncplane* n){
}
int ncplane_cursor_move_yx(ncplane* n, int y, int x){
if(x >= n->lenx){
logerror("Target x %d >= length %d\n", x, n->lenx);
return -1;
}else if(x < 0){
if(x < 0){
if(x < -1){
logerror("Negative target x %d\n", x);
return -1;
}
}else if((unsigned)x >= n->lenx){
logerror("Target x %d >= length %u\n", x, n->lenx);
return -1;
}else{
n->x = x;
}
if(y >= n->leny){
logerror("Target y %d >= height %d\n", y, n->leny);
return -1;
}else if(y < 0){
if(y < 0){
if(y < -1){
logerror("Negative target y %d\n", y);
return -1;
}
}else if(y >= n->leny){
logerror("Target y %d >= height %u\n", y, n->leny);
return -1;
}else{
n->y = y;
}
@ -717,7 +717,7 @@ int ncplane_resize_internal(ncplane* n, int keepy, int keepx,
logerror("Can't achieve meaningless size %ux%u\n", ylen, xlen);
return -1;
}
int rows, cols;
unsigned rows, cols;
ncplane_dim_yx(n, &rows, &cols);
if(keepleny + keepy > (unsigned)rows){
logerror("Can't keep %d@%d rows from %d\n", keepleny, keepy, rows);
@ -1101,7 +1101,7 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){
goto err;
}
}
int dimy, dimx;
unsigned dimy, dimx;
if(update_term_dimensions(&dimy, &dimx, &ret->tcache, ret->margin_b)){
goto err;
}
@ -1225,7 +1225,7 @@ int notcurses_stop(notcurses* nc){
// wrote. move it to the bottom left of the screen, *unless*
// PRESERVE_CURSOR was used, which is a bit more complex.
if((nc->flags & NCOPTION_PRESERVE_CURSOR) || !get_escape(&nc->tcache, ESCAPE_SMCUP)){
int targy = nc->rstate.logendy;
unsigned targy = nc->rstate.logendy;
fbuf_reset(&nc->rstate.f);
if(++targy >= nc->lfdimy){
fbuf_putc(&nc->rstate.f, '\n');
@ -1547,7 +1547,7 @@ void scroll_down(ncplane* n){
}
n->logrow = (n->logrow + 1) % n->leny;
nccell* row = n->fb + nfbcellidx(n, n->y, 0);
for(int clearx = 0 ; clearx < n->lenx ; ++clearx){
for(unsigned clearx = 0 ; clearx < n->lenx ; ++clearx){
nccell_release(n, &row[clearx]);
}
memset(row, 0, sizeof(*row) * n->lenx);
@ -1998,7 +1998,7 @@ 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, ymax, xmax;
int 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){
@ -2009,6 +2009,7 @@ int ncplane_box(ncplane* n, const nccell* ul, const nccell* ur,
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){
@ -2211,7 +2212,7 @@ int ncplane_erase_region(ncplane* n, int ystart, int xstart, int ylen, int xlen)
logerror("Illegal start of erase (%d, %d)\n", ystart, xstart);
return -1;
}
if(ystart >= ncplane_dim_y(n) || xstart >= ncplane_dim_x(n)){
if(ystart >= (int)ncplane_dim_y(n) || xstart >= (int)ncplane_dim_x(n)){
logerror("Illegal start of erase (%d, %d)\n", ystart, xstart);
return -1;
}
@ -2225,7 +2226,7 @@ int ncplane_erase_region(ncplane* n, int ystart, int xstart, int ylen, int xlen)
xstart = 0;
xlen = ncplane_dim_x(n);
}
if(xlen > ncplane_dim_x(n) || xstart + xlen > ncplane_dim_x(n)){
if(xlen > (int)ncplane_dim_x(n) || xstart + xlen > (int)ncplane_dim_x(n)){
xlen = ncplane_dim_x(n) - xstart;
}
if(ylen < 0){
@ -2238,12 +2239,12 @@ int ncplane_erase_region(ncplane* n, int ystart, int xstart, int ylen, int xlen)
ystart = 0;
ylen = ncplane_dim_y(n);
}
if(ylen > ncplane_dim_y(n) || ystart + ylen > ncplane_dim_y(n)){
if(ylen > (int)ncplane_dim_y(n) || ystart + ylen > (int)ncplane_dim_y(n)){
ylen = ncplane_dim_y(n) - ystart;
}
// special-case the full plane erasure, as it's powerfully optimized (O(1))
if(ystart == 0 && xstart == 0 &&
ylen == ncplane_dim_y(n) && xlen == ncplane_dim_x(n)){
ylen == (int)ncplane_dim_y(n) && xlen == (int)ncplane_dim_x(n)){
int tmpy = n->y; // preserve cursor location
int tmpx = n->x;
ncplane_erase(n);
@ -2378,7 +2379,8 @@ bool ncplane_translate_abs(const ncplane* n, int* restrict y, int* restrict x){
if(*y < 0){
return false;
}
if(*y >= n->leny){
unsigned yval = *y;
if(yval >= n->leny){
return false;
}
}
@ -2386,7 +2388,8 @@ bool ncplane_translate_abs(const ncplane* n, int* restrict y, int* restrict x){
if(*x < 0){
return false;
}
if(*x >= n->lenx){
unsigned xval = *x;
if(xval >= n->lenx){
return false;
}
}
@ -2464,7 +2467,7 @@ int (*ncplane_resizecb(const ncplane* n))(ncplane*){
int ncplane_resize_marginalized(ncplane* n){
const ncplane* parent = ncplane_parent_const(n);
// a marginalized plane cannot be larger than its oppressor plane =]
int maxy, maxx;
unsigned maxy, maxx;
if(parent == n){ // root plane, need to use pile size
ncpile* p = ncplane_pile(n);
maxy = p->dimy;
@ -2478,7 +2481,7 @@ int ncplane_resize_marginalized(ncplane* n){
if((maxx -= (n->margin_r + (n->absx - n->boundto->absx))) < 1){
maxx = 1;
}
int oldy, oldx;
unsigned oldy, oldx;
ncplane_dim_yx(n, &oldy, &oldx); // current dimensions of 'n'
int keepleny = oldy > maxy ? maxy : oldy;
int keeplenx = oldx > maxx ? maxx : oldx;
@ -2495,7 +2498,7 @@ int ncplane_resize_maximize(ncplane* n){
const ncpile* pile = ncplane_pile(n); // FIXME should be taken against parent
const int rows = pile->dimy;
const int cols = pile->dimx;
int oldy, oldx;
unsigned oldy, oldx;
ncplane_dim_yx(n, &oldy, &oldx); // current dimensions of 'n'
int keepleny = oldy > rows ? rows : oldy;
int keeplenx = oldx > cols ? cols : oldx;
@ -2951,9 +2954,21 @@ uint32_t* ncplane_as_rgba(const ncplane* nc, ncblitter_e blit,
}
// return a heap-allocated copy of the contents
char* ncplane_contents(ncplane* nc, unsigned begy, unsigned begx, unsigned leny, unsigned lenx){
if(begx >= (unsigned)nc->lenx || begy >= (unsigned)nc->leny){
logerror("beginning coordinates (%u/%u) exceeded area (%d/%d)\n",
char* ncplane_contents(ncplane* nc, int begy, int begx, unsigned leny, unsigned lenx){
if(begy < 0){
if(begy != -1){
logerror("invalid y coordinate: %d\n", begy);
}
begy = nc->y;
}
if(begx < 0){
if(begx != -1){
logerror("invalid x coordinate: %d\n", begx);
}
begx = nc->x;
}
if((unsigned)begx >= nc->lenx || (unsigned)begy >= nc->leny){
logerror("beginning coordinates (%d/%d) exceeded area (%u/%u)\n",
begy, begx, nc->leny, nc->lenx);
return NULL;
}
@ -2964,7 +2979,7 @@ char* ncplane_contents(ncplane* nc, unsigned begy, unsigned begx, unsigned leny,
leny = nc->leny - begy;
}
if(nc->lenx - begx < lenx || nc->leny - begy < leny){
logerror("ending coordinates (%u/%u) exceeded lengths (%d/%d)\n",
logerror("ending coordinates (%u/%u) exceeded lengths (%u/%u)\n",
begy + leny, begx + lenx, nc->leny, nc->lenx);
return NULL;
}
@ -3173,8 +3188,8 @@ int ncstrwidth_valid(const char* egcs, int* validbytes, int* validwidth){
}
void ncplane_pixelgeom(const ncplane* n, int* RESTRICT pxy, int* RESTRICT pxx,
int* RESTRICT celldimy, int* RESTRICT celldimx,
int* RESTRICT maxbmapy, int* RESTRICT maxbmapx){
unsigned* RESTRICT celldimy, unsigned* RESTRICT celldimx,
unsigned* RESTRICT maxbmapy, unsigned* RESTRICT maxbmapx){
notcurses* nc = ncplane_notcurses(n);
if(celldimy){
*celldimy = nc->tcache.cellpixy;

@ -25,11 +25,11 @@ typedef struct ncplot {
to span the horizontal area. if there are more slots than there are
columns, we prefer showing more recent slots to less recent. if there are
fewer slots than there are columns, they prefer the left side. */
int rangex;
unsigned rangex;
/* domain minimum and maximum. if detectdomain is true, these are
progressively enlarged/shrunk to fit the sample set. if not, samples
outside these bounds are counted, but the displayed range covers only this. */
int slotcount;
unsigned slotcount;
int slotstart; /* index of most recently-written slot */
bool labelaxisd; /* label dependent axis (consumes PREFIXCOLUMNS columns) */
bool exponentiali; /* exponential independent axis */
@ -95,9 +95,9 @@ int redraw_pixelplot_##T(nc##X##plot* ncp){ \
} \
const int scale = ncplane_notcurses_const(ncp->plot.ncp)->tcache.cellpixx; \
ncplane_erase(ncp->plot.ncp); \
int dimy, dimx; \
unsigned dimy, dimx; \
ncplane_dim_yx(ncp->plot.ncp, &dimy, &dimx); \
const int scaleddim = dimx * scale; \
const unsigned scaleddim = dimx * scale; \
/* each transition is worth this much change in value */ \
const size_t states = ncplane_notcurses_const(ncp->plot.ncp)->tcache.cellpixy; \
/* FIXME can we not rid ourselves of this meddlesome double? either way, the \
@ -117,12 +117,12 @@ int redraw_pixelplot_##T(nc##X##plot* ncp){ \
const int startx = ncp->plot.labelaxisd ? PREFIXCOLUMNS : 0; /* plot cols begin here */ \
/* if we want fewer slots than there are available columns, our final column \
will be other than the plane's final column. most recent x goes here. */ \
const int finalx = (ncp->plot.slotcount < scaleddim - 1 - (startx * scale) ? \
startx + (ncp->plot.slotcount / scale) - 1 : dimx - 1); \
const unsigned finalx = (ncp->plot.slotcount < scaleddim - 1 - (startx * scale) ? \
startx + (ncp->plot.slotcount / scale) - 1 : dimx - 1); \
ncplane_set_styles(ncp->plot.ncp, ncp->plot.legendstyle); \
if(ncp->plot.labelaxisd){ \
/* show the *top* of each interval range */ \
for(int y = 0 ; y < dimy ; ++y){ \
for(unsigned y = 0 ; y < dimy ; ++y){ \
ncplane_set_channels(ncp->plot.ncp, ncp->plot.channels[y * states]); \
char buf[PREFIXSTRLEN + 1]; \
if(ncp->plot.exponentiali){ \
@ -147,7 +147,7 @@ int redraw_pixelplot_##T(nc##X##plot* ncp){ \
ncplane_printf_yx(ncp->plot.ncp, 0, PREFIXCOLUMNS - strlen(ncp->plot.title), "%s", ncp->plot.title); \
} \
ncplane_set_styles(ncp->plot.ncp, NCSTYLE_NONE); \
if(finalx < startx){ /* exit on pathologically narrow planes */ \
if((int)finalx < startx){ /* exit on pathologically narrow planes */ \
return 0; \
} \
if(!interval){ \
@ -188,7 +188,7 @@ int redraw_pixelplot_##T(nc##X##plot* ncp){ \
given cell. */ \
T intervalbase = ncp->miny; \
bool done = !ncp->plot.bset->fill; \
for(int y = 0 ; y < dimy ; ++y){ \
for(unsigned y = 0 ; y < dimy ; ++y){ \
/* if we've got at least one interval's worth on the number of positions \
times the number of intervals per position plus the starting offset, \
we're going to print *something* */ \
@ -264,10 +264,10 @@ int redraw_plot_##T(nc##X##plot* ncp){ \
return -1; \
} \
ncplane_erase(ncp->plot.ncp); \
const int scale = ncp->plot.bset->width; \
int dimy, dimx; \
const unsigned scale = ncp->plot.bset->width; \
unsigned dimy, dimx; \
ncplane_dim_yx(ncp->plot.ncp, &dimy, &dimx); \
const int scaleddim = dimx * scale; \
const unsigned scaleddim = dimx * scale; \
/* each transition is worth this much change in value */ \
const size_t states = ncp->plot.bset->height + 1; \
/* FIXME can we not rid ourselves of this meddlesome double? either way, the \
@ -287,12 +287,12 @@ int redraw_plot_##T(nc##X##plot* ncp){ \
const int startx = ncp->plot.labelaxisd ? PREFIXCOLUMNS : 0; /* plot cols begin here */ \
/* if we want fewer slots than there are available columns, our final column \
will be other than the plane's final column. most recent x goes here. */ \
const int finalx = (ncp->plot.slotcount < scaleddim - 1 - (startx * scale) ? \
startx + (ncp->plot.slotcount / scale) - 1 : dimx - 1); \
const unsigned finalx = (ncp->plot.slotcount < scaleddim - 1 - (startx * scale) ? \
startx + (ncp->plot.slotcount / scale) - 1 : dimx - 1); \
ncplane_set_styles(ncp->plot.ncp, ncp->plot.legendstyle); \
if(ncp->plot.labelaxisd){ \
/* show the *top* of each interval range */ \
for(int y = 0 ; y < dimy ; ++y){ \
for(unsigned y = 0 ; y < dimy ; ++y){ \
ncplane_set_channels(ncp->plot.ncp, ncp->plot.channels[y]); \
char buf[PREFIXSTRLEN + 1]; \
if(ncp->plot.exponentiali){ \
@ -315,7 +315,7 @@ int redraw_plot_##T(nc##X##plot* ncp){ \
ncplane_printf_yx(ncp->plot.ncp, 0, PREFIXCOLUMNS - strlen(ncp->plot.title), "%s", ncp->plot.title); \
} \
ncplane_set_styles(ncp->plot.ncp, NCSTYLE_NONE); \
if(finalx < startx){ /* exit on pathologically narrow planes */ \
if((int)finalx < startx){ /* exit on pathologically narrow planes */ \
return 0; \
} \
if(!interval){ \
@ -346,13 +346,13 @@ int redraw_plot_##T(nc##X##plot* ncp){ \
T intervalbase = ncp->miny; \
const wchar_t* egc = ncp->plot.bset->plotegcs; \
bool done = !ncp->plot.bset->fill; \
for(int y = 0 ; y < dimy ; ++y){ \
for(unsigned y = 0 ; y < dimy ; ++y){ \
ncplane_set_channels(ncp->plot.ncp, ncp->plot.channels[y]); \
size_t egcidx = 0, sumidx = 0; \
/* if we've got at least one interval's worth on the number of positions \
times the number of intervals per position plus the starting offset, \
we're going to print *something* */ \
for(int i = 0 ; i < scale ; ++i){ \
for(unsigned i = 0 ; i < scale ; ++i){ \
sumidx *= states; \
if(intervalbase < gvals[i]){ \
if(ncp->plot.exponentiali){ \
@ -470,13 +470,13 @@ create_##T(nc##X##plot* ncpp, ncplane* n, const ncplot_options* opts, const T mi
ncplane_destroy(n); \
return NULL; \
} \
int sdimy, sdimx; \
unsigned sdimy, sdimx; \
ncplane_dim_yx(n, &sdimy, &sdimx); \
if(sdimx <= 0){ \
ncplane_destroy(n); \
return NULL; \
} \
int dimx = sdimx; \
unsigned dimx = sdimx; \
ncpp->plot.title = strdup(opts->title ? opts->title : ""); \
ncpp->plot.rangex = opts->rangex; \
/* if we're sizing the plot based off the plane dimensions, scale it by the \

@ -48,7 +48,7 @@ static int
progbar_redraw(ncprogbar* n){
struct ncplane* ncp = ncprogbar_plane(n);
// get current dimensions; they might have changed
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(ncp, &dimy, &dimx);
const bool horizontal = dimx > dimy;
int range, delt, pos;
@ -83,11 +83,11 @@ progbar_redraw(ncprogbar* n){
}
ncplane_home(ncp);
if(notcurses_canutf8(ncplane_notcurses(ncp))){
if(ncplane_highgradient(ncp, ul, ur, bl, br, dimy - 1, dimx - 1) <= 0){
if(ncplane_gradient2x1(ncp, -1, -1, 0, 0, ul, ur, bl, br) <= 0){
return -1;
}
}else{
if(ncplane_gradient(ncp, " ", 0, ul, ur, bl, br, dimy - 1, dimx - 1) <= 0){
if(ncplane_gradient(ncp, -1, -1, 0, 0, " ", 0, ul, ur, bl, br) <= 0){
return -1;
}
}
@ -117,7 +117,7 @@ progbar_redraw(ncprogbar* n){
const int egcidx = (int)(chunk / (eachcell / 8));
const char* egc = egcs + egcidx * 5;
if(horizontal){
for(int freepos = 0 ; freepos < dimy ; ++freepos){
for(unsigned freepos = 0 ; freepos < dimy ; ++freepos){
if(notcurses_canutf8(ncplane_notcurses(ncp))){
nccell* c = ncplane_cell_ref_yx(ncp, freepos, pos);
if(pool_blit_direct(&ncp->pool, c, egc, strlen(egc), 1) <= 0){
@ -131,7 +131,7 @@ progbar_redraw(ncprogbar* n){
}
}
}else{
for(int freepos = 0 ; freepos < dimx ; ++freepos){
for(unsigned freepos = 0 ; freepos < dimx ; ++freepos){
if(notcurses_canutf8(ncplane_notcurses(ncp))){
nccell* c = ncplane_cell_ref_yx(ncp, pos, freepos);
if(pool_blit_direct(&ncp->pool, c, egc, strlen(egc), 1) <= 0){
@ -149,13 +149,13 @@ progbar_redraw(ncprogbar* n){
pos += delt;
while(pos >= 0 && pos < range){
if(horizontal){
for(int freepos = 0 ; freepos < dimy ; ++freepos){
for(unsigned freepos = 0 ; freepos < dimy ; ++freepos){
nccell* c = ncplane_cell_ref_yx(ncp, freepos, pos);
nccell_release(ncp, c);
nccell_init(c);
}
}else{
for(int freepos = 0 ; freepos < dimx ; ++freepos){
for(unsigned freepos = 0 ; freepos < dimx ; ++freepos){
nccell* c = ncplane_cell_ref_yx(ncp, pos, freepos);
nccell_release(ncp, c);
nccell_init(c);

@ -114,8 +114,7 @@ typedef enum {
static int
draw_borders(ncplane* n, unsigned mask, uint64_t channel, direction_e direction){
int lenx, leny;
int ret = 0;
unsigned lenx, leny;
ncplane_dim_yx(n, &leny, &lenx);
int maxx = lenx - 1;
int maxy = leny - 1;
@ -142,6 +141,7 @@ draw_borders(ncplane* n, unsigned mask, uint64_t channel, direction_e direction)
// we're left following the previous stanza, end based on maxhorizy.
const bool candrawbottom = y <= maxy || direction == DIRECTION_UP || (mask & NCBOXMASK_TOP);
const int maxhorizy = maxy - (candrawbottom && !(mask & NCBOXMASK_BOTTOM));
int ret = 0;
while(y <= maxhorizy){
if(!(mask & NCBOXMASK_LEFT)){
ret |= ncplane_cursor_move_yx(n, y, 0);
@ -412,7 +412,7 @@ trim_reel_overhang(ncreel* r, nctablet* top, nctablet* bottom){
}
//fprintf(stderr, "trimming: top %p bottom %p\n", top->p, bottom->p);
ncplane_yx(top->p, &y, NULL);
int ylen, xlen;
unsigned ylen, xlen;
ncplane_dim_yx(top->p, &ylen, &xlen);
const int miny = !(r->ropts.bordermask & NCBOXMASK_TOP);
int boty = y + ylen - 1;
@ -559,7 +559,7 @@ tighten_reel(ncreel* r){
return -1;
}
}
int ylen;
unsigned ylen;
ncplane_dim_yx(cur->p, &ylen, NULL);
expected += ylen + 1;
//fprintf(stderr, "bottom (%p) gets %p\n", bottom, cur);
@ -572,7 +572,8 @@ tighten_reel(ncreel* r){
cur = r->tablets;
if(cur){
const ncplane* n = cur->p;
int yoff, ylen, rylen;
int yoff;
unsigned ylen, rylen;
ncplane_dim_yx(r->p, &rylen, NULL);
ncplane_yx(n, &yoff, NULL);
ncplane_dim_yx(n, &ylen, NULL);

@ -9,7 +9,7 @@
// two. new areas are initialized to empty, just like a new plane. lost areas
// have their egcpool entries purged.
static nccell*
restripe_lastframe(notcurses* nc, int rows, int cols){
restripe_lastframe(notcurses* nc, unsigned rows, unsigned cols){
assert(rows);
assert(cols);
const size_t size = sizeof(*nc->lastframe) * (rows * cols);
@ -21,7 +21,7 @@ restripe_lastframe(notcurses* nc, int rows, int cols){
size_t maxlinecopy = sizeof(nccell) * copycols;
size_t minlineset = sizeof(nccell) * cols - maxlinecopy;
unsigned zorch = nc->lfdimx > cols ? nc->lfdimx - cols : 0;
for(int y = 0 ; y < rows ; ++y){
for(unsigned y = 0 ; y < rows ; ++y){
if(y < nc->lfdimy){
if(maxlinecopy){
memcpy(&tmp[cols * y], &nc->lastframe[nc->lfdimx * y], maxlinecopy);
@ -40,8 +40,8 @@ restripe_lastframe(notcurses* nc, int rows, int cols){
}
}
// excise any egcpool entries from below the new plane area
for(int y = rows ; y < nc->lfdimy ; ++y){
for(int x = 0 ; x < nc->lfdimx ; ++x){
for(unsigned y = rows ; y < nc->lfdimy ; ++y){
for(unsigned x = 0 ; x < nc->lfdimx ; ++x){
pool_release(&nc->pool, &nc->lastframe[fbcellidx(y, nc->lfdimx, x)]);
}
}
@ -57,9 +57,9 @@ restripe_lastframe(notcurses* nc, int rows, int cols){
// at the same origin. Initiates a resize cascade for the pile containing |pp|.
// The current terminal geometry, changed or not, is written to |rows|/|cols|.
static int
notcurses_resize_internal(ncplane* pp, int* restrict rows, int* restrict cols){
notcurses_resize_internal(ncplane* pp, unsigned* restrict rows, unsigned* restrict cols){
notcurses* n = ncplane_notcurses(pp);
int r, c;
unsigned r, c;
if(rows == NULL){
rows = &r;
}
@ -67,8 +67,8 @@ notcurses_resize_internal(ncplane* pp, int* restrict rows, int* restrict cols){
cols = &c;
}
ncpile* pile = ncplane_pile(pp);
int oldrows = pile->dimy;
int oldcols = pile->dimx;
unsigned oldrows = pile->dimy;
unsigned oldcols = pile->dimx;
*rows = oldrows;
*cols = oldcols;
if(update_term_dimensions(rows, cols, &n->tcache, n->margin_b)){
@ -111,7 +111,7 @@ notcurses_resize_internal(ncplane* pp, int* restrict rows, int* restrict cols){
// Check for a window resize on the standard pile.
static int
notcurses_resize(notcurses* n, int* restrict rows, int* restrict cols){
notcurses_resize(notcurses* n, unsigned* restrict rows, unsigned* restrict cols){
pthread_mutex_lock(&n->pilelock);
int ret = notcurses_resize_internal(notcurses_stdplane(n), rows, cols);
pthread_mutex_unlock(&n->pilelock);
@ -239,13 +239,14 @@ __attribute__ ((nonnull (1, 2, 7)))
static void
paint(ncplane* p, struct crender* rvec, int dstleny, int dstlenx,
int dstabsy, int dstabsx, sprixel** sprixelstack){
int y, x, dimy, dimx, offy, offx;
unsigned y, x, dimy, dimx;
int offy, offx;
ncplane_dim_yx(p, &dimy, &dimx);
offy = p->absy - dstabsy;
offx = p->absx - dstabsx;
//fprintf(stderr, "PLANE %p %d %d %d %d %d %d %p\n", p, dimy, dimx, offy, offx, dstleny, dstlenx, p->sprite);
// skip content above or to the left of the physical screen
int starty, startx;
unsigned starty, startx;
if(offy < 0){
starty = -offy;
}else{
@ -526,21 +527,43 @@ postpaint(const tinfo* ti, nccell* lastframe, int dimy, int dimx,
// merging one plane down onto another is basically just performing a render
// using only these two planes, with the result written to the lower plane.
int ncplane_mergedown(ncplane* restrict src, ncplane* restrict dst,
unsigned begsrcy, unsigned begsrcx,
unsigned leny, unsigned lenx,
unsigned dsty, unsigned dstx){
int begsrcy, int begsrcx, unsigned leny, unsigned lenx,
int dsty, int dstx){
//fprintf(stderr, "Merging down %d/%d @ %d/%d to %d/%d\n", leny, lenx, begsrcy, begsrcx, dsty, dstx);
if(dsty >= (unsigned)dst->leny || dstx >= (unsigned)dst->lenx){
if(dsty < 0){
if(dsty != -1){
logerror("invalid dsty %d\n", dsty);
return -1;
}
dsty = dst->y;
}
if(dstx < 0){
if(dstx != -1){
logerror("invalid dstx %d\n", dstx);
return -1;
}
dstx = dst->x;
}
if((unsigned)dsty >= dst->leny || (unsigned)dstx >= dst->lenx){
logerror("dest origin %u/%u ≥ dest dimensions %d/%d\n",
dsty, dstx, dst->leny, dst->lenx);
return -1;
}
if(dst->leny - leny < dsty || dst->lenx - lenx < dstx){
logerror("dest len %u/%u ≥ dest dimensions %d/%d\n",
leny, lenx, dst->leny, dst->lenx);
return -1;
if(begsrcy < 0){
if(begsrcy != -1){
logerror("invalid begsrcy %d\n", begsrcy);
return -1;
}
begsrcy = src->y;
}
if(begsrcx < 0){
if(begsrcx != -1){
logerror("invalid begsrcx %d\n", begsrcx);
return -1;
}
begsrcx = src->x;
}
if(begsrcy >= (unsigned)src->leny || begsrcx >= (unsigned)src->lenx){
if((unsigned)begsrcy >= src->leny || (unsigned)begsrcx >= src->lenx){
logerror("source origin %u/%u ≥ source dimensions %d/%d\n",
begsrcy, begsrcx, src->leny, src->lenx);
return -1;
@ -557,7 +580,12 @@ int ncplane_mergedown(ncplane* restrict src, ncplane* restrict dst,
return -1;
}
}
if(src->leny - leny < begsrcy || src->lenx - lenx < begsrcx){
if(dst->leny - leny < (unsigned)dsty || dst->lenx - lenx < (unsigned)dstx){
logerror("dest len %u/%u ≥ dest dimensions %d/%d\n",
leny, lenx, dst->leny, dst->lenx);
return -1;
}
if(src->leny - leny < (unsigned)begsrcy || src->lenx - lenx < (unsigned)begsrcx){
logerror("source len %u/%u ≥ source dimensions %d/%d\n",
leny, lenx, src->leny, src->lenx);
return -1;
@ -931,14 +959,14 @@ clean_sprixels(notcurses* nc, ncpile* p, fbuf* f, int scrolls){
// scroll the lastframe data |rows| up, to reflect scrolling reality
static void
scroll_lastframe(notcurses* nc, int rows){
scroll_lastframe(notcurses* nc, unsigned rows){
// the top |rows| rows need be released (though not more than the actual
// number of rows!)
if(rows > nc->lfdimy){
rows = nc->lfdimy;
}
for(int targy = 0 ; targy < rows ; ++targy){
for(int targx = 0 ; targx < nc->lfdimx ; ++targx){
for(unsigned targy = 0 ; targy < rows ; ++targy){
for(unsigned targx = 0 ; targx < nc->lfdimx ; ++targx){
const size_t damageidx = targy * nc->lfdimx + targx;
nccell* c = &nc->lastframe[damageidx];
pool_release(&nc->pool, c);
@ -947,7 +975,7 @@ scroll_lastframe(notcurses* nc, int rows){
// now for all rows subsequent, up through lfdimy - rows, move them back.
// if we scrolled all rows, we will not move anything (and we just
// released everything).
for(int targy = 0 ; targy < nc->lfdimy - rows ; ++targy){
for(unsigned targy = 0 ; targy < nc->lfdimy - rows ; ++targy){
const size_t dstidx = targy * nc->lfdimx;
nccell* dst = &nc->lastframe[dstidx];
const size_t srcidx = dstidx + rows * nc->lfdimx;
@ -955,7 +983,7 @@ scroll_lastframe(notcurses* nc, int rows){
memcpy(dst, src, sizeof(*dst) * nc->lfdimx);
}
// now for the last |rows| rows, initialize them to 0.
int targy = nc->lfdimy - rows;
unsigned targy = nc->lfdimy - rows;
while(targy < nc->lfdimy){
const size_t dstidx = targy * nc->lfdimx;
nccell* dst = &nc->lastframe[dstidx];
@ -1093,9 +1121,9 @@ rasterize_core(notcurses* nc, const ncpile* p, fbuf* f, unsigned phase){
struct crender* rvec = p->crender;
// we only need to emit a coordinate if it was damaged. the damagemap is a
// bit per coordinate, one per struct crender.
for(int y = nc->margin_t; y < p->dimy + nc->margin_t ; ++y){
for(unsigned y = nc->margin_t; y < p->dimy + nc->margin_t ; ++y){
const int innery = y - nc->margin_t;
for(int x = nc->margin_l ; x < p->dimx + nc->margin_l ; ++x){
for(unsigned x = nc->margin_l ; x < p->dimx + nc->margin_l ; ++x){
const int innerx = x - nc->margin_l;
const size_t damageidx = innery * nc->lfdimx + innerx;
unsigned r, g, b, br, bg, bb;
@ -1361,7 +1389,7 @@ success:
}
// FIXME need to work with the most recently-rendered pile, no?
int notcurses_refresh(notcurses* nc, int* restrict dimy, int* restrict dimx){
int notcurses_refresh(notcurses* nc, unsigned* restrict dimy, unsigned* restrict dimx){
if(notcurses_resize(nc, dimy, dimx)){
return -1;
}
@ -1406,15 +1434,15 @@ int ncpile_render_to_file(ncplane* n, FILE* fp){
if(fbuf_init(&f)){
return -1;
}
const int count = (nc->lfdimx > p->dimx ? nc->lfdimx : p->dimx) *
(nc->lfdimy > p->dimy ? nc->lfdimy : p->dimy);
const unsigned count = (nc->lfdimx > p->dimx ? nc->lfdimx : p->dimx) *
(nc->lfdimy > p->dimy ? nc->lfdimy : p->dimy);
p->crender = malloc(count * sizeof(*p->crender));
if(p->crender == NULL){
fbuf_free(&f);
return -1;
}
init_rvec(p->crender, count);
for(int i = 0 ; i < count ; ++i){
for(unsigned i = 0 ; i < count ; ++i){
p->crender[i].s.damaged = 1;
}
int ret = raster_and_write(nc, p, &f);
@ -1575,27 +1603,31 @@ pool_egc_copy(const egcpool* e, const nccell* c){
return strdup(egcpool_extended_gcluster(e, c));
}
char* notcurses_at_yx(notcurses* nc, int yoff, int xoff, uint16_t* stylemask, uint64_t* channels){
char* egc = NULL;
if(nc->lastframe){
if(yoff >= 0 && yoff < nc->lfdimy){
if(xoff >= 0 || xoff < nc->lfdimx){
const nccell* srccell = &nc->lastframe[yoff * nc->lfdimx + xoff];
if(nccell_wide_right_p(srccell)){
return notcurses_at_yx(nc, yoff, xoff - 1, stylemask, channels);
}
if(stylemask){
*stylemask = srccell->stylemask;
}
if(channels){
*channels = srccell->channels;
}
//fprintf(stderr, "COPYING: %d from %p\n", srccell->gcluster, &nc->pool);
egc = pool_egc_copy(&nc->pool, srccell);
}
}
char* notcurses_at_yx(notcurses* nc, unsigned yoff, unsigned xoff, uint16_t* stylemask, uint64_t* channels){
if(nc->lastframe == NULL){
logerror("haven't yet rendered\n");
return NULL;
}
return egc;
if(yoff >= nc->lfdimy){
logerror("invalid coordinates: %u/%u\n", yoff, xoff);
return NULL;
}
if(xoff >= nc->lfdimx){
logerror("invalid coordinates: %u/%u\n", yoff, xoff);
return NULL;
}
const nccell* srccell = &nc->lastframe[yoff * nc->lfdimx + xoff];
if(nccell_wide_right_p(srccell)){
return notcurses_at_yx(nc, yoff, xoff - 1, stylemask, channels);
}
if(stylemask){
*stylemask = srccell->stylemask;
}
if(channels){
*channels = srccell->channels;
}
//fprintf(stderr, "COPYING: %d from %p\n", srccell->gcluster, &nc->pool);
return pool_egc_copy(&nc->pool, srccell);
}
int ncdirect_set_bg_rgb_f(ncdirect* nc, unsigned rgb, fbuf* f){

@ -46,7 +46,7 @@ typedef struct ncmultiselector {
struct ncmselector_int* items; // items, descriptions, and statuses, heap-copied
unsigned itemcount; // number of pairs in 'items'
char* title; // can be NULL, in which case there's no riser
int titlecols; // columns occupied by title
unsigned titlecols; // columns occupied by title
char* secondary; // can be NULL
int secondarycols; // columns occupied by secondary
char* footer; // can be NULL
@ -94,21 +94,25 @@ ncselector_draw(ncselector* n){
size_t riserwidth = n->titlecols + 4;
int offx = ncplane_halign(n->ncp, NCALIGN_RIGHT, riserwidth);
ncplane_cursor_move_yx(n->ncp, 0, 0);
ncplane_hline(n->ncp, &transchar, offx);
if(offx){
ncplane_hline(n->ncp, &transchar, offx);
}
ncplane_cursor_move_yx(n->ncp, 0, offx);
ncplane_rounded_box_sized(n->ncp, 0, n->boxchannels, 3, riserwidth, 0);
n->ncp->channels = n->titlechannels;
ncplane_printf_yx(n->ncp, 1, offx + 1, " %s ", n->title);
yoff += 2;
ncplane_cursor_move_yx(n->ncp, 1, 0);
ncplane_hline(n->ncp, &transchar, offx);
if(offx){
ncplane_hline(n->ncp, &transchar, offx);
}
}
int bodywidth = ncselector_body_width(n);
int dimy, dimx;
unsigned bodywidth = ncselector_body_width(n);
unsigned dimy, dimx;
ncplane_dim_yx(n->ncp, &dimy, &dimx);
int xoff = ncplane_halign(n->ncp, NCALIGN_RIGHT, bodywidth);
if(xoff){
for(int y = yoff + 1 ; y < dimy ; ++y){
for(unsigned y = yoff + 1 ; y < dimy ; ++y){
ncplane_cursor_move_yx(n->ncp, y, 0);
ncplane_hline(n->ncp, &transchar, xoff);
}
@ -223,8 +227,8 @@ ncselector_draw(ncselector* n){
static void
ncselector_dim_yx(const ncselector* n, int* ncdimy, int* ncdimx){
int rows = 0, cols = 0; // desired dimensions
int dimy, dimx; // dimensions of containing screen
const ncplane* parent = ncplane_parent(n->ncp);
unsigned dimy, dimx; // dimensions of containing plane
ncplane_dim_yx(parent, &dimy, &dimx);
if(n->title){ // header adds two rows for riser
rows += 2;
@ -590,20 +594,24 @@ ncmultiselector_draw(ncmultiselector* n){
size_t riserwidth = n->titlecols + 4;
int offx = ncplane_halign(n->ncp, NCALIGN_RIGHT, riserwidth);
ncplane_cursor_move_yx(n->ncp, 0, 0);
ncplane_hline(n->ncp, &transchar, offx);
if(offx){
ncplane_hline(n->ncp, &transchar, offx);
}
ncplane_rounded_box_sized(n->ncp, 0, n->boxchannels, 3, riserwidth, 0);
n->ncp->channels = n->titlechannels;
ncplane_printf_yx(n->ncp, 1, offx + 1, " %s ", n->title);
yoff += 2;
ncplane_cursor_move_yx(n->ncp, 1, 0);
ncplane_hline(n->ncp, &transchar, offx);
if(offx){
ncplane_hline(n->ncp, &transchar, offx);
}
}
int bodywidth = ncmultiselector_body_width(n);
int dimy, dimx;
unsigned bodywidth = ncmultiselector_body_width(n);
unsigned dimy, dimx;
ncplane_dim_yx(n->ncp, &dimy, &dimx);
int xoff = ncplane_halign(n->ncp, NCALIGN_RIGHT, bodywidth);
if(xoff){
for(int y = yoff + 1 ; y < dimy ; ++y){
for(unsigned y = yoff + 1 ; y < dimy ; ++y){
ncplane_cursor_move_yx(n->ncp, y, 0);
ncplane_hline(n->ncp, &transchar, xoff);
}
@ -816,9 +824,9 @@ bool ncmultiselector_offer_input(ncmultiselector* n, const ncinput* nc){
// calculate the necessary dimensions based off properties of the selector and
// the containing plane
static int
ncmultiselector_dim_yx(const ncmultiselector* n, int* ncdimy, int* ncdimx){
int rows = 0, cols = 0; // desired dimensions
int dimy, dimx; // dimensions of containing screen
ncmultiselector_dim_yx(const ncmultiselector* n, unsigned* ncdimy, unsigned* ncdimx){
unsigned rows = 0, cols = 0; // desired dimensions
unsigned dimy, dimx; // dimensions of containing screen
ncplane_dim_yx(ncplane_parent(n->ncp), &dimy, &dimx);
if(n->title){ // header adds two rows for riser
rows += 2;
@ -908,7 +916,7 @@ ncmultiselector* ncmultiselector_create(ncplane* n, const ncmultiselector_option
goto freeitems;
}
}
int dimy, dimx;
unsigned dimy, dimx;
ns->ncp = n;
if(ncmultiselector_dim_yx(ns, &dimy, &dimx)){
goto freeitems;

@ -277,9 +277,9 @@ scrub_color_table(sprixel* s){
if(s->n && s->n->tam){
// we use the sprixel cell geometry rather than the plane's because this
// is called during our initial blit, before we've resized the plane.
for(int y = 0 ; y < s->dimy ; ++y){
for(int x = 0 ; x < s->dimx ; ++x){
int txyidx = y * s->dimx + x;
for(unsigned y = 0 ; y < s->dimy ; ++y){
for(unsigned x = 0 ; x < s->dimx ; ++x){
unsigned txyidx = y * s->dimx + x;
sprixcell_e state = s->n->tam[txyidx].state;
if(state == SPRIXCELL_ANNIHILATED || state == SPRIXCELL_ANNIHILATED_TRANS){
//fprintf(stderr, "POSTEXRACT WIPE %d/%d\n", y, x);
@ -382,14 +382,14 @@ void sixel_refresh(const ncpile* p, sprixel* s){
}
int absy, absx;
ncplane_abs_yx(s->n, &absy, &absx);
for(int y = 0 ; y < s->dimy ; ++y){
const int yy = absy + y;
for(int x = 0 ; x < s->dimx ; ++x){
int idx = y * s->dimx + x;
for(unsigned y = 0 ; y < s->dimy ; ++y){
const unsigned yy = absy + y;
for(unsigned x = 0 ; x < s->dimx ; ++x){
unsigned idx = y * s->dimx + x;
if(s->needs_refresh[idx]){
const int xx = absx + x;
const unsigned xx = absx + x;
if(xx < p->dimx && yy < p->dimy){
int ridx = yy * p->dimx + xx;
unsigned ridx = yy * p->dimx + xx;
struct crender *r = &p->crender[ridx];
r->s.damaged = 1;
}
@ -962,8 +962,8 @@ int sixel_scrub(const ncpile* p, sprixel* s){
loginfo("%d state %d at %d/%d (%d/%d)\n", s->id, s->invalidated, s->movedfromy, s->movedfromx, s->dimy, s->dimx);
int starty = s->movedfromy;
int startx = s->movedfromx;
for(int yy = starty ; yy < starty + s->dimy && yy < p->dimy ; ++yy){
for(int xx = startx ; xx < startx + s->dimx && xx < p->dimx ; ++xx){
for(int yy = starty ; yy < starty + (int)s->dimy && yy < (int)p->dimy ; ++yy){
for(int xx = startx ; xx < startx + (int)s->dimx && xx < (int)p->dimx ; ++xx){
int ridx = yy * p->dimx + xx;
struct crender *r = &p->crender[ridx];
if(!s->n){
@ -1014,11 +1014,11 @@ int sixel_draw(const tinfo* ti, const ncpile* p, sprixel* s, fbuf* f,
return -1;
}
if(s->invalidated == SPRIXEL_MOVED){
for(int yy = s->movedfromy ; yy < s->movedfromy + s->dimy && yy < p->dimy ; ++yy){
for(int yy = s->movedfromy ; yy < s->movedfromy + (int)s->dimy && yy < (int)p->dimy ; ++yy){
if(yy < 0){
continue;
}
for(int xx = s->movedfromx ; xx < s->movedfromx + s->dimx && xx < p->dimx ; ++xx){
for(int xx = s->movedfromx ; xx < s->movedfromx + (int)s->dimx && xx < (int)p->dimx ; ++xx){
if(xx < 0){
continue;
}

@ -11,16 +11,16 @@ void sprixel_debug(const sprixel* s, FILE* out){
s->invalidated);
if(s->n){
int idx = 0;
for(int y = 0 ; y < s->dimy ; ++y){
for(int x = 0 ; x < s->dimx ; ++x){
for(unsigned y = 0 ; y < s->dimy ; ++y){
for(unsigned x = 0 ; x < s->dimx ; ++x){
fprintf(out, "%d", s->n->tam[idx].state);
++idx;
}
fprintf(out, "\n");
}
idx = 0;
for(int y = 0 ; y < s->dimy ; ++y){
for(int x = 0 ; x < s->dimx ; ++x){
for(unsigned y = 0 ; y < s->dimy ; ++y){
for(unsigned x = 0 ; x < s->dimx ; ++x){
if(s->n->tam[idx].state == SPRIXCELL_ANNIHILATED){
if(s->n->tam[idx].auxvector){
fprintf(out, "%03d] %p\n", idx, s->n->tam[idx].auxvector);
@ -153,7 +153,7 @@ sprixel* sprixel_alloc(const tinfo* ti, ncplane* n, int dimy, int dimx){
// |pixy| and |pixx| are the output pixel geometry (i.e. |pixy| must be a
// multiple of 6 for sixel). output coverage ought already have been loaded.
// takes ownership of 's' on success. frees any existing glyph.
int sprixel_load(sprixel* spx, fbuf* f, int pixy, int pixx,
int sprixel_load(sprixel* spx, fbuf* f, unsigned pixy, unsigned pixx,
int parse_start, sprixel_e state){
assert(spx->n);
if(spx->cellpxy > 0){ // don't explode on ncdirect case

@ -141,7 +141,7 @@ typedef struct sprixel {
sprixel_e invalidated;// sprixel invalidation state
struct sprixel* next;
struct sprixel* prev;
int dimy, dimx; // cell geometry
unsigned dimy, dimx; // cell geometry
int pixy, pixx; // pixel geometry (might be smaller than cell geo)
int cellpxy, cellpxx; // cell-pixel geometry at time of creation
// each tacache entry is one of 0 (standard opaque cell), 1 (cell with
@ -214,8 +214,8 @@ void fbcon_scroll(const struct ncpile* p, tinfo* ti, int rows);
void sixel_refresh(const struct ncpile* p, sprixel* s);
// takes ownership of s on success.
int sprixel_load(sprixel* spx, fbuf* f, int pixy, int pixx, int parse_start,
sprixel_e state);
int sprixel_load(sprixel* spx, fbuf* f, unsigned pixy, unsigned pixx,
int parse_start, sprixel_e state);
#ifdef __cplusplus
}

@ -22,8 +22,8 @@ typedef struct nctabbed {
void nctabbed_redraw(nctabbed* nt){
nctab* t;
int drawn_cols = 0;
int rows, cols;
unsigned drawn_cols = 0;
unsigned rows, cols;
if(nt->tabcount == 0){
// no tabs = nothing to draw
ncplane_erase(nt->hp);
@ -148,7 +148,7 @@ nctab* nctab_prev(nctab* t){
nctabbed* nctabbed_create(ncplane* n, const nctabbed_options* topts){
nctabbed_options zeroed = {};
ncplane_options nopts = {};
int nrows, ncols;
unsigned nrows, ncols;
nctabbed* nt;
if(!topts){
topts = &zeroed;

@ -1144,7 +1144,7 @@ char* termdesc_longterm(const tinfo* ti){
// send a u7 request, and wait until we have a cursor report. if input's ttyfd
// is valid, we can just camp there. otherwise, we need dance with potential
// user input looking at infd.
int locate_cursor(tinfo* ti, int* cursor_y, int* cursor_x){
int locate_cursor(tinfo* ti, unsigned* cursor_y, unsigned* cursor_x){
#ifdef __MINGW64__
if(ti->outhandle){
CONSOLE_SCREEN_BUFFER_INFO conbuf;

@ -112,7 +112,7 @@ typedef struct tinfo {
// be acquired on all terminals with pixel support.
unsigned cellpixy; // cell pixel height, might be 0
unsigned cellpixx; // cell pixel width, might be 0
int dimy, dimx; // most recent cell geometry
unsigned dimy, dimx; // most recent cell geometry
unsigned supported_styles; // bitmask over NCSTYLE_* driven via sgr/ncv
@ -155,16 +155,16 @@ typedef struct tinfo {
// on TERM heuristics. otherwise, we attempt to detect sixel support, and
// query the details of the implementation.
int color_registers; // sixel color registers (post pixel_query_done)
int sixel_maxx; // maximum theoretical sixel width
unsigned sixel_maxx; // maximum theoretical sixel width
// in sixel, we can't render to the bottom row, lest we force a one-line
// scroll. we thus clamp sixel_maxy_pristine to the minimum of
// sixel_maxy_pristine (the reported sixel_maxy), and the number of rows
// less one times the cell height. sixel_maxy is thus recomputed whenever
// we get a resize event. it is only defined if we have sixel_maxy_pristine,
// so kitty graphics (which don't force a scroll) never deal with this.
int sixel_maxy; // maximum working sixel height
int sixel_maxy_pristine; // maximum theoretical sixel height, as queried
int sprixel_scale_height; // sprixel must be a multiple of this many rows
unsigned sixel_maxy; // maximum working sixel height
unsigned sixel_maxy_pristine; // maximum theoretical sixel height, as queried
unsigned sprixel_scale_height;// sprixel must be a multiple of this many rows
const char* termname; // terminal name from environment variables/init
char* termversion; // terminal version (freeform) from query responses
queried_terminals_e qterm; // detected terminal class
@ -242,7 +242,7 @@ void free_terminfo_cache(tinfo* ti);
// return a heap-allocated copy of termname + termversion
char* termdesc_longterm(const tinfo* ti);
int locate_cursor(tinfo* ti, int* cursor_y, int* cursor_x);
int locate_cursor(tinfo* ti, unsigned* cursor_y, unsigned* cursor_x);
// tlen -- size of escape table. tused -- used bytes in same.
// returns -1 if the starting location is >= 65535. otherwise,

@ -261,7 +261,7 @@ void* nctree_next(nctree* n){
if(tmp != n->curitem){
n->curitem = tmp;
n->activerow += rows;
if(n->activerow >= ncplane_dim_y(n->items.ncp)){
if(n->activerow >= (int)ncplane_dim_y(n->items.ncp)){
n->activerow = ncplane_dim_y(n->items.ncp) - 1;
}
}
@ -315,7 +315,7 @@ draw_tree_item(nctree* n, nctree_int_item* nii, const unsigned* path,
}else{
// FIXME possibly enlarge nii->ncp?
}
if(ncplane_y(nii->ncp) <= *frontiert || *frontierb >= ncplane_dim_y(n->items.ncp)){
if(ncplane_y(nii->ncp) <= *frontiert || *frontierb >= (int)ncplane_dim_y(n->items.ncp)){
ncplane_move_yx(nii->ncp, *frontiert, ncplane_x(nii->ncp));
}else{
ncplane_move_yx(nii->ncp, *frontierb, ncplane_x(nii->ncp));
@ -329,7 +329,7 @@ draw_tree_item(nctree* n, nctree_int_item* nii, const unsigned* path,
if(ncplane_y(nii->ncp) <= *frontiert){
*frontiert = ncplane_y(nii->ncp) - 1;
}
if(ncplane_y(nii->ncp) + ncplane_dim_y(nii->ncp) > *frontierb){
if(ncplane_y(nii->ncp) + (int)ncplane_dim_y(nii->ncp) > *frontierb){
*frontierb = ncplane_y(nii->ncp) + ncplane_dim_y(nii->ncp);
}
return 0;
@ -408,7 +408,7 @@ nctree_inner_redraw(nctree* n, unsigned* tmppath){
nii = n->curitem;
// draw items below the current one FIXME
memcpy(tmppath, n->currentpath, sizeof(*tmppath) * (n->maxdepth + 1));
while(frontierb < ncplane_dim_y(n->items.ncp)){
while(frontierb < (int)ncplane_dim_y(n->items.ncp)){
if((tmpnii = nctree_next_internal(n, tmppath)) == nii){
break;
}

@ -22,7 +22,7 @@ struct ncvisual_details;
typedef struct ncvisual {
struct ncvisual_details* details;// implementation-specific details
uint32_t* data; // (scaled) RGBA image data, rowstride bytes per row
int pixx, pixy; // pixel geometry, *not* cell geometry
unsigned pixx, pixy; // pixel geometry, *not* cell geometry
// lines are sometimes padded. this many true bytes per row in data.
int rowstride;
bool owndata; // we own data iff owndata == true
@ -42,7 +42,7 @@ ncvisual_set_data(ncvisual* ncv, void* data, bool owned){
// shrink one dimension to retrieve the original aspect ratio
static inline void
scale_visual(const ncvisual* ncv, int* disprows, int* dispcols){
scale_visual(const ncvisual* ncv, unsigned* disprows, unsigned* dispcols){
float xratio = (float)(*dispcols) / ncv->pixx;
if(xratio * ncv->pixy > *disprows){
xratio = (float)(*disprows) / ncv->pixy;

@ -121,7 +121,8 @@ ncvisual* ncvisual_create(void){
}
static inline void
ncvisual_origin(const struct ncvisual_options* vopts, int* restrict begy, int* restrict begx){
ncvisual_origin(const struct ncvisual_options* vopts, unsigned* restrict begy,
unsigned* restrict begx){
*begy = vopts ? vopts->begy : 0;
*begx = vopts ? vopts->begx : 0;
}
@ -133,7 +134,8 @@ int ncvisual_blitter_geom(const notcurses* nc, const ncvisual* n,
ncblitter_e* blitter){
ncvgeom geom;
const struct blitset* bset;
int disppxy, disppxx, outy, outx, placey, placex;
unsigned disppxy, disppxx, outy, outx;
int placey, placex;
if(ncvisual_geom_inner(&nc->tcache, n, vopts, &geom, &bset,
&disppxy, &disppxx, &outy, &outx,
&placey, &placex)){
@ -168,8 +170,8 @@ int ncvisual_blitter_geom(const notcurses* nc, const ncvisual* n,
// accounts for sixels being a multiple of six pixels tall.
static void
shape_sprixel_plane(const tinfo* ti, ncplane* parent, const ncvisual* ncv,
ncscale_e scaling, int* disppixy, int* disppixx,
uint64_t flags, int* outy, int* outx,
ncscale_e scaling, unsigned* disppixy, unsigned* disppixx,
uint64_t flags, unsigned* outy, unsigned* outx,
int* placey, int* placex, int pxoffy, int pxoffx){
if(scaling != NCSCALE_NONE && scaling != NCSCALE_NONE_HIRES){
// disppixy/disppix are treated initially as cells
@ -219,8 +221,8 @@ shape_sprixel_plane(const tinfo* ti, ncplane* parent, const ncvisual* ncv,
int ncvisual_geom_inner(const tinfo* ti, const ncvisual* n,
const struct ncvisual_options* vopts, ncvgeom* geom,
const struct blitset** bset,
int* disppixy, int* disppixx,
int* outy, int* outx,
unsigned* disppixy, unsigned* disppixx,
unsigned* outy, unsigned* outx,
int* placey, int* placex){
if(ti == NULL && n == NULL){
logerror("got NULL for both sources\n");
@ -286,17 +288,13 @@ int ncvisual_geom_inner(const tinfo* ti, const ncvisual* n,
geom->leny = vopts->leny;
*placey = vopts->y;
*placex = vopts->x;
logdebug("vis %dx%d+%dx%d %p\n", geom->begy, geom->begx, geom->leny, geom->lenx, n->data);
if(geom->begy < 0 || geom->begx < 0){
logerror("invalid geometry for visual %d %d %d %d\n", geom->begy, geom->begx, geom->leny, geom->lenx);
return -1;
}
logdebug("vis %ux%u+%ux%u %p\n", geom->begy, geom->begx, geom->leny, geom->lenx, n->data);
if(n->data == NULL){
logerror("no data in visual\n");
return -1;
}
if(geom->begx >= n->pixx || geom->begy >= n->pixy){
logerror("visual too large %d > %d or %d > %d\n", geom->begy, n->pixy, geom->begx, n->pixx);
logerror("visual too large %u > %d or %u > %d\n", geom->begy, n->pixy, geom->begx, n->pixx);
return -1;
}
if(geom->lenx == 0){ // 0 means "to the end"; use all available source material
@ -340,13 +338,13 @@ int ncvisual_geom_inner(const tinfo* ti, const ncvisual* n,
}
if(scaling == NCSCALE_NONE || scaling == NCSCALE_NONE_HIRES){
// FIXME clamp to sprixel limits
int rows = ((geom->leny + ti->cellpixy - 1) / ti->cellpixy) + !!vopts->pxoffy;
unsigned rows = ((geom->leny + ti->cellpixy - 1) / ti->cellpixy) + !!vopts->pxoffy;
if(rows > ncplane_dim_y(vopts->n)){
logerror("sprixel too tall %d for plane %d\n", geom->leny + vopts->pxoffy,
ncplane_dim_y(vopts->n) * ti->cellpixy);
return -1;
}
int cols = ((geom->lenx + ti->cellpixx - 1) / ti->cellpixx) + !!vopts->pxoffx;
unsigned cols = ((geom->lenx + ti->cellpixx - 1) / ti->cellpixx) + !!vopts->pxoffx;
if(cols > ncplane_dim_x(vopts->n)){
logerror("sprixel too wide %d for plane %d\n", geom->lenx + vopts->pxoffx,
ncplane_dim_x(vopts->n) * ti->cellpixx);
@ -405,7 +403,7 @@ int ncvisual_geom_inner(const tinfo* ti, const ncvisual* n,
logerror("pixel offsets cannot be used with cell blitting\n");
return -1;
}
int dispcols, disprows;
unsigned dispcols, disprows;
if(vopts->n == NULL || (vopts->flags & NCVISUAL_OPTION_CHILDPLANE)){ // create plane
//fprintf(stderr, "CPATH1, create beg %dx%d len %dx%d\n", geom->begy, geom->begx, geom->leny, geom->lenx);
if(scaling == NCSCALE_NONE || scaling == NCSCALE_NONE_HIRES){
@ -463,7 +461,8 @@ int ncvisual_geom_inner(const tinfo* ti, const ncvisual* n,
int ncvisual_geom(const notcurses* nc, const ncvisual* n,
const struct ncvisual_options* vopts, ncvgeom* geom){
const struct blitset* bset;
int disppxy, disppxx, outy, outx, placey, placex;
unsigned disppxy, disppxx, outy, outx;
int placey, placex;
return ncvisual_geom_inner(nc ? &nc->tcache : NULL, n, vopts, geom, &bset,
&disppxy, &disppxx, &outy, &outx, &placey, &placex);
}
@ -543,7 +542,9 @@ void* bgra_to_rgba(const void* data, int rows, int* rowstride, int cols, int alp
// pixels. Returns the area of the box (0 if there are no pixels).
int ncvisual_bounding_box(const ncvisual* ncv, int* leny, int* lenx,
int* offy, int* offx){
int trow, lcol = -1, rcol = INT_MAX; // FIXME shouldn't need lcol init
unsigned lcol = 0;
unsigned rcol = UINT_MAX;
unsigned trow;
// first, find the topmost row with a real pixel. if there is no such row,
// there are no such pixels. if we find one, we needn't look in this region
// for other extrema, so long as we keep the leftmost and rightmost through
@ -551,13 +552,12 @@ int ncvisual_bounding_box(const ncvisual* ncv, int* leny, int* lenx,
// and rightmost pixel of whichever row has the topmost valid pixel. unlike
// the topmost, they'll need be further verified.
for(trow = 0 ; trow < ncv->pixy ; ++trow){
int x;
for(x = 0 ; x < ncv->pixx ; ++x){
for(unsigned x = 0 ; x < ncv->pixx ; ++x){
uint32_t rgba = ncv->data[trow * ncv->rowstride / 4 + x];
if(rgba){
lcol = x; // leftmost pixel of topmost row
// now find rightmost pixel of topmost row
int xr;
unsigned xr;
for(xr = ncv->pixx - 1 ; xr > x ; --xr){
rgba = ncv->data[trow * ncv->rowstride / 4 + xr];
if(rgba){ // rightmost pixel of topmost row
@ -578,20 +578,19 @@ int ncvisual_bounding_box(const ncvisual* ncv, int* leny, int* lenx,
*offy = 0;
*offx = 0;
}else{
assert(lcol >= 0);
assert(rcol < ncv->pixx);
// we now know topmost row, and left/rightmost through said row. now we must
// find the bottommost row, checking left/rightmost throughout.
int brow;
unsigned brow;
for(brow = ncv->pixy - 1 ; brow > trow ; --brow){
int x;
unsigned x;
for(x = 0 ; x < ncv->pixx ; ++x){
uint32_t rgba = ncv->data[brow * ncv->rowstride / 4 + x];
if(rgba){
if(x < lcol){
lcol = x;
}
int xr;
unsigned xr;
for(xr = ncv->pixx - 1 ; xr > x && xr > rcol ; --xr){
rgba = ncv->data[brow * ncv->rowstride / 4 + xr];
if(rgba){ // rightmost pixel of bottommost row
@ -610,15 +609,15 @@ int ncvisual_bounding_box(const ncvisual* ncv, int* leny, int* lenx,
}
// we now know topmost and bottommost row, and left/rightmost within those
// two sections. now check the rest for left and rightmost.
for(int y = trow + 1 ; y < brow ; ++y){
for(int x = 0 ; x < lcol ; ++x){
for(unsigned y = trow + 1 ; y < brow ; ++y){
for(unsigned x = 0 ; x < lcol ; ++x){
uint32_t rgba = ncv->data[y * ncv->rowstride / 4 + x];
if(rgba){
lcol = x;
break;
}
}
for(int x = ncv->pixx - 1 ; x > rcol ; --x){
for(unsigned x = ncv->pixx - 1 ; x > rcol ; --x){
uint32_t rgba = ncv->data[y * ncv->rowstride / 4 + x];
if(rgba){
rcol = x;
@ -746,14 +745,16 @@ int ncvisual_rotate(ncvisual* ncv, double rads){
}
memset(data, 0, bbarea * 4);
//fprintf(stderr, "bbarea: %d bby: %d bbx: %d centy: %d centx: %d bbcenty: %d bbcentx: %d\n", bbarea, bby, bbx, centy, centx, bbcenty, bbcentx);
for(int y = 0 ; y < ncv->pixy ; ++y){
for(int x = 0 ; x < ncv->pixx ; ++x){
for(unsigned y = 0 ; y < ncv->pixy ; ++y){
for(unsigned x = 0 ; x < ncv->pixx ; ++x){
int targx = x, targy = y;
rotate_point(&targy, &targx, stheta, ctheta, centy, centx);
const int deconvx = targx - bboffx;
const int deconvy = targy - bboffy;
if(deconvy >= 0 && deconvx >= 0 && deconvy < bby && deconvx < bbx){
data[deconvy * bbx + deconvx] = ncv->data[y * (ncv->rowstride / 4) + x];
if(targx > bboffx && targy > bboffy){
const int deconvx = targx - bboffx;
const int deconvy = targy - bboffy;
if(deconvy < bby && deconvx < bbx){
data[deconvy * bbx + deconvx] = ncv->data[y * (ncv->rowstride / 4) + x];
}
}
//fprintf(stderr, "CW: %d/%d (%08x) -> %d/%d (stride: %d)\n", y, x, ncv->data[y * (ncv->rowstride / 4) + x], targy, targx, ncv->rowstride);
//fprintf(stderr, "wrote %08x to %d (%d)\n", data[targy * ncv->pixy + targx], targy * ncv->pixy + targx, (targy * ncv->pixy + targx) * 4);
@ -1113,7 +1114,8 @@ ncplane* ncvisual_blit(notcurses* nc, ncvisual* ncv, const struct ncvisual_optio
vopts->leny, vopts->lenx, vopts->begy, vopts->begx, vopts->n);
ncvgeom geom;
const struct blitset* bset;
int disppxy, disppxx, outy, outx, placey, placex;
unsigned disppxy, disppxx, outy, outx;
int placey, placex;
if(ncvisual_geom_inner(&nc->tcache, ncv, vopts, &geom, &bset,
&disppxy, &disppxx, &outy, &outx,
&placey, &placex)){
@ -1199,7 +1201,7 @@ ncvisual* ncvisual_from_plane(const ncplane* n, ncblitter_e blit,
if(rgba == NULL){
return NULL;
}
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(n, &dimy, &dimx);
ncvisual* ncv = ncvisual_from_rgba(rgba, py, px * 4, px);
free(rgba);
@ -1241,22 +1243,26 @@ int ncvisual_simple_streamer(ncvisual* ncv, struct ncvisual_options* vopts,
return ret;
}
int ncvisual_set_yx(const struct ncvisual* n, int y, int x, uint32_t pixel){
if(y >= n->pixy || y < 0){
int ncvisual_set_yx(const struct ncvisual* n, unsigned y, unsigned x, uint32_t pixel){
if(y >= n->pixy){
logerror("invalid coordinates %u/%u\n", y, x);
return -1;
}
if(x >= n->pixx || x < 0){
if(x >= n->pixx){
logerror("invalid coordinates %u/%u\n", y, x);
return -1;
}
n->data[y * (n->rowstride / 4) + x] = pixel;
return 0;
}
int ncvisual_at_yx(const ncvisual* n, int y, int x, uint32_t* pixel){
if(y >= n->pixy || y < 0){
int ncvisual_at_yx(const ncvisual* n, unsigned y, unsigned x, uint32_t* pixel){
if(y >= n->pixy){
logerror("invalid coordinates %u/%u\n", y, x);
return -1;
}
if(x >= n->pixx || x < 0){
if(x >= n->pixx){
logerror("invalid coordinates %u/%u\n", y, x);
return -1;
}
*pixel = n->data[y * (n->rowstride / 4) + x];
@ -1287,7 +1293,7 @@ create_polyfill_op(int y, int x, struct topolyfill** stack){
// exploding once i multithreaded the [yield] demo. hence the clumsy stack
// and hand-rolled iteration. alas, poor yorick!
static int
ncvisual_polyfill_core(ncvisual* n, int y, int x, uint32_t rgba, uint32_t match){
ncvisual_polyfill_core(ncvisual* n, unsigned y, unsigned x, uint32_t rgba, uint32_t match){
struct topolyfill* stack = malloc(sizeof(*stack));
if(stack == NULL){
return -1;
@ -1332,11 +1338,13 @@ ncvisual_polyfill_core(ncvisual* n, int y, int x, uint32_t rgba, uint32_t match)
return ret;
}
int ncvisual_polyfill_yx(ncvisual* n, int y, int x, uint32_t rgba){
if(y >= n->pixy || y < 0){
int ncvisual_polyfill_yx(ncvisual* n, unsigned y, unsigned x, uint32_t rgba){
if(y >= n->pixy){
logerror("invalid coordinates %u/%u\n", y, x);
return -1;
}
if(x >= n->pixx || x < 0){
if(x >= n->pixx){
logerror("invalid coordinates %u/%u\n", y, x);
return -1;
}
uint32_t* pixel = &n->data[y * (n->rowstride / 4) + x];

@ -141,7 +141,7 @@ subtitle_plane_from_text(ncplane* parent, const char* text){
uint64_t channels = 0;
ncchannels_set_fg_alpha(&channels, NCALPHA_HIGHCONTRAST);
ncchannels_set_fg_rgb8(&channels, 0x88, 0x88, 0x88);
ncplane_stain(n, -1, -1, channels, channels, channels, channels);
ncplane_stain(n, -1, -1, 0, 0, channels, channels, channels, channels);
ncchannels_set_fg_default(&channels);
ncplane_puttext(n, 0, NCALIGN_LEFT, text, NULL);
ncchannels_set_bg_alpha(&channels, NCALPHA_TRANSPARENT);

@ -88,7 +88,7 @@ auto perframe(struct ncvisual* ncv, struct ncvisual_options* vopts,
if(!nc.render()){
return -1;
}
int dimx, dimy, oldx, oldy;
unsigned dimx, dimy, oldx, oldy;
nc.get_term_dim(&dimy, &dimx);
ncplane_dim_yx(vopts->n, &oldy, &oldx);
uint64_t absnow = timespec_to_ns(abstime);
@ -346,7 +346,7 @@ int direct_mode_player(int argc, char** argv, ncscale_e scalemode,
if(dm.streamfile(argv[i], perframe_direct, &vopts, NULL)){
failed = true;
}
int y, x;
unsigned y, x;
dm.get_cursor_yx(&y, &x);
if(x){
std::cout << std::endl;
@ -361,7 +361,7 @@ int rendered_mode_player_inner(NotCurses& nc, int argc, char** argv,
bool quiet, bool loop,
double timescale, double displaytime,
bool noninterp, uint32_t transcolor){
int dimy, dimx;
unsigned dimy, dimx;
std::unique_ptr<Plane> stdn(nc.get_stdplane(&dimy, &dimx));
uint64_t transchan = 0;
ncchannels_set_fg_alpha(&transchan, NCALPHA_TRANSPARENT);

@ -11,9 +11,9 @@ emit(struct ncplane* n, const char* str){
// draw a bitmap of 6x6 cells with a cell left out
static int
wipebitmap(struct notcurses* nc){
int cellpxy, cellpxx;
unsigned cellpxy, cellpxx;
ncplane_pixelgeom(notcurses_stdplane(nc), NULL, NULL,
&cellpxy, &cellpxx, NULL, NULL);
&cellpxy, &cellpxx, NULL, NULL);
int pixy = cellpxy * 6;
int pixx = cellpxx * 6;
uint32_t* pixels = malloc(sizeof(*pixels) * pixx * pixy);
@ -79,7 +79,7 @@ wipebitmap(struct notcurses* nc){
sleep(2);
ncplane_erase(notcurses_stdplane(nc));
for(int i = cellpxy ; i < 5 * cellpxy ; ++i){
for(unsigned i = cellpxy ; i < 5 * cellpxy ; ++i){
memset(pixels + (i * 6 * cellpxx + cellpxx), 0, cellpxx * 4 * sizeof(*pixels));
}
struct ncvisual* ncve = ncvisual_from_rgba(pixels, 6 * cellpxy, 6 * cellpxx * 4, 6 * cellpxx);

@ -14,7 +14,7 @@ int main(void){
if(nc == NULL){
return EXIT_FAILURE;
}
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* n = notcurses_stddim_yx(nc, &dimy, &dimx);
wchar_t wc = 0x4e00;
ncplane_set_scrolling(n, true);

@ -35,13 +35,13 @@ int main(void){
if(n == NULL){
return EXIT_FAILURE;
}
int y, x;
unsigned y, x;
if(ncdirect_cursor_yx(n, &y, &x)){
goto err;
}
int dimx = ncdirect_dim_x(n);
int dimy = ncdirect_dim_y(n);
printf("Cursor: column %d/%d row %d/%d\n", x, dimx, y, dimy);
unsigned dimx = ncdirect_dim_x(n);
unsigned dimy = ncdirect_dim_y(n);
printf("Cursor: column %u/%u row %u/%u\n", x, dimx, y, dimy);
ncdirect_stop(n);
return EXIT_SUCCESS;

@ -36,14 +36,14 @@ int main(void){
ret |= ncdirect_cursor_right(n, dimx / 2);
ret |= ncdirect_cursor_up(n, dimy / 2);
printf(" erperperp! \n");
int y = -420, x = -420;
unsigned y, x;
// FIXME try a push/pop
if(ncdirect_cursor_yx(n, &y, &x) == 0){
printf("\n\tRead cursor position: y: %d x: %d\n", y, x);
y += 2; // we just went down two lines
while(y > 3){
ret = -1;
int newy;
unsigned newy;
if(ncdirect_cursor_yx(n, &newy, NULL)){
break;
}

@ -8,8 +8,7 @@ int main(void){
}
uint64_t flags = NCDIRECT_OPTION_DRAIN_INPUT;
struct ncdirect* n = ncdirect_core_init(NULL, stdout, flags);
putchar('\n');
for(int i = 0 ; i < 15 ; ++i){
for(int i = 1 ; i < 15 ; ++i){
uint64_t c1 = 0, c2 = 0;
ncchannels_set_fg_rgb8(&c1, 0x0, 0x10 * i, 0xff);
ncchannels_set_fg_rgb8(&c2, 0x10 * i, 0x0, 0x0);
@ -21,7 +20,7 @@ int main(void){
ncdirect_set_bg_default(n);
putchar('\n');
}
for(int i = 0 ; i < 15 ; ++i){
for(int i = 1 ; i < 15 ; ++i){
uint64_t c1 = 0, c2 = 0;
ncchannels_set_fg_rgb8(&c1, 0x0, 0x10 * i, 0xff);
ncchannels_set_fg_rgb8(&c2, 0x10 * i, 0x0, 0x0);

@ -25,7 +25,7 @@ int main(int argc, char** argv){
if(nc == NULL){
return EXIT_FAILURE;
}
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* n = notcurses_stddim_yx(nc, &dimy, &dimx);
ncplane_set_scrolling(n, true);
for(int i = 0 ; i < rows ; ++i){

@ -6,13 +6,13 @@
// gradient of 'A's changing color and background changing in reverse
static int
gradientA(struct notcurses* nc){
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* stdn = notcurses_stddim_yx(nc, &dimy, &dimx);
uint64_t ul = NCCHANNELS_INITIALIZER(0, 0, 0, 0xff, 0xff, 0xff);
uint64_t ur = NCCHANNELS_INITIALIZER(0, 0xff, 0xff, 0xff, 0, 0);
uint64_t ll = NCCHANNELS_INITIALIZER(0xff, 0, 0, 0, 0xff, 0xff);
uint64_t lr = NCCHANNELS_INITIALIZER(0xff, 0xff, 0xff, 0, 0, 0);
if(ncplane_gradient(stdn, "A", NCSTYLE_NONE, ul, ur, ll, lr, dimy - 1, dimx - 1) <= 0){
if(ncplane_gradient(stdn, 0, 0, 0, 0, "A", NCSTYLE_NONE, ul, ur, ll, lr) <= 0){
return -1;
}
if(notcurses_render(nc)){
@ -24,20 +24,20 @@ gradientA(struct notcurses* nc){
static int
gradStriations(struct notcurses* nc){
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* stdn = notcurses_stddim_yx(nc, &dimy, &dimx);
uint64_t ul = NCCHANNELS_INITIALIZER(0, 0, 0, 0xff, 0xff, 0xff);
uint64_t ur = NCCHANNELS_INITIALIZER(0, 0xff, 0xff, 0xff, 0, 0);
uint64_t ll = NCCHANNELS_INITIALIZER(0xff, 0, 0, 0, 0xff, 0xff);
uint64_t lr = NCCHANNELS_INITIALIZER(0xff, 0xff, 0xff, 0, 0, 0);
if(ncplane_gradient(stdn, "", NCSTYLE_NONE, ul, ur, ll, lr, dimy - 1, dimx - 1) <= 0){
if(ncplane_gradient(stdn, 0, 0, 0, 0, "", NCSTYLE_NONE, ul, ur, ll, lr) <= 0){
return -1;
}
if(notcurses_render(nc)){
return -1;
}
sleep(1);
if(ncplane_gradient(stdn, "", NCSTYLE_NONE, ul, ur, ll, lr, dimy - 1, dimx - 1) <= 0){
if(ncplane_gradient(stdn, 0, 0, 0, 0, "", NCSTYLE_NONE, ul, ur, ll, lr) <= 0){
return -1;
}
if(notcurses_render(nc)){
@ -49,13 +49,13 @@ gradStriations(struct notcurses* nc){
static int
gradHigh(struct notcurses* nc){
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* stdn = notcurses_stddim_yx(nc, &dimy, &dimx);
uint64_t ul = NCCHANNEL_INITIALIZER(0, 0, 0);
uint64_t ur = NCCHANNEL_INITIALIZER(0, 0xff, 0xff);
uint64_t ll = NCCHANNEL_INITIALIZER(0xff, 0, 0);
uint64_t lr = NCCHANNEL_INITIALIZER(0xff, 0xff, 0xff);
if(ncplane_highgradient(stdn, ul, ur, ll, lr, dimy - 1, dimx - 1) <= 0){
if(ncplane_gradient2x1(stdn, 0, 0, 0, 0, ul, ur, ll, lr) <= 0){
return -1;
}
if(notcurses_render(nc)){

@ -2,8 +2,8 @@
struct ncvisual*
draw_grid(struct ncplane* stdn){
int maxby, maxbx;
int cellpxy, cellpxx;
unsigned maxby, maxbx;
unsigned cellpxy, cellpxx;
ncplane_pixelgeom(stdn, NULL, NULL, &cellpxy, &cellpxx, &maxby, &maxbx);
if(cellpxy <= 1 || cellpxx <= 1){
fprintf(stderr, "cell-pixel geometry: %d %d\n", cellpxy, cellpxx);
@ -15,20 +15,20 @@ draw_grid(struct ncplane* stdn){
}
// we want an inlay on each cell, so if they're 10 wide, we want pixels
// at 0, 9, 10, 19, 20, 29, etc.
for(int y = 0 ; y < maxby ; ++y){
for(unsigned y = 0 ; y < maxby ; ++y){
uint32_t* row = rgba + y * maxbx;
for(int x = 0 ; x < maxbx ; ++x){
for(unsigned x = 0 ; x < maxbx ; ++x){
uint32_t* px = row + x;
ncpixel_set_a(px, 255);
ncpixel_set_r(px, 0x39);
ncpixel_set_g(px, 0xff);
ncpixel_set_b(px, 0xa0);
}
for(int yi = 0 ; yi < cellpxy - 2 ; ++yi){
for(unsigned yi = 0 ; yi < cellpxy - 2 ; ++yi){
++y;
if(y < maxby){
row = rgba + y * maxbx;
for(int x = 0 ; x < maxbx ; ++x){
for(unsigned x = 0 ; x < maxbx ; ++x){
uint32_t* px = row + x;
ncpixel_set_a(px, 255);
ncpixel_set_r(px, 0x39);
@ -47,12 +47,12 @@ draw_grid(struct ncplane* stdn){
++y;
row = rgba + y * maxbx;
if(y < maxby){
for(int x = 0 ; x < maxbx ; ++x){
uint32_t* px = row + x;
ncpixel_set_a(px, 255);
ncpixel_set_r(px, 0x39);
ncpixel_set_g(px, 0xff);
ncpixel_set_b(px, 0xa0);
for(unsigned x = 0 ; x < maxbx ; ++x){
uint32_t* px = row + x;
ncpixel_set_a(px, 255);
ncpixel_set_r(px, 0x39);
ncpixel_set_g(px, 0xff);
ncpixel_set_b(px, 0xa0);
}
}
}
@ -74,7 +74,7 @@ int main(void){
if(nc == NULL){
return EXIT_FAILURE;
}
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* stdn = notcurses_stddim_yx(nc, &dimy, &dimx);
struct ncvisual* ncv = draw_grid(stdn);
if(ncv == NULL){

@ -130,7 +130,7 @@ int main(int argc, char **argv){
putchar('\n');
}
if(realcols > 20){
for(int z = 0 ; z < realcols && z < ncdirect_dim_x(n) ; ++z){
for(unsigned z = 0 ; z < realcols && z < ncdirect_dim_x(n) ; ++z){
if(z % 10){
putchar(' ');
}else{

@ -8,10 +8,10 @@ handle(struct notcurses* nc, const char *fn){
if(ncv == NULL){
return -1;
}
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* stdn = notcurses_stddim_yx(nc, &dimy, &dimx);
for(int y = 0 ; y < dimy ; y += 15){
for(int x = 0 ; x < dimx ; x += 15){
for(unsigned y = 0 ; y < dimy ; y += 15){
for(unsigned x = 0 ; x < dimx ; x += 15){
uint64_t channels = NCCHANNELS_INITIALIZER(rand() % 256, rand() % 256, 100, rand() % 256, 100, 140);
ncplane_set_base(stdn, "a", 0, channels);
struct ncvisual_options vopts = {

@ -31,7 +31,7 @@ pbar_fill(struct notcurses* nc, struct ncprogbar* pbar){
static struct ncprogbar*
hbar_make(struct notcurses* nc, uint64_t flags){
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* std = notcurses_stddim_yx(nc, &dimy, &dimx);
struct ncplane_options nopts = {
.y = 1,
@ -45,8 +45,9 @@ hbar_make(struct notcurses* nc, uint64_t flags){
if(pbar == NULL){
return NULL;
}
int posy, posx, pdimy, pdimx;
int posy, posx;
ncplane_yx(pbar, &posy, &posx);
unsigned pdimy, pdimx;
ncplane_dim_yx(pbar, &pdimy, &pdimx);
ncplane_cursor_move_yx(std, posy - 1, posx - 1);
uint64_t channels = 0;
@ -71,7 +72,7 @@ hbar_make(struct notcurses* nc, uint64_t flags){
static struct ncprogbar*
pbar_make(struct notcurses* nc, uint64_t flags){
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* std = notcurses_stddim_yx(nc, &dimy, &dimx);
struct ncplane_options nopts = {
.y = dimy / 2,
@ -85,8 +86,9 @@ pbar_make(struct notcurses* nc, uint64_t flags){
if(pbar == NULL){
return NULL;
}
int posy, posx, pdimy, pdimx;
int posy, posx;
ncplane_yx(pbar, &posy, &posx);
unsigned pdimy, pdimx;
ncplane_dim_yx(pbar, &pdimy, &pdimx);
ncplane_cursor_move_yx(std, posy - 1, posx - 1);
uint64_t channels = 0;

@ -30,7 +30,7 @@ int main(int argc, const char** argv){
| NCOPTION_DRAIN_INPUT,
};
struct notcurses* nc = notcurses_init(&opts, NULL);
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* std = notcurses_stddim_yx(nc, &dimy, &dimx);
while(*++argv){
if(render_qrcode(std, dimy, dimx, *argv)){

@ -17,7 +17,7 @@ int main(void){
if(nc == NULL){
return EXIT_FAILURE;
}
int y, x, dimy, dimx;
unsigned dimy, dimx;
struct ncplane* n = notcurses_stdplane(nc);
ncplane_dim_yx(n, &dimy, &dimx);
int r , g, b;
@ -25,8 +25,8 @@ int main(void){
g = 0x80;
b = 0;
ncplane_set_bg_rgb8(n, 0x40, 0x20, 0x40);
for(y = 0 ; y < dimy ; ++y){
for(x = 0 ; x < dimx ; ++x){
for(unsigned y = 0 ; y < dimy ; ++y){
for(unsigned x = 0 ; x < dimx ; ++x){
if(ncplane_set_fg_rgb8(n, r, g, b)){
goto err;
}

@ -29,7 +29,7 @@ int main(int argc, char** argv){
if((nc = notcurses_init(&opts, NULL)) == NULL){
return EXIT_FAILURE;
}
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* n = ncplane_dup(notcurses_stddim_yx(nc, &dimy, &dimx), NULL);
if(!n){
notcurses_stop(nc);

@ -14,7 +14,7 @@ int main(void){
if(nc == NULL){
return EXIT_FAILURE;
}
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* n = notcurses_stddim_yx(nc, &dimy, &dimx);
char c = 'A';
ncplane_set_scrolling(n, true);

@ -13,7 +13,7 @@ int main(void){
if(nc == NULL){
return EXIT_FAILURE;
}
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* n = notcurses_stddim_yx(nc, &dimy, &dimx);
ncplane_set_scrolling(n, true);
// FIXME do full permutations?

@ -63,7 +63,7 @@ int main(int argc, char** argv){
if(!nc){
return EXIT_FAILURE;
}
int rows, cols;
unsigned rows, cols;
struct ncplane* stdp = notcurses_stddim_yx(nc, &rows, &cols);
struct ncplane_options popts = {
.y = 3,

@ -413,8 +413,7 @@ ncdup_paint(struct ncplane* n){
uint32_t tr = NCCHANNEL_INITIALIZER(0x88, 0x88, 0x88);
uint32_t bl = NCCHANNEL_INITIALIZER(0x88, 0x88, 0x88);
uint32_t br = NCCHANNEL_INITIALIZER(0xff, 0xff, 0xff);
return ncplane_highgradient_sized(n, tl, tr, bl, br,
ncplane_dim_y(n), ncplane_dim_x(n));
return ncplane_gradient2x1(n, -1, -1, 0, 0, tl, tr, bl, br);
}
static int

@ -31,7 +31,7 @@ auto main(int argc, const char** argv) -> int {
notcurses_options ncopts{};
ncopts.flags = NCOPTION_INHIBIT_SETLOCALE;
NotCurses nc(ncopts);
int dimy, dimx;
unsigned dimy, dimx;
auto n = std::make_unique<Plane *>(nc.get_stdplane(&dimy, &dimx));
nc.get_term_dim(&dimy, &dimx);
ncreader_options opts{};
@ -55,7 +55,7 @@ auto main(int argc, const char** argv) -> int {
return EXIT_FAILURE;
}
ncinput ni;
int tgeomy, tgeomx, vgeomy, vgeomx;
unsigned tgeomy, tgeomx, vgeomy, vgeomx;
struct ncplane* ncp = ncreader_plane(nr);
struct ncplane* tplane = ncplane_above(ncp);
ncplane_dim_yx(tplane, &tgeomy, &tgeomx);

@ -189,7 +189,7 @@ int runreels(struct notcurses* nc, struct ncreel* nr){
static int
resize_reel(struct ncplane* n){
const struct ncplane* p = ncplane_parent_const(n);
int py, px;
unsigned py, px;
ncplane_dim_yx(p, &py, &px);
if(ncplane_resize(n, 0, 0, 0, 0, 0, 0, py - 1, px) < 0){
return -1;
@ -210,7 +210,7 @@ int main(int argc, char** argv){
if(nc == nullptr){
return EXIT_FAILURE;
}
int dimy, dimx;
unsigned dimy, dimx;
auto nstd = notcurses_stddim_yx(nc, &dimy, &dimx);
struct ncplane* n;
if(ncplane_putstr_aligned(nstd, 0, NCALIGN_CENTER, "(a)dd (d)el (+/-) change lines (q)uit") <= 0){

@ -23,7 +23,7 @@ int main(int argc, char** argv){
}
struct ncvisual_options vopts{};
bool failed = false;
int dimy, dimx;
unsigned dimy, dimx;
int top = 0;
int bot;
auto ncv = ncvisual_from_file(file);

@ -14,7 +14,7 @@ auto main() -> int {
if(nc == nullptr){
return EXIT_FAILURE;
}
int y, x, dimy, dimx;
unsigned dimy, dimx;
struct ncplane* n = notcurses_stdplane(nc);
ncplane_dim_yx(n, &dimy, &dimx);
int r , g, b;
@ -22,11 +22,11 @@ auto main() -> int {
g = 0x80;
b = 0;
ncplane_set_fg_rgb8(n, 0x40, 0x20, 0x40);
for(y = 0 ; y < dimy ; ++y){
for(unsigned y = 0 ; y < dimy ; ++y){
if(ncplane_cursor_move_yx(n, y, 0)){
goto err;
}
for(x = 0 ; x < dimx ; ++x){
for(unsigned x = 0 ; x < dimx ; ++x){
if(ncplane_set_bg_rgb8(n, r, g, b)){
goto err;
}

@ -42,7 +42,7 @@ TEST_CASE("Ncpp"
NotCurses nc{ nopts };
auto std1 = nc.get_stdplane();
CHECK(nullptr != std1);
int y, x;
unsigned y, x;
auto std2 = nc.get_stdplane(&y, &x);
CHECK(nullptr != std2);
CHECK(0 < x);

@ -52,7 +52,7 @@ TEST_CASE("Bitmaps") {
vopts.n = nn;
vopts.blitter = NCBLIT_PIXEL;
vopts.flags = NCVISUAL_OPTION_NODEGRADE;
int maxy, maxx;
unsigned maxy, maxx;
ncplane_pixelgeom(n_, nullptr, nullptr, nullptr, nullptr, &maxy, &maxx);
CHECK(0 == ncvisual_resize(ncv, maxy, maxx));
auto n = ncvisual_blit(nc_, ncv, &vopts);
@ -539,7 +539,7 @@ TEST_CASE("Bitmaps") {
CHECK(s->dimy == dimy);
CHECK(s->dimx == dimx);
const auto tam = n->tam;
for(int i = 0 ; i < s->dimy * s->dimx ; ++i){
for(unsigned i = 0 ; i < s->dimy * s->dimx ; ++i){
int py = (i / dimx) * nc_->tcache.cellpixy;
int px = (i % dimx) * nc_->tcache.cellpixx;
// cells with a transparent pixel ought be SPRIXCELL_MIXED;
@ -595,10 +595,10 @@ TEST_CASE("Bitmaps") {
CHECK(newn);
ncplane_move_bottom(newn);
CHECK(0 == notcurses_render(nc_));
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(n_, &dimy, &dimx);
for(int y = 0 ; y < dimy ; ++y){
for(int x = 0 ; x < dimx ; ++x){
for(unsigned y = 0 ; y < dimy ; ++y){
for(unsigned x = 0 ; x < dimx ; ++x){
CHECK(1 == ncplane_putchar_yx(n_, y, x, 'x'));
// FIXME generates too much output, OOMing ctest
// CHECK(0 == notcurses_render(nc_));
@ -624,7 +624,7 @@ TEST_CASE("Bitmaps") {
vopts.flags = NCVISUAL_OPTION_NODEGRADE | NCVISUAL_OPTION_CHILDPLANE;
auto n = ncvisual_blit(nc_, ncv, &vopts);
REQUIRE(nullptr != n);
for(int i = 0 ; i <= ncplane_dim_x(n_) ; ++i){
for(unsigned i = 0 ; i <= ncplane_dim_x(n_) ; ++i){
CHECK(0 == ncplane_move_yx(n, 0, i));
CHECK(0 == notcurses_render(nc_));
}
@ -646,7 +646,7 @@ TEST_CASE("Bitmaps") {
vopts.x = ncplane_dim_x(n_) - 3;
auto n = ncvisual_blit(nc_, ncv, &vopts);
REQUIRE(nullptr != n);
for(int i = ncplane_dim_x(n_) - 3 ; i >= 0 ; --i){
for(int i = static_cast<int>(ncplane_dim_x(n_)) - 3 ; i >= 0 ; --i){
CHECK(0 == ncplane_move_yx(n, 0, i));
CHECK(0 == notcurses_render(nc_));
}
@ -667,7 +667,7 @@ TEST_CASE("Bitmaps") {
vopts.flags = NCVISUAL_OPTION_NODEGRADE | NCVISUAL_OPTION_CHILDPLANE;
auto n = ncvisual_blit(nc_, ncv, &vopts);
REQUIRE(nullptr != n);
for(int i = 0 ; i <= ncplane_dim_y(n_) ; ++i){
for(unsigned i = 0 ; i <= ncplane_dim_y(n_) ; ++i){
CHECK(0 == ncplane_move_yx(n, i, 0));
CHECK(0 == notcurses_render(nc_));
}
@ -689,7 +689,7 @@ TEST_CASE("Bitmaps") {
vopts.flags = NCVISUAL_OPTION_NODEGRADE | NCVISUAL_OPTION_CHILDPLANE;
auto n = ncvisual_blit(nc_, ncv, &vopts);
REQUIRE(nullptr != n);
for(int i = ncplane_dim_y(n_) - 3 ; i >= 0 ; --i){
for(int i = static_cast<int>(ncplane_dim_y(n_)) - 3 ; i >= 0 ; --i){
CHECK(0 == ncplane_move_yx(n, i, 0));
CHECK(0 == notcurses_render(nc_));
}

@ -71,7 +71,7 @@ TEST_CASE("Cell") {
SUBCASE("SetItalic") {
nccell c = CELL_TRIVIAL_INITIALIZER;
int dimy, dimx;
unsigned dimy, dimx;
notcurses_term_dim_yx(nc_, &dimy, &dimx);
nccell_set_styles(&c, NCSTYLE_ITALIC);
CHECK(1 == nccell_load(n_, &c, "i"));
@ -84,7 +84,7 @@ TEST_CASE("Cell") {
SUBCASE("SetBold") {
nccell c = CELL_TRIVIAL_INITIALIZER;
int dimy, dimx;
unsigned dimy, dimx;
notcurses_term_dim_yx(nc_, &dimy, &dimx);
nccell_set_styles(&c, NCSTYLE_BOLD);
CHECK(1 == nccell_load(n_, &c, "b"));
@ -97,7 +97,7 @@ TEST_CASE("Cell") {
SUBCASE("SetUnderline") {
nccell c = CELL_TRIVIAL_INITIALIZER;
int dimy, dimx;
unsigned dimy, dimx;
notcurses_term_dim_yx(nc_, &dimy, &dimx);
nccell_set_styles(&c, NCSTYLE_UNDERLINE);
CHECK(1 == nccell_load(n_, &c, "u"));

@ -139,14 +139,12 @@ TEST_CASE("Direct") {
CHECK(nullptr != ncdv);
CHECK(0 == ncdirect_raster_frame(nc_, ncdv, NCALIGN_LEFT));
ncdirectf_free(dirf);
int y, x;
int dimy = ncdirect_dim_y(nc_);
int dimx = ncdirect_dim_x(nc_);
unsigned y, x;
// FIXME fails if u6 is reversed (on e.g. kmscon)
CHECK(0 == ncdirect_cursor_yx(nc_, &y, &x));
CHECK(0 <= y);
auto dimy = ncdirect_dim_y(nc_);
auto dimx = ncdirect_dim_x(nc_);
CHECK(dimy > y);
CHECK(0 <= x);
CHECK(dimx > x);
}
}
@ -163,13 +161,11 @@ TEST_CASE("Direct") {
CHECK(nullptr != ncdv);
CHECK(0 == ncdirect_raster_frame(nc_, ncdv, NCALIGN_LEFT));
ncdirectf_free(dirf);
int y, x;
int dimy = ncdirect_dim_y(nc_);
int dimx = ncdirect_dim_x(nc_);
unsigned y, x;
CHECK(0 == ncdirect_cursor_yx(nc_, &y, &x));
CHECK(0 <= y);
auto dimy = ncdirect_dim_y(nc_);
auto dimx = ncdirect_dim_x(nc_);
CHECK(dimy > y);
CHECK(0 <= x);
CHECK(dimx > x);
}
}

@ -7,7 +7,7 @@ TEST_CASE("Erase") {
if(!nc_){
return;
}
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* n_ = notcurses_stddim_yx(nc_, &dimy, &dimx);
REQUIRE(n_);
@ -21,8 +21,8 @@ TEST_CASE("Erase") {
// clear all columns to the left of cursor, inclusive
SUBCASE("EraseColumnsLeft") {
CHECK(0 == ncplane_erase_region(n_, -1, -1, 0, -INT_MAX));
for(int y = 0 ; y < dimy ; ++y){
for(int x = 0 ; x < dimx ; ++x){
for(unsigned y = 0 ; y < dimy ; ++y){
for(unsigned x = 0 ; x < dimx ; ++x){
char* c = ncplane_at_yx(n_, y, x, nullptr, nullptr);
REQUIRE(nullptr != c);
if(x <= dimx / 2){
@ -38,8 +38,8 @@ TEST_CASE("Erase") {
// clear all columns to the right of cursor, inclusive
SUBCASE("EraseColumnsRight") {
CHECK(0 == ncplane_erase_region(n_, -1, -1, 0, INT_MAX));
for(int y = 0 ; y < dimy ; ++y){
for(int x = 0 ; x < dimx ; ++x){
for(unsigned y = 0 ; y < dimy ; ++y){
for(unsigned x = 0 ; x < dimx ; ++x){
char* c = ncplane_at_yx(n_, y, x, nullptr, nullptr);
REQUIRE(nullptr != c);
if(x >= dimx / 2){
@ -55,8 +55,8 @@ TEST_CASE("Erase") {
// clear all rows above cursor, inclusive
SUBCASE("EraseRowsAbove") {
CHECK(0 == ncplane_erase_region(n_, -1, -1, -INT_MAX, 0));
for(int y = 0 ; y < dimy ; ++y){
for(int x = 0 ; x < dimx ; ++x){
for(unsigned y = 0 ; y < dimy ; ++y){
for(unsigned x = 0 ; x < dimx ; ++x){
char* c = ncplane_at_yx(n_, y, x, nullptr, nullptr);
REQUIRE(nullptr != c);
if(y <= dimy / 2){
@ -72,8 +72,8 @@ TEST_CASE("Erase") {
// clear all rows below cursor, inclusive
SUBCASE("EraseRowsBelow") {
CHECK(0 == ncplane_erase_region(n_, -1, -1, INT_MAX, 0));
for(int y = 0 ; y < dimy ; ++y){
for(int x = 0 ; x < dimx ; ++x){
for(unsigned y = 0 ; y < dimy ; ++y){
for(unsigned x = 0 ; x < dimx ; ++x){
char* c = ncplane_at_yx(n_, y, x, nullptr, nullptr);
REQUIRE(nullptr != c);
if(y >= dimy / 2){
@ -89,8 +89,8 @@ TEST_CASE("Erase") {
// current cursor to the end of the line
SUBCASE("EraseToEOL") {
CHECK(0 == ncplane_erase_region(n_, -1, -1, 1, INT_MAX));
for(int y = 0 ; y < dimy ; ++y){
for(int x = 0 ; x < dimx ; ++x){
for(unsigned y = 0 ; y < dimy ; ++y){
for(unsigned x = 0 ; x < dimx ; ++x){
char* c = ncplane_at_yx(n_, y, x, nullptr, nullptr);
REQUIRE(nullptr != c);
if(y == dimy / 2 && x >= dimx / 2){
@ -106,8 +106,8 @@ TEST_CASE("Erase") {
// current cursor to the start of the line
SUBCASE("EraseToSOL") {
CHECK(0 == ncplane_erase_region(n_, -1, -1, 1, -INT_MAX));
for(int y = 0 ; y < dimy ; ++y){
for(int x = 0 ; x < dimx ; ++x){
for(unsigned y = 0 ; y < dimy ; ++y){
for(unsigned x = 0 ; x < dimx ; ++x){
char* c = ncplane_at_yx(n_, y, x, nullptr, nullptr);
REQUIRE(nullptr != c);
if(y == dimy / 2 && x <= dimx / 2){
@ -123,8 +123,8 @@ TEST_CASE("Erase") {
// current cursor to the end of the line using -1 len
SUBCASE("EraseToEOLNeg") {
CHECK(0 == ncplane_erase_region(n_, -1, -1, -1, INT_MAX));
for(int y = 0 ; y < dimy ; ++y){
for(int x = 0 ; x < dimx ; ++x){
for(unsigned y = 0 ; y < dimy ; ++y){
for(unsigned x = 0 ; x < dimx ; ++x){
char* c = ncplane_at_yx(n_, y, x, nullptr, nullptr);
REQUIRE(nullptr != c);
if(y == dimy / 2 && x >= dimx / 2){
@ -140,8 +140,8 @@ TEST_CASE("Erase") {
// current cursor to the start of the line using -1 len
SUBCASE("EraseToSOLNeg") {
CHECK(0 == ncplane_erase_region(n_, -1, -1, -1, -INT_MAX));
for(int y = 0 ; y < dimy ; ++y){
for(int x = 0 ; x < dimx ; ++x){
for(unsigned y = 0 ; y < dimy ; ++y){
for(unsigned x = 0 ; x < dimx ; ++x){
char* c = ncplane_at_yx(n_, y, x, nullptr, nullptr);
REQUIRE(nullptr != c);
if(y == dimy / 2 && x <= dimx / 2){
@ -157,8 +157,8 @@ TEST_CASE("Erase") {
// current cursor only
SUBCASE("EraseCurrentCursor") {
CHECK(0 == ncplane_erase_region(n_, -1, -1, 1, 1));
for(int y = 0 ; y < dimy ; ++y){
for(int x = 0 ; x < dimx ; ++x){
for(unsigned y = 0 ; y < dimy ; ++y){
for(unsigned x = 0 ; x < dimx ; ++x){
char* c = ncplane_at_yx(n_, y, x, nullptr, nullptr);
REQUIRE(nullptr != c);
if(y == dimy / 2 && x == dimx / 2){

@ -38,14 +38,14 @@ TEST_CASE("Fade") {
return;
}
REQUIRE(0 == ncplane_cursor_move_yx(n_, 0, 0));
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(n_, &dimy, &dimx);
nccell c = CELL_CHAR_INITIALIZER('*');
nccell_set_fg_rgb8(&c, 0xff, 0xff, 0xff);
unsigned rgb = 0xffffffu;
CHECK(!ncplane_set_scrolling(n_, true));
for(int y = 0 ; y < dimy ; ++y){
for(int x = 0 ; x < dimx ; ++x){
for(unsigned y = 0 ; y < dimy ; ++y){
for(unsigned x = 0 ; x < dimx ; ++x){
rgb -= 32;
if(rgb < 32){
rgb = 0xffffffu;

@ -6,7 +6,7 @@ TEST_CASE("Fbuf") {
if(!nc_){
return;
}
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* n_ = notcurses_stddim_yx(nc_, &dimy, &dimx);
REQUIRE(n_);
REQUIRE(0 == ncplane_cursor_move_yx(n_, 0, 0));

@ -16,7 +16,7 @@ TEST_CASE("Fills") {
// can't polyfill with a null glyph
SUBCASE("PolyfillNullGlyph") {
int dimx, dimy;
unsigned dimx, dimy;
ncplane_dim_yx(n_, &dimy, &dimx);
nccell c = CELL_TRIVIAL_INITIALIZER;
CHECK(0 > ncplane_polyfill_yx(n_, dimy, dimx, &c));
@ -24,13 +24,13 @@ TEST_CASE("Fills") {
// trying to polyfill an invalid cell ought be an error
SUBCASE("PolyfillOffplane") {
int dimx, dimy;
unsigned dimx, dimy;
ncplane_dim_yx(n_, &dimy, &dimx);
nccell c = CELL_CHAR_INITIALIZER('+');
CHECK(0 > ncplane_polyfill_yx(n_, dimy, 0, &c));
CHECK(0 > ncplane_polyfill_yx(n_, 0, dimx, &c));
CHECK(0 > ncplane_polyfill_yx(n_, 0, -1, &c));
CHECK(0 > ncplane_polyfill_yx(n_, -1, 0, &c));
CHECK(0 > ncplane_polyfill_yx(n_, 0, -2, &c));
CHECK(0 > ncplane_polyfill_yx(n_, -2, 0, &c));
}
SUBCASE("PolyfillOnGlyph") {
@ -116,16 +116,16 @@ TEST_CASE("Fills") {
uint64_t c = 0;
ncchannels_set_fg_rgb(&c, 0x40f040);
ncchannels_set_bg_rgb(&c, 0x40f040);
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(n_, &dimy, &dimx);
REQUIRE(0 < ncplane_gradient_sized(n_, "M", 0, c, c, c, c, dimy, dimx));
REQUIRE(0 < ncplane_gradient(n_, -1, -1, dimy, dimx, "M", 0, c, c, c, c));
nccell cl = CELL_TRIVIAL_INITIALIZER;
uint64_t channels = 0;
ncchannels_set_fg_rgb(&channels, 0x40f040);
ncchannels_set_bg_rgb(&channels, 0x40f040);
// check all squares
for(int y = 0 ; y < dimy ; ++y){
for(int x = 0 ; x < dimx ; ++x){
for(unsigned y = 0 ; y < dimy ; ++y){
for(unsigned x = 0 ; x < dimx ; ++x){
REQUIRE(0 <= ncplane_at_yx_cell(n_, y, x, &cl));
CHECK(htole('M') == cl.gcluster);
CHECK(0 == cl.stylemask);
@ -146,9 +146,9 @@ TEST_CASE("Fills") {
ncchannels_set_bg_rgb(&ur, 0x40f040);
ncchannels_set_fg_rgb(&lr, 0xf040f0);
ncchannels_set_bg_rgb(&lr, 0xf040f0);
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(n_, &dimy, &dimx);
REQUIRE(0 < ncplane_gradient_sized(n_, "V", 0, ul, ur, ll, lr, dimy, dimx));
REQUIRE(0 < ncplane_gradient(n_, 0, 0, dimy, dimx, "V", 0, ul, ur, ll, lr));
nccell c = CELL_TRIVIAL_INITIALIZER;
uint64_t channels = 0;
ncchannels_set_fg_rgb(&channels, 0x40f040);
@ -157,9 +157,9 @@ TEST_CASE("Fills") {
// the components ought be going in the correct direction.
uint64_t lastyrgb, lastxrgb;
lastyrgb = -1;
for(int y = 0 ; y < dimy ; ++y){
for(unsigned y = 0 ; y < dimy ; ++y){
lastxrgb = -1;
for(int x = 0 ; x < dimx ; ++x){
for(unsigned x = 0 ; x < dimx ; ++x){
REQUIRE(0 <= ncplane_at_yx_cell(n_, y, x, &c));
CHECK(htole('V') == c.gcluster);
CHECK(0 == c.stylemask);
@ -197,9 +197,9 @@ TEST_CASE("Fills") {
ncchannels_set_bg_rgb(&ll, 0x40f040);
ncchannels_set_fg_rgb(&lr, 0xf040f0);
ncchannels_set_bg_rgb(&lr, 0xf040f0);
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(n_, &dimy, &dimx);
REQUIRE(0 < ncplane_gradient_sized(n_, "H", 0, ul, ur, ll, lr, dimy, dimx));
REQUIRE(0 < ncplane_gradient(n_, 0, 0, dimy, dimx, "H", 0, ul, ur, ll, lr));
// check corners FIXME
CHECK(0 == notcurses_render(nc_));
}
@ -215,9 +215,9 @@ TEST_CASE("Fills") {
ncchannels_set_bg_rgb(&ur, 0xf040f0);
ncchannels_set_fg_rgb(&lr, 0xffffff);
ncchannels_set_bg_rgb(&lr, 0x000000);
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(n_, &dimy, &dimx);
REQUIRE(0 < ncplane_gradient_sized(n_, "X", 0, ul, ur, ll, lr, dimy, dimx));
REQUIRE(0 < ncplane_gradient(n_, 0, 0, dimy, dimx, "X", 0, ul, ur, ll, lr));
// check corners FIXME
CHECK(0 == notcurses_render(nc_));
}
@ -233,14 +233,14 @@ TEST_CASE("Fills") {
ncchannels_set_bg_rgb(&ll, 0xff0000);
ncchannels_set_fg_rgb(&ur, 0xff00ff);
ncchannels_set_bg_rgb(&ur, 0x00ff00);
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(n_, &dimy, &dimx);
REQUIRE(0 < ncplane_gradient_sized(n_, "S", 0, ul, ur, ll, lr, dimy, dimx));
REQUIRE(0 < ncplane_gradient(n_, 0, 0, dimy, dimx, "S", 0, ul, ur, ll, lr));
// check corners FIXME
CHECK(0 == notcurses_render(nc_));
}
SUBCASE("Ncplane_Format") {
SUBCASE("Format") {
int sbytes;
CHECK(0 == ncplane_set_fg_rgb(n_, 0x444444));
CHECK(1 == ncplane_putegc(n_, "A", &sbytes));
@ -251,32 +251,31 @@ TEST_CASE("Fills") {
CHECK(0 == ncplane_cursor_move_yx(n_, 0, 0));
nccell c = CELL_TRIVIAL_INITIALIZER;
nccell_on_styles(&c, NCSTYLE_BOLD);
CHECK(0 < ncplane_format(n_, 0, 0, c.stylemask));
CHECK(0 < ncplane_format(n_, 0, 0, 0, 0, c.stylemask));
nccell d = CELL_TRIVIAL_INITIALIZER;
CHECK(1 == ncplane_at_yx_cell(n_, 0, 0, &d));
CHECK(d.stylemask == c.stylemask);
CHECK(0x444444 == nccell_fg_rgb(&d));
}
SUBCASE("Ncplane_Stain") {
SUBCASE("Stain") {
int sbytes;
CHECK(0 == ncplane_set_fg_rgb(n_, 0x444444));
for(int y = 0 ; y < 8 ; ++y){
for(int x = 0 ; x < 8 ; ++x){
for(unsigned y = 0 ; y < 8 ; ++y){
for(unsigned x = 0 ; x < 8 ; ++x){
CHECK(1 == ncplane_putegc_yx(n_, y, x, "A", &sbytes));
}
}
CHECK(0 == notcurses_render(nc_));
// EGC/color should change, but nothing else
CHECK(0 == ncplane_cursor_move_yx(n_, 0, 0));
uint64_t channels = 0;
ncchannels_set_fg_rgb8(&channels, 0x88, 0x99, 0x77);
ncchannels_set_bg_rgb(&channels, 0);
REQUIRE(0 < ncplane_stain(n_, 7, 7, channels, channels, channels, channels));
REQUIRE(0 < ncplane_stain(n_, 0, 0, 7, 7, channels, channels, channels, channels));
CHECK(0 == notcurses_render(nc_));
nccell d = CELL_TRIVIAL_INITIALIZER;
for(int y = 0 ; y < 8 ; ++y){
for(int x = 0 ; x < 8 ; ++x){
for(unsigned y = 0 ; y < 7 ; ++y){
for(unsigned x = 0 ; x < 7 ; ++x){
CHECK(1 == ncplane_at_yx_cell(n_, y, x, &d));
CHECK(channels == d.channels);
REQUIRE(cell_simple_p(&d));
@ -291,11 +290,10 @@ TEST_CASE("Fills") {
CHECK(0 == ncplane_set_fg_rgb(n_, 0x444444));
CHECK(1 == ncplane_putegc_yx(n_, 0, 0, "A", &sbytes));
CHECK(0 == notcurses_render(nc_));
CHECK(0 == ncplane_cursor_move_yx(n_, 0, 0));
uint64_t channels = 0;
ncchannels_set_fg_rgb8(&channels, 0x88, 0x99, 0x77);
ncchannels_set_bg_rgb(&channels, 0);
REQUIRE(0 < ncplane_gradient(n_, "A", 0, channels, channels, channels, channels, 0, 0));
REQUIRE(0 < ncplane_gradient(n_, 0, 0, 0, 0, "A", 0, channels, channels, channels, channels));
CHECK(0 == notcurses_render(nc_));
nccell d = CELL_TRIVIAL_INITIALIZER;
CHECK(1 == ncplane_at_yx_cell(n_, 0, 0, &d));
@ -316,23 +314,22 @@ TEST_CASE("Fills") {
ncchannels_set_fg_rgb8(&chan2, 0x77, 0x99, 0x88);
ncchannels_set_bg_rgb(&chan1, 0);
ncchannels_set_bg_rgb(&chan2, 0);
REQUIRE(0 < ncplane_gradient(n_, "A", 0, chan1, chan2, chan1, chan2, 0, 3));
CHECK(0 < ncplane_gradient(n_, 0, 0, 0, 3, "A", 0, chan1, chan2, chan1, chan2));
CHECK(0 == notcurses_render(nc_));
nccell d = CELL_TRIVIAL_INITIALIZER;
CHECK(1 == ncplane_at_yx_cell(n_, 0, 0, &d));
CHECK(chan1 == d.channels);
REQUIRE(cell_simple_p(&d));
CHECK(cell_simple_p(&d));
CHECK(htole('A') == d.gcluster);
CHECK(0 == ncplane_cursor_move_yx(n_, 0, 0));
REQUIRE(0 < ncplane_gradient(n_, "A", 0, chan2, chan1, chan2, chan1, 0, 3));
CHECK(0 < ncplane_gradient(n_, 0, 0, 0, 3, "A", 0, chan2, chan1, chan2, chan1));
CHECK(1 == ncplane_at_yx_cell(n_, 0, 0, &d));
REQUIRE(cell_simple_p(&d));
CHECK(cell_simple_p(&d));
CHECK(htole('A') == d.gcluster);
CHECK(chan2 == d.channels);
}
// Unlike a typical gradient, a high gradient ought be able to do a vertical
// change in a single row.
// change in a single row (though not a single column).
SUBCASE("HighGradient2Colors1Row") {
uint32_t ul, ur, ll, lr;
ul = ur = ll = lr = 0;
@ -340,9 +337,8 @@ TEST_CASE("Fills") {
ncchannel_set(&lr, 0x000000);
ncchannel_set(&ll, 0x00ffff);
ncchannel_set(&ur, 0xff00ff);
int dimy, dimx;
ncplane_dim_yx(n_, &dimy, &dimx);
REQUIRE(0 < ncplane_highgradient_sized(n_, ul, ur, ll, lr, dimy, dimx));
CHECK(0 > ncplane_gradient2x1(n_, 0, 0, 1, 1, ul, ur, ll, lr));
CHECK(0 < ncplane_gradient2x1(n_, 0, 0, 1, 2, ul, ur, ll, lr));
CHECK(0 == notcurses_render(nc_));
}
@ -353,9 +349,7 @@ TEST_CASE("Fills") {
ncchannel_set(&lr, 0x000000);
ncchannel_set(&ll, 0x00ffff);
ncchannel_set(&ur, 0xff00ff);
int dimy, dimx;
ncplane_dim_yx(n_, &dimy, &dimx);
REQUIRE(0 < ncplane_highgradient_sized(n_, ul, ur, ll, lr, dimy, dimx));
CHECK(0 < ncplane_gradient2x1(n_, 0, 0, 0, 0, ul, ur, ll, lr));
CHECK(0 == notcurses_render(nc_));
}
@ -499,8 +493,8 @@ TEST_CASE("Fills") {
CHECK(0 < ncplane_polyfill_yx(p2, 0, 0, &c2));
CHECK(0 == ncplane_mergedown_simple(p2, p1));
CHECK(0 == notcurses_render(nc_));
for(int y = 0 ; y < DIMY ; ++y){
for(int x = 0 ; x < DIMX ; ++x){
for(unsigned y = 0 ; y < DIMY ; ++y){
for(unsigned x = 0 ; x < DIMX ; ++x){
CHECK(0 < ncplane_at_yx_cell(p1, y, x, &c1));
if(y < 1 || y > 5 || x < 1 || x > 5){
auto cstr = nccell_strdup(p1, &c1);
@ -539,7 +533,7 @@ TEST_CASE("Fills") {
ncchannels_set_fg_rgb(&ur, 0xff0000);
ncchannels_set_fg_rgb(&bl, 0x00ff00);
ncchannels_set_fg_rgb(&br, 0x0000ff);
ncplane_highgradient_sized(p1, ul, ur, bl, br, DIMY, DIMX);
ncplane_gradient2x1(p1, 0, 0, DIMY, DIMX, ul, ur, bl, br);
CHECK(0 == notcurses_render(nc_));
struct ncplane_options n2opts = {
.y = 3,
@ -554,11 +548,11 @@ TEST_CASE("Fills") {
};
auto p2 = ncplane_create(n_, &n2opts);
REQUIRE(p2);
ncplane_highgradient_sized(p2, br, bl, ur, ul, DIMY / 2, DIMX / 2);
ncplane_gradient2x1(p2, 0, 0, DIMY / 2, DIMX / 2, br, bl, ur, ul);
CHECK(0 == ncplane_mergedown_simple(p2, p1));
CHECK(0 == notcurses_render(nc_));
for(int y = 0 ; y < DIMY ; ++y){
for(int x = 0 ; x < DIMX ; ++x){
for(unsigned y = 0 ; y < DIMY ; ++y){
for(unsigned x = 0 ; x < DIMX ; ++x){
nccell c1 = CELL_TRIVIAL_INITIALIZER;
CHECK(0 < ncplane_at_yx_cell(p1, y, x, &c1));
if(y < 1 || y > 5 || x < 1 || x > 5){
@ -581,7 +575,7 @@ TEST_CASE("Fills") {
#ifdef USE_QRCODEGEN
SUBCASE("QRCodes") {
const char* qr = "a very simple qr code";
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(n_, &dimy, &dimx);
CHECK(0 < ncplane_qrcode(n_, &dimy, &dimx, qr, strlen(qr)));
CHECK(0 == notcurses_render(nc_));

@ -10,7 +10,7 @@ TEST_CASE("Geometry") {
SUBCASE("Center") {
const struct test {
int leny, lenx; // geometries
unsigned leny, lenx; // geometries
int centy, centx; // pre-calculated centers
} tests[] = {
{ 1, 1, 0, 0, },
@ -52,7 +52,7 @@ TEST_CASE("Geometry") {
SUBCASE("CenterAbs") {
const struct test {
int leny, lenx; // geometries
unsigned leny, lenx; // geometries
int absy, absx; // location of the origin
int centy, centx; // pre-calculated centers
} tests[] = {

@ -145,7 +145,7 @@ auto lang_and_term() -> void {
std::cerr << "Couldn't create notcurses testing framework" << std::endl;
exit(EXIT_FAILURE);
}
int dimy, dimx;
unsigned dimy, dimx;
notcurses_stddim_yx(nc, &dimy, &dimx);
std::cout << "Detected geometry: " << dimx << 'x' << dimy << std::endl;
notcurses_stop(nc);

@ -52,7 +52,7 @@ TEST_CASE("Media") {
}
SUBCASE("LoadImageCreatePlane") {
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(ncp_, &dimy, &dimx);
auto ncv = ncvisual_from_file(find_data("changes.jpg").get());
REQUIRE(ncv);
@ -72,7 +72,7 @@ TEST_CASE("Media") {
}
SUBCASE("LoadImage") {
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(ncp_, &dimy, &dimx);
auto ncv = ncvisual_from_file(find_data("changes.jpg").get());
REQUIRE(ncv);
@ -88,7 +88,7 @@ TEST_CASE("Media") {
}
SUBCASE("InflateImage") {
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(ncp_, &dimy, &dimx);
auto ncv = ncvisual_from_file(find_data("changes.jpg").get());
REQUIRE(ncv);
@ -112,7 +112,7 @@ TEST_CASE("Media") {
}
SUBCASE("PlaneDuplicate") {
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(ncp_, &dimy, &dimx);
auto ncv = ncvisual_from_file(find_data("changes.jpg").get());
REQUIRE(ncv);
@ -124,7 +124,7 @@ TEST_CASE("Media") {
REQUIRE(nullptr != needle);
struct ncplane* newn = ncplane_dup(ncp_, needle);
free(needle);
int ndimx, ndimy;
unsigned ndimx, ndimy;
REQUIRE(nullptr != newn);
ncvisual_destroy(ncv);
ncplane_erase(ncp_);
@ -137,7 +137,7 @@ TEST_CASE("Media") {
SUBCASE("LoadVideoASCIIScale") {
if(notcurses_canopen_videos(nc_)){
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(ncp_, &dimy, &dimx);
auto ncv = ncvisual_from_file(find_data("notcursesIII.mkv").get());
REQUIRE(ncv);
@ -161,7 +161,7 @@ TEST_CASE("Media") {
SUBCASE("LoadVideoHalfScale") {
if(notcurses_canopen_videos(nc_)){
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(ncp_, &dimy, &dimx);
auto ncv = ncvisual_from_file(find_data("notcursesIII.mkv").get());
REQUIRE(ncv);
@ -185,7 +185,7 @@ TEST_CASE("Media") {
// quadblitter is default for NCSCALE_SCALE_HIRES
SUBCASE("LoadVideoQuadScale") {
if(notcurses_canopen_videos(nc_)){
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(ncp_, &dimy, &dimx);
auto ncv = ncvisual_from_file(find_data("notcursesIII.mkv").get());
REQUIRE(ncv);
@ -208,7 +208,7 @@ TEST_CASE("Media") {
SUBCASE("LoadVideoSexScale") {
if(notcurses_canopen_videos(nc_)){
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(ncp_, &dimy, &dimx);
auto ncv = ncvisual_from_file(find_data("notcursesIII.mkv").get());
REQUIRE(ncv);
@ -231,7 +231,7 @@ TEST_CASE("Media") {
SUBCASE("LoadVideoBrailleScale") {
if(notcurses_canopen_videos(nc_)){
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(ncp_, &dimy, &dimx);
auto ncv = ncvisual_from_file(find_data("notcursesIII.mkv").get());
REQUIRE(ncv);
@ -256,7 +256,7 @@ TEST_CASE("Media") {
SUBCASE("LoadVideoPixelStretchOnePlane") {
if(notcurses_check_pixel_support(nc_) > 0){
if(notcurses_canopen_videos(nc_)){
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(ncp_, &dimy, &dimx);
auto ncv = ncvisual_from_file(find_data("notcursesIII.mkv").get());
REQUIRE(ncv);
@ -285,7 +285,7 @@ TEST_CASE("Media") {
SUBCASE("LoadVideoPixelScaleDifferentPlanes") {
if(notcurses_check_pixel_support(nc_) > 0){
if(notcurses_canopen_videos(nc_)){
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(ncp_, &dimy, &dimx);
auto ncv = ncvisual_from_file(find_data("notcursesIII.mkv").get());
REQUIRE(ncv);
@ -308,7 +308,7 @@ TEST_CASE("Media") {
SUBCASE("LoopVideo") {
if(notcurses_canopen_videos(nc_)){
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(ncp_, &dimy, &dimx);
auto ncv = ncvisual_from_file(find_data("notcursesIII.mkv").get());
REQUIRE(ncv);
@ -335,7 +335,7 @@ TEST_CASE("Media") {
SUBCASE("LoadVideoCreatePlane") {
if(notcurses_canopen_videos(nc_)){
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(ncp_, &dimy, &dimx);
auto ncv = ncvisual_from_file(find_data("notcursesIII.mkv").get());
REQUIRE(ncv);

@ -17,7 +17,7 @@ TEST_CASE("NotcursesBase") {
}
SUBCASE("TermDimensions") {
int x, y;
unsigned x, y;
notcurses_term_dim_yx(nc_, &y, &x);
auto stry = getenv("LINES");
if(stry){
@ -32,9 +32,9 @@ TEST_CASE("NotcursesBase") {
}
SUBCASE("RefreshSameSize") {
int x, y;
unsigned x, y;
notcurses_term_dim_yx(nc_, &y, &x);
int newx, newy;
unsigned newx, newy;
CHECK(0 == notcurses_refresh(nc_, &newy, &newx));
CHECK(newx == x);
CHECK(newy == y);
@ -56,17 +56,17 @@ TEST_CASE("NotcursesBase") {
// create planes partitioning the entirety of the screen, one at each coordinate
SUBCASE("TileScreenWithPlanes") {
int maxx, maxy;
unsigned maxx, maxy;
notcurses_term_dim_yx(nc_, &maxy, &maxx);
auto total = maxx * maxy;
auto planes = new struct ncplane*[total];
int* planesecrets = new int[total];
for(int y = 0 ; y < maxy ; ++y){
for(int x = 0 ; x < maxx ; ++x){
for(unsigned y = 0 ; y < maxy ; ++y){
for(unsigned x = 0 ; x < maxx ; ++x){
const auto idx = y * maxx + x;
struct ncplane_options nopts = {
.y = y,
.x = x,
.y = static_cast<int>(y),
.x = static_cast<int>(x),
.rows = 1,
.cols = 1,
.userptr = &planesecrets[idx],
@ -80,8 +80,8 @@ TEST_CASE("NotcursesBase") {
}
}
REQUIRE(0 == notcurses_render(nc_));
for(int y = 0 ; y < maxy ; ++y){
for(int x = 0 ; x < maxx ; ++x){
for(unsigned y = 0 ; y < maxy ; ++y){
for(unsigned x = 0 ; x < maxx ; ++x){
const auto idx = y * maxx + x;
auto userptr = ncplane_userptr(planes[idx]);
REQUIRE(userptr);

@ -5,7 +5,7 @@ TEST_CASE("Piles") {
if(!nc_){
return;
}
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* n_ = notcurses_stddim_yx(nc_, &dimy, &dimx);
REQUIRE(nullptr != n_);

@ -2,7 +2,7 @@
#include "main.h"
void BoxPermutationsRounded(struct notcurses* nc, struct ncplane* n, unsigned edges) {
int dimx, dimy;
unsigned dimx, dimy;
ncplane_dim_yx(n, &dimy, &dimx);
REQUIRE(2 < dimy);
REQUIRE(47 < dimx);
@ -38,9 +38,9 @@ TEST_CASE("Plane") {
// Dimensions of the standard plane ought be the same as those of the context
SUBCASE("StdPlaneDimensions") {
int cols, rows;
unsigned cols, rows;
notcurses_term_dim_yx(nc_, &rows, &cols);
int ncols, nrows;
unsigned ncols, nrows;
ncplane_dim_yx(n_, &nrows, &ncols);
CHECK(rows == nrows);
CHECK(cols == ncols);
@ -48,7 +48,7 @@ TEST_CASE("Plane") {
// Verify that we can move to all four coordinates of the standard plane
SUBCASE("MoveStdPlaneDimensions") {
int cols, rows;
unsigned cols, rows;
notcurses_term_dim_yx(nc_, &rows, &cols);
CHECK(0 == ncplane_cursor_move_yx(n_, 0, 0));
int x, y;
@ -71,7 +71,7 @@ TEST_CASE("Plane") {
// Verify that we can move to all four coordinates of the standard plane
SUBCASE("MoveBeyondPlaneFails") {
int cols, rows;
unsigned cols, rows;
notcurses_term_dim_yx(nc_, &rows, &cols);
CHECK(0 > ncplane_cursor_move_yx(n_, -2, 0));
CHECK(0 > ncplane_cursor_move_yx(n_, -2, -2));
@ -198,13 +198,13 @@ TEST_CASE("Plane") {
}
SUBCASE("HorizontalLines") {
int x, y;
unsigned x, y;
ncplane_dim_yx(n_, &y, &x);
REQUIRE(0 < y);
REQUIRE(0 < x);
nccell c{};
nccell_load(n_, &c, "-");
for(int yidx = 0 ; yidx < y ; ++yidx){
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;
@ -217,13 +217,13 @@ TEST_CASE("Plane") {
}
SUBCASE("VerticalLines") {
int x, y;
unsigned x, y;
ncplane_dim_yx(n_, &y, &x);
REQUIRE(0 < y);
REQUIRE(0 < x);
nccell c{};
nccell_load(n_, &c, "|");
for(int xidx = 1 ; xidx < x - 1 ; ++xidx){
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;
@ -237,7 +237,7 @@ TEST_CASE("Plane") {
// reject attempts to draw boxes beyond the boundaries of the ncplane
SUBCASE("BadlyPlacedBoxen") {
int x, y;
unsigned x, y;
ncplane_dim_yx(n_, &y, &x);
REQUIRE(2 < y);
REQUIRE(2 < x);
@ -274,7 +274,7 @@ TEST_CASE("Plane") {
}
SUBCASE("BoxPermutationsDouble") {
int dimx, dimy;
unsigned dimx, dimy;
ncplane_dim_yx(n_, &dimy, &dimx);
REQUIRE(2 < dimx);
REQUIRE(47 < dimx);
@ -289,7 +289,7 @@ TEST_CASE("Plane") {
}
SUBCASE("PerimeterRoundedBox") {
int x, y;
unsigned x, y;
ncplane_dim_yx(n_, &y, &x);
REQUIRE(2 < y);
REQUIRE(2 < x);
@ -299,7 +299,7 @@ TEST_CASE("Plane") {
}
SUBCASE("PerimeterRoundedBoxSized") {
int x, y;
unsigned x, y;
ncplane_dim_yx(n_, &y, &x);
REQUIRE(2 < y);
REQUIRE(2 < x);
@ -309,7 +309,7 @@ TEST_CASE("Plane") {
}
SUBCASE("PerimeterDoubleBox") {
int x, y;
unsigned x, y;
ncplane_dim_yx(n_, &y, &x);
REQUIRE(2 < y);
REQUIRE(2 < x);
@ -319,7 +319,7 @@ TEST_CASE("Plane") {
}
SUBCASE("PerimeterDoubleBoxSized") {
int x, y;
unsigned x, y;
ncplane_dim_yx(n_, &y, &x);
REQUIRE(2 < y);
REQUIRE(2 < x);
@ -401,7 +401,7 @@ TEST_CASE("Plane") {
// for the standard plane, and that we can change it.
SUBCASE("UserPtr") {
CHECK(nullptr == ncplane_userptr(n_));
int x, y;
unsigned x, y;
void* sentinel = &x;
notcurses_term_dim_yx(nc_, &y, &x);
struct ncplane_options nopts = {
@ -427,7 +427,7 @@ TEST_CASE("Plane") {
// create a new plane, the same size as the terminal, and verify that it
// occupies the same dimensions as the standard plane.
SUBCASE("NewPlaneSameSize") {
int x, y;
unsigned x, y;
notcurses_term_dim_yx(nc_, &y, &x);
struct ncplane_options nopts = {
.y = 0,
@ -439,11 +439,11 @@ TEST_CASE("Plane") {
};
struct ncplane* ncp = ncplane_create(n_, &nopts);
REQUIRE(ncp);
int px, py;
unsigned px, py;
ncplane_dim_yx(ncp, &py, &px);
CHECK(y == py);
CHECK(x == px);
int sx, sy;
unsigned sx, sy;
ncplane_dim_yx(n_, &sy, &sx);
CHECK(sy == py);
CHECK(sx == px);
@ -453,7 +453,7 @@ TEST_CASE("Plane") {
// create a new plane, the same size as the terminal, and verify that it
// occupies the same dimensions as the standard plane, but on another pile.
SUBCASE("NewPileSameSize") {
int x, y;
unsigned x, y;
notcurses_term_dim_yx(nc_, &y, &x);
struct ncplane_options nopts = {
.y = 0,
@ -465,11 +465,11 @@ TEST_CASE("Plane") {
};
struct ncplane* ncp = ncpile_create(nc_, &nopts);
REQUIRE(ncp);
int px, py;
unsigned px, py;
ncplane_dim_yx(ncp, &py, &px);
CHECK(y == py);
CHECK(x == px);
int sx, sy;
unsigned sx, sy;
ncplane_dim_yx(n_, &sy, &sx);
CHECK(sy == py);
CHECK(sx == px);
@ -484,7 +484,7 @@ TEST_CASE("Plane") {
}
SUBCASE("ShrinkPlane") {
int maxx, maxy;
unsigned maxx, maxy;
int x = 0, y = 0;
notcurses_term_dim_yx(nc_, &maxy, &maxx);
struct ncplane_options nopts = {
@ -528,9 +528,9 @@ TEST_CASE("Plane") {
}
SUBCASE("GrowPlane") {
int maxx = 2, maxy = 2;
unsigned maxx = 2, maxy = 2;
int x = 0, y = 0;
int dimy, dimx;
unsigned dimy, dimx;
notcurses_term_dim_yx(nc_, &dimy, &dimx);
x = dimx / 2 - 1;
y = dimy / 2 - 1;
@ -552,7 +552,7 @@ TEST_CASE("Plane") {
REQUIRE(0 == ncplane_resize(newp, 1, 1, maxy - 3, maxx - 3, 1, 1, maxy, maxx));
// FIXME check dims, pos
}
while(y < dimy){
while(y < static_cast<int>(dimy)){
++maxy;
if(y){
++y;
@ -560,7 +560,7 @@ TEST_CASE("Plane") {
REQUIRE(0 == ncplane_resize(newp, 1, 0, maxy - 2, maxx, 1, 0, maxy, maxx));
// FIXME check dims, pos
}
while(x < dimx){
while(x < static_cast<int>(dimx)){
++maxx;
if(x){
++x;
@ -588,7 +588,7 @@ TEST_CASE("Plane") {
CHECK(0 == testcell.stylemask);
CHECK(0 == testcell.channels);
nccell_release(n_, &testcell);
int dimy, dimx;
unsigned dimy, dimx;
ncplane_dim_yx(n_, &dimy, &dimx);
REQUIRE(0 == ncplane_cursor_move_yx(n_, 1, dimx - strlen(STR2)));
REQUIRE(0 < ncplane_putstr(n_, STR2));
@ -626,7 +626,7 @@ TEST_CASE("Plane") {
CHECK(0 == testcell.stylemask);
CHECK(0 == testcell.channels);
nccell_release(n_, &testcell);
int dimy, dimx;
unsigned dimy, dimx;
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));
@ -684,7 +684,7 @@ TEST_CASE("Plane") {
SUBCASE("BoxGradients") {
const auto sidesz = 5;
int dimx, dimy;
unsigned dimx, dimy;
ncplane_dim_yx(n_, &dimy, &dimx);
REQUIRE(20 < dimy);
REQUIRE(40 < dimx);
@ -722,7 +722,7 @@ TEST_CASE("Plane") {
SUBCASE("BoxSideColors") {
const auto sidesz = 5;
int dimx, dimy;
unsigned dimx, dimy;
ncplane_dim_yx(n_, &dimy, &dimx);
REQUIRE(20 < dimy);
REQUIRE(40 < dimx);
@ -778,14 +778,14 @@ TEST_CASE("Plane") {
}
SUBCASE("NewPlaneOnRight") {
int ncols, nrows;
unsigned ncols, nrows;
ncplane_dim_yx(n_, &nrows, &ncols);
nccell ul{}, ll{}, lr{}, ur{}, hl{}, vl{};
int y, x;
ncplane_yx(n_, &y, &x);
struct ncplane_options nopts = {
.y = y,
.x = ncols - 3,
.x = static_cast<int>(ncols) - 3,
.rows = 2,
.cols = 2,
.userptr = nullptr, .name = nullptr, .resizecb = nullptr, .flags = 0,
@ -801,7 +801,7 @@ TEST_CASE("Plane") {
}
SUBCASE("MoveToLowerRight") {
int ncols, nrows;
unsigned ncols, nrows;
ncplane_dim_yx(n_, &nrows, &ncols);
nccell ul{}, ll{}, lr{}, ur{}, hl{}, vl{};
int y, x;
@ -859,7 +859,7 @@ TEST_CASE("Plane") {
}
SUBCASE("MouseEvent") {
int dimy, dimx;
unsigned dimy, dimx;
notcurses_stddim_yx(nc_, &dimy, &dimx);
struct ncplane_options nopts = {
.y = 1,
@ -1087,14 +1087,14 @@ TEST_CASE("Plane") {
int y, x;
CHECK(1 == ncplane_set_base(n, " ", 0, channels));
CHECK(0 == notcurses_render(nc_));
for(int i = 0 ; i < ncplane_dim_y(n) ; ++i){
for(unsigned i = 0 ; i < ncplane_dim_y(n) ; ++i){
ncplane_cursor_yx(n, &y, &x);
CHECK(i == y);
CHECK(0 == x);
CHECK(0 < ncplane_putstr(n, "here's a line\n"));
CHECK(0 == notcurses_render(nc_));
}
for(int i = 0 ; i < ncplane_dim_y(n) ; ++i){
for(unsigned i = 0 ; i < ncplane_dim_y(n) ; ++i){
ncplane_cursor_yx(n, &y, &x);
CHECK(ncplane_dim_y(n) - 1 == y);
CHECK(0 == x);

@ -7,7 +7,7 @@ TEST_CASE("Readers") {
if(!nc_){
return;
}
int dimx, dimy;
unsigned dimx, dimy;
struct ncplane* n_ = notcurses_stddim_yx(nc_, &dimy, &dimx);
REQUIRE(n_);
REQUIRE(0 == ncplane_cursor_move_yx(n_, 0, 0));

@ -22,7 +22,7 @@ auto ncreel_validate(const ncreel* n) -> bool {
}else if(y == cury){
return false;
}
int ylen, xlen;
unsigned ylen, xlen;
ncplane_dim_yx(np, &ylen, &xlen);
cury = y + ylen - 1;
}
@ -32,11 +32,12 @@ auto ncreel_validate(const ncreel* n) -> bool {
do{
const ncplane* np = t->p;
if(np){
int y, x, ylen, xlen;
int y, x;
unsigned ylen, xlen;
ncplane_yx(np, &y, &x);
ncplane_dim_yx(np, &ylen, &xlen);
//fprintf(stderr, "backwards: %p (%p) @ %d\n", t, np, y);
if(y + ylen - 1 > cury - 1){
if(y + static_cast<int>(ylen) - 1 > cury - 1){
if(wentaround){
return false;
}
@ -69,9 +70,9 @@ int check_allborders(nctablet* t, bool drawfromtop) {
(void)drawfromtop;
auto ncp = nctablet_plane(t);
REQUIRE(ncp);
int rows, cols;
unsigned rows, cols;
ncplane_dim_yx(ncp, &rows, &cols);
int srows, scols;
unsigned srows, scols;
ncplane_dim_yx(notcurses_stdplane(ncplane_notcurses(ncp)), &srows, &scols);
CHECK(srows >= rows + 3);
CHECK(scols == cols + 4);
@ -82,9 +83,9 @@ int check_noborders(nctablet* t, bool drawfromtop) {
(void)drawfromtop;
auto ncp = nctablet_plane(t);
REQUIRE(ncp);
int rows, cols;
unsigned rows, cols;
ncplane_dim_yx(ncp, &rows, &cols);
int srows, scols;
unsigned srows, scols;
ncplane_dim_yx(notcurses_stdplane(ncplane_notcurses(ncp)), &srows, &scols);
CHECK(srows == rows);
CHECK(scols == cols);
@ -95,9 +96,9 @@ int check_notborders(nctablet* t, bool drawfromtop) {
(void)drawfromtop;
auto ncp = nctablet_plane(t);
REQUIRE(ncp);
int rows, cols;
unsigned rows, cols;
ncplane_dim_yx(ncp, &rows, &cols);
int srows, scols;
unsigned srows, scols;
ncplane_dim_yx(notcurses_stdplane(ncplane_notcurses(ncp)), &srows, &scols);
CHECK(srows == rows + 2); // we get maximum possible size to try out
CHECK(scols == cols + 2);
@ -108,9 +109,9 @@ int check_norborders(nctablet* t, bool drawfromtop) {
(void)drawfromtop;
auto ncp = nctablet_plane(t);
REQUIRE(ncp);
int rows, cols;
unsigned rows, cols;
ncplane_dim_yx(ncp, &rows, &cols);
int srows, scols;
unsigned srows, scols;
ncplane_dim_yx(notcurses_stdplane(ncplane_notcurses(ncp)), &srows, &scols);
CHECK(srows >= rows + 1);
CHECK(scols == cols + 2);
@ -286,7 +287,7 @@ TEST_CASE("Reels") {
SUBCASE("TransparentBackground") {
ncreel_options r{};
int dimy, dimx;
unsigned dimy, dimx;
notcurses_term_dim_yx(nc_, &dimy, &dimx);
uint64_t channels = 0;
ncchannels_set_bg_alpha(&channels, NCALPHA_TRANSPARENT);

@ -5,7 +5,7 @@ TEST_CASE("Resize") {
if(!nc_){
return;
}
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* n_ = notcurses_stddim_yx(nc_, &dimy, &dimx);
REQUIRE(n_);
uint64_t ul, ur, ll, lr;
@ -21,8 +21,8 @@ TEST_CASE("Resize") {
// start at full size, and shrink to a nothing
SUBCASE("ResizeShrink") {
int y = dimy;
int x = dimx;
unsigned y = dimy;
unsigned x = dimx;
struct ncplane_options nopts = {
.y = 0,
.x = 0,
@ -33,7 +33,7 @@ TEST_CASE("Resize") {
};
struct ncplane* testn = ncplane_create(n_, &nopts);
REQUIRE(nullptr != testn);
REQUIRE(0 < ncplane_gradient_sized(testn, "V", 0, ul, ur, ll, lr, y, x));
REQUIRE(0 < ncplane_gradient(testn, -1, -1, y, x, "V", 0, ul, ur, ll, lr));
CHECK(0 == notcurses_render(nc_));
while(y > 1 || x > 1){
y = y > 1 ? y - 1 : y;
@ -46,8 +46,8 @@ TEST_CASE("Resize") {
// start at 1x1, and enlarge to fill the screen
SUBCASE("ResizeEnlarge") {
int y = 2;
int x = 2;
unsigned y = 2;
unsigned x = 2;
struct ncplane_options nopts = {
.y = 0,
.x = 0,
@ -58,13 +58,13 @@ TEST_CASE("Resize") {
};
struct ncplane* testn = ncplane_create(n_, &nopts);
REQUIRE(nullptr != testn);
REQUIRE(0 < ncplane_gradient_sized(testn, "V", 0, ul, ur, ll, lr, y, x));
REQUIRE(0 < ncplane_gradient(testn, -1, -1, y, x, "V", 0, ul, ur, ll, lr));
CHECK(0 == notcurses_render(nc_));
while(y < dimy || x < dimx){
y = y < dimy ? y + 1 : y;
x = x < dimx ? x + 1 : x;
CHECK(0 == ncplane_resize(testn, 0, 0, 0, 0, 0, 0, y, x));
REQUIRE(0 < ncplane_gradient_sized(testn, "V", 0, ul, ur, ll, lr, y, x));
REQUIRE(0 < ncplane_gradient(testn, -1, -1, y, x, "V", 0, ul, ur, ll, lr));
CHECK(0 == notcurses_render(nc_));
}
CHECK(0 == ncplane_destroy(testn));

@ -35,7 +35,7 @@ TEST_CASE("Rotate") {
CHECK(0 == notcurses_stop(nc_));
return;
}
int dimy, dimx;
unsigned dimy, dimx;
struct ncplane* n_ = notcurses_stddim_yx(nc_, &dimy, &dimx);
REQUIRE(n_);
@ -98,7 +98,7 @@ TEST_CASE("Rotate") {
.margin_b = 0, .margin_r = 0,
};
struct ncplane* testn = ncplane_create(n_, &nopts);
REQUIRE(0 < ncplane_gradient_sized(testn, " ", 0, ul, ur, ll, lr, 8, 16));
REQUIRE(0 < ncplane_gradient(testn, -1, -1, 8, 16, " ", 0, ul, ur, ll, lr));
RotateCW(nc_, testn);
CHECK(0 == ncplane_destroy(testn));
}
@ -117,7 +117,7 @@ TEST_CASE("Rotate") {
.margin_b = 0, .margin_r = 0,
};
struct ncplane* testn = ncplane_create(n_, &nopts);
REQUIRE(0 < ncplane_gradient_sized(testn, " ", 0, ul, ur, ll, lr, 8, 32));
REQUIRE(0 < ncplane_gradient(testn, -1, -1, 8, 32, " ", 0, ul, ur, ll, lr));
RotateCW(nc_, testn);
CHECK(0 == ncplane_destroy(testn));
}
@ -136,7 +136,7 @@ TEST_CASE("Rotate") {
.margin_b = 0, .margin_r = 0,
};
struct ncplane* testn = ncplane_create(n_, &nopts);
REQUIRE(0 < ncplane_gradient_sized(testn, " ", 0, ul, ur, ll, lr, 8, 16));
REQUIRE(0 < ncplane_gradient(testn, -1, -1, 8, 16, " ", 0, ul, ur, ll, lr));
RotateCCW(nc_, testn);
CHECK(0 == ncplane_destroy(testn));
}
@ -155,7 +155,7 @@ TEST_CASE("Rotate") {
.margin_b = 0, .margin_r = 0,
};
struct ncplane* testn = ncplane_create(n_, &nopts);
REQUIRE(0 < ncplane_gradient_sized(testn, " ", 0, ul, ur, ll, lr, 8, 32));
REQUIRE(0 < ncplane_gradient(testn, -1, -1, 8, 32, " ", 0, ul, ur, ll, lr));
RotateCCW(nc_, testn);
CHECK(0 == ncplane_destroy(testn));
}

@ -273,7 +273,7 @@ TEST_CASE("Scrolling") {
CHECK(0 < ncplane_polyfill_yx(np, 0, 0, &c));
CHECK(0 == ncplane_cursor_move_yx(n_, ncplane_dim_y(n_) - 1, 0));
CHECK(0 == notcurses_render(nc_));
for(int i = 0 ; i < ncplane_dim_y(np) + starty ; ++i){
for(unsigned i = 0 ; i < ncplane_dim_y(np) + starty ; ++i){
CHECK(starty - i == ncplane_y(np));
CHECK(0 == ncplane_putchar(n_, '\n'));
CHECK(0 == notcurses_render(nc_));
@ -301,7 +301,7 @@ TEST_CASE("Scrolling") {
CHECK(0 < ncplane_polyfill_yx(np, 0, 0, &c));
CHECK(0 == ncplane_cursor_move_yx(n_, ncplane_dim_y(n_) - 1, 0));
CHECK(0 == notcurses_render(nc_));
for(int i = 0 ; i < ncplane_dim_y(np) + starty ; ++i){
for(unsigned i = 0 ; i < ncplane_dim_y(np) + starty ; ++i){
CHECK(starty == ncplane_y(np));
CHECK(0 == ncplane_putchar(n_, '\n'));
CHECK(0 == notcurses_render(nc_));

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save