ashish-yadav11 / st

My fork of the suckless terminal with proper scrolling support, text reflow and a few other additions.
22 stars 0 forks source link

Letters disappear in nano #3

Closed humky closed 2 years ago

humky commented 2 years ago

I have some visual glitches in nano (5.9) when navigating the cursor along the lines (horizontally) by holding left or right arrow. Some letters disappear. I believe the issue is in the scroll patch because I have my own heavily patched version of st and it doesn't have this bug. The bug appears in your build, or in my build after your scroll/reflow integration. vim doesn't have this bug. I use bspwm if it has any importance.

ashish-yadav11 commented 2 years ago

Try changing minlatency and maxlatency to default values in config.h.

ashish-yadav11 commented 2 years ago

I am not able to reproduce the issue.

ashish-yadav11 commented 2 years ago

Morever scroll/reflow only comes into play when resizing the st window.

humky commented 2 years ago

latency didn't help, set to 30, 80, cursor is very leggy, bug persists.

ashish-yadav11 commented 2 years ago

Can you send a video or something?

ashish-yadav11 commented 2 years ago

Default latency is 8, 33 by the way.

humky commented 2 years ago

Tried with freshly compiled nano 5.8 https://fastupload.co/1111217

Tried without .bashrc, same.

ashish-yadav11 commented 2 years ago

One thing is for sure that it is not being caused by scrolling/reflow part. Scrolling/reflow doesn't happen on alt-screen. Also I am not being able to reproduce the issue (but I have nano 5.9). I wouldn't be able to help you with the issue for a week or so. I have my exams from tomorrow.

ashish-yadav11 commented 2 years ago

If you can, you can try to find changes I have made in CSI code handlings related to cursor movement (see commit 4e9d5c5eb22754e9df6553d39dec4fe27b8727ca). I think some bug there might be causing the issue.

humky commented 2 years ago

Sorry my knowledge of C is very superficial, I can't help with source that much. It shouldn't matter though, If you can't reproduce it, it has to be something else, we have the same source code, computers supposed to be deterministic? Then it's some other code which is different on our machines.

ashish-yadav11 commented 2 years ago

The bug is happening in the build on this repository only, right?

humky commented 2 years ago

The bug is happening in the build on this repository only, right?

yes, my own build, and default st is fine.

ashish-yadav11 commented 2 years ago

Are you sure you are on the latest commit?

humky commented 2 years ago

git log -i commit ade8fcdfeae20d865490f9a0af30659fd438f50f (HEAD -> main, origin/main, origin/HEAD)

I just git clone it, I didn't touch the head or anything

ashish-yadav11 commented 2 years ago

I will relook into this after a week.

humky commented 2 years ago

Ok. I will poke some more, maybe I'll find something.

--

Works fine in tmux

humky commented 2 years ago

92c5965daf4e951a6fc1ff86d35a32650d0e5425 introduces it

humky commented 2 years ago

Using old

void
tputtab(int n)
{
    uint x = term.c.x;

    if (n > 0) {
        while (x < term.col && n--)
            for (++x; x < term.col && !term.tabs[x]; ++x)
                /* nothing */ ;
    } else if (n < 0) {
        while (x > 0 && n++)
            for (--x; x > 0 && !term.tabs[x]; --x)
                /* nothing */ ;
    }
    term.c.x = LIMIT(x, 0, term.col-1);
}
void
tcontrolcode(uchar ascii)
{
    switch (ascii) {
    case '\t':   /* HT */
        tputtab(1);

fixes it.

That's my limit in understanding. good luck on the exams

ashish-yadav11 commented 2 years ago

Are you completely sure that replacing twritetab() with tputtab(1) fixes the issue? I am unable to understand how the tabbing thing could lead to washing out of characters on moving the cursor.

humky commented 2 years ago

Yes, you still have this function defined, just replacing twritetab() with tputtab(1) solves missing characters. If you have any ideas how to debug I can try that.

ashish-yadav11 commented 2 years ago

Undo all changes, in twritetab function, replace GLYPH_TAB and GLYPH_TDUMMY with GLYPH_SET. See if the issue occurs. Also did you observe the behaviour in any program other than nano?

humky commented 2 years ago

What do you mean undo all changes? It was written from scratch and at the same commit it became buggy. Changing GLYPH_TAB and GLYPH_TDUMMY with GLYPH_SET didn't help. No, only in nano.

Tried most recent, and at the point of first introduction, with GLYPH_SET, still bugy.

ashish-yadav11 commented 2 years ago

I meant the changes you might have made.

ashish-yadav11 commented 2 years ago

Work on the latest state/commit. Comment out "if selected" and "selclear" lines from the twritetab function. See if the issue persists.

humky commented 2 years ago

Same.

ashish-yadav11 commented 2 years ago

Try this

void
twritetab(void)
{
    int x = term.c.x, y = term.c.y;

    /* selected() takes relative coordinates */
//  if (selected(x + term.scr, y + term.scr))
//      selclear();

//  term.line[y][x].u = ' ';
//  term.line[y][x].state = GLYPH_TAB;

    while (++x < term.col && !term.tabs[x]) {
//      term.line[y][x].u = ' ';
//      term.line[y][x].state = GLYPH_TDUMMY;
    }

    term.c.x = MIN(x, term.col-1);
}
humky commented 2 years ago

It still bugs out, but I think it somehow different to the previous time. Letters are shifting or something, not just disappearing, and it happens less frequently.

I tried in a new document, even without tabs still the same.

ashish-yadav11 commented 2 years ago

Wait this is impossible. The change must be equivalent to replacing twritetab with tputtab(1). Anyhow replace

    term.c.x = MIN(x, term.col-1);

with

    term.c.x = LIMIT(x, 0, term.col-1);

in the function.

ashish-yadav11 commented 2 years ago

If that also doesn't work, try


void
twritetab(void)
{
    uint x = term.c.x;

    if (x < term.col)
        for (++x; x < term.col && !term.tabs[x]; ++x)
    term.c.x = LIMIT(x, 0, term.col-1);
}
humky commented 2 years ago
void
twritetab(void)
{
    int x = term.c.x, y = term.c.y;

    /* selected() takes relative coordinates */
//  if (selected(x + term.scr, y + term.scr))
//      selclear();

//  term.line[y][x].u = ' ';
//  term.line[y][x].state = GLYPH_TAB;

    while (++x < term.col && !term.tabs[x]) {
//      term.line[y][x].u = ' ';
//      term.line[y][x].state = GLYPH_TDUMMY;
    }
        term.c.x = LIMIT(x, 0, term.col-1);
}

Works, I had issues with copying it from github, it produces additional //

ashish-yadav11 commented 2 years ago

Now uncomment first two commented lines. What happens then?

humky commented 2 years ago
void
twritetab(void)
{
    int x = term.c.x, y = term.c.y;

    /* selected() takes relative coordinates */
    if (selected(x + term.scr, y + term.scr))
         selclear();

  //  term.line[y][x].u = ' ';
  //  term.line[y][x].state = GLYPH_TAB;

      while (++x < term.col && !term.tabs[x]) {
      //      term.line[y][x].u = ' ';
      //      term.line[y][x].state = GLYPH_TDUMMY;
          }
              term.c.x = LIMIT(x, 0, term.col-1);
}

This one is working

ashish-yadav11 commented 2 years ago

Now uncomment GLYPH_* lines. Also revert last line to what it used to be (term.c.x = MIN(..)).

humky commented 2 years ago

Without term.line[y][x].u = ' ';?

ashish-yadav11 commented 2 years ago

yes

humky commented 2 years ago

Still working.

What it does?

ashish-yadav11 commented 2 years ago

Now uncomment first of the left ones (not in the loop).

humky commented 2 years ago

Bugs out

ashish-yadav11 commented 2 years ago

Still working.

What it does?

These are "hacks" for implementing copying of tab characters in the terminal.

ashish-yadav11 commented 2 years ago

Bugs out

What do you mean? Uncommenting all lines also doesn't cause any issue?

humky commented 2 years ago

uncomenting term.line[y][x].u = ' '; outside of while starts bugging again. second one remains commented

ashish-yadav11 commented 2 years ago

Okay, are you using tab keys for movement by any chance?

humky commented 2 years ago

I use arrows which are KC_LEFT, KC_DOWN, KC_UP, KC_RGHT in qmk firmware. I also have this stty werase '^H' in .bashrc, to have Ctrl-Backspace delete whole word. My .inputrc doesn't have anything unusual.

ashish-yadav11 commented 2 years ago

Can you try lxterminal and see if you face the same issue in nano? It also has the capability of copying tab characters.

humky commented 2 years ago

lxterminal 0.4.0 works fine.

ashish-yadav11 commented 2 years ago

It could be a bug in nano. Pressing movement keys should not lead to sending tab characters in my limited knowledge.

ashish-yadav11 commented 2 years ago

lxterminal 0.4.0 works fine.

hmm.

humky commented 2 years ago

Why can't you reproduce?

ashish-yadav11 commented 2 years ago

I have no idea.

ashish-yadav11 commented 2 years ago

What version of nano are you using? What distro?