mirror of
https://github.com/dankamongmen/notcurses.git
synced 2024-11-08 01:10:23 +00:00
no autogrow for standard plane, add autogrow tests #2440
This commit is contained in:
parent
27bf6e0eee
commit
c8e601e457
@ -459,7 +459,8 @@ but upon reaching the bottom right corner of the plane, it is impossible to
|
||||
place more output without a scrolling event. If autogrow is in play, the plane
|
||||
will automatically be enlarged to accommodate output. If scrolling is disabled,
|
||||
growth takes place to the right; it otherwise takes place at the bottom. The
|
||||
plane only grows in one dimension.
|
||||
plane only grows in one dimension. Autogrow cannot be enabled for the standard
|
||||
plane.
|
||||
|
||||
Creating a plane with the **NCPLANE_OPTION_AUTOGROW** flag is equivalent to
|
||||
immediately calling **ncplane_set_autogrow** on that plane with an argument
|
||||
|
@ -112,6 +112,7 @@ typedef struct ncplane {
|
||||
int margin_b, margin_r;// bottom and right margins, stored for resize
|
||||
bool scrolling; // is scrolling enabled? always disabled by default
|
||||
bool fixedbound; // are we fixed relative to the parent's scrolling?
|
||||
bool autogrow; // do we grow to accommodate output?
|
||||
|
||||
// we need to track any widget to which we are bound, so that (1) we don't
|
||||
// end up bound to two widgets and (2) we can clean them up on shutdown
|
||||
|
@ -513,6 +513,7 @@ ncplane* ncplane_new_internal(notcurses* nc, ncplane* n,
|
||||
}
|
||||
p->scrolling = nopts->flags & NCPLANE_OPTION_VSCROLL;
|
||||
p->fixedbound = nopts->flags & NCPLANE_OPTION_FIXED;
|
||||
p->autogrow = nopts->flags & NCPLANE_OPTION_AUTOGROW;
|
||||
p->widget = NULL;
|
||||
p->wdestruct = NULL;
|
||||
if(nopts->flags & NCPLANE_OPTION_MARGINALIZED){
|
||||
@ -2832,6 +2833,20 @@ bool ncplane_scrolling_p(const ncplane* n){
|
||||
return n->scrolling;
|
||||
}
|
||||
|
||||
bool ncplane_set_autogrow(ncplane* n, unsigned growp){
|
||||
if(n == notcurses_stdplane_const(ncplane_notcurses_const(n))){
|
||||
logerror("can't set the standard plane autogrow\n");
|
||||
return false;
|
||||
}
|
||||
bool old = n->autogrow;
|
||||
n->autogrow = growp;
|
||||
return old;
|
||||
}
|
||||
|
||||
bool ncplane_autogrow_p(const ncplane* n){
|
||||
return n->autogrow;
|
||||
}
|
||||
|
||||
// extract an integer, which must be non-negative, and followed by either a
|
||||
// comma or a NUL terminator.
|
||||
static int
|
||||
|
20
src/tests/autogrow.cpp
Normal file
20
src/tests/autogrow.cpp
Normal file
@ -0,0 +1,20 @@
|
||||
#include "main.h"
|
||||
|
||||
TEST_CASE("Autogrow") {
|
||||
auto nc_ = testing_notcurses();
|
||||
if(!nc_){
|
||||
return;
|
||||
}
|
||||
struct ncplane* n_ = notcurses_stdplane(nc_);
|
||||
REQUIRE(n_);
|
||||
|
||||
// verify that the standard plane has scrolling disabled initially, and that
|
||||
// we cannot enable it at runtime.
|
||||
SUBCASE("AutogrowDisabledStdplane") {
|
||||
CHECK(!ncplane_set_autogrow(n_, true)); // disabled at start?
|
||||
CHECK(!ncplane_set_autogrow(n_, false)); // attempt to enable failed?
|
||||
}
|
||||
|
||||
CHECK(0 == notcurses_stop(nc_));
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user