diff --git a/src/lib/reader.c b/src/lib/reader.c index 3c18e3116..1066e0bb7 100644 --- a/src/lib/reader.c +++ b/src/lib/reader.c @@ -89,10 +89,10 @@ int ncreader_move_left(ncreader* n){ if(y == 0){ return -1; // no move possible } - viewx = n->textarea->lenx - 1; // FIXME find end of particular row + viewx = n->ncp->lenx - 1; // FIXME find end of particular row --y; - textx = viewx; - n->xproject = 0; + textx = n->textarea->x - 1; + n->xproject = n->textarea->x - n->ncp->x; }else{ // if we're on the first column of the viewarea, but not the first column // of the textarea, we must be able to scroll to the left. do so. diff --git a/src/poc/reader.cpp b/src/poc/reader.cpp index d9e93dbc7..fafdcb10e 100644 --- a/src/poc/reader.cpp +++ b/src/poc/reader.cpp @@ -7,11 +7,26 @@ using namespace ncpp; -auto main() -> int { +auto usage(const char* argv0, int ret) -> void { + std::cerr << "usage: " << argv0 << " [ -hs ]" << std::endl; + exit(ret); +} + +auto main(int argc, const char** argv) -> int { if(!setlocale(LC_ALL, "")){ std::cout << "Error setting locale\n"; return EXIT_FAILURE; } + bool horscroll = false; + if(argc == 2){ + if(strcmp(argv[1], "-hs") == 0){ + horscroll = true; + }else{ + usage(argv[0], EXIT_FAILURE); + } + }else if(argc > 2){ + usage(argv[0], EXIT_FAILURE); + } notcurses_options nopts{}; nopts.flags = NCOPTION_INHIBIT_SETLOCALE; NotCurses nc(nopts); @@ -22,6 +37,7 @@ auto main() -> int { opts.physrows = dimy / 8; opts.physcols = dimx / 2; opts.egc = "░"; + opts.flags = horscroll ? NCREADER_OPTION_HORSCROLL : 0; // FIXME c++ is crashing //Reader nr(nc, 0, 0, &opts); auto nr = ncreader_create(**n, 2, 2, &opts); @@ -38,8 +54,15 @@ auto main() -> int { break; } int y, x; - ncplane_cursor_yx(ncreader_plane(nr), &y, &x); + struct ncplane* ncp = ncreader_plane(nr); + ncplane_cursor_yx(ncp, &y, &x); nc.cursor_enable(y + 2, x + 2); + int ncpy, ncpx; + ncplane_cursor_yx(ncp, &ncpy, &ncpx); + int tgeomy, tgeomx, vgeomy, vgeomx; + (*n)->get_dim(&tgeomy, &tgeomx); + ncplane_dim_yx(ncp, &vgeomy, &vgeomx); + (*n)->printf(0, 0, "Cursor: %d/%d Viewgeom: %d/%d Textgeom: %d/%d", ncpy, ncpx, vgeomy, vgeomx, tgeomy, tgeomx); nc.render(); } nc.render();