mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-09 17:19:03 -04:00
ncreel_options: add flag field #590
This commit is contained in:
parent
66bafd59b3
commit
fbed12cd80
1
USAGE.md
1
USAGE.md
@ -1826,6 +1826,7 @@ typedef struct ncreel_options {
|
||||
uint64_t tabletchan; // tablet border styling channel
|
||||
uint64_t focusedchan;// focused tablet border styling channel
|
||||
uint64_t bgchannel; // background colors
|
||||
unsigned flags; // bitfield over NCREEL_OPTIONS_*
|
||||
} ncreel_options;
|
||||
|
||||
struct nctablet;
|
||||
|
@ -11,6 +11,9 @@ notcurses_reel - high-level widget for hierarchical data
|
||||
**#include <notcurses/notcurses.h>**
|
||||
|
||||
```c
|
||||
#define NCREEL_OPTIONS_INFINITESCROLL 0x0001
|
||||
#define NCREEL_OPTIONS_CIRCULAR 0x0002
|
||||
|
||||
typedef struct ncreel_options {
|
||||
// require this many rows and columns (including borders).
|
||||
// otherwise, a message will be displayed stating that a
|
||||
@ -32,15 +35,6 @@ typedef struct ncreel_options {
|
||||
// bottom left) upon creation / resize. an ncreel_move()
|
||||
// operation updates these.
|
||||
int toff, roff, boff, loff;
|
||||
// is scrolling infinite (can one move down or up forever, or is
|
||||
// an end reached?). if true, 'circular' specifies how to handle
|
||||
// the special case of an incompletely-filled reel.
|
||||
bool infinitescroll;
|
||||
// is navigation circular (does moving down from the last panel
|
||||
// move to the first, and vice versa)? only meaningful when
|
||||
// infinitescroll is true. if infinitescroll is false, this must
|
||||
// be false.
|
||||
bool circular;
|
||||
// notcurses can draw a border around the ncreel, and also
|
||||
// around the component tablets. inhibit borders by setting all
|
||||
// valid bits in the masks. partially inhibit borders by setting
|
||||
@ -54,6 +48,7 @@ typedef struct ncreel_options {
|
||||
uint64_t tabletchan; // tablet border styling channel
|
||||
uint64_t focusedchan;// focused tablet border styling channel
|
||||
uint64_t bgchannel; // background colors
|
||||
unsigned flags; // bitfield over NCREEL_OPTIONS_*
|
||||
} ncreel_options;
|
||||
```
|
||||
|
||||
|
@ -2211,6 +2211,15 @@ API int ncblit_rgba(struct ncplane* nc, int placey, int placex, int linesize,
|
||||
// This structure is amenable to line- and page-based navigation via keystrokes,
|
||||
// scrolling gestures, trackballs, scrollwheels, touchpads, and verbal commands.
|
||||
|
||||
// is scrolling infinite (can one move down or up forever, or is an end
|
||||
// reached?). if true, 'circular' specifies how to handle the special case of
|
||||
// an incompletely-filled reel.
|
||||
#define NCREEL_OPTIONS_INFINITESCROLL 0x0001
|
||||
// is navigation circular (does moving down from the last panel move to the
|
||||
// first, and vice versa)? only meaningful when infinitescroll is true. if
|
||||
// infinitescroll is false, this must be false.
|
||||
#define NCREEL_OPTIONS_CIRCULAR 0x0002
|
||||
|
||||
typedef struct ncreel_options {
|
||||
// require this many rows and columns (including borders). otherwise, a
|
||||
// message will be displayed stating that a larger terminal is necessary, and
|
||||
@ -2229,14 +2238,6 @@ typedef struct ncreel_options {
|
||||
// desired offsets within the surrounding WINDOW (top right bottom left) upon
|
||||
// creation / resize. an ncreel_move() operation updates these.
|
||||
int toff, roff, boff, loff;
|
||||
// is scrolling infinite (can one move down or up forever, or is an end
|
||||
// reached?). if true, 'circular' specifies how to handle the special case of
|
||||
// an incompletely-filled reel.
|
||||
bool infinitescroll;
|
||||
// is navigation circular (does moving down from the last panel move to the
|
||||
// first, and vice versa)? only meaningful when infinitescroll is true. if
|
||||
// infinitescroll is false, this must be false.
|
||||
bool circular;
|
||||
// notcurses can draw a border around the ncreel, and also around the
|
||||
// component tablets. inhibit borders by setting all valid bits in the masks.
|
||||
// partially inhibit borders by setting individual bits in the masks. the
|
||||
@ -2249,6 +2250,7 @@ typedef struct ncreel_options {
|
||||
uint64_t tabletchan; // tablet border styling channel
|
||||
uint64_t focusedchan;// focused tablet border styling channel
|
||||
uint64_t bgchannel; // background colors
|
||||
unsigned flags; // bitfield over NCREEL_OPTIONS_*
|
||||
} ncreel_options;
|
||||
|
||||
struct nctablet;
|
||||
|
@ -403,6 +403,7 @@ typedef struct ncreel_options {
|
||||
uint64_t tabletchan;
|
||||
uint64_t focusedchan;
|
||||
uint64_t bgchannel;
|
||||
unsigned flags; // bitfield over NCREEL_OPTIONS_*
|
||||
} ncreel_options;
|
||||
struct ncreel* ncreel_create(struct ncplane* nc, const ncreel_options* popts, int efd);
|
||||
struct ncplane* ncreel_plane(struct ncreel* pr);
|
||||
|
@ -278,8 +278,6 @@ ncreel_demo_core(struct notcurses* nc, int efdr, int efdw){
|
||||
bool aborted = false;
|
||||
int x = 8, y = 4;
|
||||
ncreel_options popts = {
|
||||
.infinitescroll = true,
|
||||
.circular = true,
|
||||
.min_supported_cols = 8,
|
||||
.min_supported_rows = 5,
|
||||
.bordermask = 0,
|
||||
@ -291,6 +289,7 @@ ncreel_demo_core(struct notcurses* nc, int efdr, int efdw){
|
||||
.roff = x,
|
||||
.boff = y,
|
||||
.bgchannel = 0,
|
||||
.flags = NCREEL_OPTIONS_INFINITESCROLL | NCREEL_OPTIONS_CIRCULAR,
|
||||
};
|
||||
channels_set_fg_rgb(&popts.focusedchan, 58, 150, 221);
|
||||
channels_set_bg_rgb(&popts.focusedchan, 97, 214, 214);
|
||||
|
@ -551,8 +551,8 @@ validate_ncreel_opts(ncplane* w, const ncreel_options* ropts){
|
||||
if(w == NULL){
|
||||
return false;
|
||||
}
|
||||
if(!ropts->infinitescroll){
|
||||
if(ropts->circular){
|
||||
if(ropts->flags & NCREEL_OPTIONS_CIRCULAR){
|
||||
if(!(ropts->flags & NCREEL_OPTIONS_INFINITESCROLL)){
|
||||
return false; // can't set circular without infinitescroll
|
||||
}
|
||||
}
|
||||
|
@ -13,14 +13,13 @@ ncreel_options NcReel::default_options = {
|
||||
/* roff */ 0,
|
||||
/* boff */ 0,
|
||||
/* loff */ 0,
|
||||
/* infinitescroll */ false,
|
||||
/* circular */ false,
|
||||
/* bordermask */ NCBox::MaskBottom | NCBox::MaskTop | NCBox::MaskRight | NCBox::MaskLeft,
|
||||
/* borderchan */ 0,
|
||||
/* tabletmask */ 0,
|
||||
/* tabletchan */ 0,
|
||||
/* focusedchan */ 0,
|
||||
/* bgchannel */ 0,
|
||||
/* flags */ 0,
|
||||
};
|
||||
|
||||
Plane* NcReel::get_plane () const noexcept
|
||||
|
@ -34,15 +34,14 @@ TEST_CASE("Reels") {
|
||||
|
||||
SUBCASE("InitLinearInfinite") {
|
||||
ncreel_options r{};
|
||||
r.infinitescroll = true;
|
||||
r.flags = NCREEL_OPTIONS_INFINITESCROLL;
|
||||
struct ncreel* nr = ncreel_create(n_, &r, -1);
|
||||
REQUIRE(nr);
|
||||
}
|
||||
|
||||
SUBCASE("InitCircular") {
|
||||
ncreel_options r{};
|
||||
r.infinitescroll = true;
|
||||
r.circular = true;
|
||||
r.flags = NCREEL_OPTIONS_INFINITESCROLL | NCREEL_OPTIONS_CIRCULAR;
|
||||
struct ncreel* nr = ncreel_create(n_, &r, -1);
|
||||
REQUIRE(nr);
|
||||
REQUIRE(0 == ncreel_destroy(nr));
|
||||
@ -51,8 +50,7 @@ TEST_CASE("Reels") {
|
||||
// circular is not allowed to be true when infinitescroll is false
|
||||
SUBCASE("FiniteCircleRejected") {
|
||||
ncreel_options r{};
|
||||
r.infinitescroll = false;
|
||||
r.circular = true;
|
||||
r.flags = NCREEL_OPTIONS_CIRCULAR;
|
||||
struct ncreel* nr = ncreel_create(n_, &r, -1);
|
||||
REQUIRE(!nr);
|
||||
}
|
||||
@ -61,7 +59,6 @@ TEST_CASE("Reels") {
|
||||
// even if there are no tablets. They both ought return nullptr.
|
||||
SUBCASE("MovementWithoutTablets") {
|
||||
ncreel_options r{};
|
||||
r.infinitescroll = false;
|
||||
struct ncreel* nr = ncreel_create(n_, &r, -1);
|
||||
REQUIRE(nr);
|
||||
CHECK(!ncreel_next(nr));
|
||||
@ -72,7 +69,6 @@ TEST_CASE("Reels") {
|
||||
|
||||
SUBCASE("OneTablet") {
|
||||
ncreel_options r{};
|
||||
r.infinitescroll = false;
|
||||
struct ncreel* nr = ncreel_create(n_, &r, -1);
|
||||
REQUIRE(nr);
|
||||
struct nctablet* t = ncreel_add(nr, nullptr, nullptr, panelcb, nullptr);
|
||||
@ -84,7 +80,6 @@ TEST_CASE("Reels") {
|
||||
|
||||
SUBCASE("MovementWithOneTablet") {
|
||||
ncreel_options r{};
|
||||
r.infinitescroll = false;
|
||||
struct ncreel* nr = ncreel_create(n_, &r, -1);
|
||||
REQUIRE(nr);
|
||||
struct nctablet* t = ncreel_add(nr, nullptr, nullptr, panelcb, nullptr);
|
||||
@ -100,7 +95,6 @@ TEST_CASE("Reels") {
|
||||
|
||||
SUBCASE("DeleteActiveTablet") {
|
||||
ncreel_options r{};
|
||||
r.infinitescroll = false;
|
||||
struct ncreel* nr = ncreel_create(n_, &r, -1);
|
||||
REQUIRE(nr);
|
||||
struct nctablet* t = ncreel_add(nr, nullptr, nullptr, panelcb, nullptr);
|
||||
|
Loading…
x
Reference in New Issue
Block a user