[notcurses.h] move utility functions to the bottom

This commit is contained in:
nick black 2021-12-06 12:52:52 -05:00 committed by nick black
parent 5bf2f57561
commit 4b393e2c5f

View File

@ -95,30 +95,6 @@ typedef enum {
NCSCALE_SCALE_HIRES, NCSCALE_SCALE_HIRES,
} ncscale_e; } ncscale_e;
// Returns the number of columns occupied by the longest valid prefix of a
// multibyte (UTF-8) string. If an invalid character is encountered, -1 will be
// returned, and the number of valid bytes and columns will be written into
// *|validbytes| and *|validwidth| (assuming them non-NULL). If the entire
// string is valid, *|validbytes| and *|validwidth| reflect the entire string.
API int ncstrwidth(const char* egcs, int* validbytes, int* validwidth);
// input functions like notcurses_get() return ucs32-encoded uint32_t. convert
// a series of uint32_t to utf8. result must be at least 4 bytes per input
// uint32_t (6 bytes per uint32_t will future-proof against Unicode expansion).
// the number of bytes used is returned, or -1 if passed illegal ucs32, or too
// small of a buffer.
API int notcurses_ucs32_to_utf8(const uint32_t* ucs32, unsigned ucs32count,
unsigned char* resultbuf, size_t buflen);
// Returns a heap-allocated copy of the user name under which we are running.
API ALLOC char* notcurses_accountname(void);
// Returns a heap-allocated copy of the local host name.
API ALLOC char* notcurses_hostname(void);
// Returns a heap-allocated copy of human-readable OS name and version.
API ALLOC char* notcurses_osversion(void);
// background cannot be highcontrast, only foreground // background cannot be highcontrast, only foreground
#define NCALPHA_HIGHCONTRAST 0x30000000ull #define NCALPHA_HIGHCONTRAST 0x30000000ull
#define NCALPHA_TRANSPARENT 0x20000000ull #define NCALPHA_TRANSPARENT 0x20000000ull
@ -1892,6 +1868,21 @@ API ALLOC uint32_t* ncplane_as_rgba(const struct ncplane* n, ncblitter_e blit,
unsigned* pxdimy, unsigned* pxdimx) unsigned* pxdimy, unsigned* pxdimx)
__attribute__ ((nonnull (1))); __attribute__ ((nonnull (1)));
// Returns the number of columns occupied by the longest valid prefix of a
// multibyte (UTF-8) string. If an invalid character is encountered, -1 will be
// returned, and the number of valid bytes and columns will be written into
// *|validbytes| and *|validwidth| (assuming them non-NULL). If the entire
// string is valid, *|validbytes| and *|validwidth| reflect the entire string.
API int ncstrwidth(const char* egcs, int* validbytes, int* validwidth);
// input functions like notcurses_get() return ucs32-encoded uint32_t. convert
// a series of uint32_t to utf8. result must be at least 4 bytes per input
// uint32_t (6 bytes per uint32_t will future-proof against Unicode expansion).
// the number of bytes used is returned, or -1 if passed illegal ucs32, or too
// small of a buffer.
API int notcurses_ucs32_to_utf8(const uint32_t* ucs32, unsigned ucs32count,
unsigned char* resultbuf, size_t buflen);
// Return the offset into 'availu' at which 'u' ought be output given the // Return the offset into 'availu' at which 'u' ought be output given the
// requirements of 'align'. Return -INT_MAX on invalid 'align'. Undefined // requirements of 'align'. Return -INT_MAX on invalid 'align'. Undefined
// behavior on negative 'availu' or 'u'. // behavior on negative 'availu' or 'u'.
@ -4407,6 +4398,15 @@ API char* ncreader_contents(const struct ncreader* n)
// UTF-8 input will be heap-duplicated and written to 'contents'. // UTF-8 input will be heap-duplicated and written to 'contents'.
API void ncreader_destroy(struct ncreader* n, char** contents); API void ncreader_destroy(struct ncreader* n, char** contents);
// Returns a heap-allocated copy of the user name under which we are running.
API ALLOC char* notcurses_accountname(void);
// Returns a heap-allocated copy of the local host name.
API ALLOC char* notcurses_hostname(void);
// Returns a heap-allocated copy of human-readable OS name and version.
API ALLOC char* notcurses_osversion(void);
// Dump selected Notcurses state to the supplied 'debugfp'. Output is freeform, // Dump selected Notcurses state to the supplied 'debugfp'. Output is freeform,
// newline-delimited, and subject to change. It includes geometry of all // newline-delimited, and subject to change. It includes geometry of all
// planes, from all piles. No line has more than 80 columns' worth of output. // planes, from all piles. No line has more than 80 columns' worth of output.