Handle fallout from reversion of Notcurses::render() semantic inversion (see #510)

This commit is contained in:
nick black 2020-04-18 15:28:26 -04:00
parent 3ea7bbba18
commit 60e3e604a8
No known key found for this signature in database
GPG Key ID: 5F43400C21CBFACC
8 changed files with 12 additions and 13 deletions

View File

@ -7,6 +7,8 @@ rearrangements of Notcurses.
terminals. `ncdirect_cursor_yx()` ought be considered experimental; it
must read a response from the terminal, and this can interact poorly with
other uses of standard input.
* 1.3.1 unintentionally inverted the C++ `Notcurses::render()` wrapper's
return code. The previous semantics have been restored.
* 1.3.1 (2020-04-18)
* `ncplane_at_yx()` and `ncplane_at_cursor()` have been changed to return a
@ -19,9 +21,6 @@ rearrangements of Notcurses.
parameters, thus matching every other function with these two parameters.
It moved `const char* egc` before either, to force a type error, as the
change would otherwise be likely to go overlooked.
* The C++ `Notcurses::render()` function now returns non-zero on failure,
mirroring the behavior of the core C `notcurses_render()`. This is an
inversion of its previous behavior.
* Scrolling is now completely implemented. When a plane has scrolling enabled
through use of `ncplane_set_scrolling(true)`, output past the end of the
last line will now result in the top line of the plane being lost, all

View File

@ -190,7 +190,7 @@ void Tick(ncpp::NotCurses* nc, uint64_t sec) {
if(ncplot_add_sample(plot, sec, 0)){
throw std::runtime_error("couldn't register timetick");
}
if(nc->render()){
if(!nc->render()){
throw std::runtime_error("error rendering");
}
}
@ -232,7 +232,7 @@ int main(void){
}
n->styles_set(CellStyle::None);
n->set_bg_default();
if(nc.render()){
if(!nc.render()){
throw std::runtime_error("error rendering");
}
int y = 2;
@ -299,7 +299,7 @@ int main(void){
mtx.unlock();
break;
}
if(nc.render()){
if(!nc.render()){
mtx.unlock();
throw std::runtime_error("error rendering");
}

View File

@ -52,7 +52,7 @@ void DrawBoard() { // draw all fixed components of the game
scoreplane_->printf(0, 1, "%s", cuserid(nullptr));
scoreplane_->set_fg(0x00d0a0);
UpdateScore();
if(nc_.render()){
if(!nc_.render()){
throw TetrisNotcursesErr("render()");
}
}

View File

@ -18,7 +18,7 @@ bool MoveDown() { // returns true if the game has ended as a result of this move
}else{
++y;
}
if(nc_.render()){
if(!nc_.render()){
throw TetrisNotcursesErr("render()");
}
}

View File

@ -11,7 +11,7 @@ void MoveLateral(int direction) { // pass in -1 for left, 1 for right
}
}else{
x += shift;
if(nc_.render()){
if(!nc_.render()){
throw TetrisNotcursesErr("render()");
}
}

View File

@ -34,7 +34,7 @@ std::unique_ptr<ncpp::Plane> NewPiece() {
y += ((x = ((x + 2) % cols)) == 0);
}
}
if(nc_.render()){
if(!nc_.render()){
throw TetrisNotcursesErr("render()");
}
return n;

View File

@ -9,7 +9,7 @@ void RotateCcw() {
if(InvalidMove() && !curpiece_->rotate_cw()){
throw TetrisNotcursesErr("rotate_cw()");
}
if(nc_.render()){
if(!nc_.render()){
throw TetrisNotcursesErr("render()");
}
}
@ -25,7 +25,7 @@ void RotateCw() {
if(InvalidMove() && !curpiece_->rotate_ccw()){
throw TetrisNotcursesErr("rotate_ccw()");
}
if(nc_.render()){
if(!nc_.render()){
throw TetrisNotcursesErr("render()");
}
}

View File

@ -85,7 +85,7 @@ int perframe([[maybe_unused]] struct notcurses* _nc, struct ncvisual* ncv, void*
ns -= s * NANOSECS_IN_SEC;
stdn->printf(0, NCAlign::Right, "%02ld:%02ld:%02ld.%04ld",
h, m, s, ns / 1000000);
if(nc.render()){
if(!nc.render()){
return -1;
}
int dimx, dimy, oldx, oldy, keepy, keepx;