mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 01:29:05 -04:00
CMake: visibility=hidden by default #56
This commit is contained in:
parent
5aa0b4912d
commit
f14ee490f2
@ -4,7 +4,9 @@ project(notcurses VERSION 0.0.9
|
|||||||
HOMEPAGE_URL "https://nick-black.com/dankwiki/index.php/notcurses"
|
HOMEPAGE_URL "https://nick-black.com/dankwiki/index.php/notcurses"
|
||||||
LANGUAGES C CXX)
|
LANGUAGES C CXX)
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
|
set(CMAKE_C_VISIBILITY_PRESET hidden)
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
|
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
|
||||||
|
|
||||||
configure_file(tools/version.h.in include/version.h)
|
configure_file(tools/version.h.in include/version.h)
|
||||||
|
|
||||||
|
@ -11,8 +11,10 @@
|
|||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define API __attribute__((visibility("default")))
|
||||||
|
|
||||||
// Get a human-readable string describing the running notcurses version.
|
// Get a human-readable string describing the running notcurses version.
|
||||||
const char* notcurses_version(void);
|
API const char* notcurses_version(void);
|
||||||
|
|
||||||
struct cell; // a coordinate on an ncplane: an EGC plus styling
|
struct cell; // a coordinate on an ncplane: an EGC plus styling
|
||||||
struct ncplane; // a drawable notcurses surface, composed of cells
|
struct ncplane; // a drawable notcurses surface, composed of cells
|
||||||
@ -80,66 +82,66 @@ typedef struct notcurses_options {
|
|||||||
|
|
||||||
// Initialize a notcurses context, corresponding to a connected terminal.
|
// Initialize a notcurses context, corresponding to a connected terminal.
|
||||||
// Returns NULL on error, including any failure to initialize terminfo.
|
// Returns NULL on error, including any failure to initialize terminfo.
|
||||||
struct notcurses* notcurses_init(const notcurses_options* opts);
|
API struct notcurses* notcurses_init(const notcurses_options* opts);
|
||||||
|
|
||||||
// Destroy a notcurses context.
|
// Destroy a notcurses context.
|
||||||
int notcurses_stop(struct notcurses* nc);
|
API int notcurses_stop(struct notcurses* nc);
|
||||||
|
|
||||||
// Make the physical screen match the virtual screen. Changes made to the
|
// Make the physical screen match the virtual screen. Changes made to the
|
||||||
// virtual screen (i.e. most other calls) will not be visible until after a
|
// virtual screen (i.e. most other calls) will not be visible until after a
|
||||||
// successful call to notcurses_render().
|
// successful call to notcurses_render().
|
||||||
int notcurses_render(struct notcurses* nc);
|
API int notcurses_render(struct notcurses* nc);
|
||||||
|
|
||||||
// Refresh our idea of the terminal's dimensions, reshaping the standard plane
|
// Refresh our idea of the terminal's dimensions, reshaping the standard plane
|
||||||
// if necessary. Without a call to this function following a terminal resize
|
// if necessary. Without a call to this function following a terminal resize
|
||||||
// (as signaled via SIGWINCH), notcurses_render() might not function properly.
|
// (as signaled via SIGWINCH), notcurses_render() might not function properly.
|
||||||
// References to ncplanes remain valid following a resize operation, but the
|
// References to ncplanes remain valid following a resize operation, but the
|
||||||
// cursor might have changed position.
|
// cursor might have changed position.
|
||||||
int notcurses_resize(struct notcurses* n);
|
API int notcurses_resize(struct notcurses* n);
|
||||||
|
|
||||||
// Get a reference to the standard plane (one matching our current idea of the
|
// Get a reference to the standard plane (one matching our current idea of the
|
||||||
// terminal size) for this terminal.
|
// terminal size) for this terminal.
|
||||||
struct ncplane* notcurses_stdplane(struct notcurses* nc);
|
API struct ncplane* notcurses_stdplane(struct notcurses* nc);
|
||||||
const struct ncplane* notcurses_stdplane_const(const struct notcurses* nc);
|
API const struct ncplane* notcurses_stdplane_const(const struct notcurses* nc);
|
||||||
|
|
||||||
// Create a new plane at the specified offset (relative to the standard plane)
|
// Create a new plane at the specified offset (relative to the standard plane)
|
||||||
// and the specified size. The number of rows and columns must both be positive.
|
// and the specified size. The number of rows and columns must both be positive.
|
||||||
// This plane is initially at the top of the z-buffer, as if ncplane_move_top()
|
// This plane is initially at the top of the z-buffer, as if ncplane_move_top()
|
||||||
// had been called on it. The void* 'opaque' can be retrieved (and reset) later.
|
// had been called on it. The void* 'opaque' can be retrieved (and reset) later.
|
||||||
struct ncplane* notcurses_newplane(struct notcurses* nc, int rows, int cols,
|
API struct ncplane* notcurses_newplane(struct notcurses* nc, int rows, int cols,
|
||||||
int yoff, int xoff, void* opaque);
|
int yoff, int xoff, void* opaque);
|
||||||
|
|
||||||
// Destroy the specified ncplane. None of its contents will be visible after
|
// Destroy the specified ncplane. None of its contents will be visible after
|
||||||
// the next call to notcurses_render(). It is an error to attempt to destroy
|
// the next call to notcurses_render(). It is an error to attempt to destroy
|
||||||
// the standard plane.
|
// the standard plane.
|
||||||
int ncplane_destroy(struct ncplane* n);
|
API int ncplane_destroy(struct ncplane* n);
|
||||||
|
|
||||||
// Move this plane relative to the standard plane.
|
// Move this plane relative to the standard plane.
|
||||||
int ncplane_move_yx(struct ncplane* n, int y, int x);
|
API int ncplane_move_yx(struct ncplane* n, int y, int x);
|
||||||
|
|
||||||
// Get the origin of this plane relative to the standard plane.
|
// Get the origin of this plane relative to the standard plane.
|
||||||
void ncplane_yx(const struct ncplane* n, int* y, int* x);
|
API void ncplane_yx(const struct ncplane* n, int* y, int* x);
|
||||||
|
|
||||||
// Splice ncplane 'n' out of the z-buffer, and reinsert it above 'above'.
|
// Splice ncplane 'n' out of the z-buffer, and reinsert it above 'above'.
|
||||||
void ncplane_move_above(struct ncplane* n, struct ncplane* above);
|
API void ncplane_move_above(struct ncplane* n, struct ncplane* above);
|
||||||
// Splice ncplane 'n' out of the z-buffer, and reinsert it below 'below'.
|
// Splice ncplane 'n' out of the z-buffer, and reinsert it below 'below'.
|
||||||
void ncplane_move_below(struct ncplane* n, struct ncplane* below);
|
API void ncplane_move_below(struct ncplane* n, struct ncplane* below);
|
||||||
// Splice ncplane 'n' out of the z-buffer, and reinsert it at the top or bottom.
|
// Splice ncplane 'n' out of the z-buffer, and reinsert it at the top or bottom.
|
||||||
void ncplane_move_top(struct ncplane* n);
|
API void ncplane_move_top(struct ncplane* n);
|
||||||
void ncplane_move_bottom(struct ncplane* n);
|
API void ncplane_move_bottom(struct ncplane* n);
|
||||||
|
|
||||||
// Retrieve the topmost cell at this location on the screen, returning it in
|
// Retrieve the topmost cell at this location on the screen, returning it in
|
||||||
// 'c'. If there is more than a byte of gcluster, it will be returned as a heap
|
// 'c'. If there is more than a byte of gcluster, it will be returned as a heap
|
||||||
// allocation in '*gclust', and '*c' will be 0x80.
|
// allocation in '*gclust', and '*c' will be 0x80.
|
||||||
void notcurses_getc(const struct notcurses* n, cell* c, char** gclust);
|
API void notcurses_getc(const struct notcurses* n, cell* c, char** gclust);
|
||||||
|
|
||||||
// Manipulate the opaque user pointer associated with this plane.
|
// Manipulate the opaque user pointer associated with this plane.
|
||||||
void ncplane_set_userptr(struct ncplane* n, void* opaque);
|
API void ncplane_set_userptr(struct ncplane* n, void* opaque);
|
||||||
void* ncplane_userptr(struct ncplane* n);
|
API void* ncplane_userptr(struct ncplane* n);
|
||||||
const void* ncplane_userptr_const(const struct ncplane* n);
|
API const void* ncplane_userptr_const(const struct ncplane* n);
|
||||||
|
|
||||||
// Returns the dimensions of this ncplane.
|
// Returns the dimensions of this ncplane.
|
||||||
void ncplane_dimyx(const struct ncplane* n, int* rows, int* cols);
|
API void ncplane_dimyx(const struct ncplane* n, int* rows, int* cols);
|
||||||
|
|
||||||
// Return our current idea of the terminal dimensions in rows and cols.
|
// Return our current idea of the terminal dimensions in rows and cols.
|
||||||
static inline void
|
static inline void
|
||||||
@ -150,21 +152,21 @@ notcurses_term_dimyx(const struct notcurses* n, int* rows, int* cols){
|
|||||||
// Move the cursor to the specified position (the cursor needn't be visible).
|
// Move the cursor to the specified position (the cursor needn't be visible).
|
||||||
// Returns -1 on error, including negative parameters, or ones exceeding the
|
// Returns -1 on error, including negative parameters, or ones exceeding the
|
||||||
// plane's dimensions.
|
// plane's dimensions.
|
||||||
int ncplane_cursor_move_yx(struct ncplane* n, int y, int x);
|
API int ncplane_cursor_move_yx(struct ncplane* n, int y, int x);
|
||||||
|
|
||||||
// Get the current position of the cursor within n. y and/or x may be NULL.
|
// Get the current position of the cursor within n. y and/or x may be NULL.
|
||||||
void ncplane_cursor_yx(const struct ncplane* n, int* y, int* x);
|
API void ncplane_cursor_yx(const struct ncplane* n, int* y, int* x);
|
||||||
|
|
||||||
// Replace the cell underneath the cursor with the provided cell 'c', and
|
// Replace the cell underneath the cursor with the provided cell 'c', and
|
||||||
// advance the cursor by the width of the cell (but not past the end of the
|
// advance the cursor by the width of the cell (but not past the end of the
|
||||||
// plane). On success, returns the number of columns the cursor was advanced.
|
// plane). On success, returns the number of columns the cursor was advanced.
|
||||||
// On failure, -1 is returned.
|
// On failure, -1 is returned.
|
||||||
int ncplane_putc(struct ncplane* n, const cell* c);
|
API int ncplane_putc(struct ncplane* n, const cell* c);
|
||||||
|
|
||||||
// Retrieve the cell under this plane's cursor, returning it in 'c'. If there
|
// Retrieve the cell under this plane's cursor, returning it in 'c'. If there
|
||||||
// is more than a byte of gcluster, it will be returned as a heap allocation in
|
// is more than a byte of gcluster, it will be returned as a heap allocation in
|
||||||
// '*gclust', and '*c' will be 0x80. Returns -1 on error, 0 on success.
|
// '*gclust', and '*c' will be 0x80. Returns -1 on error, 0 on success.
|
||||||
int ncplane_getc(const struct ncplane* n, cell* c, char** gclust);
|
API int ncplane_getc(const struct ncplane* n, cell* c, char** gclust);
|
||||||
|
|
||||||
// Write a series of cells to the current location, using the current style.
|
// Write a series of cells to the current location, using the current style.
|
||||||
// They will be interpreted as a series of columns (according to the definition
|
// They will be interpreted as a series of columns (according to the definition
|
||||||
@ -172,11 +174,11 @@ int ncplane_getc(const struct ncplane* n, cell* c, char** gclust);
|
|||||||
// (though not beyond the end of the plane); this number is returned on success.
|
// (though not beyond the end of the plane); this number is returned on success.
|
||||||
// On error, a non-positive number is returned, indicating the number of cells
|
// On error, a non-positive number is returned, indicating the number of cells
|
||||||
// which were written before the error.
|
// which were written before the error.
|
||||||
int ncplane_putstr(struct ncplane* n, const char* gclustarr);
|
API int ncplane_putstr(struct ncplane* n, const char* gclustarr);
|
||||||
|
|
||||||
// The ncplane equivalents of printf(3) and vprintf(3).
|
// The ncplane equivalents of printf(3) and vprintf(3).
|
||||||
int ncplane_printf(struct ncplane* n, const char* format, ...);
|
API int ncplane_printf(struct ncplane* n, const char* format, ...);
|
||||||
int ncplane_vprintf(struct ncplane* n, const char* format, va_list ap);
|
API int ncplane_vprintf(struct ncplane* n, const char* format, va_list ap);
|
||||||
|
|
||||||
// Draw horizontal or vertical lines using the specified cell, starting at the
|
// Draw horizontal or vertical lines using the specified cell, starting at the
|
||||||
// current cursor position. The cursor will end at the cell following the last
|
// current cursor position. The cursor will end at the cell following the last
|
||||||
@ -184,13 +186,13 @@ int ncplane_vprintf(struct ncplane* n, const char* format, va_list ap);
|
|||||||
// lines), just as if ncplane_putc() was called at that spot. Return the
|
// lines), just as if ncplane_putc() was called at that spot. Return the
|
||||||
// number of cells drawn on success. On error, return the negative number of
|
// number of cells drawn on success. On error, return the negative number of
|
||||||
// cells drawn.
|
// cells drawn.
|
||||||
int ncplane_hline(struct ncplane* n, const cell* c, int len);
|
API int ncplane_hline(struct ncplane* n, const cell* c, int len);
|
||||||
int ncplane_vline(struct ncplane* n, const cell* c, int len);
|
API int ncplane_vline(struct ncplane* n, const cell* c, int len);
|
||||||
|
|
||||||
// Draw a box with its upper-left corner at the current cursor position, and its
|
// Draw a box with its upper-left corner at the current cursor position, and its
|
||||||
// lower-right corner at 'ystop'x'xstop'. The 6 cells provided are used to draw the
|
// lower-right corner at 'ystop'x'xstop'. The 6 cells provided are used to draw the
|
||||||
// upper-left, ur, ll, and lr corners, then the horizontal and vertical lines.
|
// upper-left, ur, ll, and lr corners, then the horizontal and vertical lines.
|
||||||
int ncplane_box(struct ncplane* n, const cell* ul, const cell* ur,
|
API int ncplane_box(struct ncplane* n, const cell* ul, const cell* ur,
|
||||||
const cell* ll, const cell* lr, const cell* hline,
|
const cell* ll, const cell* lr, const cell* hline,
|
||||||
const cell* vline, int ystop, int xstop);
|
const cell* vline, int ystop, int xstop);
|
||||||
|
|
||||||
@ -209,7 +211,7 @@ ncplane_box_sized(struct ncplane* n, const cell* ul, const cell* ur,
|
|||||||
// Erase every cell in the ncplane, resetting all attributes to normal, all
|
// Erase every cell in the ncplane, resetting all attributes to normal, all
|
||||||
// colors to the default color, and all cells to undrawn. All cells associated
|
// colors to the default color, and all cells to undrawn. All cells associated
|
||||||
// with this ncplane is invalidated, and must not be used after the call.
|
// with this ncplane is invalidated, and must not be used after the call.
|
||||||
void ncplane_erase(struct ncplane* n);
|
API void ncplane_erase(struct ncplane* n);
|
||||||
|
|
||||||
// Set the current fore/background color using RGB specifications. If the
|
// Set the current fore/background color using RGB specifications. If the
|
||||||
// terminal does not support directly-specified 3x8b cells (24-bit "Direct
|
// terminal does not support directly-specified 3x8b cells (24-bit "Direct
|
||||||
@ -217,29 +219,29 @@ void ncplane_erase(struct ncplane* n);
|
|||||||
// will be interpreted in some lossy fashion. None of r, g, or b may exceed 255.
|
// will be interpreted in some lossy fashion. None of r, g, or b may exceed 255.
|
||||||
// "HP-like" terminals require setting foreground and background at the same
|
// "HP-like" terminals require setting foreground and background at the same
|
||||||
// time using "color pairs"; notcurses will manage color pairs transparently.
|
// time using "color pairs"; notcurses will manage color pairs transparently.
|
||||||
int ncplane_fg_rgb8(struct ncplane* n, int r, int g, int b);
|
API int ncplane_fg_rgb8(struct ncplane* n, int r, int g, int b);
|
||||||
int ncplane_bg_rgb8(struct ncplane* n, int r, int g, int b);
|
API int ncplane_bg_rgb8(struct ncplane* n, int r, int g, int b);
|
||||||
|
|
||||||
// Set the specified style bits for the ncplane 'n', whether they're actively
|
// Set the specified style bits for the ncplane 'n', whether they're actively
|
||||||
// supported or not.
|
// supported or not.
|
||||||
void ncplane_set_style(struct ncplane* n, unsigned stylebits);
|
API void ncplane_set_style(struct ncplane* n, unsigned stylebits);
|
||||||
|
|
||||||
// Add the specified styles to the ncplane's existing spec.
|
// Add the specified styles to the ncplane's existing spec.
|
||||||
void ncplane_enable_styles(struct ncplane* n, unsigned stylebits);
|
API void ncplane_enable_styles(struct ncplane* n, unsigned stylebits);
|
||||||
|
|
||||||
// Remove the specified styles from the ncplane's existing spec.
|
// Remove the specified styles from the ncplane's existing spec.
|
||||||
void ncplane_disable_styles(struct ncplane* n, unsigned stylebits);
|
API void ncplane_disable_styles(struct ncplane* n, unsigned stylebits);
|
||||||
|
|
||||||
// Fine details about terminal
|
// Fine details about terminal
|
||||||
|
|
||||||
// Returns a 16-bit bitmask in the LSBs of supported NCURSES-style attributes
|
// Returns a 16-bit bitmask in the LSBs of supported NCURSES-style attributes
|
||||||
// (WA_UNDERLINE, WA_BOLD, etc.) The attribute is only indicated as supported
|
// (WA_UNDERLINE, WA_BOLD, etc.) The attribute is only indicated as supported
|
||||||
// if the terminal can support it together with color.
|
// if the terminal can support it together with color.
|
||||||
unsigned notcurses_supported_styles(const struct notcurses* nc);
|
API unsigned notcurses_supported_styles(const struct notcurses* nc);
|
||||||
|
|
||||||
// Returns the number of colors supported by the palette, or 1 if there is no
|
// Returns the number of colors supported by the palette, or 1 if there is no
|
||||||
// color support.
|
// color support.
|
||||||
int notcurses_palette_size(const struct notcurses* nc);
|
API int notcurses_palette_size(const struct notcurses* nc);
|
||||||
|
|
||||||
// Working with cells
|
// Working with cells
|
||||||
|
|
||||||
@ -251,14 +253,14 @@ cell_init(cell* c){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Breaks the UTF-8 string in 'gcluster' down, setting up the cell 'c'.
|
// Breaks the UTF-8 string in 'gcluster' down, setting up the cell 'c'.
|
||||||
int cell_load(struct ncplane* n, cell* c, const char* gcluster);
|
API int cell_load(struct ncplane* n, cell* c, const char* gcluster);
|
||||||
|
|
||||||
// Duplicate 'c' into 'targ'. Not intended for external use; exposed for the
|
// Duplicate 'c' into 'targ'. Not intended for external use; exposed for the
|
||||||
// benefit of unit tests.
|
// benefit of unit tests.
|
||||||
int cell_duplicate(struct ncplane* n, cell* targ, const cell* c);
|
API int cell_duplicate(struct ncplane* n, cell* targ, const cell* c);
|
||||||
|
|
||||||
// Release resources held by the cell 'c'.
|
// Release resources held by the cell 'c'.
|
||||||
void cell_release(struct ncplane* n, cell* c);
|
API void cell_release(struct ncplane* n, cell* c);
|
||||||
|
|
||||||
#define CELL_STYLE_MASK 0xffff0000ul
|
#define CELL_STYLE_MASK 0xffff0000ul
|
||||||
#define CELL_ALPHA_MASK 0x0000fffful
|
#define CELL_ALPHA_MASK 0x0000fffful
|
||||||
@ -372,11 +374,34 @@ cell_wide_p(const cell* c){
|
|||||||
// load up six cells with the EGCs necessary to draw a light, rounded box.
|
// load up six cells with the EGCs necessary to draw a light, rounded box.
|
||||||
// returns 0 on success, -1 on error. on error, any cells this function might
|
// returns 0 on success, -1 on error. on error, any cells this function might
|
||||||
// have loaded before the error are cell_release()d.
|
// have loaded before the error are cell_release()d.
|
||||||
int ncplane_rounded_box_cells(struct ncplane* n, cell* ul, cell* ur, cell* ll,
|
static inline int
|
||||||
cell* lr, cell* hl, cell* vl);
|
ncplane_rounded_box_cells(struct ncplane* n, cell* ul, cell* ur, cell* ll,
|
||||||
|
cell* lr, cell* hl, cell* vl){
|
||||||
|
if(cell_load(n, ul, "╭") > 0){
|
||||||
|
if(cell_load(n, ur, "╮") > 0){
|
||||||
|
if(cell_load(n, ll, "╰") > 0){
|
||||||
|
if(cell_load(n, lr, "╯") > 0){
|
||||||
|
if(cell_load(n, hl, "─") > 0){
|
||||||
|
if(cell_load(n, vl, "│") > 0){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
cell_release(n, hl);
|
||||||
|
}
|
||||||
|
cell_release(n, lr);
|
||||||
|
}
|
||||||
|
cell_release(n, ll);
|
||||||
|
}
|
||||||
|
cell_release(n, ur);
|
||||||
|
}
|
||||||
|
cell_release(n, ul);
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
// multimedia functionality
|
// multimedia functionality
|
||||||
int notcurses_visual_open(struct notcurses* nc, const char* filename);
|
API int notcurses_visual_open(struct notcurses* nc, const char* filename);
|
||||||
|
|
||||||
|
#undef API
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include "egcpool.h"
|
|
||||||
|
|
||||||
#define POOL_MINIMUM_ALLOC BUFSIZ
|
|
||||||
|
|
||||||
int egcpool_grow(egcpool* pool, size_t len){
|
|
||||||
size_t newsize = pool->poolsize * 2;
|
|
||||||
if(newsize < POOL_MINIMUM_ALLOC){
|
|
||||||
newsize = POOL_MINIMUM_ALLOC;
|
|
||||||
}
|
|
||||||
while(len > newsize - pool->poolsize){ // ensure we make enough space
|
|
||||||
newsize *= 2;
|
|
||||||
}
|
|
||||||
// offsets only have 24 bits available...
|
|
||||||
if(newsize >= 1u << 24u){
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
typeof(*pool->pool)* tmp = realloc(pool->pool, newsize);
|
|
||||||
if(tmp == NULL){
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
pool->pool = tmp;
|
|
||||||
memset(pool->pool + pool->poolsize, 0, newsize - pool->poolsize);
|
|
||||||
pool->poolsize = newsize;
|
|
||||||
return 0;
|
|
||||||
}
|
|
@ -23,12 +23,36 @@ typedef struct egcpool {
|
|||||||
int poolwrite; // next place to *look for* a place to write
|
int poolwrite; // next place to *look for* a place to write
|
||||||
} egcpool;
|
} egcpool;
|
||||||
|
|
||||||
|
#define POOL_MINIMUM_ALLOC BUFSIZ
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
egcpool_init(egcpool* p){
|
egcpool_init(egcpool* p){
|
||||||
memset(p, 0, sizeof(*p));
|
memset(p, 0, sizeof(*p));
|
||||||
}
|
}
|
||||||
|
|
||||||
int egcpool_grow(egcpool* pool, size_t len);
|
static inline int
|
||||||
|
egcpool_grow(egcpool* pool, size_t len){
|
||||||
|
size_t newsize = pool->poolsize * 2;
|
||||||
|
if(newsize < POOL_MINIMUM_ALLOC){
|
||||||
|
newsize = POOL_MINIMUM_ALLOC;
|
||||||
|
}
|
||||||
|
while(len > newsize - pool->poolsize){ // ensure we make enough space
|
||||||
|
newsize *= 2;
|
||||||
|
}
|
||||||
|
// offsets only have 24 bits available...
|
||||||
|
if(newsize >= 1u << 24u){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
// nasty cast here because c++ source might include this header :/
|
||||||
|
typeof(*pool->pool)* tmp = (typeof(pool->pool))realloc(pool->pool, newsize);
|
||||||
|
if(tmp == NULL){
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
pool->pool = tmp;
|
||||||
|
memset(pool->pool + pool->poolsize, 0, newsize - pool->poolsize);
|
||||||
|
pool->poolsize = newsize;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Eat an EGC from the UTF-8 string input. This consists of extracting a
|
// Eat an EGC from the UTF-8 string input. This consists of extracting a
|
||||||
// multibyte via mbtowc, then continuing to extract any which have zero
|
// multibyte via mbtowc, then continuing to extract any which have zero
|
||||||
|
@ -895,26 +895,3 @@ void ncplane_erase(ncplane* n){
|
|||||||
n->channels = 0;
|
n->channels = 0;
|
||||||
n->attrword = 0;
|
n->attrword = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ncplane_rounded_box_cells(ncplane* n, cell* ul, cell* ur, cell* ll,
|
|
||||||
cell* lr, cell* hl, cell* vl){
|
|
||||||
if(cell_load(n, ul, "╭") > 0){
|
|
||||||
if(cell_load(n, ur, "╮") > 0){
|
|
||||||
if(cell_load(n, ll, "╰") > 0){
|
|
||||||
if(cell_load(n, lr, "╯") > 0){
|
|
||||||
if(cell_load(n, hl, "─") > 0){
|
|
||||||
if(cell_load(n, vl, "│") > 0){
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
cell_release(n, hl);
|
|
||||||
}
|
|
||||||
cell_release(n, lr);
|
|
||||||
}
|
|
||||||
cell_release(n, ll);
|
|
||||||
}
|
|
||||||
cell_release(n, ur);
|
|
||||||
}
|
|
||||||
cell_release(n, ul);
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user