Граф коммитов

185 Коммитов

Автор SHA1 Сообщение Дата
Simon Tatham 7d394fc9e9 Stop sending release events for mouse wheel 'buttons' in X mouse mode.
On Windows (X mouse reporting of the mouse wheel isn't currently done
by the Unix front end, though I'm shortly about to fix that too) a
mouse wheel event is translated into a virtual button, and we send
both a press and a release of that button to terminal.c, which encodes
both in X mouse reporting escape sequences and passes them on to the
server. This isn't consistent with what xterm does - scroll-wheel
events are encoded _like_ button presses, but differ semantically in
that they don't have matching releases. So we're updating to match
xterm.

[originally from svn r10138]
2014-02-16 16:40:45 +00:00
Simon Tatham 8da4fa5063 Use the new host_str* functions to improve IPv6 literal support.
I've gone through everywhere we handle host names / addresses (on
command lines, in PuTTY config, in port forwarding, in X display
names, in host key storage...) and tried to make them handle IPv6
literals sensibly, by using the host_str* functions I introduced in my
previous commit. Generally it's now OK to use a bracketed IPv6 literal
anywhere a hostname might have been valid; in a few cases where no
ambiguity exists (e.g. no :port suffix is permitted anyway)
unbracketed IPv6 literals are also acceptable.

[originally from svn r10120]
2014-01-25 15:58:54 +00:00
Simon Tatham bb78583ad2 Implement connection sharing between instances of PuTTY.
The basic strategy is described at the top of the new source file
sshshare.c. In very brief: an 'upstream' PuTTY opens a Unix-domain
socket or Windows named pipe, and listens for connections from other
PuTTYs wanting to run sessions on the same server. The protocol spoken
down that socket/pipe is essentially the bare ssh-connection protocol,
using a trivial binary packet protocol with no encryption, and the
upstream has to do some fiddly transformations that I've been
referring to as 'channel-number NAT' to avoid resource clashes between
the sessions it's managing.

This is quite different from OpenSSH's approach of using the Unix-
domain socket as a means of passing file descriptors around; the main
reason for that is that fd-passing is Unix-specific but this system
has to work on Windows too. However, there are additional advantages,
such as making it easy for each downstream PuTTY to run its own
independent set of port and X11 forwardings (though the method for
making the latter work is quite painful).

Sharing is off by default, but configuration is intended to be very
easy in the normal case - just tick one box in the SSH config panel
and everything else happens automatically.

[originally from svn r10083]
2013-11-17 14:05:41 +00:00
Simon Tatham c4833bae5a Find ToUnicodeEx() at run time, not load time.
This restores PuTTY's backward compatibility to versions of Windows
too old to have ToUnicodeEx in their system libraries, which was
accidentally broken in 0.63.

[originally from svn r10061]
2013-11-17 14:03:20 +00:00
Simon Tatham 94fd7bbf94 Replace GetQueueStatus with PeekMessage(PM_NOREMOVE).
A couple of users report that my recent reworking of the Windows
top-level message loop has led to messages occasionally being lost,
and MsgWaitForMultipleObjects blocking when it ought to have been
called with a zero timeout. I haven't been able to reproduce this
myself, but according to one reporter, PeekMessage(PM_NOREMOVE) is
effective at checking for a non-empty message queue in a way that
GetQueueStatus is not. Switch to using that instead. Thanks to Eric
Flumerfelt for debugging and testing help.

[originally from svn r10057]
2013-11-11 23:01:47 +00:00
Simon Tatham 0e233b0d87 Avoid leaving unread Windows messages in the queue.
Jochen Erwied points out that once you've used PeekMessage to remove
_one_ message from the message queue, MsgWaitForMultipleObjects will
consider the whole queue to have been 'read', or at least looked at
and deemed uninteresting, and so it will block until a further message
comes in. Hence, my change in r10040 which stops us from looping on
PeekMessage until the queue is empty has the effect of causing the
rest of the message queue not to be acted on until a new message comes
in to unblock it. Fix by checking if the queue is nonempty in advance
of calling MsgWaitForMultipleObjects, and if so, giving it a zero
timeout just as we do if there's a pending toplevel callback.

[originally from svn r10052]
[r10040 == 5c4ce2fadf]
2013-10-25 17:44:02 +00:00
Simon Tatham 5c4ce2fadf Only run one toplevel callback per event loop iteration.
This change attempts to reinstate as a universal property something
which was sporadically true of the ad-hockery that came before
toplevel callbacks: that if there's a _very long_ queue of things to
be done through the callback mechanism, the doing of them will be
interleaved with re-checks of other event sources, which might (e.g.)
cause a flag to be set which makes the next callback decide not to do
anything after all.

[originally from svn r10040]
2013-09-15 14:05:31 +00:00
Simon Tatham 4db5c2899f 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.

[originally from svn r10025]
2013-08-17 16:06:40 +00:00
Simon Tatham 9d5903b163 Revamp Windows pending_netevent using toplevel callbacks.
This greatly simplifies the process of calling select_result() from
the top level after receiving WM_NETEVENT.

[originally from svn r10024]
2013-08-17 16:06:35 +00:00
Simon Tatham d35a41f6ba 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.

[originally from svn r10023]
2013-08-17 16:06:27 +00:00
Simon Tatham 43c9748ac9 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.

[originally from svn r10021]
2013-08-17 16:06:18 +00:00
Simon Tatham 7be9af74ec 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.

[originally from svn r10020]
2013-08-17 16:06:12 +00:00
Simon Tatham 75c79e318f 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.

[originally from svn r10019]
2013-08-17 16:06:08 +00:00
Simon Tatham ba49faec3d Reinstate a piece of code accidentally removed in r9214, where Windows
PuTTY does not trim a colon suffix off the hostname if it contains
_more than one_ colon. This allows IPv6 literals to be entered.

(Really we need to do a much bigger revamp of all uses of hostnames to
arrange that square-bracketed IPv6 literals work consistently, but
this at least removes a regression over 0.62.)

[originally from svn r9983]
[r9214 == a1f3b7a358]
2013-08-04 19:32:10 +00:00
Simon Tatham 5e2c794424 Increase FONT_MAXNO from 0x2f to 0x40, to ensure the fonts[] array
includes every possible combination of the font bitfields, in
particular ATTR_OEM|ATTR_NARROW.

[originally from svn r9966]
2013-07-22 07:12:31 +00:00
Simon Tatham 81a11efdaf Correct an inequality sign causing the bounds check in Windows
palette_set() to be bogus. Fortunately, this isn't exploitable through
the terminal emulator, because the palette escape sequence parser
contains its own bounds check before even calling palette_set().

While I'm at it, fix the same goof in the OS X version! That port is
more or less abandoned, but that's no excuse for leaving obviously
wrong code lying around.

[originally from svn r9965]
2013-07-22 07:12:26 +00:00
Simon Tatham b99bec3b02 Another big batch of memory leak fixes, again mostly on error paths.
The most interesting one is printer_add_enum, which I've modified to
take a char ** rather than a char * so that it can both realloc its
input buffer _and_ return NULL to indicate error.

[originally from svn r9959]
2013-07-22 07:11:54 +00:00
Simon Tatham c46fc37ebc Switch to translating keystrokes using ToUnicodeEx rather than
ToAsciiEx, where possible.

This enables support for keys which generate Unicode characters that
aren't in the system code page, which seems to me like a perverse way
for Windows to have set up the system code page but apparently does
happen, e.g. (I'm told) U+0219 and U+021B on Romanian keyboards.

Patch mostly due to Andrei Damian-Fekete.

[originally from svn r9942]
2013-07-20 11:31:24 +00:00
Simon Tatham acf38797eb Add a nonfatal() function everywhere, to be used for reporting things
that the user really ought to know but that are not actually fatal to
continued operation of PuTTY or a single network connection.

[originally from svn r9932]
2013-07-19 17:44:28 +00:00
Simon Tatham c3df7b9b15 Patch from Hideki Eiraku to make PuTTY call GetScrollInfo, so it can
use 32-bit scrollbar position data instead of being limited to the
16-bit version that comes in scrollbar messages' wParam.

[originally from svn r9720]
2012-12-04 20:53:19 +00:00
Simon Tatham 8e56c52eaa A user points out that we should free the 'hProcess' and 'hThread'
handles returned in the PROCESS_INFORMATION structure after we call
CreateProcess.

[originally from svn r9686]
2012-10-10 18:29:16 +00:00
Simon Tatham 74902c6966 Sumudu Fernando points out that in the big r9214 destabilisation I
mistakenly rearranged the logic in an if statement in window.c, with
the effect that scroll-wheel events are no longer sent via xterm mouse
tracking. Put it back to the way it was.

[originally from svn r9679]
[r9214 == a1f3b7a358]
2012-10-02 19:31:33 +00:00
Ben Harris d5836982e2 Two related changes to timing code:
First, make absolute times unsigned.  This means that it's safe to 
depend on their overflow behaviour (which is undefined for signed 
integers).  This requires a little extra care in handling comparisons, 
but I think I've correctly adjusted them all.

Second, functions registered with schedule_timer() are guaranteed to be 
called with precisely the time that was returned by schedule_timer().  
Thus, it's only necessary to check these values for equality rather than 
doing risky range checks, so do that.

The timing code still does lots that's undefined, unnecessary, or just
wrong, but this is a good start.

[originally from svn r9667]
2012-09-18 21:42:48 +00:00
Simon Tatham bc6e0952ef Introduce a third setting for the 'bold as colour' mode, which lets
you both brighten the colour _and_ bold the font at the same time.
(Fixes 'bold-font-colour' and Debian #193352.)

[originally from svn r9559]
2012-06-09 15:09:22 +00:00
Simon Tatham d095b3c35c Fix from Robert de Bath which reorders the Windows initialisation
sequence: since init_fonts sets up ucsdata based on the available
Windows fonts, we should call it before passing ucsdata to term_init.

[originally from svn r9527]
2012-05-13 15:59:24 +00:00
Simon Tatham 16a02bb9fc Bug fix from Robert de Bath: since lpDx_maybe is always supposed to
equal either lpDx or NULL, we mustn't forget to update it when we
realloc lpDx.

[originally from svn r9526]
2012-05-13 15:59:22 +00:00
Simon Tatham 3225f3743e Patch from Robert de Bath to ifdef out the Windows-specific hack for
the offset horizontal line characters in the VT100 line-drawing set
(o,p,r,s), so that no trace of it - and hence no pointless performance
hit - is compiled into the cross-platform modules on non-Windows
platforms.

[originally from svn r9467]
2012-04-22 14:22:10 +00:00
Simon Tatham 053d2ba6d1 Patch from Yoshida Masato to fill in the missing pieces of Windows
UTF-16 support. High Unicode characters in the terminal are now
converted back into surrogates during copy and draw operations, and
the Windows drawing code takes account of that when splitting up the
UTF-16 string for display. Meanwhile, accidental uses of wchar_t have
been replaced with 32-bit integers in parts of the cross-platform code
which were expecting not to have to deal with UTF-16.

[originally from svn r9409]
2012-02-17 19:28:55 +00:00
Simon Tatham e350ca2b4e WM_SIZE/SIZE_MAXIMIZED can show up even during an interactive resize,
so we should ensure we treat it the same way as other WM_SIZEs that
show up during that time: set the width and height in conf, and set
the flag to have that width and height enacted on WM_EXITSIZEMOVE.

Fixes a bug in which dragging a PuTTY window directly from the Win7
snapped-to-half-screen position to the snapped-to-maximised state
would leave the terminal in the pre-snapped size.

[originally from svn r9404]
2012-02-05 10:08:20 +00:00
Simon Tatham 9c75fe9a3f Change the semantics of 'FontSpec' so that it's a dynamically
allocated type.

The main reason for this is to stop it from taking up a fixed large
amount of space in every 'struct value' subunion in conf.c, although
that makes little difference so far because Filename is still doing
the same thing (and is therefore next on my list). However, the
removal of its arbitrary length limit is not to be sneezed at.

[originally from svn r9314]
2011-10-01 17:38:59 +00:00
Simon Tatham 947962e0b9 Revamp of EOF handling in all network connections, pipes and other
data channels. Should comprehensively fix 'half-closed', in principle,
though it's a big and complicated change and so there's a good chance
I've made at least one mistake somewhere.

All connections should now be rigorous about propagating end-of-file
(or end-of-data-stream, or socket shutdown, or whatever) independently
in both directions, except in frontends with no mechanism for sending
explicit EOF (e.g. interactive terminal windows) or backends which are
basically always used for interactive sessions so it's unlikely that
an application would be depending on independent EOF (telnet, rlogin).

EOF should now never accidentally be sent while there's still buffered
data to go out before it. (May help fix 'portfwd-corrupt', and also I
noticed recently that the ssh main session channel can accidentally
have MSG_EOF sent before the output bufchain is clear, leading to
embarrassment when it subsequently does send the output).

[originally from svn r9279]
2011-09-13 11:44:03 +00:00
Simon Tatham ef099150a6 Fix 'Duplicate Session' on Windows, broken during the config revamp.
(In an embarrassingly silly way, too. No end of difficult stuff about
Conf serialisation done with great care and working just fine, and
then a trivial goof in using sscanf lets the whole lot down.)

[originally from svn r9237]
2011-07-20 15:55:07 +00:00
Simon Tatham c33c02fb84 Reinstate a missing invocation of the FONT_QUALITY macro which I
accidentally removed in the big config revamp.

[originally from svn r9231]
2011-07-18 18:04:39 +00:00
Jacob Nevins fadbd546fc Fix a typo in r9214 that plausibly explains a resizing weirdness I had with
today's snapshot on Windows.

[originally from svn r9230]
[r9214 == a1f3b7a358]
2011-07-17 22:35:08 +00:00
Jacob Nevins 086764f5f4 When doing manual underlining, underline the text in question rather than a box
to the right of it. Probably introduced sometime around r9063.

[originally from svn r9217]
[r9063 == 00b32eda3c]
2011-07-15 16:03:06 +00:00
Simon Tatham a1f3b7a358 Post-release destabilisation! Completely remove the struct type
'Config' in putty.h, which stores all PuTTY's settings and includes an
arbitrary length limit on every single one of those settings which is
stored in string form. In place of it is 'Conf', an opaque data type
everywhere outside the new file conf.c, which stores a list of (key,
value) pairs in which every key contains an integer identifying a
configuration setting, and for some of those integers the key also
contains extra parts (so that, for instance, CONF_environmt is a
string-to-string mapping). Everywhere that a Config was previously
used, a Conf is now; everywhere there was a Config structure copy,
conf_copy() is called; every lookup, adjustment, load and save
operation on a Config has been rewritten; and there's a mechanism for
serialising a Conf into a binary blob and back for use with Duplicate
Session.

User-visible effects of this change _should_ be minimal, though I
don't doubt I've introduced one or two bugs here and there which will
eventually be found. The _intended_ visible effects of this change are
that all arbitrary limits on configuration strings and lists (e.g.
limit on number of port forwardings) should now disappear; that list
boxes in the configuration will now be displayed in a sorted order
rather than the arbitrary order in which they were added to the list
(since the underlying data structure is now a sorted tree234 rather
than an ad-hoc comma-separated string); and one more specific change,
which is that local and dynamic port forwardings on the same port
number are now mutually exclusive in the configuration (putting 'D' in
the key rather than the value was a mistake in the first place).

One other reorganisation as a result of this is that I've moved all
the dialog.c standard handlers (dlg_stdeditbox_handler and friends)
out into config.c, because I can't really justify calling them generic
any more. When they took a pointer to an arbitrary structure type and
the offset of a field within that structure, they were independent of
whether that structure was a Config or something completely different,
but now they really do expect to talk to a Conf, which can _only_ be
used for PuTTY configuration, so I've renamed them all things like
conf_editbox_handler and moved them out of the nominally independent
dialog-box management module into the PuTTY-specific config.c.

[originally from svn r9214]
2011-07-14 18:52:21 +00:00
Simon Tatham 09080057ca Set the 'must_close_session' flag at the end of close_session(), so
that we won't keep calling close_session() again the next time we go
round the message loop. Should fix unclean-close-hang. Thanks to Simon
Coleman for debugging.

[originally from svn r9115]
2011-03-02 18:52:03 +00:00
Simon Tatham a45f984c75 Stop general_textout() from trying to slice up the input clipping
rectangle into smaller ones: it doesn't work any more, since the new
variable-pitch code can now call general_textout() with a larger
clipping rectangle than the text it's meant to be displaying. Instead,
general_textout() now uses the same semantics as the next loop up in
do_text_internal(): the first piece of text it displays uses the
opacity setting passed in, which blanks the entire clipping rectangle
if necessary, and then subsequent overlays are non-opaque. And the
same clipping rectangle is used throughout.

[originally from svn r9067]
2010-12-30 00:06:43 +00:00
Simon Tatham a418e0d2dc Rationalise the mechanism in do_text_internal for providing the 'lpDx'
array to ExtTextOut:
 - move it inside the new big loop (this should fix a potential bug
   whereby the DBCS handling altered some elements of it but the loop
   did not actually step along it)
 - initialise it more sensibly
 - rename it to lpDx rather than IpDx, since as far as I can tell the
   latter name was derived from a misreading of the former in the
   Windows API docs.

[originally from svn r9066]
2010-12-29 23:48:54 +00:00
Jacob Nevins 46355d29ae Move some not-compiled-in debug code somewhere more useful.
[originally from svn r9065]
2010-12-29 22:38:36 +00:00
Simon Tatham 3a691b5e0d Fix segfault in general_textout with variable-pitch fonts: we can't
pass null lpDx, because general_textout depends on it being filled in.
Instead we null it out in the calls to subroutines _from_
general_textout.

[originally from svn r9064]
2010-12-29 16:00:58 +00:00
Simon Tatham 00b32eda3c Support for using variable-pitch fonts for the terminal on Windows.
Done in much the same way as it is in the GTK front end: the character
cell width is determined using the font's digits (which seems to give
generally not-too-offensive spacing in most cases, at the expense of
Ms and Ws typically overhanging a bit into adjacent cells) and each
character is centred in its cell. Overhangs never leave permanent
droppings on the window, because the existing work done in r5003
handles them just fine even in this stressful scenario.

There's a hacky new checkbox in the Appearance panel to make
variable-pitch fonts appear in the font selector (they still don't by
default, because I still think it's _usually_ not What You Want); the
checkbox state is not actually stored as part of a saved session, but
it should be automatically ticked when reloading a session that's got
a variable pitch font selected.

(I'm half-expecting a potential flurry of requests for this feature in
the wake of http://xkcd.com/840/ , so I thought I'd pre-empt them :-)

[originally from svn r9063]
[r5003 == ba470dec5e]
2010-12-29 14:11:25 +00:00
Simon Tatham 6538793a72 Thou shalt not suffer a misplaced apostrophe to live.
[originally from svn r9061]
2010-12-29 11:57:04 +00:00
Simon Tatham 0adb957784 Fix resize handling when enabling and disabling full-screen mode.
I'm not sure whether I broke this in the recent revamp or whether it
was always broken, but: transitions in and out of full-screen mode
work by first maximising or restoring the window, which triggers a
WM_SIZE, whose handler then fiddles with the window style to disable
or re-enable all the furniture, which in turn triggers a recursive
WM_SIZE. The trouble is, after returning from the handler for the
inner WM_SIZE, the rest of the outer handler runs, and its client area
size is now out of date.

So I've added a flag which is set when a resize is handled 'properly',
so that after returning from the inner WM_SIZE handler the outer one
knows not to try to redo badly work that's already been done well.

[originally from svn r9056]
2010-12-27 12:58:39 +00:00
Simon Tatham 1a03fa9292 Support for Windows 7 jump lists (right-click on a program's taskbar
icon, even if the program isn't running at the time, to be presented
with an application-defined collection of helpful links). The current
jump list is updated every time a saved session is loaded, and shows
the last few launchable saved sessions (i.e. not those like Default
Settings) that were loaded. Also, if Pageant or PuTTYgen or both is in
the same directory as the PuTTY binary, the jump list will present
links to launch those too.

Based on a patch sent last year by Daniel B. Roy, though it's barely
recognisable any more...

[originally from svn r9046]
2010-12-23 17:32:28 +00:00
Simon Tatham 6cd24c839d The special treatment of Alt-resize (to cause resizing to affect the
font instead of the terminal size) should only be active in
RESIZE_EITHER mode - in RESIZE_TERM it is worse than useless.

[originally from svn r9045]
2010-12-23 17:16:19 +00:00
Simon Tatham 674f68f1ef Another fix to yesterday's window-resizing revamp: when restoring from
maximised state, we must be sure to disable the window offset used to
centre the terminal in cases where the window is non-negotiably the
wrong size (e.g. maximised). Hence we must call reset_window after our
terminal resize.

[originally from svn r9044]
2010-12-23 15:44:20 +00:00
Simon Tatham 17f6ca0360 Pay attention to the width and height provided in WM_SIZE even when
restoring a maximised window.

Failure to do this was noticeable in the following scenario (again
using Aero UI enhancements):
 1. resize window using topmost resize handle, and move pointer to top
    of screen which 'maximises' the window vertically
 2. now maximise the window properly using the maximise button in top
    right
 3. now restore. Notepad restores to its position before step 1,
    because Aero remembers that position for the purpose, but PuTTY
    thinks it knows better. Only now it doesn't any more.

[originally from svn r9041]
2010-12-22 16:14:11 +00:00
Simon Tatham 0b6407878a Reorganise handling of WM_SIZE to fix two generality problems.
Firstly, maximise and restore events were expected never to occur
during an interactive resize process (i.e. between WM_ENTERSIZEMOVE
and WM_EXITSIZEMOVE), but in fact Aero now allows this to happen if
you move the pointer to the top of the screen while dragging the
window.

Secondly, plain old WM_SIZE events were expected never to occur
_outside_ interactive resizes, but Aero permits that too (e.g.
Windows-left and Windows-right), and also third-party window
repositioning tools will send these.

[originally from svn r9040]
2010-12-22 15:49:33 +00:00
Simon Tatham 9f274bed91 Create, and use for all loads of system DLLs, a wrapper function
called load_system32_dll() which constructs a full pathname for the
DLL using GetSystemDirectory.

The only DLL load not covered by this change is the one for
gssapi32.dll, because that one's not in the system32 directory.

[originally from svn r8993]
2010-09-13 08:29:45 +00:00
Jacob Nevins fb64d89902 A comment typo fix I've had lying around for a while.
[originally from svn r8974]
2010-07-30 19:45:40 +00:00
Simon Tatham d5aa23c116 New SSH bug flag, for 'can't handle SSH2_MSG_IGNORE'. Another user
today reported an SSH2_MSG_UNIMPLEMENTED from a Cisco router which
looks as if it was triggered by SSH2_MSG_IGNORE, so I'm
experimentally putting this flag in. Currently must be manually
enabled, though if it turns out to solve the user's problem then
I'll probably add at least one version string...

[Edited commit message: actually, I also committed in error a piece
of experimental code as part of this checkin. Serve me right for not
running 'svn diff' first.]

[originally from svn r8926]
2010-04-23 18:32:15 +00:00
Simon Tatham 4d77b65677 Centralise generation of the control sequences for arrow keys into a
function in terminal.c, and replace the cloned-and-hacked handling
code in all our front ends with calls to that.

This was intended for code cleanliness, but a side effect is to make
the GTK arrow-key handling support disabling of application cursor
key mode in the Features panel. Previously that checkbox was
accidentally ignored, and nobody seems to have noticed before!

[originally from svn r8896]
2010-03-06 15:50:26 +00:00
Jacob Nevins b85038d8a9 Use DECL/GET_WINDOWS_FUNCTION in a few more places in place of ad-hoc
GetProcAddress().

[originally from svn r8739]
2009-11-08 19:22:28 +00:00
Jacob Nevins f59f13d0f6 Remove is_shift_pressed() -- it's not been used since r4906.
[originally from svn r8666]
[r4906 == 7ecf13564a]
2009-09-27 16:20:39 +00:00
Jacob Nevins 5094b58a20 If there are no saved sessions, put a grayed "(No sessions)" entry on the saved
sessions submenu of the terminal window context menu (as Pageant does), rather
than an empty menu (which often renders poorly).

[originally from svn r8648]
2009-09-13 23:29:11 +00:00
Jacob Nevins bfacfe29a5 Keep the state of the "Full Screen" menu item on the Ctrl+right-click context
menu in sync with reality and the system menu.

[originally from svn r8620]
2009-08-15 17:45:17 +00:00
Simon Tatham 9b2515f97e Don't call ReleaseCapture() on any mouse-button-up event. Instead,
only call it when the _last_ mouse button comes back up. Otherwise,
xterm mouse tracking will lose a button-up event if you press down
two buttons, move the mouse outside the window, then release them
one at a time.

[originally from svn r8425]
2009-01-21 18:47:03 +00:00
Simon Tatham 75913faf82 Weaken the assertion in general_textout(). It was failing in the
case of double-width text (ESC # 3, ESC # 4, ESC # 6), because the
string passed to it was not truncated to the same width as the
clipping rectangle. (In fact, it _can't_ reliably be, in the case
where the window width is odd.) So instead we just assert that we
managed to _at least_ fill the clipping rectangle, not that we
exactly filled it.

The problem is easily reproduced by sending ESC # 8 (fill the screen
with Es) followed by ESC # 3. It doesn't typically happen, though,
if you _manually_ fill the screen with Es, because in that case
PuTTY's terminal buffer ends up being filled with CSET_ACP | 'E' or
similar, which means that general_textout() never gets called
because one of the other branches of do_text_internal() does the
work instead. ESC # 8 will fill the terminal buffer with genuine
_Unicode_ 'E' characters, which exercises the failing code path.

[originally from svn r8403]
2009-01-09 18:55:45 +00:00
Jacob Nevins 2550cd617c Remove a couple of unused variables.
[originally from svn r8393]
2009-01-06 00:16:35 +00:00
Jacob Nevins 5611259468 r8338 broke pasting with Shift-Ins and from the context menu on Windows.
Divert these to use the request_paste() interface.

[originally from svn r8377]
[r8338 == 54835a9838]
2008-12-29 20:04:42 +00:00
Jacob Nevins 8d19864dc9 "Derek" points out that reporting of wheel event coordinates to the host on
Windows was relative to the screen origin, not the window origin. 

[originally from svn r8375]
2008-12-20 19:02:09 +00:00
Simon Tatham 54835a9838 Move the code that reads the Windows clipboard into a trivial
subthread, so that it won't deadlock if fetching the content of the
clipboard turns out to depend on a network connection forwarded
through PuTTY.

[originally from svn r8338]
2008-11-28 18:28:23 +00:00
Simon Tatham 9c6a1127b4 Some Windows keymaps, it turns out, don't translate the key
combination Ctrl + \ as the Ctrl-\ character. All of mine have, but
at least one laptop turns out not to. Do so explicitly.

[originally from svn r8182]
2008-09-14 15:11:42 +00:00
Jacob Nevins 6c14388c1d Remove port number validation from Windows PuTTY -- it could cause unnecessary
trouble with serial connections, and a port number of zero gets caught later
anyway.

[originally from svn r7634]
2007-07-01 15:41:09 +00:00
Jacob Nevins 46c00b0f38 Rationalise access to, and content of, backends[] array.
Should be no significant change in behaviour.
(Well, entering usernames containing commas on Plink's command line will be
a little harder now.)

[originally from svn r7628]
2007-06-30 21:56:44 +00:00
Jacob Nevins befd797f97 Since r7265, a user could not launch a PuTTY session to a specific host by
simply specifying a hostname on the command line -- this would bring up the
config dialog. Use a slightly more sophisticated notion of whether the user
meant to launch a session.

[originally from svn r7321]
[r7265 == 5d76e00dac]
2007-02-25 00:50:24 +00:00
Jacob Nevins c5374da822 Ctrl-Break now sends a Break signal (previously it was equivalent to Ctrl-C).
[originally from svn r7295]
[this svn revision also touched putty-wishlist]
2007-02-18 14:02:39 +00:00
Jacob Nevins 8230ce9fa0 Unbreak "Duplicate session" on Windows, in a similar way to r7291.
[originally from svn r7292]
[r7291 == 062b5ab3e4]
2007-02-17 17:44:24 +00:00
Simon Tatham 062b5ab3e4 r7265 broke the legacy `putty @sessionname' construction, which I
wouldn't care about except for the fact that it's still used to
implement the Saved Sessions menu item in PuTTY and Pageant.

[originally from svn r7291]
[r7265 == 5d76e00dac]
2007-02-16 18:44:07 +00:00
Simon Tatham 5d76e00dac Avoid launching a session from the Default Settings, even if they do
represent a launchable session, unless the user can be construed to
have really meant it. This means:
 - starting up PuTTY when the Default Settings are launchable still
   brings up the config box, and you have to hit Open to actually
   launch that session
 - double-clicking on Default Settings from the config box will load
   them but not launch them.
On the other hand:
 - explicitly loading the Default Settings on the command line using
   `-load' _does_ still launch them.

[originally from svn r7265]
2007-02-10 17:02:41 +00:00
Simon Tatham b3a5cdc5fb Kai Jourdan spotted a rather embarrassing double-free, and Minefield
confirms that it's a real problem.

[originally from svn r7168]
2007-01-26 14:06:08 +00:00
Simon Tatham 7a4ef1491e The direct link between the terminal and the back end via
term_provide_resize_fn() was not being broken when the back end was
destroyed on session termination, causing resizing an inactive PuTTY
to be a segfault hazard.

[originally from svn r7143]
2007-01-24 13:53:28 +00:00
Simon Tatham f437af50f1 Update WINVER to 0x500 to avoid build failures from Jacob's
FlashWindow changes. Also fiddle with the <multimon.h> include,
which was subtly broken in turn by that.

[originally from svn r7120]
2007-01-16 21:32:02 +00:00
Jacob Nevins 1c081c99be At least, I have the technology to fix `beepind-win2k'.
Tested on Win98, Win2K, and WinXP.

[originally from svn r7119]
[this svn revision also touched putty-wishlist]
2007-01-16 20:54:58 +00:00
Jacob Nevins f9afa5e784 According to Frank Dijcks, this cast makes OpenWatcom happier.
[originally from svn r7089]
2007-01-10 00:46:45 +00:00
Simon Tatham 42801b7e9e Get rid of all the MSVC warnings.
[originally from svn r7086]
2007-01-09 18:24:07 +00:00
Simon Tatham 57a763b0ec Reinstate RDB's pending_netevent mechanism, which was removed in
r4906 in the process of adding the new timing code. It seems to have
been what was previously preventing spew-lockup, and still seems to
prevent it now I've put it back in.

[originally from svn r7071]
[r4906 == 7ecf13564a]
[this svn revision also touched putty-wishlist]
2007-01-07 12:40:21 +00:00
Simon Tatham 1dac1bc911 Initial support for HTML Help. All the ad-hoc help-file finding code
and various calls to WinHelp() have been centralised into a new file
winhelp.c, which in turn has been modified to detect a .CHM file as
well as .HLP and select between them as appropriate. It explicitly
tries to load HHCTRL.OCX and use GetProcAddress, meaning that it
_should_ still work correctly on pre-HTML-Help platforms, falling
gracefully back to WinHelp, but although I tested this by
temporarily renaming my own HHCTRL.OCX I haven't yet been able to
test it on a real HTML-Help-free platform.

Also in this checkin: a new .but file and docs makefile changes to
make it convenient to build the sources for a .CHM. As yet, owing to
limitations of Halibut's CHM support, I'm not able to write a .CHM
directly, more's the pity.

[originally from svn r7000]
2006-12-17 11:16:07 +00:00
Simon Tatham 230d400ddc Reinstate as much of the Windows font-linking behaviour as I can
easily manage, by adopting a hybrid approach to Unicode text
display. The old approach of simply calling ExtTextOutW provided
font linking without us having to lift a finger, but didn't do the
right thing when it came to bidirectional or Arabic-shaped text.
Arabeyes' replacement exact_textout() supported the latter, but
turned out to break the former (with no warning from the Windows API
documentation, so it's not their fault).

So now I've got a second wrapper layer called general_textout(),
which splits the input string into substrings based on bidi
character class. Any character liable to cause bidi or shaping
behaviour if fed straight to ExtTextOutW is instead fed through
Arabeyes' exact_textout(), but the rest is fed straight to
ExtTextOutW as it used to be.

The effect appears to be that font linking is restored for all
characters _except_ Arabic and other bidi scripts, which means in
particular that we are no longer in a state of regression over 0.57.
(0.57 would have done font linking on Arabic as well, but would also
have misbidied it, so we've merely exchanged one failure mode for
another slightly less harmful one in that situation.)

[originally from svn r6910]
2006-11-18 15:10:48 +00:00
Simon Tatham a2338cb6f2 Fix breakage of `Restart Session' in r6802. When restarting the
session, we were clearing the new session_closed flag, but failing
to clear must_close_session; with that set, the session was being
opened but immediately re-closed.

[originally from svn r6857]
[r6802 == 0dcdb6c3c1]
2006-09-21 11:48:32 +00:00
Simon Tatham f0a9c33f25 The Windows HANDLE type, despite being a `void *', does not actually
behave like a pointer. In particular, the right thing to set a
HANDLE to to indicate that it's invalid is INVALID_HANDLE_VALUE, not
NULL. Crack down on sloppy use of NULL HANDLEs across all Windows
code.

(There is one oddity, which is that {Create,Open}FileMapping are
documented to return a NULL HANDLE instead of INVALID_HANDLE_VALUE
on failure. Shrug. If MS want to be inconsistent, I suppose I have
to live with it.)

[originally from svn r6833]
2006-08-29 18:32:44 +00:00
Simon Tatham 4c460326d9 Apparently MsgWaitForMultipleObjects doesn't always return the
values one might expect, which means that GetMessage() was
occasionally blocking the process. That appears to be the last of
the annoying data loss issues, so I think the Windows serial back
end actually looks vaguely reliable now. Phew.

[originally from svn r6830]
2006-08-28 19:09:28 +00:00
Simon Tatham 38ebd5f5ba Missed a couple of instances of cfg_launchable().
[originally from svn r6824]
2006-08-28 17:41:02 +00:00
Simon Tatham 34f747421d Support for Windows PuTTY connecting straight to a local serial port
in place of making a network connection. This has involved a couple
of minor infrastructure changes:
 - New dlg_label_change() function in the dialog.h interface, which
   alters the label on a control. Only used, at present, to switch
   the Host Name and Port boxes into Serial Line and Speed, which
   means that any platform not implementing serial connections (i.e.
   currently all but Windows) does not need to actually do anything
   in this function. Yet.
 - New small piece of infrastructure: cfg_launchable() determines
   whether a Config structure describes a session ready to be
   launched. This was previously determined by seeing if it had a
   non-empty host name, but it has to check the serial line as well
   so there's a centralised function for it. I haven't gone through
   all front ends and arranged for this function to be used
   everywhere it needs to be; so far I've only checked Windows.
 - Similarly, cfg_dest() returns the destination of a connection
   (host name or serial line) in a text format suitable for putting
   into messages such as `Unable to connect to %s'.

[originally from svn r6815]
2006-08-28 10:35:12 +00:00
Simon Tatham 0dcdb6c3c1 Start using notify_remote_exit() in the Windows front end, in place
of the previous ad-hockery which depended on the return value from
select_result() and hence which will not adapt sensibly to a world
in which the primary session is something local rather than a
network connection.

[originally from svn r6802]
2006-08-26 10:04:46 +00:00
Simon Tatham 291533d3f9 New piece of Windows infrastructure: winhandl.c takes Plink's
thread-based approach to stdin and stdout, wraps it in a halfway
sensible API, and makes it a globally available service across all
network tools.

There is no direct functionality enhancement from this checkin:
winplink.c now talks to the new API instead of doing it all
internally, but does nothing different as a result.

However, this should lay the groundwork for several diverse pieces
of work in future: pipe-based ProxyCommand on Windows, a serial port
back end, and (hopefully) a pipe-based means of communicating with
Pageant, which should have sensible blocking behaviour and hence
permit asynchronous agent requests and decrypt-on-demand.

[originally from svn r6797]
2006-08-25 22:10:16 +00:00
Jacob Nevins 7958a63147 Sprinkle some header comments in various files in an attempt to explain what
they're for.

[originally from svn r6639]
2006-04-23 18:26:03 +00:00
Owen Dunn 806c2b73ce Update size when going from maximised to full screen.
[originally from svn r6618]
2006-03-29 17:55:40 +00:00
Simon Tatham 3f6dfdaa61 David Damerell tells me I should be using Ctrl-hjklyubn rather than
Shift-hjklyubn for batch movement in NetHack, because they have
subtly different behaviour within the game and the Ctrl-moves are
more useful. Unfortunately, PuTTY's NetHack keypad mode doesn't
support Ctrl-moves. Therefore, it does now :-)

[originally from svn r6593]
2006-03-08 18:10:12 +00:00
Jacob Nevins f9c1d0acf8 Alain Guibert points out that palette changes weren't causing the space
between the text area and the window border to be refreshed.
Fixed on Windows. Gtk still has a similar problem.

[originally from svn r6583]
2006-02-25 14:13:46 +00:00
Jacob Nevins dd73d2a836 Fix `restart-reset-terminal': terminal now restored to a sensible state when
reusing a window to restart a session.

[originally from svn r6577]
[this svn revision also touched putty-wishlist]
2006-02-19 14:59:48 +00:00
Owen Dunn d526e3bb33 Preserve more attributes of text copied as RTF. Thanks to Stephen Balousek.
[originally from svn r6555]
2006-02-13 22:18:17 +00:00
Jacob Nevins ef2db06457 Oops. Since r6546, old "Special Commands" menus weren't being deleted from the
context menu, and they tended to pile up.

[originally from svn r6547]
[r6546 == 3cdf5b739f]
2006-02-10 20:57:40 +00:00
Jacob Nevins 3cdf5b739f Users of Virtual Dimension are reporting that the "Close" menu item and
button tend to get disabled on login.
After a suggestion by "Tkil", change the way we handle the specials menu
to be robust against the window menu being externally modified.

[originally from svn r6546]
[this svn revision also touched putty-wishlist]
2006-02-09 23:06:57 +00:00
Jacob Nevins 4da1f2b17e Somewhat gruesome tweak to use SetClassLongPtr where available and degrade
nicely elsewhere, which should fix `win64' _properly_.
Tested on recent-ish MinGW (with GetWindowLongPtr but not GetClassLongPtr),
and VC++ 6.0 with a recent SDK, but not with vanilla VC++.

[originally from svn r6535]
[this svn revision also touched putty-wishlist]
2006-01-27 20:49:59 +00:00
Owen Dunn b61713fb3f Don't explicitly open the logfile on startup; it'll automatically be opened
by logwrite() as necessary.  Should fix win-askappend-multi.

[originally from svn r6533]
2006-01-25 22:46:33 +00:00
Owen Dunn dd924a644e Configurable font quality on Windows. (Together with a little bit of
macro stuff to cope with the inadequacy of VC++ 6 headers.)

[originally from svn r6519]
2006-01-11 23:42:02 +00:00
Simon Tatham 0a4b6612fb A few small changes to make the PuTTY source base more usable as a
basis for other terminal-involving applications: a stub
implementation of the printing interface, an additional function in
notiming.c, and also I've renamed the front-end function beep() to
do_beep() so as not to clash with beep() in lib[n]curses.

[originally from svn r6479]
2005-12-09 20:04:19 +00:00
Jacob Nevins 8719f92c14 Revamp SSH authentication code so that user interaction is more
abstracted out; replace loops structured around a single interaction
per loop with less tortuous code (fixes: `ki-multiprompt-crash',
`ssh1-bad-passphrase-crash'; makes `ssh2-password-expiry' and
`proxy-password-prompt' easier).

The new interaction abstraction has a lot of fields that are unused in
the current code (things like window captions); this is groundwork for
`gui-auth'. However, ssh.c still writes directly to stderr; that may
want to be fixed.

In the GUI apps, user interaction is moved to terminal.c. This should
make it easier to fix things like UTF-8 username entry, although I
haven't attempted to do so. Also, control character filtering can be
tailored to be appropriate for individual front-ends; so far I don't
promise anything other than not having made it any worse.

I've tried to test this fairly exhaustively (although Mac stuff is
untested, as usual). It all seems to basically work, but I bet there
are new bugs. (One I know about is that you can no longer make the
PuTTY window go away with a ^D at the password prompt; this should be
fixed.)

[originally from svn r6437]
[this svn revision also touched putty-wishlist]
2005-10-30 20:24:09 +00:00