bring notcurses_cell.3 up to date #949

This commit is contained in:
nick black 2020-08-24 15:15:27 -04:00
parent 8b75769476
commit f2d92b0f05
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
2 changed files with 63 additions and 77 deletions

View File

@ -72,8 +72,12 @@ typedef struct cell {
**const char* cell_extended_gcluster(const struct ncplane* n, const cell* c);** **const char* cell_extended_gcluster(const struct ncplane* n, const cell* c);**
**char* cell_strdup(const struct ncplane* n, const cell* c);**
**int cell_load_simple(struct ncplane* n, cell* c, char ch);** **int cell_load_simple(struct ncplane* n, cell* c, char ch);**
**char* cell_extract(const struct ncplane* n, const cell* c, uint16_t* stylemask, uint64_t* channels);**
**unsigned cell_bchannel(const cell* cl);** **unsigned cell_bchannel(const cell* cl);**
**unsigned cell_fchannel(const cell* cl);** **unsigned cell_fchannel(const cell* cl);**
@ -116,20 +120,25 @@ Cells make up the framebuffer associated with each plane, with one cell per
addressable coordinate. You should not usually need to interact directly addressable coordinate. You should not usually need to interact directly
with cells. with cells.
Each **cell** contains exactly one extended grapheme cluster. If the EGC happens Each **cell** contains exactly one extended grapheme cluster. If the EGC
to be a single ASCII character, i.e. a single character with a value less than is encoded in UTF-8 with four or fewer bytes (all Unicode codepoints as of
128, it is encoded directly into the **cell**'s **gcluster** field, and no Unicode 13 can be encoded in no more than four UTF-8 bytes), it is encoded
additional storage is necessary. In this case, **cell_simple_p()** is **true**. directly into the **cell**'s **gcluster** field, and no additional storage
Otherwise, the EGC is stored as a UTF-8 string in some backing egcpool. Egcpools is necessary. Otherwise, the EGC is stored as a nul-terminated UTF-8 string in
are associated with **ncplane**s, so **cell**s must be considered associated some backing egcpool. Egcpools are associated with **ncplane**s, so **cell**s
with **ncplane**s. Indeed, **ncplane_erase()** destroys the backing storage for must be considered associated with **ncplane**s. Indeed, **ncplane_erase()**
all a plane's cells, invalidating them. This association is formed at the time destroys the backing storage for all a plane's cells, invalidating them. This
of **cell_load()**, **cell_prime()**, or **cell_duplicate()**. All of these association is formed at the time of **cell_load()**, **cell_prime()**, or
functions first call **cell_release()**, as does **cell_load_simple()**. When **cell_duplicate()**. All of these functions first call **cell_release()**, as
done using a **cell** entirely, call **cell_release()**. **ncplane_destroy()** does **cell_load_simple()**. When done using a **cell** entirely, call
will free up the memory used by the **cell**, but the backing egcpool has a **cell_release()**. **ncplane_destroy()** will free up the memory used by the
maximum size of 32MiB, and failure to release **cell**s can eventually block new **cell**, but the backing egcpool has a maximum size of 16MiB, and failure to
output. release **cell**s can eventually block new output.
**cell_extended_gcluster** provides a nul-terminated handle to the EGC. This
ought be considered invalidated by changes to the **cell** or **egcpool**.
The handle is **not** heap-allocated; do **not** attempt to **free(3)** it.
A heap-allocated copy can be acquired with **cell_strdup**.
# RETURN VALUES # RETURN VALUES

View File

@ -10,99 +10,76 @@ notcurses_channels - operations on notcurses channels
**#include <notcurses/notcurses.h>** **#include <notcurses/notcurses.h>**
**static inline unsigned ```c
channel_r(unsigned channel);** #define CHANNELS_RGB_INITIALIZER(fr, fg, fb, br, bg, bb) \
(((((uint64_t)(fr) << 16u) + ((uint64_t)(fg) << 8u) + (uint64_t)(fb)) << 32ull) + \
(((br) << 16u) + ((bg) << 8u) + (bb)) + CELL_BGDEFAULT_MASK + CELL_FGDEFAULT_MASK)
**static inline unsigned #define CHANNEL_RGB_INITIALIZER(r, g, b) \
channel_g(unsigned channel);** (((uint32_t)r << 16u) + ((uint32_t)g << 8u) + (b) + CELL_BGDEFAULT_MASK)
```
**static inline unsigned **unsigned channel_r(unsigned channel);**
channel_b(unsigned channel);**
**static inline unsigned **unsigned channel_g(unsigned channel);**
channel_rgb(unsigned channel, unsigned* restrict r, unsigned* restrict g,
unsigned* restrict b);**
**static inline int **unsigned channel_b(unsigned channel);**
channel_set_rgb(unsigned* channel, int r, int g, int b);**
**static inline int **unsigned channel_rgb(unsigned channel, unsigned* restrict r, unsigned* restrict g, unsigned* restrict b);**
channel_set(unsigned* channel, unsigned rgb);**
**static inline unsigned **int channel_set_rgb(unsigned* channel, int r, int g, int b);**
channel_alpha(unsigned channel);**
**static inline int **int channel_set(unsigned* channel, unsigned rgb);**
channel_set_alpha(unsigned* channel, int alpha);**
**static inline bool **unsigned channel_alpha(unsigned channel);**
channel_default_p(unsigned channel);**
**static inline unsigned **int channel_set_alpha(unsigned* channel, int alpha);**
channel_set_default(unsigned* channel);**
**static inline unsigned **bool channel_default_p(unsigned channel);**
channels_bchannel(uint64_t channels);**
**static inline unsigned **unsigned channel_set_default(unsigned* channel);**
channels_fchannel(uint64_t channels);**
**static inline uint64_t **unsigned channels_bchannel(uint64_t channels);**
channels_set_bchannel(uint64_t* channels, uint32_t channel);**
**static inline uint64_t **unsigned channels_fchannel(uint64_t channels);**
channels_set_fchannel(uint64_t* channels, uint32_t channel);**
**static inline unsigned **uint64_t channels_set_bchannel(uint64_t* channels, uint32_t channel);**
channels_fg(uint64_t channels);**
**static inline unsigned **uint64_t channels_set_fchannel(uint64_t* channels, uint32_t channel);**
channels_bg(uint64_t channels);**
**static inline unsigned **unsigned channels_fg(uint64_t channels);**
channels_fg_alpha(uint64_t channels);**
**static inline unsigned **unsigned channels_bg(uint64_t channels);**
channels_bg_alpha(uint64_t channels);**
**static inline unsigned **unsigned channels_fg_alpha(uint64_t channels);**
channels_fg_rgb(uint64_t channels, unsigned* r, unsigned* g, unsigned* b);**
**static inline unsigned **unsigned channels_bg_alpha(uint64_t channels);**
channels_bg_rgb(uint64_t channels, unsigned* r, unsigned* g, unsigned* b);**
**static inline int **unsigned channels_fg_rgb(uint64_t channels, unsigned* r, unsigned* g, unsigned* b);**
channels_set_fg_rgb(uint64_t* channels, int r, int g, int b);**
**static inline int **unsigned channels_bg_rgb(uint64_t channels, unsigned* r, unsigned* g, unsigned* b);**
channels_set_bg_rgb(uint64_t* channels, int r, int g, int b);**
**static inline int **int channels_set_fg_rgb(uint64_t* channels, int r, int g, int b);**
channels_set_fg(uint64_t* channels, unsigned rgb);**
**static inline int **int channels_set_bg_rgb(uint64_t* channels, int r, int g, int b);**
channels_set_bg(uint64_t* channels, unsigned rgb);**
**static inline int **int channels_set_fg(uint64_t* channels, unsigned rgb);**
channels_set_fg_alpha(uint64_t* channels, int alpha);**
**static inline int **int channels_set_bg(uint64_t* channels, unsigned rgb);**
channels_set_bg_alpha(uint64_t* channels, int alpha);**
**static inline bool **int channels_set_fg_alpha(uint64_t* channels, int alpha);**
channels_fg_default_p(uint64_t channels);**
**static inline bool **int channels_set_bg_alpha(uint64_t* channels, int alpha);**
channels_bg_default_p(uint64_t channels);**
**static inline uint64_t **bool channels_fg_default_p(uint64_t channels);**
channels_set_fg_default(uint64_t* channels);**
**static inline uint64_t **bool channels_bg_default_p(uint64_t channels);**
channels_set_bg_default(uint64_t* channels);**
**static inline unsigned **uint64_t channels_set_fg_default(uint64_t* channels);**
channels_blend(unsigned c1, unsigned c2, unsigned blends);**
**uint64_t channels_set_bg_default(uint64_t* channels);**
**unsigned channels_blend(unsigned c1, unsigned c2, unsigned blends);**
# DESCRIPTION # DESCRIPTION