nano-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Nano-devel] terminal not fully restored when backgrounding/foregrou


From: David Lawrence Ramsey
Subject: Re: [Nano-devel] terminal not fully restored when backgrounding/foregrounding
Date: Mon, 21 Aug 2006 15:34:44 -0400
User-agent: Thunderbird 1.5.0.5 (X11/20060719)

David Benbennick wrote:

<snip>

> My mistake; I forgot to upgrade for a while.

No problem.  It happens.

> Clearing the screen is much better than the pre-1.3.12 behavior.
> Thanks for fixing it!

No problem here either.

> But it can still be kind of annoying.  Imagine you're using Nano to
> write code.  You suspend Nano, run the compiler, get a bunch of
> warnings, restore Nano, fix one of the warnings, re-suspend.  You
> expect to still see the compiler output, but it's gone!  I think this
> is one case where Nano can afford to be slightly incompatible with
> Pico.  Especially since not clearing the screen (if you do it right,
> i.e. leave the cursor where it was last) shouldn't cause problems to
> anyone who expects the screen to be cleared.

I wish it were that simple.  I've looked into this exhaustively, and
here's what I've found out about the different ways to handle
suspension:

Method 1: Leave curses mode when suspending.

This is what nano used to do.  It preserves the screen, but doesn't give
control over the cursor.  According to the manpage, it's supposed to
always put the cursor in the bottom left corner, but, as you've seen, it
apparently gets confused sometimes as to which line is on the bottom
left.

Method 2: Stay in curses mode when suspending, but clear the screen and
temporarily reset the terminal to its initial state, and set it back
after suspending.

This is what nano does now.  It gives control of the cursor, but doesn't
preserve the screen.

Method 3: Follow method 2, but save the screen and cursor position as
they are when we start nano, restore them when suspending, and update
them afterward.

This would be the optimum solution.  Saving the cursor position via
getyx() or the like is no problem, but saving the screen is.  (It'd have
to be done after initscr(), but before the first refresh() call, as the
latter clears the screen according to its manpage.)  ncurses has
scr_dump() and scr_restore(), but using them to save and restore the
contents of the screen from a file would cause problems on read-only
media if nano was used simply as a viewer, and slang's curses emulation
doesn't implement these functions anyway.  ncurses also has
mvwinchstr(), which could be used to save lines of the screen, but slang
doesn't implement it either.  An equivalent of mvwinchstr() could be
implemented as a loop calling mvwinch(), which slang does implement, but
there are other problems: it returns the "chtype" type in ncurses, while
slang implements it as a macro with apparently no return type, and
doesn't define a "chtype" type; and while ncurses defines all macros
needed to get characters, attributes, and colors out (A_CHARTEXT,
A_ATTRIBUTES, and A_COLOR), slang only defines A_CHARTEXT and A_COLOR. slang does define all the individual attributes correctly, but checking
for them all manually is ugly and will break if any new attributes are
added.

Getting rid of slang support would deal with this problem, because then
nano could just use the ncurses functions, and even the slang author
recommends against using its curses emulation:

http://www.jedsoft.org/pipermail/slang-users_jedsoft.org/2006/000407.html

but it's still there because nano is smaller when built against slang,
which is even more of an asset if it's nano-tiny.

Now, given all this, I do appreciate the feedback, and if you have any
ideas on how to fix this, I'd certainly be interested in hearing them.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]