New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLI mode always involves at least two rows #2196
Comments
it looks like we're not emitting newlines or anything, but simply tacking a move onto the end that takes us too far. it's the very last thing we're emitting. we know we're on 2 at the beginning -- why do we go to 3? hrmm. |
ok, |
in xterm i just noticed that |
yeah. |
|
i'm wondering if this is related to |
[schwarzgerat](130) $ ./cli
notcurses 2.4.8 on Kitty 0.23.1 (Linux 5.14.15nlb)
64 rows (22px) 132 cols (11px) 1408x1452 rgb+256 colors
gcc-11.2.0 (LE)
terminfo 6.2.20210905 zlib 1.2.11 GPM n/a
avformat 58.76.100 avutil 56.70.100 swscale 5.9.100 avcodec 58.134.100
0 failed renders, 0 failed rasters, 0 refreshes, 0 input errors
RGB emits:elides: def 0:0 fg 0:0 bg 0:0
Cell emits:elides: 0:0 (0.00%) 0.00% 0.00% 0.00%
Bitmap emits:elides: 0:0 (0.00%) 0B (0.00%) SuM: 0 (0.00%)
[schwarzgerat](0) $ this is the absolute minimum notcurses cli: int main(void){
struct notcurses_options opts = {
.flags = NCOPTION_NO_ALTERNATE_SCREEN |
NCOPTION_PRESERVE_CURSOR |
NCOPTION_NO_CLEAR_BITMAPS |
NCOPTION_DRAIN_INPUT,
};
struct notcurses* nc = notcurses_init(&opts, NULL);
if(nc == NULL){
return EXIT_FAILURE;
}
notcurses_stop(nc);
return EXIT_SUCCESS;
} |
sans banners, we output (from line 2):
|
different lines are the exact same output except for that first move. ahhh, it looks like there is a linefeed at the end of our output:
and |
the following seems to remedy the problem, but i'm sure there's some case i'm not considering that prompted this dubious-looking wart: if((nc->flags & NCOPTION_PRESERVE_CURSOR) || !get_escape(&nc->tcache, ESCAPE_SMCUP)){
int targy = nc->rstate.logendy;
fbuf_reset(&nc->rstate.f);
- if(++targy >= nc->lfdimy){
+ /*if(++targy >= nc->lfdimy){
fbuf_putc(&nc->rstate.f, '\n');
--targy;
- }
+ }*/ |
yeah this has us consuming the emoji line with our closing border in maybe we just want a newline in |
hah i think that might be it lol |
and to make that work, we do need to bring the cursor out at the end...yes, this is the problem. we need an explicit newline at the end of our output to bump we've absolutely gotta junk that |
i think this only happens if you inhibit banners...? |
nope, the program above has banners, and prints an empty line. |
why this LF at the end? |
targy is 63 in this situation, while lfdimy is...0!? |
ok yeah it looks like this is just due to |
i might have a fix. |
ok, let's stop flailing around and be a bit rigorous.
so the only case we really need handle is when we've not placed the cursor at the end of our generated output, i.e. when we write something, and then move the cursor backwards in the output. and in this case, we just want to go back to wherever the furthest place we generated output is, right? |
so if that's all correct, we just need to put it at |
i think the problem is that this got mixed up with "last place we wrote", as necessary for |
no... |
it's a bit more complex than this. we don't want to put the cursor at the last place we wrote; we want to put the cursor one past the last place we wrote (more precisely, immediately past the last glyph we wrote; it might have been more than one column). this is probably best said as: we want the cursor wherever the furthest place our cursor ever was (this accounts for scrolling etc., which ought already have taken place for e.g. a glyph emitted in the lower-right corner). this would be further complicated by the fact that this works differently in the alternative and regular screens, except that so |
ok, things are now everywhere improved over what we had, and close to perfect. problems remaining:
every other test i've got is now perfect. |
got the first |
got the |
so the remaining |
hrmm so yes, since i changed |
hrmm. this case was already broken, so i think i'm going to aim to merge this, and then we'll figure it out. we still need to do this btw:
|
the one thing i don't like about this is use of ok, i looked it over. there is no "newline" in ascii/unicode to which |
i've now got i didn't do the bool though, and i've checked, and |
i'm going to go ahead and merge this, as it definitely improves things, but i'm a bit perturbed by my failure to understand this render-raster path. it'll need further study, but i've been working on this for three days. bring it home to mama. |
Run e.g.
grid
or any other CLI-style program that has no text output. There will be a blank line before the new prompt. Running e.g.true
or other such tools results in no such blank line, and we oughtn't either.The text was updated successfully, but these errors were encountered: