mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-10-31 15:20:13 +00:00
ncdirect: styles{set, on, off} -> _styles #1247
This commit is contained in:
parent
66349ecbd0
commit
1d8fcbb5e4
4
NEWS.md
4
NEWS.md
@ -1,6 +1,10 @@
|
||||
This document attempts to list user-visible changes and any major internal
|
||||
rearrangements of Notcurses.
|
||||
|
||||
* 2.1.3 (not yet released)
|
||||
* `ncdirect_styles_{set, on, off}()` have been deprecated in favor of
|
||||
`ncdirect_{set, on, off}_styles()`, to match `ncplane_` equivalents.
|
||||
|
||||
* 2.1.2 (2020-12-25)
|
||||
* Add `notcurses_linesigs_enable()` and `notcurses_linesigs_disable()`.
|
||||
* Divide `ncdirect_render_image()` into component `ncdirect_render_frame()`
|
||||
|
@ -90,17 +90,17 @@ namespace ncpp
|
||||
|
||||
void styles_set (CellStyle stylebits) const noexcept
|
||||
{
|
||||
ncdirect_styles_set (direct, static_cast<unsigned>(stylebits));
|
||||
ncdirect_set_styles (direct, static_cast<unsigned>(stylebits));
|
||||
}
|
||||
|
||||
void styles_on (CellStyle stylebits) const noexcept
|
||||
{
|
||||
ncdirect_styles_on (direct, static_cast<unsigned>(stylebits));
|
||||
ncdirect_on_styles (direct, static_cast<unsigned>(stylebits));
|
||||
}
|
||||
|
||||
void styles_off (CellStyle stylebits) const noexcept
|
||||
{
|
||||
ncdirect_styles_off (direct, static_cast<unsigned>(stylebits));
|
||||
ncdirect_off_styles (direct, static_cast<unsigned>(stylebits));
|
||||
}
|
||||
|
||||
bool cursor_move_yx (int y, int x) const NOEXCEPT_MAYBE
|
||||
|
@ -86,9 +86,17 @@ API int ncdirect_dim_x(const struct ncdirect* nc);
|
||||
API int ncdirect_dim_y(const struct ncdirect* nc);
|
||||
|
||||
// ncplane_styles_*() analogues
|
||||
API int ncdirect_styles_set(struct ncdirect* n, unsigned stylebits);
|
||||
API int ncdirect_styles_on(struct ncdirect* n, unsigned stylebits);
|
||||
API int ncdirect_styles_off(struct ncdirect* n, unsigned stylebits);
|
||||
API int ncdirect_set_styles(struct ncdirect* n, unsigned stylebits);
|
||||
API int ncdirect_on_styles(struct ncdirect* n, unsigned stylebits);
|
||||
API int ncdirect_off_styles(struct ncdirect* n, unsigned stylebits);
|
||||
|
||||
// Deprecated forms of above.
|
||||
API int ncdirect_styles_set(struct ncdirect* n, unsigned stylebits)
|
||||
__attribute__ ((deprecated));
|
||||
API int ncdirect_styles_on(struct ncdirect* n, unsigned stylebits)
|
||||
__attribute__ ((deprecated));
|
||||
API int ncdirect_styles_off(struct ncdirect* n, unsigned stylebits)
|
||||
__attribute__ ((deprecated));
|
||||
|
||||
// Move the cursor in direct mode. -1 to retain current location on that axis.
|
||||
API int ncdirect_cursor_move_yx(struct ncdirect* n, int y, int x);
|
||||
|
@ -618,7 +618,7 @@ ncdirect* ncdirect_init(const char* termtype, FILE* outfp, uint64_t flags){
|
||||
}
|
||||
ret->fgdefault = ret->bgdefault = true;
|
||||
ret->fgrgb = ret->bgrgb = 0;
|
||||
ncdirect_styles_set(ret, 0);
|
||||
ncdirect_set_styles(ret, 0);
|
||||
return ret;
|
||||
|
||||
err:
|
||||
@ -685,7 +685,12 @@ ncdirect_style_emit(ncdirect* n, unsigned stylebits, FILE* out){
|
||||
return r;
|
||||
}
|
||||
|
||||
// turn on any specified stylebits
|
||||
int ncdirect_styles_on(ncdirect* n, unsigned stylebits){
|
||||
return ncdirect_on_styles(n, stylebits);
|
||||
}
|
||||
|
||||
int ncdirect_on_styles(ncdirect* n, unsigned stylebits){
|
||||
uint32_t stylemask = n->stylemask | stylebits;
|
||||
if(ncdirect_style_emit(n, stylemask, n->ttyfp) == 0){
|
||||
if(term_setstyle(n->ttyfp, n->stylemask, stylemask, NCSTYLE_ITALIC,
|
||||
@ -702,8 +707,12 @@ int ncdirect_styles_on(ncdirect* n, unsigned stylebits){
|
||||
return -1;
|
||||
}
|
||||
|
||||
// turn off any specified stylebits
|
||||
int ncdirect_styles_off(ncdirect* n, unsigned stylebits){
|
||||
return ncdirect_off_styles(n, stylebits);
|
||||
}
|
||||
|
||||
// turn off any specified stylebits
|
||||
int ncdirect_off_styles(ncdirect* n, unsigned stylebits){
|
||||
uint32_t stylemask = n->stylemask & ~stylebits;
|
||||
if(ncdirect_style_emit(n, stylemask, n->ttyfp) == 0){
|
||||
if(term_setstyle(n->ttyfp, n->stylemask, stylemask, NCSTYLE_ITALIC,
|
||||
@ -720,8 +729,12 @@ int ncdirect_styles_off(ncdirect* n, unsigned stylebits){
|
||||
return -1;
|
||||
}
|
||||
|
||||
// set the current stylebits to exactly those provided
|
||||
int ncdirect_styles_set(ncdirect* n, unsigned stylebits){
|
||||
return ncdirect_set_styles(n, stylebits);
|
||||
}
|
||||
|
||||
// set the current stylebits to exactly those provided
|
||||
int ncdirect_set_styles(ncdirect* n, unsigned stylebits){
|
||||
uint32_t stylemask = stylebits;
|
||||
if(ncdirect_style_emit(n, stylemask, n->ttyfp) == 0){
|
||||
n->stylemask &= !(NCSTYLE_ITALIC | NCSTYLE_STRUCK); // sgr clears both
|
||||
|
@ -27,11 +27,11 @@ int main(void){
|
||||
fflush(stdout);
|
||||
int ret = 0;
|
||||
ret |= ncdirect_fg_rgb(n, 0xff8080);
|
||||
ret |= ncdirect_styles_on(n, NCSTYLE_STANDOUT);
|
||||
ret |= ncdirect_on_styles(n, NCSTYLE_STANDOUT);
|
||||
printf(" erp erp \n");
|
||||
ret |= ncdirect_fg_rgb(n, 0x80ff80);
|
||||
printf(" erp erp \n");
|
||||
ret |= ncdirect_styles_off(n, NCSTYLE_STANDOUT);
|
||||
ret |= ncdirect_off_styles(n, NCSTYLE_STANDOUT);
|
||||
printf(" erp erp \n");
|
||||
ret |= ncdirect_fg_rgb(n, 0xff8080);
|
||||
printf(" erp erp \n");
|
||||
|
@ -34,12 +34,12 @@ print_gb(struct ncdirect* nc, int r, int total){
|
||||
static int
|
||||
print_rgb8(struct ncdirect* nc, int total){
|
||||
if(random() % 2){
|
||||
if(ncdirect_styles_off(nc, NCSTYLE_ITALIC)){
|
||||
if(ncdirect_off_styles(nc, NCSTYLE_ITALIC)){
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if(random() % 16 == 0){
|
||||
if(ncdirect_styles_on(nc, NCSTYLE_ITALIC)){
|
||||
if(ncdirect_on_styles(nc, NCSTYLE_ITALIC)){
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -69,7 +69,7 @@ int main(void){
|
||||
goto err;
|
||||
}
|
||||
|
||||
if(ncdirect_styles_set(nc, NCSTYLE_BOLD)){
|
||||
if(ncdirect_set_styles(nc, NCSTYLE_BOLD)){
|
||||
goto err;
|
||||
}
|
||||
for(int t = 768 ; t ; t -= 4){
|
||||
@ -81,7 +81,7 @@ int main(void){
|
||||
goto err;
|
||||
}
|
||||
|
||||
if(ncdirect_styles_set(nc, NCSTYLE_UNDERLINE)){
|
||||
if(ncdirect_set_styles(nc, NCSTYLE_UNDERLINE)){
|
||||
goto err;
|
||||
}
|
||||
for(int t = 0 ; t < 768 ; t += 4){
|
||||
@ -93,7 +93,7 @@ int main(void){
|
||||
goto err;
|
||||
}
|
||||
|
||||
if(ncdirect_styles_set(nc, NCSTYLE_ITALIC)){
|
||||
if(ncdirect_set_styles(nc, NCSTYLE_ITALIC)){
|
||||
goto err;
|
||||
}
|
||||
for(int t = 768 ; t ; t -= 4){
|
||||
@ -112,7 +112,7 @@ int main(void){
|
||||
if(ncdirect_cursor_move_yx(nc, leny / 2, (lenx - 4) / 2)){
|
||||
goto err;
|
||||
}
|
||||
ncdirect_styles_on(nc, NCSTYLE_ITALIC);
|
||||
ncdirect_on_styles(nc, NCSTYLE_ITALIC);
|
||||
printf("dank\n");
|
||||
if(ncdirect_stop(nc)){
|
||||
return EXIT_FAILURE;
|
||||
|
@ -14,7 +14,7 @@ int main(void){
|
||||
}
|
||||
int e = 0;
|
||||
for(unsigned i = 0 ; i < (NCSTYLE_STRUCK << 1u) ; ++i){
|
||||
if(ncdirect_styles_set(nc, i)){
|
||||
if(ncdirect_set_styles(nc, i)){
|
||||
ncdirect_stop(nc);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
@ -8,31 +8,31 @@ TEST_CASE("DirectMode") {
|
||||
}
|
||||
|
||||
SUBCASE("SetItalic") {
|
||||
CHECK(0 == ncdirect_styles_set(nc_, NCSTYLE_ITALIC));
|
||||
CHECK(0 == ncdirect_set_styles(nc_, NCSTYLE_ITALIC));
|
||||
printf("DirectMode *italic*!\n");
|
||||
fflush(stdout);
|
||||
CHECK(0 == ncdirect_styles_off(nc_, NCSTYLE_ITALIC));
|
||||
CHECK(0 == ncdirect_off_styles(nc_, NCSTYLE_ITALIC));
|
||||
}
|
||||
|
||||
SUBCASE("SetBold") {
|
||||
CHECK(0 == ncdirect_styles_set(nc_, NCSTYLE_BOLD));
|
||||
CHECK(0 == ncdirect_set_styles(nc_, NCSTYLE_BOLD));
|
||||
printf("DirectMode *bold*!\n");
|
||||
fflush(stdout);
|
||||
CHECK(0 == ncdirect_styles_off(nc_, NCSTYLE_BOLD));
|
||||
CHECK(0 == ncdirect_off_styles(nc_, NCSTYLE_BOLD));
|
||||
}
|
||||
|
||||
SUBCASE("SetUnderline") {
|
||||
CHECK(0 == ncdirect_styles_set(nc_, NCSTYLE_UNDERLINE));
|
||||
CHECK(0 == ncdirect_set_styles(nc_, NCSTYLE_UNDERLINE));
|
||||
printf("DirectMode *underline*!\n");
|
||||
fflush(stdout);
|
||||
CHECK(0 == ncdirect_styles_off(nc_, NCSTYLE_UNDERLINE));
|
||||
CHECK(0 == ncdirect_off_styles(nc_, NCSTYLE_UNDERLINE));
|
||||
}
|
||||
|
||||
SUBCASE("SetStruck") {
|
||||
CHECK(0 == ncdirect_styles_set(nc_, NCSTYLE_STRUCK));
|
||||
CHECK(0 == ncdirect_set_styles(nc_, NCSTYLE_STRUCK));
|
||||
printf("DirectMode *struck*!\n");
|
||||
fflush(stdout);
|
||||
CHECK(0 == ncdirect_styles_off(nc_, NCSTYLE_STRUCK));
|
||||
CHECK(0 == ncdirect_off_styles(nc_, NCSTYLE_STRUCK));
|
||||
}
|
||||
|
||||
CHECK(0 == ncdirect_stop(nc_));
|
||||
|
Loading…
Reference in New Issue
Block a user