From 54c1d3bbaeb12864083f473801161751ba4264de Mon Sep 17 00:00:00 2001 From: nick black Date: Sat, 28 Aug 2021 02:59:30 -0400 Subject: [PATCH] notcurses-input: move legend to bottom row We don't want to possibly draw an NCBLIT_PIXEL plot over the bottom row, lest we incur undesirable scrolling. Instead, move the legend from the top row to the bottom row, and the plot one row above it. --- src/input/input.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/input/input.cpp b/src/input/input.cpp index 01de2b1d4..bf4ec52be 100644 --- a/src/input/input.cpp +++ b/src/input/input.cpp @@ -153,7 +153,7 @@ static bool dim_rows(const Plane* n){ int y, x; Cell c; - for(y = 2 ; y < dimy ; ++y){ + for(y = 0 ; y < dimy ; ++y){ for(x = 0 ; x < dimx ; ++x){ if(n->get_at(y, x, &c) < 0){ n->release(c); @@ -206,7 +206,7 @@ int input_demo(ncpp::NotCurses* nc) { constexpr auto PLOTHEIGHT = 6; auto n = nc->get_stdplane(&dimy, &dimx); struct ncplane_options nopts = { - .y = dimy - PLOTHEIGHT, + .y = dimy - PLOTHEIGHT - 1, .x = 0, .rows = PLOTHEIGHT, .cols = dimx, @@ -235,7 +235,7 @@ int input_demo(ncpp::NotCurses* nc) { n->set_fg_rgb8(0x00, 0x00, 0x00); n->set_bg_rgb8(0xbb, 0x64, 0xbb); n->styles_on(CellStyle::Underline); - if(n->putstr(0, NCAlign::Center, "mash keys, yo. give that mouse some waggle! ctrl+d exits.") <= 0){ + if(n->putstr(n->get_dim_y() - 1, NCAlign::Center, "mash keys, yo. give that mouse some waggle! ctrl+d exits.") <= 0){ ncuplot_destroy(plot); return -1; } @@ -245,7 +245,7 @@ int input_demo(ncpp::NotCurses* nc) { ncuplot_destroy(plot); return -1; } - int y = 2; + int y = 0; std::deque cells; char32_t r; done = false; @@ -313,8 +313,8 @@ int input_demo(ncpp::NotCurses* nc) { throw std::runtime_error("error rendering"); } mtx.unlock(); - if(++y >= dimy - PLOTHEIGHT){ // leave six lines free on the bottom... - y = 2; // ...and one free on the top. + if(++y >= dimy - PLOTHEIGHT - 1){ + y = 0; } while(cells.size() >= dimy - 3u){ cells.pop_back();