bugGNU nano - Bugs: bug #51923, cursor flashes to bottom of the...

 
 

bug #51923: cursor flashes to bottom of the screen when editing

Submitted by:  Mike Frysinger <vapier>
Submitted on:  Sun 03 Sep 2017 12:44:44 AM UTC  
 
Severity: 3 - NormalStatus: Fixed
Assigned to: Benno Schulenberg <bens>Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Sun 19 Nov 2017 08:13:44 AM UTC, comment #20:

Released in 2.9.0.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Wed 20 Sep 2017 07:59:03 PM UTC, comment #19:

The flashing on the bottom row should be fixed in git: ae34825f.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Wed 20 Sep 2017 07:23:47 PM UTC, comment #18:

Thanks for testing. But... the problem of ^R ^T ^W ^C not switching the cursor back on (when using --show) is present in master too. Please report it as a separate bug. And the problem of the cursor getting hidden/misplaced when doing <Up> at the top of the file list or <Down> at the bottom, is present in master also. Please report that as a separate bug too.

So the two misbehaviors that are caused by the patch are:

alfa: ^R ^T ^G does not turn the cursor off.

beta: ^R ^T <Up> puts the cursor on the status bar.

I will look into alfa, because it is a new bug. When it's fixed, I'll push the patch, and then we'll look into beta, because it is in fact a more visible version of the second of the two bugs mentioned at the top.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Mon 18 Sep 2017 08:36:17 PM UTC, comment #17:

...and in (b), "the same problem in (a)" means that the cursor isn't on the file it should be.

David Lawrence Ramsey <dolorous>
Project Administrator
Mon 18 Sep 2017 08:28:06 PM UTC, comment #16:

Check that; effect 2 sometimes doesn't occur depending on whether the cursor is on or off. More precisely, run nano with the aforementioned options, press Ctrl-W Ctrl-T, and then press Ctrl-G immediately afterward. Or, run nano with the aforementioned options, press Ctrl-W Ctrl-T, and then press Ctrl-W Ctrl-G immediately afterward; the same problem occurs in the file search help browser.

Also, there are a few other issues with cursor placement. Run nano with the aforementioned options, press Ctrl-W Ctrl-T, and then:

(a) With the cursor on the first file of the list, press Up (or Ctrl-Home). The cursor will move to the beginning of the line the status bar prompt is on, instead of remaining on the first file.

(b) With the cursor on the last file of the list, press Down (or Ctrl-End). The same problem occurs as in (a).

David Lawrence Ramsey <dolorous>
Project Administrator
Mon 18 Sep 2017 08:14:31 PM UTC, comment #15:

I've done some quick testing with the patch in comment #14. With the patch applied to git fd86696, run:

./nano --ignore -g

and then press Ctrl-W Ctrl-T to go to the file browser. Inside the file browser, the following effects occur:

1. Pressing Ctrl-W to go to the Search prompt, and then pressing Ctrl-C to cancel out of the prompt does not turn the cursor back on in the file browser (at least not until you move to another file or refresh the screen via Ctrl-L).

2. Pressing Ctrl-G to go to the file browser's help does not turn the cursor off in the help browser (at least not until you search inside the help text or refresh the screen via Ctrl-L).

David Lawrence Ramsey <dolorous>
Project Administrator
Mon 18 Sep 2017 07:34:20 PM UTC, comment #14:

Here is an updated patch that fixes the case of Unicode input.

(file #41831)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Mon 18 Sep 2017 06:56:04 PM UTC, comment #13:

Attached is a proposed patch. It works by keeping the cursor off all the time that we are not waiting for input.

If anyone has some spare time, please test.

(file #41830)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Fri 15 Sep 2017 12:05:50 AM UTC, comment #12:

You can also run script outside of screen/tmux to see what the terminal emulator sees :) Of course it has its limitations and inconveniences too, I just wanted to make sure that you're aware of this useful tool.

I cannot comment on the patch itself. It's probably good :)

Egmont Koblinger <egmont>
Thu 14 Sep 2017 11:55:49 PM UTC, comment #11:

script would work too, but it's not as useful (imo) for on the fly testing. it'll give you a full session, but doesn't make it easy to narrow down events.

in my case, it also wouldn't help to make sure there's no funny business going on in between. if you run inside of screen or tmux, script will capture nano's behavior, but won't show what the terminal emulator itself sees (since screen/tmux will mangle/swallow things).

with that patch, i no longer see the cursor flashing around.

Mike Frysinger <vapier>
Project Member
Thu 14 Sep 2017 08:20:10 PM UTC, comment #10:

FYI: Instead of adding debug stuff or strace'ing, I'm wondering if you guys have heard of script(1), probably the easiest and simplest way of recording the app's output.

Egmont Koblinger <egmont>
Wed 13 Sep 2017 07:52:14 PM UTC, comment #9:

When I catch a strace, and press and hold j, sequences like these get repeated over and over again:

\33[?25l
\33[34;44H\33(B\33[0;7m3/3\33[34;62H2/3 (66\r\33(B\33[m
\33[?12l\33[?25h
\33[3;7Hj

Indeed, the cursor gets switched back on ("\33[?25h") before moving the cursor ("\33[row;colH") to the place where the j gets printed.

So... nano should switch the cursor back on not in the main routine but only after doupdate() has been called.

Attached patch should get rid of all the cursor flashes during editing. (It will also show the cursor in places where it shouldn't be, like in the help viewer and the file browser, but that will require some extra logic to determine whether that relocated curs_set() should really be called or not.)

(Strangely, for me it does the "\r" in the expected place: before switching the cursor back on.)

(file #41799)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Wed 13 Sep 2017 07:07:10 AM UTC, comment #8:

i added debug code to the terminal that dumps the exact sequences transmitted :)

i guess a local/terminal independent way would be to run strace against nano. ncurses is in-process, so any write() calls would be seen by strace.

Mike Frysinger <vapier>
Project Member
Tue 12 Sep 2017 07:09:21 PM UTC, comment #7:

How do you catch the codes that ncurses sends to the terminal?

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Thu 07 Sep 2017 03:58:17 PM UTC, comment #6:

here's exactly what the terminal sees when i press "j" once in an empty buffer. the terminal is 202 rows x 58 cols, and i'm not using screen/tmux/etc... TERM is set to xterm-256color and i'm using hterm.

\e[?25l\e[58;99H\e(B\e[0;7m2/2\e[58;116H1/2 (50%) ]\e(B\e[m\e[?12l\e[?25h\r\e[2dj

\e[?25l - DECTCEM - hide cursor
\e[58;99H - CUP - move cursor to row 58 col 99 (so the middle of the status buffer)
\e(B - SCS - set character map to US (weird, but OK)
\e[0;7m - SGR - set to normal/inverse colors
2/2 - update the column display to "2/2"
\e[58;116H - CUP - move cursor to row 58 col 116 (so end of the status buffer)
1/2 (50%) ] - update the character display
\e(B - SCS - set character map to US
\e[m - SGR - set back to normal colors
\e[?12l - disable blinking cursor
\e[?25h - DECTEM - show cursor
\r - move cursor to col 0
\e[2d - VPA - move cursor to row 2
j - display the "j" i typed

so yes, the cursor is shown before being moved. seems like the "show cursor" should have come after the \r\e[2d sequence.

the reason i notice the movement is that this terminal emulator will update the cursor position immediately when it goes from invisible->visible. if i change it to schedule the position update (which happens once the current stream finishes), it's much less of an issue. i'll have to think about this more though as the visibility transitions are always immediate which means we'd get stale data.

Mike Frysinger <vapier>
Project Member
Tue 05 Sep 2017 08:38:41 PM UTC, comment #5:

i had traced the escape sequences emitted a bit to try and double check it wasn't a terminal emulation bug. i'll give it another try to double check.

that patch does help mitigate it in the meantime. the cursor still flashes, but to the end of the status bar rather than the bottom left corner.

i'm using ncurses-6.0 fwiw.

Mike Frysinger <vapier>
Project Member
Sun 03 Sep 2017 10:59:25 PM UTC, comment #4:

For the record, I can't reproduce the original problem in the first place. I've tried with Xfce-terminal and Konsole (regarding the latter, I was finally able to get KDE5 installed), both with blinking cursors, and with xterm without a blinking cursor; I've also tried it with lines past 100000 columns. If it's an ncurses bug, I'm using ncurses 5.9.

David Lawrence Ramsey <dolorous>
Project Administrator
Sun 03 Sep 2017 08:48:02 PM UTC, comment #3:

Attached patch should reduce the distraction on regular-sized terminals, because normally the --constantshow line will fit fine on the status bar. So the patch activates the workaround only when the message is close to filling the entire row.

With this patch, I don't see the flahes any more, not anywhere on the bottom row.

(file #41725)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Sun 03 Sep 2017 11:34:59 AM UTC, comment #2:

Okay, I have been able to reproduce. But it is quite rare: in most cases the cursor is already beyond column 500 before I see the first flash. On my old laptop it is more frequent: half of the time the first flash is within a handful of seconds, and it occurs both on Gnome Terminal and on a Linux console (I didn't check on xterm). It also seems to occur more easily when using a blinking cursor (my default cursor is steady).

In my opinion, this must be a bug in ncurses, because whenever nano is writing to the status bar, the cursor is off. And it is switched off even before placing the cursor anywhere in the status bar. So... somehow the terminal (or ncurses) sometimes shows the cursor character even though the cursor is off.

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Sun 03 Sep 2017 09:34:27 AM UTC, comment #1:

I don't see this flashing. Not on an Xfce terminal, nor on an xterm nor on a Linux console (VT). What terminal are you using?

It should not be possible for the cursor to be visible, because it only gets switched on in the main loop, just before waiting for input. But... I remember seeing brief flashes at the tail of a statusbar message on my old laptop -- flashes that should also have been impossible because the cursor was off. That was on Gnome Terminal. Or are you maybe using an older ncurses?

If you apply the attached testing patch (that should hide the cursor entirely, as long as you don't do any searching or linting or justifying or verbatim input), do you still see the flashing at the start of the status bar when using --constantshow --nohelp?

(file #41721)

Benno Schulenberg <bens>
Project AdministratorIn charge of this item.
Sun 03 Sep 2017 12:44:44 AM UTC, original submission:

since commit b93767b54fd55112ea091f0c906c9fc7089f263f (screen: defeat a VTE/Konsole bug also for the case of --constantshow), when editing files, i see the cursor briefly flash to the bottom left corner of the screen before moving back to its current position when editing content. before the commit, it would flash to the end of the status bar and back up which was less distracting.

run:
- nano --ignorercfiles --constantshow --nohelp
- held down "j" key
- observe bottom left corner and watch cursor flash there and back

looks like we hide the cursor, move it around and update the status bar, show the cursor, and then move it back to the original place. seems like we should move the cursor and then show it ?

Mike Frysinger <vapier>
Project Member

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by egmont (Posted a comment)
  • -unavailable- added by dolorous (Posted a comment)
  • -unavailable- added by bens (Updated the item)
  • -unavailable- added by bens
  • -unavailable- added by vapier (Submitted the item)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 10 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Sun 19 Nov 2017 08:13:44 AM UTCbensOpen/ClosedOpen=>Closed
    Wed 20 Sep 2017 07:59:03 PM UTCbensStatusIn Progress=>Fixed
    Mon 18 Sep 2017 07:34:20 PM UTCbensAttached File-=>Added 0001-display-rework-the-switching-on-and-off-of-the-curso.patch, #41831
    Mon 18 Sep 2017 06:56:04 PM UTCbensAttached File-=>Added 0001-display-rework-the-switching-on-and-off-of-the-curso.patch, #41830
    Wed 13 Sep 2017 07:52:14 PM UTCbensAttached File-=>Added switch-cursor-on-AFTER-screen-has-been-updated.patch, #41799
    Sun 03 Sep 2017 08:48:02 PM UTCbensAttached File-=>Added reduce-distraction.patch, #41725
      StatusNone=>In Progress
      Assigned toNone=>bens
    Sun 03 Sep 2017 09:34:27 AM UTCbensAttached File-=>Added dont-show-the-cursor-at-all.patch, #41721
      Carbon-Copy-=>Added dolorous

    Back to the top


    Powered by Savane 3.1-cleanup1