bugGNU nano - Bugs: bug #45684, nano completely redraws screen...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #45684: nano completely redraws screen when editing a line

Submitter:  Wyatt Ward <wyatt8740>
Submitted:  Mon 03 Aug 2015 07:14:40 PM UTC
   
 
Severity:  4 - Important Status:  Fixed
Assigned to:  bens Open/Closed:  Closed

Jump to the original submission

Sun 06 Sep 2015 02:55:17 PM UTC, comment #17: 

I'm glad this was resolved - though the flyback transformer in the terminal died three days ago, sadly. :p

Thanks!

Wyatt Ward <wyatt8740>
Sat 05 Sep 2015 09:32:15 AM UTC, comment #16: 

Fixed in SVN, r5370.  Thanks for testing the first version of the patch.

Benno Schulenberg <bens>
Group administrator
Sun 23 Aug 2015 07:20:17 PM UTC, comment #15: 

Hello Wyatt,

Please forget all earlier patches.  The first patch will avoid forcing a redraw of the screen even when you type accented letters.

The second and third patch are meant to be used together (without the first one).  With these two applied, please try try the procedure I described, with 'src/nano --syntax=tough NEWS', to see if you can find circumstances in which the screen still gets redrawn unnecessarily.

(file #34703, file #34704, file #34705)

Benno Schulenberg <bens>
Group administrator
Sat 22 Aug 2015 10:10:30 AM UTC, comment #14: 

Hi Wyatt.  So, you're able to build from SVN.  Good!  :)

And with the patch applied, and without disabling syntax highlighting, you no longer see any redrawing of the screen when you type characters into a line?  What happens when you delete characters?  What when you split a line into two with Enter?  What when you join two lines with Backspace or Delete?  Do you see any redrawing then?  (Probably only of the two affected lines.)

(The thing is, nano still redraws the entire screen, but ncurses no longer bothers to redraw it because it "sees" that nothing has changed.  As long as a line does not contain characters other than plain ASCII, nano will not force ncurses to redraw that line.  Do you ever use a language with accented characters or another alphabet?  Spanish?  Polish?  Russian?)

I'd like you to try a different patch (if you have time for it).  Unapply the first one, and apply the attached one.  Then add the following two line at the end of your .nanorc file:

syntax "tough"
color brightred start="\"" end="\""

Then start nano with: 'src/nano --syntax=tough NEWS' and try to figure out when exactly a line gets redrawn on the screen.  When you type or delete characters into/from a line?  When you split or join a line?  When you type a double quote (")?  And another one?  Don't worry about nano sometimes 'colouring' things wrongly -- there is still some mistake in the colouring code -- just concentrate on the redrawing.  When does it happen?  And which lines are redrawn?

(If, with the first patch unapplied, always the whole screen gets redrawn, then reapply it and then see when things get redrawn.)

(Underlining...  Maybe we could add, besides 'bright', a color modifier called 'underlined'? :)

(file #34698)

Benno Schulenberg <bens>
Group administrator
Fri 21 Aug 2015 03:12:17 AM UTC, comment #13: 

Good news, benno - that patch works!

I get the emphasis (bright text) when I don't use --syntax=none, but the screen is no longer re-drawn.

Thanks a ton. Also, while it is a monochrome terminal it does have emphasis (bright text), blink, and underline support. I personally cannot stand blinking but underlining and emphasis might be useful. Just a possibility, though.

Wyatt Ward <wyatt8740>
Fri 21 Aug 2015 02:06:52 AM UTC, comment #12: 

Hi Benno. Terribly sorry. Was moving to college dorm.

I did try the latest trunk and it worked - I will try the attached patch now. Thanks.

Wyatt Ward <wyatt8740>
Mon 17 Aug 2015 08:16:32 PM UTC, comment #11: 

Hello Wyatt,

Are you able to test the patch?

Benno Schulenberg <bens>
Group administrator
Sun 09 Aug 2015 09:04:12 AM UTC, comment #10: 

With attached patch (which should apply to 2.4.2 -- no need to build from SVN), you should no longer see nano redraw the current line when you just type extra characters into it.  (Suppress the redrawing of the screen with --syntax=none.  I will try and make a patch for that later.)

(file #34612)

Benno Schulenberg <bens>
Group administrator
Thu 06 Aug 2015 08:10:36 PM UTC, comment #9: 

Thanks for the video; that shows the problem nicely.  (I'm puzzled though: when you use the low 1200 speed, it seems to redraw the screen for every character separately, but when you use the higher speed, it seems that sometimes several characters appear in a single redrawing.  Strange.)

Anyway, as it is a monochrome terminal, syntax highlighting is not of any use.  So when you're working on that terminal, you really should make sure nano isn't trying to apply any syntax to the files you're editing.  Either by aliasing nano to "nano --syntax=none", or by preventing ~/.nanorc or /etc/nanorc from including any syntax files.  That should avoid the biggest issue for you.

But it is indeed silly that nano redraws the entire screen for every character that is typed.  Because for any added or deleted character, nano could simply check whether the multiline regex matches have changed from the ones before the character was added/deleted, and only redraw the entire screen in those cases -- which should be relatively rare.

(I have little time these days, but will be looking at this.)

Benno Schulenberg <bens>
Group administrator
Tue 04 Aug 2015 10:31:25 PM UTC, comment #8: 

I should mention also that I slowed down the terminal to 1200 baud for the first portion of that video.

Wyatt Ward <wyatt8740>
Tue 04 Aug 2015 10:30:29 PM UTC, comment #7: 

forgive the horrible auto focusing of my camera. Here's the video. https://www.youtube.com/watch?v=m2C8Jj55RqY&t=2m10s

Wyatt Ward <wyatt8740>
Tue 04 Aug 2015 09:59:47 PM UTC, comment #6: 

I will check SVN. Sorry :p

I see the cursor moving - that's how I know it's redrawing.

I'm uploading a video now in case it helps. It'll be a while though.

Wyatt Ward <wyatt8740>
Tue 04 Aug 2015 09:55:36 PM UTC, comment #5: 

The lorem ipsum file was a .txt.

 GNU nano, version 2.4.2
 (C) 1999..2015 Free Software Foundation, Inc.
 Email: -email is unavailable- Web: http://www.nano-editor.org/
 Compiled options: --disable-libmagic --disable-wrapping-as-root --enable-utf8

it's debian sid's repository version.

Wyatt Ward <wyatt8740>
Tue 04 Aug 2015 08:10:44 PM UTC, comment #4: 

What version of nano are you running?  (Please paste the complete output of 'nano --version'.)  What extension did your "lorem ipsum" file have?  Because nano will pick the syntax mainly based on the ending of the filename.  If it does not recognize any ending, it will use the 'default' syntax (if your nanorc files include it), and this default syntax does not have any multiline regexes, so it should not cause the entire screen to be redrawn.

Nano redraws the entire screen because with any character that you type (or delete) you may have created or undone the start or end of a multiline regex -- so this may cause a recolouring of almost all of the text on the screen.  And thus nano has to redraw it, because only in the redrawing does it evaluate those regexes.

It should be possible to make nano more clever about this, but...  Could you try and run the latest nano from SVN, and see if it is already a bit better?  But even if not, if you can run SVN, I will have a patch or two for you to try.

(The redrawing of the current line happens always because of some undrlying bug in ncurses: nano has to call wredrawln() to ensure that characters that occupy more than one column are drawn correctly.  See bug #31743.  To speed up line redrawing, maybe it would be possible to skip that call as long as nano hasn't seen any multibyte characters.  Hmm.  At least it could skip that call when it's not using UTF-8.)

By the way, how do you notice that nano is redrawing the entire line?  Can you see that visually?  Or do you capture what is being sent over the serial line?

Benno Schulenberg <bens>
Group administrator
Tue 04 Aug 2015 04:52:31 PM UTC, comment #3: 

I noticed I forgot to read some of your questions:

It happens with any file I edit unless I use --syntax=none. It even did it on a 'lorem ipsum' file I made.

it only redraws the line I'm currently on with --syntax=none. Marking text and moving horizontally only redraws the one line. moving vertically after marking it only redraws the line the cursor is currently on. It is still redrawing the entire line though.

Wyatt Ward <wyatt8740>
Tue 04 Aug 2015 06:12:18 AM UTC, comment #2: 

Sorry, I should have mentioned how I run it.

I ran it as 'nano -w example-file'.

I just now tried --syntax=none, and it worked, I think, though it was still re-drawing the entire line unnecessarily - it no longer redraws the whole page though. It would probably be necessary to redraw the page with lines longer than 80 columns, but it redraws the whole line on shorter lines too.

Thanks for looking at it!

I might try uploading a video somewhere later.

Wyatt Ward <wyatt8740>
Mon 03 Aug 2015 08:25:31 PM UTC, comment #1: 

This is an interesting bug, and one that I would like to solve: it will probably speed up nano quite a bit on all machines.  So, first of all: thanks for posting!  (My machine is not fast, but too fast to see any redrawing.)

Second: does it happen with any kind of file that you edit?  Does it also happen when you start nano with --syntax=none?  Does it happen when you just move the cursor?  Does it happen when you set the mark and then move the cursor (horizontally, vertically)?

Benno Schulenberg <bens>
Group administrator
Mon 03 Aug 2015 07:14:40 PM UTC, original submission:  

I have an IBM 3161 ASCII display station - a circa 1985 rs232 terminal. I've been using many curses programs with success on it - including emacs, vim, and joe's pico interface (jpico). However, in nano, with every single character I type, the entire screen gets redrawn. Thus, there is approximately a half second pause between each character I type being sent to the screen when running at 19200 baud. The 3161 should support this mode of operation properly.

If it would help to resolve this bug, I have the original manual the terminal came with. It'd be difficult but I could scan any information you need from it, upon request.

I am relatively sure this is not a curses/termcap bug, because as I mentioned, jpico, emacs, and vim all work smoothly when typing a single line.

P.S. I can run any tests or record videos if you want me to.

I've attached my settings on the terminal side in case they are useful or I am doing something wrong.

Wyatt Ward <wyatt8740>

 

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

Attached Files
file #34704:  do-not-always-refresh.patch added by bens (499B - text/x-diff)
file #34571:  3161-opts.jpg added by wyatt8740 (171KiB - image/jpeg - picture of the options screens of the 3161)

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by bens (Posted a comment)
  • -email is unavailable- added by wyatt8740 (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 12 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2015-12-07 bens Open/ClosedOpen Closed
    2015-09-05 bens StatusNeed Info Fixed
    2015-08-23 bens Attached File- Added dont-redraw-when-not-wide.patch, #34703
        Attached File- Added do-not-always-refresh.patch, #34704
        Attached File- Added call-reset-multis-less-often.patch, #34705
    2015-08-22 bens Attached File- Added call-reset-multis-less-often.patch, #34698
    2015-08-17 bens StatusNone Need Info
    2015-08-09 bens Attached File- Added dont-redraw-when-just-ascii.patch, #34612
        SummaryNano completely redraws screen when editing a line on IBM 3161 terminal nano completely redraws screen when editing a line
    2015-08-03 bens Severity3 - Normal 4 - Important
        Assigned toNone bens
    2015-08-03 wyatt8740 Attached File- Added 3161-opts.jpg, #34571

    Back to the top

    Powered by Savane 3.13-3230.
    Corresponding source code