mirror of
https://github.com/dankamongmen/notcurses
synced 2025-03-10 01:29:05 -04:00
with PRESERVE_CURSOR, track logical end of output #1906
This commit is contained in:
parent
e767fd0b5f
commit
af418a221f
@ -193,7 +193,7 @@ unicodedumper(struct ncplane* n, tinfo* ti, const char* indent){
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*static int
|
||||
static int
|
||||
display_logo(const tinfo* ti, struct ncplane* n, const char* path){
|
||||
struct ncvisual* ncv = ncvisual_from_file(path);
|
||||
if(ncv == NULL){
|
||||
@ -220,7 +220,7 @@ display_logo(const tinfo* ti, struct ncplane* n, const char* path){
|
||||
}
|
||||
ncvisual_destroy(ncv);
|
||||
return 0;
|
||||
}*/
|
||||
}
|
||||
|
||||
static void
|
||||
tinfo_debug_bitmaps(struct ncplane* n, const tinfo* ti, const char* indent){
|
||||
@ -247,7 +247,7 @@ tinfo_debug_bitmaps(struct ncplane* n, const tinfo* ti, const char* indent){
|
||||
char* path = prefix_data("notcurses.png");
|
||||
if(path){
|
||||
// FIXME hold off until #1883 is resolved
|
||||
//display_logo(ti, n, path);
|
||||
display_logo(ti, n, path);
|
||||
free(path);
|
||||
}
|
||||
}
|
||||
|
@ -123,6 +123,15 @@ typedef struct rasterstate {
|
||||
unsigned lastbr; // background rgb, overloaded for palindexed bg
|
||||
unsigned lastbg;
|
||||
unsigned lastbb;
|
||||
|
||||
// used in CLI mode, these track the end of logical output, to place the
|
||||
// cursor following each rasterization. they are tracked thusly:
|
||||
// * initialized to the initial physical cursor position
|
||||
// * when we write to a physical row greater than logendy, update both
|
||||
// * when we scroll, subtract one from logendy
|
||||
// * if logendy reaches -1, reset both to 0
|
||||
int logendy, logendx;
|
||||
|
||||
uint16_t curattr; // current attributes set (does not include colors)
|
||||
// we elide a color escape iff the color has not changed between two cells
|
||||
bool fgelidable;
|
||||
|
@ -1111,14 +1111,14 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){
|
||||
free(ret);
|
||||
return NULL;
|
||||
}
|
||||
const char* shortname_term = termname();
|
||||
// const char* longname_term = longname();
|
||||
int cursor_y = -1, cursor_x = -1;
|
||||
const char* shortname_term = termname(); // longname() is also available
|
||||
ret->rstate.logendy = -1;
|
||||
ret->rstate.logendx = -1;
|
||||
if(interrogate_terminfo(&ret->tcache, ret->ttyfd, shortname_term, utf8,
|
||||
opts->flags & NCOPTION_NO_ALTERNATE_SCREEN, 0,
|
||||
opts->flags & NCOPTION_NO_FONT_CHANGES,
|
||||
opts->flags & NCOPTION_PRESERVE_CURSOR ? &cursor_y : NULL,
|
||||
opts->flags & NCOPTION_PRESERVE_CURSOR ? &cursor_x : NULL)){
|
||||
opts->flags & NCOPTION_PRESERVE_CURSOR ? &ret->rstate.logendy : NULL,
|
||||
opts->flags & NCOPTION_PRESERVE_CURSOR ? &ret->rstate.logendx : NULL)){
|
||||
goto err;
|
||||
}
|
||||
int dimy, dimx;
|
||||
@ -1158,12 +1158,14 @@ notcurses* notcurses_core_init(const notcurses_options* opts, FILE* outfp){
|
||||
free_plane(ret->stdplane);
|
||||
goto err;
|
||||
}
|
||||
if(cursor_y >= 0 && cursor_x >= 0){
|
||||
if(!ret->suppress_banner && locate_cursor_early(ret, &cursor_y, &cursor_x)){
|
||||
free_plane(ret->stdplane);
|
||||
goto err;
|
||||
if(ret->rstate.logendy >= 0 && ret->rstate.logendx >= 0){
|
||||
if(!ret->suppress_banner){
|
||||
if(locate_cursor_early(ret, &ret->rstate.logendy, &ret->rstate.logendx)){
|
||||
free_plane(ret->stdplane);
|
||||
goto err;
|
||||
}
|
||||
}
|
||||
ncplane_cursor_move_yx(ret->stdplane, cursor_y, cursor_x);
|
||||
ncplane_cursor_move_yx(ret->stdplane, ret->rstate.logendy, ret->rstate.logendx);
|
||||
}
|
||||
if(set_fd_nonblocking(ret->tcache.input.infd, 1, &ret->stdio_blocking_save)){
|
||||
goto err;
|
||||
@ -1247,9 +1249,8 @@ int notcurses_stop(notcurses* nc){
|
||||
if(nc){
|
||||
ret |= notcurses_stop_minimal(nc);
|
||||
// if we were not using the alternate screen, our cursor's wherever we last
|
||||
// wrote. move it to the bottom left of the screen, *unless*
|
||||
// NCOPTION_PRESERVE_CURSOR was used, in which case it's right where we
|
||||
// want it (i think? FIXME maybe next line's start?).
|
||||
// wrote. move it to the bottom left of the screen, *unless* PRESERVE_CURSOR
|
||||
// was used, in which case it's right where we want it.
|
||||
if(!(nc->flags & NCOPTION_PRESERVE_CURSOR)){
|
||||
if(!get_escape(&nc->tcache, ESCAPE_SMCUP)){
|
||||
// if ldimy is 0, we've not yet written anything; leave it untouched
|
||||
|
Loading…
x
Reference in New Issue
Block a user