Add a general way to request an immediate top-level callback.

This is a little like schedule_timer, in that the callback you provide
will be run from the top-level message loop of whatever application
you're in; but unlike the timer mechanism, it will happen
_immediately_.

The aim is to provide a general way to avoid re-entrance of code, in
cases where just _doing_ the thing you want done is liable to trigger
a confusing recursive call to the function in which you came to the
decision to do it; instead, you just request a top-level callback at
the message loop's earliest convenience, and do it then.


git-svn-id: svn://svn.tartarus.org/sgt/putty@10019 cda61777-01e9-0310-a592-d414129be87e
Revamp the terminal paste mechanism using toplevel callbacks.

I've removed the ad-hoc front-end bodgery in the Windows and GTK ports
to arrange for term_paste to be called at the right moments, and
instead, terminal.c itself deals with knowing when to send the next
chunk of pasted data using a combination of timers and the new
top-level callback mechanism.

As a happy side effect, it's now all in one place so I can actually
understand what it's doing! It turns out that what all that confusing
code was up to is: send a line of pasted data, and delay sending the
next line until either a CR or LF is returned from the server
(typically indicating that the pasted text has been received and
echoed) or 450ms elapse, whichever comes first.


git-svn-id: svn://svn.tartarus.org/sgt/putty@10020 cda61777-01e9-0310-a592-d414129be87e
Revamp Windows's close_session() using toplevel callbacks.

Instead of setting a must_close_session flag and having special code
in the message loop to check it, we'll schedule the call to
close_session using the new top-level callback system.


git-svn-id: svn://svn.tartarus.org/sgt/putty@10021 cda61777-01e9-0310-a592-d414129be87e
Revamp GTK's session close handling using toplevel callbacks.

Instead of having a special GTK idle function for dealing with session
closing, I now use the new top-level callback mechanism which is
slightly simpler for calling a one-off function.

Also in this commit, I've arranged for connection_fatal to queue a
call to the same session close function after displaying the message
box, with the effect that now all the same processing takes place no
matter whether the session closes cleanly or uncleanly - e.g. the SSH
specials submenu is cleaned out, as it should be.


git-svn-id: svn://svn.tartarus.org/sgt/putty@10022 cda61777-01e9-0310-a592-d414129be87e
Revamp net_pending_errors using toplevel callbacks.

Again, I've removed the special-purpose ad-hockery from the assorted
front end message loops that dealt with deferred handling of socket
errors, and instead uxnet.c and winnet.c arrange that for themselves
by calling the new general top-level callback mechanism.


git-svn-id: svn://svn.tartarus.org/sgt/putty@10023 cda61777-01e9-0310-a592-d414129be87e
Revamp Windows pending_netevent using toplevel callbacks.

This greatly simplifies the process of calling select_result() from
the top level after receiving WM_NETEVENT.


git-svn-id: svn://svn.tartarus.org/sgt/putty@10024 cda61777-01e9-0310-a592-d414129be87e
Make calling term_nopaste() a cross-platform feature.

It was one of those things that went in ages ago on Windows and never
got replicated in the Unix front end. And it needn't be: ldisc.c is a
perfect place to put it, since it knows which of the data it's sending
is based on a keystroke and which is automatically generated, and it
also has access to the terminal context. So now a keypress can
interrupt a runaway paste on all platforms.


git-svn-id: svn://svn.tartarus.org/sgt/putty@10025 cda61777-01e9-0310-a592-d414129be87e