2006-04-23 18:26:03 +00:00
|
|
|
/*
|
|
|
|
* window.c - the PuTTY(tel) main program, which runs a PuTTY terminal
|
|
|
|
* emulator and backend in a window.
|
|
|
|
*/
|
|
|
|
|
1999-01-08 13:02:13 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
1999-11-22 10:07:24 +00:00
|
|
|
#include <ctype.h>
|
2000-10-09 12:53:32 +00:00
|
|
|
#include <time.h>
|
2006-08-26 10:04:46 +00:00
|
|
|
#include <limits.h>
|
2001-11-07 22:22:53 +00:00
|
|
|
#include <assert.h>
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2007-01-16 21:32:02 +00:00
|
|
|
#ifndef NO_MULTIMON
|
|
|
|
#define COMPILE_MULTIMON_STUBS
|
|
|
|
#endif
|
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
#define PUTTY_DO_GLOBALS /* actually _define_ globals */
|
1999-01-08 13:02:13 +00:00
|
|
|
#include "putty.h"
|
2002-10-22 16:11:33 +00:00
|
|
|
#include "terminal.h"
|
2000-09-27 15:21:04 +00:00
|
|
|
#include "storage.h"
|
1999-01-08 13:02:13 +00:00
|
|
|
#include "win_res.h"
|
|
|
|
|
2003-10-12 13:46:12 +00:00
|
|
|
#ifndef NO_MULTIMON
|
|
|
|
#include <multimon.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <imm.h>
|
|
|
|
#include <commctrl.h>
|
|
|
|
#include <richedit.h>
|
|
|
|
#include <mmsystem.h>
|
|
|
|
|
2004-11-02 22:30:24 +00:00
|
|
|
/* From MSDN: In the WM_SYSCOMMAND message, the four low-order bits of
|
|
|
|
* wParam are used by Windows, and should be masked off, so we shouldn't
|
|
|
|
* attempt to store information in them. Hence all these identifiers have
|
2004-11-02 23:06:20 +00:00
|
|
|
* the low 4 bits clear. Also, identifiers should < 0xF000. */
|
2004-11-02 22:30:24 +00:00
|
|
|
|
1999-10-28 16:29:06 +00:00
|
|
|
#define IDM_SHOWLOG 0x0010
|
|
|
|
#define IDM_NEWSESS 0x0020
|
|
|
|
#define IDM_DUPSESS 0x0030
|
2004-08-14 13:04:18 +00:00
|
|
|
#define IDM_RESTART 0x0040
|
|
|
|
#define IDM_RECONF 0x0050
|
|
|
|
#define IDM_CLRSB 0x0060
|
|
|
|
#define IDM_RESET 0x0070
|
2001-12-06 13:28:02 +00:00
|
|
|
#define IDM_HELP 0x0140
|
|
|
|
#define IDM_ABOUT 0x0150
|
|
|
|
#define IDM_SAVEDSESS 0x0160
|
|
|
|
#define IDM_COPYALL 0x0170
|
|
|
|
#define IDM_FULLSCREEN 0x0180
|
2003-11-19 20:48:30 +00:00
|
|
|
#define IDM_PASTE 0x0190
|
2006-02-09 23:06:57 +00:00
|
|
|
#define IDM_SPECIALSEP 0x0200
|
1999-10-28 16:29:06 +00:00
|
|
|
|
2003-04-04 20:21:05 +00:00
|
|
|
#define IDM_SPECIAL_MIN 0x0400
|
|
|
|
#define IDM_SPECIAL_MAX 0x0800
|
|
|
|
|
1999-10-28 16:29:06 +00:00
|
|
|
#define IDM_SAVED_MIN 0x1000
|
2004-11-02 23:06:20 +00:00
|
|
|
#define IDM_SAVED_MAX 0x5000
|
|
|
|
#define MENU_SAVED_STEP 16
|
2004-11-02 17:44:06 +00:00
|
|
|
/* Maximum number of sessions on saved-session submenu */
|
2004-11-02 23:06:20 +00:00
|
|
|
#define MENU_SAVED_MAX ((IDM_SAVED_MAX-IDM_SAVED_MIN) / MENU_SAVED_STEP)
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2005-08-10 18:31:24 +00:00
|
|
|
#define WM_IGNORE_CLIP (WM_APP + 2)
|
|
|
|
#define WM_FULLSCR_ON_MAX (WM_APP + 3)
|
|
|
|
#define WM_AGENT_CALLBACK (WM_APP + 4)
|
2008-11-28 18:28:23 +00:00
|
|
|
#define WM_GOT_CLIPDATA (WM_APP + 6)
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2000-10-20 18:36:15 +00:00
|
|
|
/* Needed for Chinese support and apparently not always defined. */
|
|
|
|
#ifndef VK_PROCESSKEY
|
|
|
|
#define VK_PROCESSKEY 0xE5
|
|
|
|
#endif
|
|
|
|
|
2001-12-16 12:11:56 +00:00
|
|
|
/* Mouse wheel support. */
|
2001-05-13 11:19:20 +00:00
|
|
|
#ifndef WM_MOUSEWHEEL
|
2001-12-16 12:11:56 +00:00
|
|
|
#define WM_MOUSEWHEEL 0x020A /* not defined in earlier SDKs */
|
|
|
|
#endif
|
|
|
|
#ifndef WHEEL_DELTA
|
|
|
|
#define WHEEL_DELTA 120
|
2001-05-13 11:19:20 +00:00
|
|
|
#endif
|
|
|
|
|
2003-01-25 16:22:49 +00:00
|
|
|
static Mouse_Button translate_button(Mouse_Button button);
|
2001-05-06 14:35:20 +00:00
|
|
|
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
|
|
|
|
static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
|
|
|
|
unsigned char *output);
|
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
|
|
|
static void conftopalette(void);
|
2003-09-03 20:14:38 +00:00
|
|
|
static void systopalette(void);
|
1999-01-08 13:02:13 +00:00
|
|
|
static void init_palette(void);
|
2001-09-15 15:54:24 +00:00
|
|
|
static void init_fonts(int, int);
|
2001-05-10 08:34:20 +00:00
|
|
|
static void another_font(int);
|
|
|
|
static void deinit_fonts(void);
|
2001-11-29 21:30:59 +00:00
|
|
|
static void set_input_locale(HKL);
|
2005-04-07 01:36:28 +00:00
|
|
|
static void update_savedsess_menu(void);
|
2007-01-16 20:54:58 +00:00
|
|
|
static void init_flashwindow(void);
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2001-12-07 21:21:03 +00:00
|
|
|
static int is_full_screen(void);
|
|
|
|
static void make_full_screen(void);
|
|
|
|
static void clear_full_screen(void);
|
|
|
|
static void flip_full_screen(void);
|
2008-11-28 18:28:23 +00:00
|
|
|
static int process_clipdata(HGLOBAL clipdata, int unicode);
|
2001-12-07 21:21:03 +00:00
|
|
|
|
2001-09-15 15:54:24 +00:00
|
|
|
/* Window layout information */
|
|
|
|
static void reset_window(int);
|
2001-10-17 21:21:03 +00:00
|
|
|
static int extra_width, extra_height;
|
2010-12-29 14:11:25 +00:00
|
|
|
static int font_width, font_height, font_dualwidth, font_varpitch;
|
2001-09-15 15:54:24 +00:00
|
|
|
static int offset_width, offset_height;
|
|
|
|
static int was_zoomed = 0;
|
|
|
|
static int prev_rows, prev_cols;
|
|
|
|
|
2007-01-07 12:40:21 +00:00
|
|
|
static int pending_netevent = 0;
|
|
|
|
static WPARAM pend_netevent_wParam = 0;
|
|
|
|
static LPARAM pend_netevent_lParam = 0;
|
|
|
|
static void enact_pending_netevent(void);
|
2001-05-13 14:42:17 +00:00
|
|
|
static void flash_window(int mode);
|
2001-12-20 14:18:01 +00:00
|
|
|
static void sys_cursor_update(void);
|
2002-03-13 22:15:14 +00:00
|
|
|
static int get_fullscreen_rect(RECT * ss);
|
2000-03-17 10:34:41 +00:00
|
|
|
|
2001-12-20 14:18:01 +00:00
|
|
|
static int caret_x = -1, caret_y = -1;
|
|
|
|
|
2002-10-30 18:12:46 +00:00
|
|
|
static int kbd_codepage;
|
|
|
|
|
2002-10-26 10:16:19 +00:00
|
|
|
static void *ldisc;
|
2002-10-26 10:33:59 +00:00
|
|
|
static Backend *back;
|
|
|
|
static void *backhandle;
|
2002-10-26 10:16:19 +00:00
|
|
|
|
2003-01-14 18:28:23 +00:00
|
|
|
static struct unicode_data ucsdata;
|
2006-08-26 10:04:46 +00:00
|
|
|
static int must_close_session, session_closed;
|
2005-03-21 22:20:22 +00:00
|
|
|
static int reconfiguring = FALSE;
|
2002-10-30 18:12:46 +00:00
|
|
|
|
2006-02-09 23:06:57 +00:00
|
|
|
static const struct telnet_special *specials = NULL;
|
|
|
|
static HMENU specials_menu = NULL;
|
|
|
|
static int n_specials = 0;
|
2003-04-04 20:21:05 +00:00
|
|
|
|
2008-11-28 18:28:23 +00:00
|
|
|
static wchar_t *clipboard_contents;
|
|
|
|
static size_t clipboard_length;
|
|
|
|
|
2004-11-27 13:20:21 +00:00
|
|
|
#define TIMING_TIMER_ID 1234
|
|
|
|
static long timing_next_time;
|
|
|
|
|
2003-11-19 20:48:30 +00:00
|
|
|
static struct {
|
|
|
|
HMENU menu;
|
|
|
|
} popup_menus[2];
|
|
|
|
enum { SYSMENU, CTXMENU };
|
2005-04-07 01:36:28 +00:00
|
|
|
static HMENU savedsess_menu;
|
2003-11-19 20:48:30 +00:00
|
|
|
|
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
|
|
|
Conf *conf; /* exported to windlg.c */
|
|
|
|
|
|
|
|
static void conf_cache_data(void);
|
|
|
|
int cursor_type;
|
|
|
|
int vtmode;
|
2003-01-12 15:32:31 +00:00
|
|
|
|
2005-04-07 01:36:28 +00:00
|
|
|
static struct sesslist sesslist; /* for saved-session menu */
|
2002-10-30 18:12:46 +00:00
|
|
|
|
2003-04-28 13:59:32 +00:00
|
|
|
struct agent_callback {
|
|
|
|
void (*callback)(void *, void *, int);
|
|
|
|
void *callback_ctx;
|
|
|
|
void *data;
|
|
|
|
int len;
|
|
|
|
};
|
|
|
|
|
1999-01-08 13:02:13 +00:00
|
|
|
#define FONT_NORMAL 0
|
|
|
|
#define FONT_BOLD 1
|
|
|
|
#define FONT_UNDERLINE 2
|
|
|
|
#define FONT_BOLDUND 3
|
2001-05-10 08:34:20 +00:00
|
|
|
#define FONT_WIDE 0x04
|
|
|
|
#define FONT_HIGH 0x08
|
|
|
|
#define FONT_NARROW 0x10
|
2001-09-15 15:54:24 +00:00
|
|
|
|
2001-05-10 08:34:20 +00:00
|
|
|
#define FONT_OEM 0x20
|
|
|
|
#define FONT_OEMBOLD 0x21
|
|
|
|
#define FONT_OEMUND 0x22
|
|
|
|
#define FONT_OEMBOLDUND 0x23
|
2001-09-15 15:54:24 +00:00
|
|
|
|
|
|
|
#define FONT_MAXNO 0x2F
|
2001-05-10 08:34:20 +00:00
|
|
|
#define FONT_SHIFT 5
|
|
|
|
static HFONT fonts[FONT_MAXNO];
|
2001-11-24 11:56:24 +00:00
|
|
|
static LOGFONT lfont;
|
2001-05-10 08:34:20 +00:00
|
|
|
static int fontflag[FONT_MAXNO];
|
1999-01-08 13:02:13 +00:00
|
|
|
static enum {
|
|
|
|
BOLD_COLOURS, BOLD_SHADOW, BOLD_FONT
|
|
|
|
} bold_mode;
|
|
|
|
static enum {
|
|
|
|
UND_LINE, UND_FONT
|
|
|
|
} und_mode;
|
|
|
|
static int descent;
|
|
|
|
|
2004-12-19 23:15:17 +00:00
|
|
|
#define NCFGCOLOURS 22
|
2004-11-28 15:13:34 +00:00
|
|
|
#define NEXTCOLOURS 240
|
|
|
|
#define NALLCOLOURS (NCFGCOLOURS + NEXTCOLOURS)
|
|
|
|
static COLORREF colours[NALLCOLOURS];
|
1999-01-08 13:02:13 +00:00
|
|
|
static HPALETTE pal;
|
|
|
|
static LPLOGPALETTE logpal;
|
2004-11-28 15:13:34 +00:00
|
|
|
static RGBTRIPLE defpal[NALLCOLOURS];
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2000-09-29 10:32:07 +00:00
|
|
|
static HBITMAP caretbm;
|
|
|
|
|
1999-01-08 13:02:13 +00:00
|
|
|
static int dbltime, lasttime, lastact;
|
|
|
|
static Mouse_Button lastbtn;
|
|
|
|
|
2001-05-06 14:20:41 +00:00
|
|
|
/* this allows xterm-style mouse handling. */
|
|
|
|
static int send_raw_mouse = 0;
|
|
|
|
static int wheel_accumulator = 0;
|
|
|
|
|
2005-02-15 17:05:58 +00:00
|
|
|
static int busy_status = BUSY_NOT;
|
|
|
|
|
1999-01-08 13:02:13 +00:00
|
|
|
static char *window_name, *icon_name;
|
|
|
|
|
2000-10-30 10:16:32 +00:00
|
|
|
static int compose_state = 0;
|
|
|
|
|
2001-12-15 14:30:58 +00:00
|
|
|
static UINT wm_mousewheel = WM_MOUSEWHEEL;
|
|
|
|
|
2001-01-24 14:08:20 +00:00
|
|
|
/* Dummy routine, only required in plink. */
|
2002-10-26 10:16:19 +00:00
|
|
|
void ldisc_update(void *frontend, int echo, int edit)
|
2001-05-06 14:35:20 +00:00
|
|
|
{
|
|
|
|
}
|
2000-09-22 13:10:19 +00:00
|
|
|
|
2005-04-21 13:57:08 +00:00
|
|
|
char *get_ttymode(void *frontend, const char *mode)
|
|
|
|
{
|
|
|
|
return term_get_ttymode(term, mode);
|
|
|
|
}
|
|
|
|
|
2004-08-14 13:04:18 +00:00
|
|
|
static void start_backend(void)
|
|
|
|
{
|
|
|
|
const char *error;
|
|
|
|
char msg[1024], *title;
|
|
|
|
char *realhost;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Select protocol. This is farmed out into a table in a
|
|
|
|
* separate file to enable an ssh-free variant.
|
|
|
|
*/
|
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
|
|
|
back = backend_from_proto(conf_get_int(conf, CONF_protocol));
|
2004-08-14 13:04:18 +00:00
|
|
|
if (back == NULL) {
|
|
|
|
char *str = dupprintf("%s Internal Error", appname);
|
|
|
|
MessageBox(NULL, "Unsupported protocol number found",
|
|
|
|
str, MB_OK | MB_ICONEXCLAMATION);
|
|
|
|
sfree(str);
|
|
|
|
cleanup_exit(1);
|
|
|
|
}
|
|
|
|
|
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
|
|
|
error = back->init(NULL, &backhandle, conf,
|
|
|
|
conf_get_str(conf, CONF_host),
|
|
|
|
conf_get_int(conf, CONF_port),
|
|
|
|
&realhost,
|
|
|
|
conf_get_int(conf, CONF_tcp_nodelay),
|
|
|
|
conf_get_int(conf, CONF_tcp_keepalives));
|
2004-08-14 13:04:18 +00:00
|
|
|
back->provide_logctx(backhandle, logctx);
|
|
|
|
if (error) {
|
|
|
|
char *str = dupprintf("%s Error", appname);
|
|
|
|
sprintf(msg, "Unable to open connection to\n"
|
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
|
|
|
"%.800s\n" "%s", conf_dest(conf), error);
|
2004-08-14 13:04:18 +00:00
|
|
|
MessageBox(NULL, msg, str, MB_ICONERROR | MB_OK);
|
|
|
|
sfree(str);
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
window_name = icon_name = NULL;
|
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
|
|
|
title = conf_get_str(conf, CONF_wintitle);
|
|
|
|
if (!*title) {
|
2004-08-14 13:04:18 +00:00
|
|
|
sprintf(msg, "%s - %s", realhost, appname);
|
|
|
|
title = msg;
|
|
|
|
}
|
|
|
|
sfree(realhost);
|
|
|
|
set_title(NULL, title);
|
|
|
|
set_icon(NULL, title);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Connect the terminal to the backend for resize purposes.
|
|
|
|
*/
|
|
|
|
term_provide_resize_fn(term, back->size, backhandle);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up a line discipline.
|
|
|
|
*/
|
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
|
|
|
ldisc = ldisc_create(conf, term, back, backhandle, NULL);
|
2004-08-14 13:04:18 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Destroy the Restart Session menu item. (This will return
|
|
|
|
* failure if it's already absent, as it will be the very first
|
|
|
|
* time we call this function. We ignore that, because as long
|
|
|
|
* as the menu item ends up not being there, we don't care
|
|
|
|
* whether it was us who removed it or not!)
|
|
|
|
*/
|
|
|
|
for (i = 0; i < lenof(popup_menus); i++) {
|
|
|
|
DeleteMenu(popup_menus[i].menu, IDM_RESTART, MF_BYCOMMAND);
|
|
|
|
}
|
|
|
|
|
2006-09-21 11:48:32 +00:00
|
|
|
must_close_session = FALSE;
|
2004-08-14 13:04:18 +00:00
|
|
|
session_closed = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void close_session(void)
|
|
|
|
{
|
|
|
|
char morestuff[100];
|
|
|
|
int i;
|
|
|
|
|
|
|
|
session_closed = TRUE;
|
|
|
|
sprintf(morestuff, "%.70s (inactive)", appname);
|
|
|
|
set_icon(NULL, morestuff);
|
|
|
|
set_title(NULL, morestuff);
|
|
|
|
|
|
|
|
if (ldisc) {
|
|
|
|
ldisc_free(ldisc);
|
|
|
|
ldisc = NULL;
|
|
|
|
}
|
|
|
|
if (back) {
|
|
|
|
back->free(backhandle);
|
|
|
|
backhandle = NULL;
|
|
|
|
back = NULL;
|
2007-01-24 13:53:28 +00:00
|
|
|
term_provide_resize_fn(term, NULL, NULL);
|
2004-08-14 13:04:18 +00:00
|
|
|
update_specials_menu(NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Show the Restart Session menu item. Do a precautionary
|
|
|
|
* delete first to ensure we never end up with more than one.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < lenof(popup_menus); i++) {
|
|
|
|
DeleteMenu(popup_menus[i].menu, IDM_RESTART, MF_BYCOMMAND);
|
|
|
|
InsertMenu(popup_menus[i].menu, IDM_DUPSESS, MF_BYCOMMAND | MF_ENABLED,
|
|
|
|
IDM_RESTART, "&Restart Session");
|
|
|
|
}
|
2011-03-02 18:52:03 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Unset the 'must_close_session' flag, or else we'll come
|
|
|
|
* straight back here the next time we go round the main message
|
|
|
|
* loop - which, worse still, will be immediately (without
|
|
|
|
* blocking) because we've just triggered a WM_SETTEXT by the
|
|
|
|
* window title change above.
|
|
|
|
*/
|
|
|
|
must_close_session = FALSE;
|
2004-08-14 13:04:18 +00:00
|
|
|
}
|
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
|
|
|
|
{
|
1999-01-08 13:02:13 +00:00
|
|
|
WNDCLASS wndclass;
|
|
|
|
MSG msg;
|
2010-12-23 17:32:28 +00:00
|
|
|
HRESULT hr;
|
1999-01-08 13:02:13 +00:00
|
|
|
int guess_width, guess_height;
|
|
|
|
|
2000-10-18 15:36:32 +00:00
|
|
|
hinst = inst;
|
2005-03-01 01:16:57 +00:00
|
|
|
hwnd = NULL;
|
2000-09-21 14:34:32 +00:00
|
|
|
flags = FLAG_VERBOSE | FLAG_INTERACTIVE;
|
1999-11-03 14:08:26 +00:00
|
|
|
|
2000-10-23 10:32:37 +00:00
|
|
|
sk_init();
|
1999-01-08 13:02:13 +00:00
|
|
|
|
|
|
|
InitCommonControls();
|
|
|
|
|
2000-10-12 12:56:33 +00:00
|
|
|
/* Ensure a Maximize setting in Explorer doesn't maximise the
|
|
|
|
* config box. */
|
|
|
|
defuse_showwindow();
|
|
|
|
|
2003-08-21 19:48:45 +00:00
|
|
|
if (!init_winver())
|
2001-08-04 15:15:07 +00:00
|
|
|
{
|
2003-08-21 19:48:45 +00:00
|
|
|
char *str = dupprintf("%s Fatal Error", appname);
|
|
|
|
MessageBox(NULL, "Windows refuses to report a version",
|
|
|
|
str, MB_OK | MB_ICONEXCLAMATION);
|
|
|
|
sfree(str);
|
|
|
|
return 1;
|
2001-08-04 15:15:07 +00:00
|
|
|
}
|
|
|
|
|
2001-12-15 14:30:58 +00:00
|
|
|
/*
|
|
|
|
* If we're running a version of Windows that doesn't support
|
|
|
|
* WM_MOUSEWHEEL, find out what message number we should be
|
|
|
|
* using instead.
|
|
|
|
*/
|
|
|
|
if (osVersion.dwMajorVersion < 4 ||
|
|
|
|
(osVersion.dwMajorVersion == 4 &&
|
|
|
|
osVersion.dwPlatformId != VER_PLATFORM_WIN32_NT))
|
|
|
|
wm_mousewheel = RegisterWindowMessage("MSWHEEL_ROLLMSG");
|
|
|
|
|
2006-12-17 11:16:07 +00:00
|
|
|
init_help();
|
2001-12-06 13:28:02 +00:00
|
|
|
|
2007-01-16 20:54:58 +00:00
|
|
|
init_flashwindow();
|
|
|
|
|
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
|
|
|
conf = conf_new();
|
|
|
|
|
2010-12-23 17:32:28 +00:00
|
|
|
/*
|
|
|
|
* Initialize COM.
|
|
|
|
*/
|
|
|
|
hr = CoInitialize(NULL);
|
|
|
|
if (hr != S_OK && hr != S_FALSE) {
|
|
|
|
char *str = dupprintf("%s Fatal Error", appname);
|
|
|
|
MessageBox(NULL, "Failed to initialize COM subsystem",
|
|
|
|
str, MB_OK | MB_ICONEXCLAMATION);
|
|
|
|
sfree(str);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
1999-01-08 13:02:13 +00:00
|
|
|
/*
|
|
|
|
* Process the command line.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
char *p;
|
2002-08-04 21:18:56 +00:00
|
|
|
int got_host = 0;
|
2007-02-25 00:50:24 +00:00
|
|
|
/* By default, we bring up the config dialog, rather than launching
|
|
|
|
* a session. This gets set to TRUE if something happens to change
|
|
|
|
* that (e.g., a hostname is specified on the command-line). */
|
|
|
|
int allow_launch = FALSE;
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2003-01-15 20:47:50 +00:00
|
|
|
default_protocol = be_default_protocol;
|
|
|
|
/* Find the appropriate default port. */
|
|
|
|
{
|
2007-06-30 21:56:44 +00:00
|
|
|
Backend *b = backend_from_proto(default_protocol);
|
2003-01-16 00:52:28 +00:00
|
|
|
default_port = 0; /* illegal */
|
2007-06-30 21:56:44 +00:00
|
|
|
if (b)
|
|
|
|
default_port = b->default_port;
|
2003-01-15 20:47:50 +00:00
|
|
|
}
|
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
|
|
|
conf_set_int(conf, CONF_logtype, LGTYP_NONE);
|
1999-10-27 14:28:11 +00:00
|
|
|
|
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
|
|
|
do_defaults(NULL, conf);
|
1999-01-08 13:02:13 +00:00
|
|
|
|
|
|
|
p = cmdline;
|
|
|
|
|
1999-10-27 14:28:11 +00:00
|
|
|
/*
|
2002-08-04 21:18:56 +00:00
|
|
|
* Process a couple of command-line options which are more
|
2010-12-23 17:32:28 +00:00
|
|
|
* easily dealt with before the line is broken up into words.
|
|
|
|
* These are the old-fashioned but convenient @sessionname and
|
|
|
|
* the internal-use-only &sharedmemoryhandle, neither of which
|
|
|
|
* are combined with anything else.
|
1999-10-27 14:28:11 +00:00
|
|
|
*/
|
2002-08-04 21:18:56 +00:00
|
|
|
while (*p && isspace(*p))
|
1999-10-27 14:28:11 +00:00
|
|
|
p++;
|
1999-01-08 13:02:13 +00:00
|
|
|
if (*p == '@') {
|
2010-12-23 17:32:28 +00:00
|
|
|
/*
|
|
|
|
* An initial @ means that the whole of the rest of the
|
|
|
|
* command line should be treated as the name of a saved
|
|
|
|
* session, with _no quoting or escaping_. This makes it a
|
|
|
|
* very convenient means of automated saved-session
|
|
|
|
* launching, via IDM_SAVEDSESS or Windows 7 jump lists.
|
|
|
|
*/
|
2000-10-20 13:23:24 +00:00
|
|
|
int i = strlen(p);
|
2001-05-06 14:35:20 +00:00
|
|
|
while (i > 1 && isspace(p[i - 1]))
|
2000-10-20 13:23:24 +00:00
|
|
|
i--;
|
|
|
|
p[i] = '\0';
|
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
|
|
|
do_defaults(p + 1, conf);
|
|
|
|
if (!conf_launchable(conf) && !do_config()) {
|
2003-10-12 13:46:12 +00:00
|
|
|
cleanup_exit(0);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
2007-02-25 00:50:24 +00:00
|
|
|
allow_launch = TRUE; /* allow it to be launched directly */
|
1999-01-08 13:02:13 +00:00
|
|
|
} else if (*p == '&') {
|
|
|
|
/*
|
|
|
|
* An initial & means we've been given a command line
|
|
|
|
* containing the hex value of a HANDLE for a file
|
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
|
|
|
* mapping object, which we must then interpret as a
|
|
|
|
* serialised Conf.
|
1999-01-08 13:02:13 +00:00
|
|
|
*/
|
|
|
|
HANDLE filemap;
|
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
|
|
|
void *cp;
|
|
|
|
unsigned cpsize;
|
2011-07-20 15:55:07 +00:00
|
|
|
if (sscanf(p + 1, "%p:%u", &filemap, &cpsize) == 2 &&
|
1999-01-08 13:02:13 +00:00
|
|
|
(cp = MapViewOfFile(filemap, FILE_MAP_READ,
|
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
|
|
|
0, 0, cpsize)) != NULL) {
|
|
|
|
conf_deserialise(conf, cp, cpsize);
|
1999-01-08 13:02:13 +00:00
|
|
|
UnmapViewOfFile(cp);
|
|
|
|
CloseHandle(filemap);
|
|
|
|
} else if (!do_config()) {
|
2003-10-12 13:46:12 +00:00
|
|
|
cleanup_exit(0);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
2007-02-25 00:50:24 +00:00
|
|
|
allow_launch = TRUE;
|
2002-08-04 21:18:56 +00:00
|
|
|
} else {
|
2001-05-06 14:35:20 +00:00
|
|
|
/*
|
2002-08-04 21:18:56 +00:00
|
|
|
* Otherwise, break up the command line and deal with
|
|
|
|
* it sensibly.
|
2001-05-06 14:35:20 +00:00
|
|
|
*/
|
2002-08-04 21:18:56 +00:00
|
|
|
int argc, i;
|
|
|
|
char **argv;
|
|
|
|
|
2002-08-06 17:57:37 +00:00
|
|
|
split_into_argv(cmdline, &argc, &argv, NULL);
|
2002-08-04 21:18:56 +00:00
|
|
|
|
|
|
|
for (i = 0; i < argc; i++) {
|
|
|
|
char *p = argv[i];
|
|
|
|
int ret;
|
|
|
|
|
2003-01-12 14:17:03 +00:00
|
|
|
ret = cmdline_process_param(p, i+1<argc?argv[i+1]:NULL,
|
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
|
|
|
1, conf);
|
2002-08-04 21:18:56 +00:00
|
|
|
if (ret == -2) {
|
|
|
|
cmdline_error("option \"%s\" requires an argument", p);
|
|
|
|
} else if (ret == 2) {
|
|
|
|
i++; /* skip next argument */
|
|
|
|
} else if (ret == 1) {
|
|
|
|
continue; /* nothing further needs doing */
|
2005-03-01 21:34:21 +00:00
|
|
|
} else if (!strcmp(p, "-cleanup") ||
|
|
|
|
!strcmp(p, "-cleanup-during-uninstall")) {
|
2002-08-04 21:18:56 +00:00
|
|
|
/*
|
|
|
|
* `putty -cleanup'. Remove all registry
|
|
|
|
* entries associated with PuTTY, and also find
|
|
|
|
* and delete the random seed file.
|
|
|
|
*/
|
2003-04-06 14:11:33 +00:00
|
|
|
char *s1, *s2;
|
2005-03-01 21:34:21 +00:00
|
|
|
/* Are we being invoked from an uninstaller? */
|
|
|
|
if (!strcmp(p, "-cleanup-during-uninstall")) {
|
|
|
|
s1 = dupprintf("Remove saved sessions and random seed file?\n"
|
|
|
|
"\n"
|
|
|
|
"If you hit Yes, ALL Registry entries associated\n"
|
|
|
|
"with %s will be removed, as well as the\n"
|
|
|
|
"random seed file. THIS PROCESS WILL\n"
|
|
|
|
"DESTROY YOUR SAVED SESSIONS.\n"
|
|
|
|
"(This only affects the currently logged-in user.)\n"
|
|
|
|
"\n"
|
|
|
|
"If you hit No, uninstallation will proceed, but\n"
|
|
|
|
"saved sessions etc will be left on the machine.",
|
|
|
|
appname);
|
|
|
|
s2 = dupprintf("%s Uninstallation", appname);
|
|
|
|
} else {
|
|
|
|
s1 = dupprintf("This procedure will remove ALL Registry entries\n"
|
|
|
|
"associated with %s, and will also remove\n"
|
|
|
|
"the random seed file. (This only affects the\n"
|
|
|
|
"currently logged-in user.)\n"
|
|
|
|
"\n"
|
|
|
|
"THIS PROCESS WILL DESTROY YOUR SAVED SESSIONS.\n"
|
|
|
|
"Are you really sure you want to continue?",
|
|
|
|
appname);
|
|
|
|
s2 = dupprintf("%s Warning", appname);
|
|
|
|
}
|
|
|
|
if (message_box(s1, s2,
|
|
|
|
MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2,
|
2005-03-01 01:16:57 +00:00
|
|
|
HELPCTXID(option_cleanup)) == IDYES) {
|
2002-08-04 21:18:56 +00:00
|
|
|
cleanup_all();
|
|
|
|
}
|
2003-04-06 14:11:33 +00:00
|
|
|
sfree(s1);
|
|
|
|
sfree(s2);
|
2002-08-04 21:18:56 +00:00
|
|
|
exit(0);
|
2005-03-19 02:26:58 +00:00
|
|
|
} else if (!strcmp(p, "-pgpfp")) {
|
|
|
|
pgp_fingerprints();
|
|
|
|
exit(1);
|
2002-08-04 21:18:56 +00:00
|
|
|
} else if (*p != '-') {
|
|
|
|
char *q = p;
|
|
|
|
if (got_host) {
|
|
|
|
/*
|
|
|
|
* If we already have a host name, treat
|
|
|
|
* this argument as a port number. NB we
|
|
|
|
* have to treat this as a saved -P
|
|
|
|
* argument, so that it will be deferred
|
|
|
|
* until it's a good moment to run it.
|
|
|
|
*/
|
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
|
|
|
int ret = cmdline_process_param("-P", p, 1, conf);
|
2002-08-04 21:18:56 +00:00
|
|
|
assert(ret == 2);
|
|
|
|
} else if (!strncmp(q, "telnet:", 7)) {
|
|
|
|
/*
|
|
|
|
* If the hostname starts with "telnet:",
|
|
|
|
* set the protocol to Telnet and process
|
|
|
|
* the string as a Telnet URL.
|
|
|
|
*/
|
|
|
|
char c;
|
|
|
|
|
|
|
|
q += 7;
|
|
|
|
if (q[0] == '/' && q[1] == '/')
|
|
|
|
q += 2;
|
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
|
|
|
conf_set_int(conf, CONF_protocol, PROT_TELNET);
|
2002-08-04 21:18:56 +00:00
|
|
|
p = q;
|
|
|
|
while (*p && *p != ':' && *p != '/')
|
|
|
|
p++;
|
|
|
|
c = *p;
|
|
|
|
if (*p)
|
|
|
|
*p++ = '\0';
|
|
|
|
if (c == ':')
|
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
|
|
|
conf_set_int(conf, CONF_port, atoi(p));
|
2002-08-04 21:18:56 +00:00
|
|
|
else
|
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
|
|
|
conf_set_int(conf, CONF_port, -1);
|
|
|
|
conf_set_str(conf, CONF_host, q);
|
2002-08-04 21:18:56 +00:00
|
|
|
got_host = 1;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Otherwise, treat this argument as a host
|
|
|
|
* name.
|
|
|
|
*/
|
|
|
|
while (*p && !isspace(*p))
|
|
|
|
p++;
|
|
|
|
if (*p)
|
|
|
|
*p++ = '\0';
|
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
|
|
|
conf_set_str(conf, CONF_host, q);
|
2002-08-04 21:18:56 +00:00
|
|
|
got_host = 1;
|
|
|
|
}
|
2002-11-20 20:09:02 +00:00
|
|
|
} else {
|
|
|
|
cmdline_error("unknown option \"%s\"", p);
|
2002-08-04 21:18:56 +00:00
|
|
|
}
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
}
|
2000-09-25 09:27:26 +00:00
|
|
|
|
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
|
|
|
cmdline_run_saved(conf);
|
2002-08-04 21:18:56 +00:00
|
|
|
|
2007-02-25 00:50:24 +00:00
|
|
|
if (loaded_session || got_host)
|
|
|
|
allow_launch = TRUE;
|
|
|
|
|
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
|
|
|
if ((!allow_launch || !conf_launchable(conf)) && !do_config()) {
|
2003-10-12 13:46:12 +00:00
|
|
|
cleanup_exit(0);
|
2002-08-04 21:18:56 +00:00
|
|
|
}
|
|
|
|
|
2001-05-13 13:23:12 +00:00
|
|
|
/*
|
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
|
|
|
* Muck about with the hostname in various ways.
|
2001-05-13 13:23:12 +00:00
|
|
|
*/
|
|
|
|
{
|
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
|
|
|
char *hostbuf = dupstr(conf_get_str(conf, CONF_host));
|
|
|
|
char *host = hostbuf;
|
|
|
|
char *p, *q;
|
2001-05-13 13:23:12 +00:00
|
|
|
|
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
|
|
|
/*
|
|
|
|
* Trim leading whitespace.
|
|
|
|
*/
|
|
|
|
host += strspn(host, " \t");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* See if host is of the form user@host, and separate
|
|
|
|
* out the username if so.
|
|
|
|
*/
|
|
|
|
if (host[0] != '\0') {
|
|
|
|
char *atsign = strrchr(host, '@');
|
|
|
|
if (atsign) {
|
|
|
|
*atsign = '\0';
|
|
|
|
conf_set_str(conf, CONF_username, host);
|
|
|
|
host = atsign + 1;
|
2000-09-25 09:27:26 +00:00
|
|
|
}
|
|
|
|
}
|
2001-05-06 15:09:32 +00:00
|
|
|
|
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
|
|
|
/*
|
|
|
|
* Trim off a colon suffix if it's there.
|
|
|
|
*/
|
|
|
|
host[strcspn(host, ":")] = '\0';
|
2004-12-30 16:45:11 +00:00
|
|
|
|
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
|
|
|
/*
|
|
|
|
* Remove any remaining whitespace.
|
|
|
|
*/
|
|
|
|
p = hostbuf;
|
|
|
|
q = host;
|
|
|
|
while (*q) {
|
|
|
|
if (*q != ' ' && *q != '\t')
|
|
|
|
*p++ = *q;
|
|
|
|
q++;
|
2004-12-30 16:45:11 +00:00
|
|
|
}
|
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
|
|
|
*p = '\0';
|
2002-10-16 11:35:13 +00:00
|
|
|
|
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
|
|
|
conf_set_str(conf, CONF_host, hostbuf);
|
|
|
|
sfree(hostbuf);
|
2002-10-16 11:35:13 +00:00
|
|
|
}
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!prev) {
|
2001-05-06 14:35:20 +00:00
|
|
|
wndclass.style = 0;
|
|
|
|
wndclass.lpfnWndProc = WndProc;
|
|
|
|
wndclass.cbClsExtra = 0;
|
|
|
|
wndclass.cbWndExtra = 0;
|
|
|
|
wndclass.hInstance = inst;
|
|
|
|
wndclass.hIcon = LoadIcon(inst, MAKEINTRESOURCE(IDI_MAINICON));
|
|
|
|
wndclass.hCursor = LoadCursor(NULL, IDC_IBEAM);
|
2001-09-15 15:54:24 +00:00
|
|
|
wndclass.hbrBackground = NULL;
|
2001-05-06 14:35:20 +00:00
|
|
|
wndclass.lpszMenuName = NULL;
|
1999-01-08 13:02:13 +00:00
|
|
|
wndclass.lpszClassName = appname;
|
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
RegisterClass(&wndclass);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
2003-01-14 18:28:23 +00:00
|
|
|
memset(&ucsdata, 0, sizeof(ucsdata));
|
|
|
|
|
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
|
|
|
conf_cache_data();
|
|
|
|
|
|
|
|
conftopalette();
|
1999-01-08 13:02:13 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Guess some defaults for the window size. This all gets
|
|
|
|
* updated later, so we don't really care too much. However, we
|
|
|
|
* do want the font width/height guesses to correspond to a
|
|
|
|
* large font rather than a small one...
|
|
|
|
*/
|
2001-05-06 14:35:20 +00:00
|
|
|
|
1999-01-08 13:02:13 +00:00
|
|
|
font_width = 10;
|
|
|
|
font_height = 20;
|
|
|
|
extra_width = 25;
|
|
|
|
extra_height = 28;
|
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
|
|
|
guess_width = extra_width + font_width * conf_get_int(conf, CONF_width);
|
|
|
|
guess_height = extra_height + font_height*conf_get_int(conf, CONF_height);
|
1999-01-08 13:02:13 +00:00
|
|
|
{
|
|
|
|
RECT r;
|
2009-09-13 23:29:11 +00:00
|
|
|
get_fullscreen_rect(&r);
|
1999-01-08 13:02:13 +00:00
|
|
|
if (guess_width > r.right - r.left)
|
|
|
|
guess_width = r.right - r.left;
|
|
|
|
if (guess_height > r.bottom - r.top)
|
|
|
|
guess_height = r.bottom - r.top;
|
|
|
|
}
|
|
|
|
|
2000-07-26 12:13:51 +00:00
|
|
|
{
|
2001-05-06 14:35:20 +00:00
|
|
|
int winmode = WS_OVERLAPPEDWINDOW | WS_VSCROLL;
|
|
|
|
int exwinmode = 0;
|
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
|
|
|
if (!conf_get_int(conf, CONF_scrollbar))
|
2001-05-06 14:35:20 +00:00
|
|
|
winmode &= ~(WS_VSCROLL);
|
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
|
|
|
if (conf_get_int(conf, CONF_resize_action) == RESIZE_DISABLED)
|
2001-05-06 14:35:20 +00:00
|
|
|
winmode &= ~(WS_THICKFRAME | WS_MAXIMIZEBOX);
|
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
|
|
|
if (conf_get_int(conf, CONF_alwaysontop))
|
2001-05-06 14:35:20 +00:00
|
|
|
exwinmode |= WS_EX_TOPMOST;
|
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
|
|
|
if (conf_get_int(conf, CONF_sunken_edge))
|
2001-05-06 14:35:20 +00:00
|
|
|
exwinmode |= WS_EX_CLIENTEDGE;
|
|
|
|
hwnd = CreateWindowEx(exwinmode, appname, appname,
|
|
|
|
winmode, CW_USEDEFAULT, CW_USEDEFAULT,
|
|
|
|
guess_width, guess_height,
|
|
|
|
NULL, NULL, inst, NULL);
|
|
|
|
}
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2004-11-27 19:41:24 +00:00
|
|
|
/*
|
|
|
|
* Initialise the terminal. (We have to do this _after_
|
|
|
|
* creating the window, since the terminal is the first thing
|
|
|
|
* which will call schedule_timer(), which will in turn call
|
2004-11-29 16:58:02 +00:00
|
|
|
* timer_change_notify() which will expect hwnd to exist.)
|
2004-11-27 19:41:24 +00:00
|
|
|
*/
|
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
|
|
|
term = term_init(conf, &ucsdata, NULL);
|
|
|
|
logctx = log_init(NULL, conf);
|
2004-11-27 19:41:24 +00:00
|
|
|
term_provide_logctx(term, logctx);
|
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
|
|
|
term_size(term, conf_get_int(conf, CONF_height),
|
|
|
|
conf_get_int(conf, CONF_width),
|
|
|
|
conf_get_int(conf, CONF_savelines));
|
2004-11-27 19:41:24 +00:00
|
|
|
|
1999-01-08 13:02:13 +00:00
|
|
|
/*
|
|
|
|
* Initialise the fonts, simultaneously correcting the guesses
|
|
|
|
* for font_{width,height}.
|
|
|
|
*/
|
2001-09-15 15:54:24 +00:00
|
|
|
init_fonts(0,0);
|
1999-01-08 13:02:13 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Correct the guesses for extra_{width,height}.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
RECT cr, wr;
|
2001-05-06 14:35:20 +00:00
|
|
|
GetWindowRect(hwnd, &wr);
|
|
|
|
GetClientRect(hwnd, &cr);
|
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
|
|
|
offset_width = offset_height = conf_get_int(conf, CONF_window_border);
|
2001-09-15 15:54:24 +00:00
|
|
|
extra_width = wr.right - wr.left - cr.right + cr.left + offset_width*2;
|
|
|
|
extra_height = wr.bottom - wr.top - cr.bottom + cr.top +offset_height*2;
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Resize the window, now we know what size we _really_ want it
|
|
|
|
* to be.
|
|
|
|
*/
|
2002-10-22 16:11:33 +00:00
|
|
|
guess_width = extra_width + font_width * term->cols;
|
|
|
|
guess_height = extra_height + font_height * term->rows;
|
2001-05-06 14:35:20 +00:00
|
|
|
SetWindowPos(hwnd, NULL, 0, 0, guess_width, guess_height,
|
|
|
|
SWP_NOMOVE | SWP_NOREDRAW | SWP_NOZORDER);
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2000-09-29 10:32:07 +00:00
|
|
|
/*
|
|
|
|
* Set up a caret bitmap, with no content.
|
|
|
|
*/
|
|
|
|
{
|
2001-05-06 14:35:20 +00:00
|
|
|
char *bits;
|
|
|
|
int size = (font_width + 15) / 16 * 2 * font_height;
|
2003-03-29 16:14:26 +00:00
|
|
|
bits = snewn(size, char);
|
2001-05-06 14:35:20 +00:00
|
|
|
memset(bits, 0, size);
|
|
|
|
caretbm = CreateBitmap(font_width, font_height, 1, 1, bits);
|
|
|
|
sfree(bits);
|
2000-09-29 10:32:07 +00:00
|
|
|
}
|
2001-01-07 16:35:44 +00:00
|
|
|
CreateCaret(hwnd, caretbm, font_width, font_height);
|
2000-09-29 10:32:07 +00:00
|
|
|
|
1999-01-08 13:02:13 +00:00
|
|
|
/*
|
|
|
|
* Initialise the scroll bar.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
SCROLLINFO si;
|
|
|
|
|
|
|
|
si.cbSize = sizeof(si);
|
2000-07-26 12:13:51 +00:00
|
|
|
si.fMask = SIF_ALL | SIF_DISABLENOSCROLL;
|
1999-01-08 13:02:13 +00:00
|
|
|
si.nMin = 0;
|
2002-10-22 16:11:33 +00:00
|
|
|
si.nMax = term->rows - 1;
|
|
|
|
si.nPage = term->rows;
|
1999-01-08 13:02:13 +00:00
|
|
|
si.nPos = 0;
|
2001-05-06 14:35:20 +00:00
|
|
|
SetScrollInfo(hwnd, SB_VERT, &si, FALSE);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Prepare the mouse handler.
|
|
|
|
*/
|
|
|
|
lastact = MA_NOTHING;
|
2001-05-06 14:20:41 +00:00
|
|
|
lastbtn = MBT_NOTHING;
|
1999-01-08 13:02:13 +00:00
|
|
|
dbltime = GetDoubleClickTime();
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up the session-control options on the system menu.
|
|
|
|
*/
|
|
|
|
{
|
2005-04-07 01:36:28 +00:00
|
|
|
HMENU m;
|
|
|
|
int j;
|
2003-04-06 14:11:33 +00:00
|
|
|
char *str;
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2003-11-19 20:48:30 +00:00
|
|
|
popup_menus[SYSMENU].menu = GetSystemMenu(hwnd, FALSE);
|
|
|
|
popup_menus[CTXMENU].menu = CreatePopupMenu();
|
|
|
|
AppendMenu(popup_menus[CTXMENU].menu, MF_ENABLED, IDM_PASTE, "&Paste");
|
|
|
|
|
2005-04-07 01:36:28 +00:00
|
|
|
savedsess_menu = CreateMenu();
|
2002-10-30 18:12:46 +00:00
|
|
|
get_sesslist(&sesslist, TRUE);
|
2005-04-07 01:36:28 +00:00
|
|
|
update_savedsess_menu();
|
2003-11-19 20:48:30 +00:00
|
|
|
|
|
|
|
for (j = 0; j < lenof(popup_menus); j++) {
|
|
|
|
m = popup_menus[j].menu;
|
|
|
|
|
|
|
|
AppendMenu(m, MF_SEPARATOR, 0, 0);
|
|
|
|
AppendMenu(m, MF_ENABLED, IDM_SHOWLOG, "&Event Log");
|
|
|
|
AppendMenu(m, MF_SEPARATOR, 0, 0);
|
|
|
|
AppendMenu(m, MF_ENABLED, IDM_NEWSESS, "Ne&w Session...");
|
|
|
|
AppendMenu(m, MF_ENABLED, IDM_DUPSESS, "&Duplicate Session");
|
2005-04-07 01:36:28 +00:00
|
|
|
AppendMenu(m, MF_POPUP | MF_ENABLED, (UINT) savedsess_menu,
|
|
|
|
"Sa&ved Sessions");
|
2003-11-19 20:48:30 +00:00
|
|
|
AppendMenu(m, MF_ENABLED, IDM_RECONF, "Chan&ge Settings...");
|
|
|
|
AppendMenu(m, MF_SEPARATOR, 0, 0);
|
|
|
|
AppendMenu(m, MF_ENABLED, IDM_COPYALL, "C&opy All to Clipboard");
|
|
|
|
AppendMenu(m, MF_ENABLED, IDM_CLRSB, "C&lear Scrollback");
|
|
|
|
AppendMenu(m, MF_ENABLED, IDM_RESET, "Rese&t Terminal");
|
|
|
|
AppendMenu(m, MF_SEPARATOR, 0, 0);
|
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
|
|
|
AppendMenu(m, (conf_get_int(conf, CONF_resize_action)
|
|
|
|
== RESIZE_DISABLED) ? MF_GRAYED : MF_ENABLED,
|
|
|
|
IDM_FULLSCREEN, "&Full Screen");
|
2003-11-19 20:48:30 +00:00
|
|
|
AppendMenu(m, MF_SEPARATOR, 0, 0);
|
2006-12-17 11:16:07 +00:00
|
|
|
if (has_help())
|
2003-11-19 20:48:30 +00:00
|
|
|
AppendMenu(m, MF_ENABLED, IDM_HELP, "&Help");
|
|
|
|
str = dupprintf("&About %s", appname);
|
|
|
|
AppendMenu(m, MF_ENABLED, IDM_ABOUT, str);
|
|
|
|
sfree(str);
|
|
|
|
}
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
2004-10-17 14:44:27 +00:00
|
|
|
start_backend();
|
2003-04-04 20:21:05 +00:00
|
|
|
|
2001-11-29 21:30:59 +00:00
|
|
|
/*
|
|
|
|
* Set up the initial input locale.
|
|
|
|
*/
|
|
|
|
set_input_locale(GetKeyboardLayout(0));
|
|
|
|
|
2001-01-07 18:24:59 +00:00
|
|
|
/*
|
2001-12-14 14:57:50 +00:00
|
|
|
* Finally show the window!
|
2001-01-07 18:24:59 +00:00
|
|
|
*/
|
2001-12-14 14:57:50 +00:00
|
|
|
ShowWindow(hwnd, show);
|
|
|
|
SetForegroundWindow(hwnd);
|
2001-01-07 18:24:59 +00:00
|
|
|
|
1999-01-08 13:02:13 +00:00
|
|
|
/*
|
|
|
|
* Set the palette up.
|
|
|
|
*/
|
|
|
|
pal = NULL;
|
|
|
|
logpal = NULL;
|
|
|
|
init_palette();
|
|
|
|
|
2004-11-27 19:34:45 +00:00
|
|
|
term_set_focus(term, GetForegroundWindow() == hwnd);
|
2001-05-06 14:35:20 +00:00
|
|
|
UpdateWindow(hwnd);
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2006-08-25 22:10:16 +00:00
|
|
|
while (1) {
|
|
|
|
HANDLE *handles;
|
|
|
|
int nhandles, n;
|
|
|
|
|
|
|
|
handles = handle_get_events(&nhandles);
|
|
|
|
|
|
|
|
n = MsgWaitForMultipleObjects(nhandles, handles, FALSE, INFINITE,
|
|
|
|
QS_ALLINPUT);
|
|
|
|
|
|
|
|
if ((unsigned)(n - WAIT_OBJECT_0) < (unsigned)nhandles) {
|
|
|
|
handle_got_event(handles[n - WAIT_OBJECT_0]);
|
|
|
|
sfree(handles);
|
2006-08-26 10:04:46 +00:00
|
|
|
if (must_close_session)
|
|
|
|
close_session();
|
2007-01-26 14:06:08 +00:00
|
|
|
} else
|
|
|
|
sfree(handles);
|
2006-08-25 22:10:16 +00:00
|
|
|
|
2006-08-28 19:09:28 +00:00
|
|
|
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
|
2006-08-25 22:10:16 +00:00
|
|
|
if (msg.message == WM_QUIT)
|
|
|
|
goto finished; /* two-level break */
|
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
if (!(IsWindow(logbox) && IsDialogMessage(logbox, &msg)))
|
|
|
|
DispatchMessage(&msg);
|
2000-07-26 12:13:51 +00:00
|
|
|
/* Send the paste buffer if there's anything to send */
|
2002-10-22 16:11:33 +00:00
|
|
|
term_paste(term);
|
2000-03-17 10:34:41 +00:00
|
|
|
/* If there's nothing new in the queue then we can do everything
|
|
|
|
* we've delayed, reading the socket, writing, and repainting
|
|
|
|
* the window.
|
|
|
|
*/
|
2006-08-26 10:04:46 +00:00
|
|
|
if (must_close_session)
|
|
|
|
close_session();
|
2006-08-28 19:09:28 +00:00
|
|
|
}
|
2001-11-25 18:39:57 +00:00
|
|
|
|
2006-08-25 22:10:16 +00:00
|
|
|
/* The messages seem unreliable; especially if we're being tricky */
|
|
|
|
term_set_focus(term, GetForegroundWindow() == hwnd);
|
2001-05-06 14:35:20 +00:00
|
|
|
|
2007-01-07 12:40:21 +00:00
|
|
|
if (pending_netevent)
|
|
|
|
enact_pending_netevent();
|
|
|
|
|
2006-08-25 22:10:16 +00:00
|
|
|
net_pending_errors();
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
2006-08-25 22:10:16 +00:00
|
|
|
finished:
|
2002-03-09 11:47:39 +00:00
|
|
|
cleanup_exit(msg.wParam); /* this doesn't return... */
|
|
|
|
return msg.wParam; /* ... but optimiser doesn't know */
|
2002-03-06 20:13:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clean up and exit.
|
|
|
|
*/
|
|
|
|
void cleanup_exit(int code)
|
|
|
|
{
|
1999-01-08 13:02:13 +00:00
|
|
|
/*
|
|
|
|
* Clean up.
|
|
|
|
*/
|
2001-05-10 08:34:20 +00:00
|
|
|
deinit_fonts();
|
1999-01-08 13:02:13 +00:00
|
|
|
sfree(logpal);
|
|
|
|
if (pal)
|
|
|
|
DeleteObject(pal);
|
2002-03-06 20:13:22 +00:00
|
|
|
sk_cleanup();
|
1999-01-08 13:02:13 +00:00
|
|
|
|
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
|
|
|
if (conf_get_int(conf, CONF_protocol) == PROT_SSH) {
|
1999-01-08 13:02:13 +00:00
|
|
|
random_save_seed();
|
2000-03-24 09:45:49 +00:00
|
|
|
#ifdef MSCRYPTOAPI
|
|
|
|
crypto_wrapup();
|
|
|
|
#endif
|
|
|
|
}
|
2006-12-17 11:16:07 +00:00
|
|
|
shutdown_help();
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2010-12-23 17:32:28 +00:00
|
|
|
/* Clean up COM. */
|
|
|
|
CoUninitialize();
|
|
|
|
|
2002-03-06 20:13:22 +00:00
|
|
|
exit(code);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
2000-10-23 10:32:37 +00:00
|
|
|
/*
|
|
|
|
* Set up, or shut down, an AsyncSelect. Called from winnet.c.
|
|
|
|
*/
|
2001-05-06 14:35:20 +00:00
|
|
|
char *do_select(SOCKET skt, int startup)
|
|
|
|
{
|
2000-10-23 10:32:37 +00:00
|
|
|
int msg, events;
|
|
|
|
if (startup) {
|
|
|
|
msg = WM_NETEVENT;
|
2001-09-07 22:39:01 +00:00
|
|
|
events = (FD_CONNECT | FD_READ | FD_WRITE |
|
|
|
|
FD_OOB | FD_CLOSE | FD_ACCEPT);
|
2000-10-23 10:32:37 +00:00
|
|
|
} else {
|
|
|
|
msg = events = 0;
|
|
|
|
}
|
|
|
|
if (!hwnd)
|
|
|
|
return "do_select(): internal error (hwnd==NULL)";
|
2003-10-12 13:46:12 +00:00
|
|
|
if (p_WSAAsyncSelect(skt, hwnd, msg, events) == SOCKET_ERROR) {
|
|
|
|
switch (p_WSAGetLastError()) {
|
2001-05-06 14:35:20 +00:00
|
|
|
case WSAENETDOWN:
|
|
|
|
return "Network is down";
|
|
|
|
default:
|
|
|
|
return "WSAAsyncSelect(): unknown error";
|
|
|
|
}
|
2000-10-23 10:32:37 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2005-04-07 01:36:28 +00:00
|
|
|
/*
|
|
|
|
* Refresh the saved-session submenu from `sesslist'.
|
|
|
|
*/
|
|
|
|
static void update_savedsess_menu(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
while (DeleteMenu(savedsess_menu, 0, MF_BYPOSITION)) ;
|
|
|
|
/* skip sesslist.sessions[0] == Default Settings */
|
|
|
|
for (i = 1;
|
|
|
|
i < ((sesslist.nsessions <= MENU_SAVED_MAX+1) ? sesslist.nsessions
|
|
|
|
: MENU_SAVED_MAX+1);
|
|
|
|
i++)
|
|
|
|
AppendMenu(savedsess_menu, MF_ENABLED,
|
|
|
|
IDM_SAVED_MIN + (i-1)*MENU_SAVED_STEP,
|
|
|
|
sesslist.sessions[i]);
|
2009-09-13 23:29:11 +00:00
|
|
|
if (sesslist.nsessions <= 1)
|
|
|
|
AppendMenu(savedsess_menu, MF_GRAYED, IDM_SAVED_MIN, "(No sessions)");
|
2005-04-07 01:36:28 +00:00
|
|
|
}
|
|
|
|
|
2003-04-04 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* Update the Special Commands submenu.
|
|
|
|
*/
|
|
|
|
void update_specials_menu(void *frontend)
|
|
|
|
{
|
2006-02-09 23:06:57 +00:00
|
|
|
HMENU new_menu;
|
2003-11-19 20:48:30 +00:00
|
|
|
int i, j;
|
2003-04-04 20:21:05 +00:00
|
|
|
|
2004-08-14 13:04:18 +00:00
|
|
|
if (back)
|
|
|
|
specials = back->get_specials(backhandle);
|
|
|
|
else
|
|
|
|
specials = NULL;
|
|
|
|
|
2003-04-04 20:21:05 +00:00
|
|
|
if (specials) {
|
2004-10-17 21:22:22 +00:00
|
|
|
/* We can't use Windows to provide a stack for submenus, so
|
|
|
|
* here's a lame "stack" that will do for now. */
|
|
|
|
HMENU saved_menu = NULL;
|
|
|
|
int nesting = 1;
|
2006-02-09 23:06:57 +00:00
|
|
|
new_menu = CreatePopupMenu();
|
2004-10-17 21:22:22 +00:00
|
|
|
for (i = 0; nesting > 0; i++) {
|
2003-04-04 20:21:05 +00:00
|
|
|
assert(IDM_SPECIAL_MIN + 0x10 * i < IDM_SPECIAL_MAX);
|
2004-10-17 21:22:22 +00:00
|
|
|
switch (specials[i].code) {
|
|
|
|
case TS_SEP:
|
2006-02-09 23:06:57 +00:00
|
|
|
AppendMenu(new_menu, MF_SEPARATOR, 0, 0);
|
2004-10-17 21:22:22 +00:00
|
|
|
break;
|
|
|
|
case TS_SUBMENU:
|
|
|
|
assert(nesting < 2);
|
|
|
|
nesting++;
|
2006-02-09 23:06:57 +00:00
|
|
|
saved_menu = new_menu; /* XXX lame stacking */
|
|
|
|
new_menu = CreatePopupMenu();
|
2004-10-17 21:22:22 +00:00
|
|
|
AppendMenu(saved_menu, MF_POPUP | MF_ENABLED,
|
2006-02-09 23:06:57 +00:00
|
|
|
(UINT) new_menu, specials[i].name);
|
2004-10-17 21:22:22 +00:00
|
|
|
break;
|
|
|
|
case TS_EXITMENU:
|
|
|
|
nesting--;
|
|
|
|
if (nesting) {
|
2006-02-09 23:06:57 +00:00
|
|
|
new_menu = saved_menu; /* XXX lame stacking */
|
2004-10-17 21:22:22 +00:00
|
|
|
saved_menu = NULL;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2006-02-09 23:06:57 +00:00
|
|
|
AppendMenu(new_menu, MF_ENABLED, IDM_SPECIAL_MIN + 0x10 * i,
|
2003-04-04 20:21:05 +00:00
|
|
|
specials[i].name);
|
2004-10-17 21:22:22 +00:00
|
|
|
break;
|
|
|
|
}
|
2003-04-04 20:21:05 +00:00
|
|
|
}
|
2004-10-17 21:22:22 +00:00
|
|
|
/* Squirrel the highest special. */
|
|
|
|
n_specials = i - 1;
|
|
|
|
} else {
|
2006-02-09 23:06:57 +00:00
|
|
|
new_menu = NULL;
|
2004-10-17 21:22:22 +00:00
|
|
|
n_specials = 0;
|
|
|
|
}
|
2004-08-14 13:04:18 +00:00
|
|
|
|
|
|
|
for (j = 0; j < lenof(popup_menus); j++) {
|
2006-02-09 23:06:57 +00:00
|
|
|
if (specials_menu) {
|
2004-10-17 21:22:22 +00:00
|
|
|
/* XXX does this free up all submenus? */
|
2007-01-09 18:24:07 +00:00
|
|
|
DeleteMenu(popup_menus[j].menu, (UINT)specials_menu, MF_BYCOMMAND);
|
2006-02-09 23:06:57 +00:00
|
|
|
DeleteMenu(popup_menus[j].menu, IDM_SPECIALSEP, MF_BYCOMMAND);
|
2004-08-14 13:04:18 +00:00
|
|
|
}
|
2006-02-10 20:57:40 +00:00
|
|
|
if (new_menu) {
|
2006-02-09 23:06:57 +00:00
|
|
|
InsertMenu(popup_menus[j].menu, IDM_SHOWLOG,
|
|
|
|
MF_BYCOMMAND | MF_POPUP | MF_ENABLED,
|
|
|
|
(UINT) new_menu, "S&pecial Command");
|
|
|
|
InsertMenu(popup_menus[j].menu, IDM_SHOWLOG,
|
|
|
|
MF_BYCOMMAND | MF_SEPARATOR, IDM_SPECIALSEP, 0);
|
2003-11-19 20:48:30 +00:00
|
|
|
}
|
2003-04-04 20:21:05 +00:00
|
|
|
}
|
2006-02-10 20:57:40 +00:00
|
|
|
specials_menu = new_menu;
|
2003-04-04 20:21:05 +00:00
|
|
|
}
|
|
|
|
|
2005-02-15 17:05:58 +00:00
|
|
|
static void update_mouse_pointer(void)
|
|
|
|
{
|
|
|
|
LPTSTR curstype;
|
|
|
|
int force_visible = FALSE;
|
|
|
|
static int forced_visible = FALSE;
|
|
|
|
switch (busy_status) {
|
|
|
|
case BUSY_NOT:
|
|
|
|
if (send_raw_mouse)
|
|
|
|
curstype = IDC_ARROW;
|
|
|
|
else
|
|
|
|
curstype = IDC_IBEAM;
|
|
|
|
break;
|
|
|
|
case BUSY_WAITING:
|
|
|
|
curstype = IDC_APPSTARTING; /* this may be an abuse */
|
|
|
|
force_visible = TRUE;
|
|
|
|
break;
|
|
|
|
case BUSY_CPU:
|
|
|
|
curstype = IDC_WAIT;
|
|
|
|
force_visible = TRUE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
assert(0);
|
|
|
|
}
|
|
|
|
{
|
|
|
|
HCURSOR cursor = LoadCursor(NULL, curstype);
|
2006-01-27 20:49:59 +00:00
|
|
|
SetClassLongPtr(hwnd, GCLP_HCURSOR, (LONG_PTR)cursor);
|
2005-02-15 17:05:58 +00:00
|
|
|
SetCursor(cursor); /* force redraw of cursor at current posn */
|
|
|
|
}
|
|
|
|
if (force_visible != forced_visible) {
|
|
|
|
/* We want some cursor shapes to be visible always.
|
|
|
|
* Along with show_mouseptr(), this manages the ShowCursor()
|
|
|
|
* counter such that if we switch back to a non-force_visible
|
|
|
|
* cursor, the previous visibility state is restored. */
|
|
|
|
ShowCursor(force_visible);
|
|
|
|
forced_visible = force_visible;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_busy_status(void *frontend, int status)
|
|
|
|
{
|
|
|
|
busy_status = status;
|
|
|
|
update_mouse_pointer();
|
|
|
|
}
|
|
|
|
|
2001-05-06 14:20:41 +00:00
|
|
|
/*
|
|
|
|
* set or clear the "raw mouse message" mode
|
|
|
|
*/
|
2002-10-26 12:58:13 +00:00
|
|
|
void set_raw_mouse_mode(void *frontend, int activate)
|
2001-05-06 14:20:41 +00:00
|
|
|
{
|
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
|
|
|
activate = activate && !conf_get_int(conf, CONF_no_mouse_rep);
|
2001-05-06 14:20:41 +00:00
|
|
|
send_raw_mouse = activate;
|
2005-02-15 17:05:58 +00:00
|
|
|
update_mouse_pointer();
|
2001-05-06 14:20:41 +00:00
|
|
|
}
|
|
|
|
|
2000-09-22 11:04:57 +00:00
|
|
|
/*
|
|
|
|
* Print a message box and close the connection.
|
|
|
|
*/
|
2002-10-26 12:58:13 +00:00
|
|
|
void connection_fatal(void *frontend, char *fmt, ...)
|
2001-05-06 14:35:20 +00:00
|
|
|
{
|
2000-09-22 11:04:57 +00:00
|
|
|
va_list ap;
|
2003-05-04 14:14:10 +00:00
|
|
|
char *stuff, morestuff[100];
|
2000-09-22 11:04:57 +00:00
|
|
|
|
|
|
|
va_start(ap, fmt);
|
2003-05-04 14:14:10 +00:00
|
|
|
stuff = dupvprintf(fmt, ap);
|
2000-09-22 11:04:57 +00:00
|
|
|
va_end(ap);
|
2003-04-06 14:11:33 +00:00
|
|
|
sprintf(morestuff, "%.70s Fatal Error", appname);
|
|
|
|
MessageBox(hwnd, stuff, morestuff, MB_ICONERROR | MB_OK);
|
2003-05-04 14:14:10 +00:00
|
|
|
sfree(stuff);
|
|
|
|
|
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
|
|
|
if (conf_get_int(conf, CONF_close_on_exit) == FORCE_ON)
|
2001-05-06 14:35:20 +00:00
|
|
|
PostQuitMessage(1);
|
2000-09-22 11:04:57 +00:00
|
|
|
else {
|
2006-08-26 10:04:46 +00:00
|
|
|
must_close_session = TRUE;
|
2000-09-22 11:04:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-08-04 21:18:56 +00:00
|
|
|
/*
|
|
|
|
* Report an error at the command-line parsing stage.
|
|
|
|
*/
|
|
|
|
void cmdline_error(char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
2003-05-04 14:14:10 +00:00
|
|
|
char *stuff, morestuff[100];
|
2002-08-04 21:18:56 +00:00
|
|
|
|
|
|
|
va_start(ap, fmt);
|
2003-05-04 14:14:10 +00:00
|
|
|
stuff = dupvprintf(fmt, ap);
|
2002-08-04 21:18:56 +00:00
|
|
|
va_end(ap);
|
2003-04-06 14:11:33 +00:00
|
|
|
sprintf(morestuff, "%.70s Command Line Error", appname);
|
|
|
|
MessageBox(hwnd, stuff, morestuff, MB_ICONERROR | MB_OK);
|
2003-05-04 14:14:10 +00:00
|
|
|
sfree(stuff);
|
2002-08-04 21:18:56 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2000-03-17 10:34:41 +00:00
|
|
|
/*
|
|
|
|
* Actually do the job requested by a WM_NETEVENT
|
|
|
|
*/
|
2007-01-07 12:40:21 +00:00
|
|
|
static void enact_pending_netevent(void)
|
2001-05-06 14:35:20 +00:00
|
|
|
{
|
2000-09-20 11:40:23 +00:00
|
|
|
static int reentering = 0;
|
2000-10-23 10:32:37 +00:00
|
|
|
extern int select_result(WPARAM, LPARAM);
|
2000-09-20 11:40:23 +00:00
|
|
|
|
|
|
|
if (reentering)
|
2001-05-06 14:35:20 +00:00
|
|
|
return; /* don't unpend the pending */
|
2000-09-20 11:40:23 +00:00
|
|
|
|
2007-01-07 12:40:21 +00:00
|
|
|
pending_netevent = FALSE;
|
|
|
|
|
2000-09-20 11:40:23 +00:00
|
|
|
reentering = 1;
|
2007-01-07 12:40:21 +00:00
|
|
|
select_result(pend_netevent_wParam, pend_netevent_lParam);
|
2000-09-20 11:40:23 +00:00
|
|
|
reentering = 0;
|
2000-03-17 10:34:41 +00:00
|
|
|
}
|
|
|
|
|
1999-01-08 13:02:13 +00:00
|
|
|
/*
|
|
|
|
* Copy the colour palette from the configuration data into defpal.
|
|
|
|
* This is non-trivial because the colour indices are different.
|
|
|
|
*/
|
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
|
|
|
static void conftopalette(void)
|
2001-05-06 14:35:20 +00:00
|
|
|
{
|
1999-01-08 13:02:13 +00:00
|
|
|
int i;
|
|
|
|
static const int ww[] = {
|
2004-11-28 15:13:34 +00:00
|
|
|
256, 257, 258, 259, 260, 261,
|
|
|
|
0, 8, 1, 9, 2, 10, 3, 11,
|
|
|
|
4, 12, 5, 13, 6, 14, 7, 15
|
1999-01-08 13:02:13 +00:00
|
|
|
};
|
|
|
|
|
2004-11-28 15:13:34 +00:00
|
|
|
for (i = 0; i < 22; i++) {
|
1999-01-08 13:02:13 +00:00
|
|
|
int w = ww[i];
|
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
|
|
|
defpal[w].rgbtRed = conf_get_int_int(conf, CONF_colours, i*3+0);
|
|
|
|
defpal[w].rgbtGreen = conf_get_int_int(conf, CONF_colours, i*3+1);
|
|
|
|
defpal[w].rgbtBlue = conf_get_int_int(conf, CONF_colours, i*3+2);
|
2004-11-28 15:13:34 +00:00
|
|
|
}
|
|
|
|
for (i = 0; i < NEXTCOLOURS; i++) {
|
|
|
|
if (i < 216) {
|
|
|
|
int r = i / 36, g = (i / 6) % 6, b = i % 6;
|
2005-10-13 21:56:43 +00:00
|
|
|
defpal[i+16].rgbtRed = r ? r * 40 + 55 : 0;
|
|
|
|
defpal[i+16].rgbtGreen = g ? g * 40 + 55 : 0;
|
|
|
|
defpal[i+16].rgbtBlue = b ? b * 40 + 55 : 0;
|
2004-11-28 15:13:34 +00:00
|
|
|
} else {
|
|
|
|
int shade = i - 216;
|
2005-10-13 21:56:43 +00:00
|
|
|
shade = shade * 10 + 8;
|
2004-11-28 15:13:34 +00:00
|
|
|
defpal[i+16].rgbtRed = defpal[i+16].rgbtGreen =
|
|
|
|
defpal[i+16].rgbtBlue = shade;
|
|
|
|
}
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
2003-09-03 20:14:38 +00:00
|
|
|
|
|
|
|
/* Override with system colours if appropriate */
|
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
|
|
|
if (conf_get_int(conf, CONF_system_colour))
|
2003-09-03 20:14:38 +00:00
|
|
|
systopalette();
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Override bit of defpal with colours from the system.
|
|
|
|
* (NB that this takes a copy the system colours at the time this is called,
|
|
|
|
* so subsequent colour scheme changes don't take effect. To fix that we'd
|
|
|
|
* probably want to be using GetSysColorBrush() and the like.)
|
|
|
|
*/
|
|
|
|
static void systopalette(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
static const struct { int nIndex; int norm; int bold; } or[] =
|
|
|
|
{
|
2004-11-28 15:13:34 +00:00
|
|
|
{ COLOR_WINDOWTEXT, 256, 257 }, /* Default Foreground */
|
|
|
|
{ COLOR_WINDOW, 258, 259 }, /* Default Background */
|
|
|
|
{ COLOR_HIGHLIGHTTEXT, 260, 260 }, /* Cursor Text */
|
|
|
|
{ COLOR_HIGHLIGHT, 261, 261 }, /* Cursor Colour */
|
2003-09-03 20:14:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
for (i = 0; i < (sizeof(or)/sizeof(or[0])); i++) {
|
|
|
|
COLORREF colour = GetSysColor(or[i].nIndex);
|
|
|
|
defpal[or[i].norm].rgbtRed =
|
|
|
|
defpal[or[i].bold].rgbtRed = GetRValue(colour);
|
|
|
|
defpal[or[i].norm].rgbtGreen =
|
|
|
|
defpal[or[i].bold].rgbtGreen = GetGValue(colour);
|
|
|
|
defpal[or[i].norm].rgbtBlue =
|
|
|
|
defpal[or[i].bold].rgbtBlue = GetBValue(colour);
|
|
|
|
}
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set up the colour palette.
|
|
|
|
*/
|
2001-05-06 14:35:20 +00:00
|
|
|
static void init_palette(void)
|
|
|
|
{
|
1999-01-08 13:02:13 +00:00
|
|
|
int i;
|
2001-05-06 14:35:20 +00:00
|
|
|
HDC hdc = GetDC(hwnd);
|
1999-01-08 13:02:13 +00:00
|
|
|
if (hdc) {
|
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
|
|
|
if (conf_get_int(conf, CONF_try_palette) &&
|
|
|
|
GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) {
|
2003-03-29 16:14:26 +00:00
|
|
|
/*
|
|
|
|
* This is a genuine case where we must use smalloc
|
|
|
|
* because the snew macros can't cope.
|
|
|
|
*/
|
1999-01-08 13:02:13 +00:00
|
|
|
logpal = smalloc(sizeof(*logpal)
|
|
|
|
- sizeof(logpal->palPalEntry)
|
2004-11-28 15:13:34 +00:00
|
|
|
+ NALLCOLOURS * sizeof(PALETTEENTRY));
|
1999-01-08 13:02:13 +00:00
|
|
|
logpal->palVersion = 0x300;
|
2004-11-28 15:13:34 +00:00
|
|
|
logpal->palNumEntries = NALLCOLOURS;
|
|
|
|
for (i = 0; i < NALLCOLOURS; i++) {
|
1999-01-08 13:02:13 +00:00
|
|
|
logpal->palPalEntry[i].peRed = defpal[i].rgbtRed;
|
|
|
|
logpal->palPalEntry[i].peGreen = defpal[i].rgbtGreen;
|
|
|
|
logpal->palPalEntry[i].peBlue = defpal[i].rgbtBlue;
|
|
|
|
logpal->palPalEntry[i].peFlags = PC_NOCOLLAPSE;
|
|
|
|
}
|
2001-05-06 14:35:20 +00:00
|
|
|
pal = CreatePalette(logpal);
|
1999-01-08 13:02:13 +00:00
|
|
|
if (pal) {
|
2001-05-06 14:35:20 +00:00
|
|
|
SelectPalette(hdc, pal, FALSE);
|
|
|
|
RealizePalette(hdc);
|
|
|
|
SelectPalette(hdc, GetStockObject(DEFAULT_PALETTE), FALSE);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
}
|
2001-05-06 14:35:20 +00:00
|
|
|
ReleaseDC(hwnd, hdc);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
if (pal)
|
2004-11-28 15:13:34 +00:00
|
|
|
for (i = 0; i < NALLCOLOURS; i++)
|
1999-01-08 13:02:13 +00:00
|
|
|
colours[i] = PALETTERGB(defpal[i].rgbtRed,
|
|
|
|
defpal[i].rgbtGreen,
|
|
|
|
defpal[i].rgbtBlue);
|
|
|
|
else
|
2004-11-28 15:13:34 +00:00
|
|
|
for (i = 0; i < NALLCOLOURS; i++)
|
1999-01-08 13:02:13 +00:00
|
|
|
colours[i] = RGB(defpal[i].rgbtRed,
|
2001-05-06 14:35:20 +00:00
|
|
|
defpal[i].rgbtGreen, defpal[i].rgbtBlue);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
2004-05-22 10:36:50 +00:00
|
|
|
/*
|
|
|
|
* This is a wrapper to ExtTextOut() to force Windows to display
|
|
|
|
* the precise glyphs we give it. Otherwise it would do its own
|
|
|
|
* bidi and Arabic shaping, and we would end up uncertain which
|
|
|
|
* characters it had put where.
|
|
|
|
*/
|
|
|
|
static void exact_textout(HDC hdc, int x, int y, CONST RECT *lprc,
|
|
|
|
unsigned short *lpString, UINT cbCount,
|
2004-10-14 16:42:43 +00:00
|
|
|
CONST INT *lpDx, int opaque)
|
2004-05-22 10:36:50 +00:00
|
|
|
{
|
2005-03-30 19:33:24 +00:00
|
|
|
#ifdef __LCC__
|
|
|
|
/*
|
|
|
|
* The LCC include files apparently don't supply the
|
|
|
|
* GCP_RESULTSW type, but we can make do with GCP_RESULTS
|
|
|
|
* proper: the differences aren't important to us (the only
|
|
|
|
* variable-width string parameter is one we don't use anyway).
|
|
|
|
*/
|
|
|
|
GCP_RESULTS gcpr;
|
|
|
|
#else
|
2004-05-22 10:36:50 +00:00
|
|
|
GCP_RESULTSW gcpr;
|
2005-03-30 19:33:24 +00:00
|
|
|
#endif
|
2004-05-22 10:36:50 +00:00
|
|
|
char *buffer = snewn(cbCount*2+2, char);
|
|
|
|
char *classbuffer = snewn(cbCount, char);
|
|
|
|
memset(&gcpr, 0, sizeof(gcpr));
|
|
|
|
memset(buffer, 0, cbCount*2+2);
|
|
|
|
memset(classbuffer, GCPCLASS_NEUTRAL, cbCount);
|
|
|
|
|
|
|
|
gcpr.lStructSize = sizeof(gcpr);
|
|
|
|
gcpr.lpGlyphs = (void *)buffer;
|
2007-01-10 00:46:45 +00:00
|
|
|
gcpr.lpClass = (void *)classbuffer;
|
2004-05-22 10:36:50 +00:00
|
|
|
gcpr.nGlyphs = cbCount;
|
|
|
|
GetCharacterPlacementW(hdc, lpString, cbCount, 0, &gcpr,
|
2004-10-14 16:42:43 +00:00
|
|
|
FLI_MASK | GCP_CLASSIN | GCP_DIACRITIC);
|
2004-05-22 10:36:50 +00:00
|
|
|
|
2004-10-14 16:42:43 +00:00
|
|
|
ExtTextOut(hdc, x, y,
|
|
|
|
ETO_GLYPH_INDEX | ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0),
|
|
|
|
lprc, buffer, cbCount, lpDx);
|
2004-05-22 10:36:50 +00:00
|
|
|
}
|
|
|
|
|
2006-11-18 15:10:48 +00:00
|
|
|
/*
|
|
|
|
* The exact_textout() wrapper, unfortunately, destroys the useful
|
|
|
|
* Windows `font linking' behaviour: automatic handling of Unicode
|
|
|
|
* code points not supported in this font by falling back to a font
|
|
|
|
* which does contain them. Therefore, we adopt a multi-layered
|
|
|
|
* approach: for any potentially-bidi text, we use exact_textout(),
|
|
|
|
* and for everything else we use a simple ExtTextOut as we did
|
|
|
|
* before exact_textout() was introduced.
|
|
|
|
*/
|
|
|
|
static void general_textout(HDC hdc, int x, int y, CONST RECT *lprc,
|
|
|
|
unsigned short *lpString, UINT cbCount,
|
|
|
|
CONST INT *lpDx, int opaque)
|
|
|
|
{
|
|
|
|
int i, j, xp, xn;
|
2010-12-30 00:06:43 +00:00
|
|
|
int bkmode = 0, got_bkmode = FALSE;
|
2006-11-18 15:10:48 +00:00
|
|
|
|
|
|
|
xp = xn = x;
|
|
|
|
|
2007-01-09 18:24:07 +00:00
|
|
|
for (i = 0; i < (int)cbCount ;) {
|
2006-11-18 15:10:48 +00:00
|
|
|
int rtl = is_rtl(lpString[i]);
|
|
|
|
|
|
|
|
xn += lpDx[i];
|
|
|
|
|
2007-01-09 18:24:07 +00:00
|
|
|
for (j = i+1; j < (int)cbCount; j++) {
|
2006-11-18 15:10:48 +00:00
|
|
|
if (rtl != is_rtl(lpString[j]))
|
|
|
|
break;
|
|
|
|
xn += lpDx[j];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Now [i,j) indicates a maximal substring of lpString
|
|
|
|
* which should be displayed using the same textout
|
|
|
|
* function.
|
|
|
|
*/
|
|
|
|
if (rtl) {
|
2010-12-30 00:06:43 +00:00
|
|
|
exact_textout(hdc, xp, y, lprc, lpString+i, j-i,
|
2010-12-29 16:00:58 +00:00
|
|
|
font_varpitch ? NULL : lpDx+i, opaque);
|
2006-11-18 15:10:48 +00:00
|
|
|
} else {
|
|
|
|
ExtTextOutW(hdc, xp, y, ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0),
|
2010-12-30 00:06:43 +00:00
|
|
|
lprc, lpString+i, j-i,
|
2010-12-29 16:00:58 +00:00
|
|
|
font_varpitch ? NULL : lpDx+i);
|
2006-11-18 15:10:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
i = j;
|
|
|
|
xp = xn;
|
2010-12-30 00:06:43 +00:00
|
|
|
|
|
|
|
bkmode = GetBkMode(hdc);
|
|
|
|
got_bkmode = TRUE;
|
|
|
|
SetBkMode(hdc, TRANSPARENT);
|
|
|
|
opaque = FALSE;
|
2006-11-18 15:10:48 +00:00
|
|
|
}
|
|
|
|
|
2010-12-30 00:06:43 +00:00
|
|
|
if (got_bkmode)
|
|
|
|
SetBkMode(hdc, bkmode);
|
2006-11-18 15:10:48 +00:00
|
|
|
}
|
|
|
|
|
2010-12-29 14:11:25 +00:00
|
|
|
static int get_font_width(HDC hdc, const TEXTMETRIC *tm)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
/* Note that the TMPF_FIXED_PITCH bit is defined upside down :-( */
|
|
|
|
if (!(tm->tmPitchAndFamily & TMPF_FIXED_PITCH)) {
|
|
|
|
ret = tm->tmAveCharWidth;
|
|
|
|
} else {
|
|
|
|
#define FIRST '0'
|
|
|
|
#define LAST '9'
|
|
|
|
ABCFLOAT widths[LAST-FIRST + 1];
|
|
|
|
int j;
|
|
|
|
|
|
|
|
font_varpitch = TRUE;
|
|
|
|
font_dualwidth = TRUE;
|
|
|
|
if (GetCharABCWidthsFloat(hdc, FIRST, LAST, widths)) {
|
|
|
|
ret = 0;
|
|
|
|
for (j = 0; j < lenof(widths); j++) {
|
|
|
|
int width = (int)(0.5 + widths[j].abcfA +
|
|
|
|
widths[j].abcfB + widths[j].abcfC);
|
|
|
|
if (ret < width)
|
|
|
|
ret = width;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ret = tm->tmMaxCharWidth;
|
|
|
|
}
|
|
|
|
#undef FIRST
|
|
|
|
#undef LAST
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
1999-01-08 13:02:13 +00:00
|
|
|
/*
|
2001-05-10 08:34:20 +00:00
|
|
|
* Initialise all the fonts we will need initially. There may be as many as
|
2010-07-30 19:45:40 +00:00
|
|
|
* three or as few as one. The other (potentially) twenty-one fonts are done
|
2001-05-10 08:34:20 +00:00
|
|
|
* if/when they are needed.
|
|
|
|
*
|
|
|
|
* We also:
|
1999-01-08 13:02:13 +00:00
|
|
|
*
|
|
|
|
* - check the font width and height, correcting our guesses if
|
|
|
|
* necessary.
|
|
|
|
*
|
|
|
|
* - verify that the bold font is the same width as the ordinary
|
|
|
|
* one, and engage shadow bolding if not.
|
|
|
|
*
|
|
|
|
* - verify that the underlined font is the same width as the
|
|
|
|
* ordinary one (manual underlining by means of line drawing can
|
|
|
|
* be done in a pinch).
|
|
|
|
*/
|
2001-09-15 15:54:24 +00:00
|
|
|
static void init_fonts(int pick_width, int pick_height)
|
2001-05-06 14:35:20 +00:00
|
|
|
{
|
1999-01-08 13:02:13 +00:00
|
|
|
TEXTMETRIC tm;
|
2001-05-10 08:34:20 +00:00
|
|
|
CPINFO cpinfo;
|
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
|
|
|
FontSpec *font;
|
2001-05-10 08:34:20 +00:00
|
|
|
int fontsize[3];
|
2000-03-11 14:15:24 +00:00
|
|
|
int i;
|
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
|
|
|
int quality;
|
1999-01-08 13:02:13 +00:00
|
|
|
HDC hdc;
|
|
|
|
int fw_dontcare, fw_bold;
|
|
|
|
|
2001-05-10 08:34:20 +00:00
|
|
|
for (i = 0; i < FONT_MAXNO; i++)
|
1999-01-08 13:02:13 +00:00
|
|
|
fonts[i] = NULL;
|
|
|
|
|
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
|
|
|
bold_mode = conf_get_int(conf, CONF_bold_colour) ?
|
|
|
|
BOLD_COLOURS : BOLD_FONT;
|
2001-09-15 15:54:24 +00:00
|
|
|
und_mode = UND_FONT;
|
|
|
|
|
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
|
|
|
font = conf_get_fontspec(conf, CONF_font);
|
|
|
|
if (font->isbold) {
|
1999-01-08 13:02:13 +00:00
|
|
|
fw_dontcare = FW_BOLD;
|
2000-10-09 12:19:09 +00:00
|
|
|
fw_bold = FW_HEAVY;
|
2001-05-06 14:35:20 +00:00
|
|
|
} else {
|
1999-01-08 13:02:13 +00:00
|
|
|
fw_dontcare = FW_DONTCARE;
|
|
|
|
fw_bold = FW_BOLD;
|
|
|
|
}
|
|
|
|
|
2000-03-11 14:15:24 +00:00
|
|
|
hdc = GetDC(hwnd);
|
|
|
|
|
2001-09-15 15:54:24 +00:00
|
|
|
if (pick_height)
|
|
|
|
font_height = pick_height;
|
|
|
|
else {
|
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
|
|
|
font_height = font->height;
|
2001-09-15 15:54:24 +00:00
|
|
|
if (font_height > 0) {
|
|
|
|
font_height =
|
|
|
|
-MulDiv(font_height, GetDeviceCaps(hdc, LOGPIXELSY), 72);
|
|
|
|
}
|
2001-03-12 12:24:07 +00:00
|
|
|
}
|
2000-03-17 10:34:41 +00:00
|
|
|
font_width = pick_width;
|
2000-03-11 14:15:24 +00:00
|
|
|
|
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
|
|
|
quality = conf_get_int(conf, CONF_font_quality);
|
1999-01-08 13:02:13 +00:00
|
|
|
#define f(i,c,w,u) \
|
2000-03-11 14:15:24 +00:00
|
|
|
fonts[i] = CreateFont (font_height, font_width, 0, 0, w, FALSE, u, FALSE, \
|
1999-01-08 13:02:13 +00:00
|
|
|
c, OUT_DEFAULT_PRECIS, \
|
2011-07-18 18:04:39 +00:00
|
|
|
CLIP_DEFAULT_PRECIS, FONT_QUALITY(quality), \
|
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
|
|
|
FIXED_PITCH | FF_DONTCARE, font->name)
|
2000-03-11 14:15:24 +00:00
|
|
|
|
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
|
|
|
f(FONT_NORMAL, font->charset, fw_dontcare, FALSE);
|
2000-03-11 14:15:24 +00:00
|
|
|
|
2001-05-10 08:34:20 +00:00
|
|
|
SelectObject(hdc, fonts[FONT_NORMAL]);
|
|
|
|
GetTextMetrics(hdc, &tm);
|
2001-09-15 15:54:24 +00:00
|
|
|
|
2005-03-21 01:05:38 +00:00
|
|
|
GetObject(fonts[FONT_NORMAL], sizeof(LOGFONT), &lfont);
|
|
|
|
|
2010-12-29 14:11:25 +00:00
|
|
|
/* Note that the TMPF_FIXED_PITCH bit is defined upside down :-( */
|
|
|
|
if (!(tm.tmPitchAndFamily & TMPF_FIXED_PITCH)) {
|
|
|
|
font_varpitch = FALSE;
|
|
|
|
font_dualwidth = (tm.tmAveCharWidth != tm.tmMaxCharWidth);
|
|
|
|
} else {
|
|
|
|
font_varpitch = TRUE;
|
|
|
|
font_dualwidth = TRUE;
|
|
|
|
}
|
2001-09-15 15:54:24 +00:00
|
|
|
if (pick_width == 0 || pick_height == 0) {
|
|
|
|
font_height = tm.tmHeight;
|
2010-12-29 14:11:25 +00:00
|
|
|
font_width = get_font_width(hdc, &tm);
|
2001-09-15 15:54:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef RDB_DEBUG_PATCH
|
|
|
|
debug(23, "Primary font H=%d, AW=%d, MW=%d",
|
|
|
|
tm.tmHeight, tm.tmAveCharWidth, tm.tmMaxCharWidth);
|
|
|
|
#endif
|
2000-03-11 14:15:24 +00:00
|
|
|
|
2001-05-10 08:34:20 +00:00
|
|
|
{
|
|
|
|
CHARSETINFO info;
|
|
|
|
DWORD cset = tm.tmCharSet;
|
|
|
|
memset(&info, 0xFF, sizeof(info));
|
2000-03-11 14:15:24 +00:00
|
|
|
|
2001-05-10 08:34:20 +00:00
|
|
|
/* !!! Yes the next line is right */
|
|
|
|
if (cset == OEM_CHARSET)
|
2003-01-14 18:28:23 +00:00
|
|
|
ucsdata.font_codepage = GetOEMCP();
|
2001-05-10 08:34:20 +00:00
|
|
|
else
|
2003-01-14 18:28:23 +00:00
|
|
|
if (TranslateCharsetInfo ((DWORD *) cset, &info, TCI_SRCCHARSET))
|
|
|
|
ucsdata.font_codepage = info.ciACP;
|
2001-05-10 08:34:20 +00:00
|
|
|
else
|
2003-01-14 18:28:23 +00:00
|
|
|
ucsdata.font_codepage = -1;
|
2001-05-06 14:35:20 +00:00
|
|
|
|
2003-01-14 18:28:23 +00:00
|
|
|
GetCPInfo(ucsdata.font_codepage, &cpinfo);
|
|
|
|
ucsdata.dbcs_screenfont = (cpinfo.MaxCharSize > 1);
|
2001-05-10 08:34:20 +00:00
|
|
|
}
|
2000-03-11 14:15:24 +00:00
|
|
|
|
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
|
|
|
f(FONT_UNDERLINE, font->charset, fw_dontcare, TRUE);
|
2000-03-11 14:15:24 +00:00
|
|
|
|
2001-05-10 08:34:20 +00:00
|
|
|
/*
|
|
|
|
* Some fonts, e.g. 9-pt Courier, draw their underlines
|
|
|
|
* outside their character cell. We successfully prevent
|
|
|
|
* screen corruption by clipping the text output, but then
|
|
|
|
* we lose the underline completely. Here we try to work
|
|
|
|
* out whether this is such a font, and if it is, we set a
|
|
|
|
* flag that causes underlines to be drawn by hand.
|
|
|
|
*
|
|
|
|
* Having tried other more sophisticated approaches (such
|
|
|
|
* as examining the TEXTMETRIC structure or requesting the
|
|
|
|
* height of a string), I think we'll do this the brute
|
|
|
|
* force way: we create a small bitmap, draw an underlined
|
|
|
|
* space on it, and test to see whether any pixels are
|
|
|
|
* foreground-coloured. (Since we expect the underline to
|
|
|
|
* go all the way across the character cell, we only search
|
|
|
|
* down a single column of the bitmap, half way across.)
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
HDC und_dc;
|
|
|
|
HBITMAP und_bm, und_oldbm;
|
|
|
|
int i, gotit;
|
|
|
|
COLORREF c;
|
|
|
|
|
|
|
|
und_dc = CreateCompatibleDC(hdc);
|
|
|
|
und_bm = CreateCompatibleBitmap(hdc, font_width, font_height);
|
|
|
|
und_oldbm = SelectObject(und_dc, und_bm);
|
|
|
|
SelectObject(und_dc, fonts[FONT_UNDERLINE]);
|
|
|
|
SetTextAlign(und_dc, TA_TOP | TA_LEFT | TA_NOUPDATECP);
|
|
|
|
SetTextColor(und_dc, RGB(255, 255, 255));
|
|
|
|
SetBkColor(und_dc, RGB(0, 0, 0));
|
|
|
|
SetBkMode(und_dc, OPAQUE);
|
|
|
|
ExtTextOut(und_dc, 0, 0, ETO_OPAQUE, NULL, " ", 1, NULL);
|
|
|
|
gotit = FALSE;
|
|
|
|
for (i = 0; i < font_height; i++) {
|
|
|
|
c = GetPixel(und_dc, font_width / 2, i);
|
|
|
|
if (c != RGB(0, 0, 0))
|
|
|
|
gotit = TRUE;
|
|
|
|
}
|
|
|
|
SelectObject(und_dc, und_oldbm);
|
|
|
|
DeleteObject(und_bm);
|
|
|
|
DeleteDC(und_dc);
|
|
|
|
if (!gotit) {
|
|
|
|
und_mode = UND_LINE;
|
|
|
|
DeleteObject(fonts[FONT_UNDERLINE]);
|
|
|
|
fonts[FONT_UNDERLINE] = 0;
|
2001-05-06 14:35:20 +00:00
|
|
|
}
|
2001-05-10 08:34:20 +00:00
|
|
|
}
|
2000-03-11 14:15:24 +00:00
|
|
|
|
2001-05-10 08:34:20 +00:00
|
|
|
if (bold_mode == BOLD_FONT) {
|
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
|
|
|
f(FONT_BOLD, font->charset, fw_bold, FALSE);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
#undef f
|
|
|
|
|
2000-03-11 14:15:24 +00:00
|
|
|
descent = tm.tmAscent + 1;
|
|
|
|
if (descent >= font_height)
|
|
|
|
descent = font_height - 1;
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2001-05-10 08:34:20 +00:00
|
|
|
for (i = 0; i < 3; i++) {
|
2000-03-11 14:15:24 +00:00
|
|
|
if (fonts[i]) {
|
2001-05-06 14:35:20 +00:00
|
|
|
if (SelectObject(hdc, fonts[i]) && GetTextMetrics(hdc, &tm))
|
2010-12-29 14:11:25 +00:00
|
|
|
fontsize[i] = get_font_width(hdc, &tm) + 256 * tm.tmHeight;
|
2001-05-06 14:35:20 +00:00
|
|
|
else
|
2001-05-10 08:34:20 +00:00
|
|
|
fontsize[i] = -i;
|
2001-05-06 14:35:20 +00:00
|
|
|
} else
|
2001-05-10 08:34:20 +00:00
|
|
|
fontsize[i] = -i;
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
ReleaseDC(hwnd, hdc);
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2001-05-10 08:34:20 +00:00
|
|
|
if (fontsize[FONT_UNDERLINE] != fontsize[FONT_NORMAL]) {
|
1999-01-08 13:02:13 +00:00
|
|
|
und_mode = UND_LINE;
|
2001-05-06 14:35:20 +00:00
|
|
|
DeleteObject(fonts[FONT_UNDERLINE]);
|
2001-05-10 08:34:20 +00:00
|
|
|
fonts[FONT_UNDERLINE] = 0;
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
2001-05-10 08:34:20 +00:00
|
|
|
if (bold_mode == BOLD_FONT &&
|
|
|
|
fontsize[FONT_BOLD] != fontsize[FONT_NORMAL]) {
|
1999-01-08 13:02:13 +00:00
|
|
|
bold_mode = BOLD_SHADOW;
|
2001-05-06 14:35:20 +00:00
|
|
|
DeleteObject(fonts[FONT_BOLD]);
|
2001-05-10 08:34:20 +00:00
|
|
|
fonts[FONT_BOLD] = 0;
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
2001-05-10 08:34:20 +00:00
|
|
|
fontflag[0] = fontflag[1] = fontflag[2] = 1;
|
|
|
|
|
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
|
|
|
init_ucs(conf, &ucsdata);
|
2001-05-10 08:34:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void another_font(int fontno)
|
|
|
|
{
|
|
|
|
int basefont;
|
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
|
|
|
int fw_dontcare, fw_bold, quality;
|
2001-05-10 08:34:20 +00:00
|
|
|
int c, u, w, x;
|
|
|
|
char *s;
|
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
|
|
|
FontSpec *font;
|
2001-05-10 08:34:20 +00:00
|
|
|
|
|
|
|
if (fontno < 0 || fontno >= FONT_MAXNO || fontflag[fontno])
|
|
|
|
return;
|
|
|
|
|
|
|
|
basefont = (fontno & ~(FONT_BOLDUND));
|
|
|
|
if (basefont != fontno && !fontflag[basefont])
|
|
|
|
another_font(basefont);
|
2000-03-11 14:15:24 +00:00
|
|
|
|
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
|
|
|
font = conf_get_fontspec(conf, CONF_font);
|
|
|
|
|
|
|
|
if (font->isbold) {
|
2001-05-10 08:34:20 +00:00
|
|
|
fw_dontcare = FW_BOLD;
|
|
|
|
fw_bold = FW_HEAVY;
|
|
|
|
} else {
|
|
|
|
fw_dontcare = FW_DONTCARE;
|
|
|
|
fw_bold = FW_BOLD;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
c = font->charset;
|
2001-05-10 08:34:20 +00:00
|
|
|
w = fw_dontcare;
|
|
|
|
u = FALSE;
|
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
|
|
|
s = font->name;
|
2001-05-10 08:34:20 +00:00
|
|
|
x = font_width;
|
|
|
|
|
|
|
|
if (fontno & FONT_WIDE)
|
|
|
|
x *= 2;
|
|
|
|
if (fontno & FONT_NARROW)
|
2001-09-15 15:54:24 +00:00
|
|
|
x = (x+1)/2;
|
2001-05-10 08:34:20 +00:00
|
|
|
if (fontno & FONT_OEM)
|
|
|
|
c = OEM_CHARSET;
|
|
|
|
if (fontno & FONT_BOLD)
|
|
|
|
w = fw_bold;
|
|
|
|
if (fontno & FONT_UNDERLINE)
|
|
|
|
u = TRUE;
|
|
|
|
|
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
|
|
|
quality = conf_get_int(conf, CONF_font_quality);
|
|
|
|
|
2001-05-10 08:34:20 +00:00
|
|
|
fonts[fontno] =
|
|
|
|
CreateFont(font_height * (1 + !!(fontno & FONT_HIGH)), x, 0, 0, w,
|
|
|
|
FALSE, u, FALSE, c, OUT_DEFAULT_PRECIS,
|
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
|
|
|
CLIP_DEFAULT_PRECIS, FONT_QUALITY(quality),
|
2010-12-29 14:11:25 +00:00
|
|
|
DEFAULT_PITCH | FF_DONTCARE, s);
|
2001-05-10 08:34:20 +00:00
|
|
|
|
|
|
|
fontflag[fontno] = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void deinit_fonts(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < FONT_MAXNO; i++) {
|
|
|
|
if (fonts[i])
|
|
|
|
DeleteObject(fonts[i]);
|
|
|
|
fonts[i] = 0;
|
|
|
|
fontflag[i] = 0;
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-26 12:58:13 +00:00
|
|
|
void request_resize(void *frontend, int w, int h)
|
2001-05-06 14:35:20 +00:00
|
|
|
{
|
2000-03-17 10:34:41 +00:00
|
|
|
int width, height;
|
2000-07-26 12:13:51 +00:00
|
|
|
|
|
|
|
/* If the window is maximized supress resizing attempts */
|
2001-09-15 15:54:24 +00:00
|
|
|
if (IsZoomed(hwnd)) {
|
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
|
|
|
if (conf_get_int(conf, CONF_resize_action) == RESIZE_TERM)
|
2001-09-15 15:54:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2001-05-06 14:35:20 +00:00
|
|
|
|
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
|
|
|
if (conf_get_int(conf, CONF_resize_action) == RESIZE_DISABLED) return;
|
2002-10-22 16:11:33 +00:00
|
|
|
if (h == term->rows && w == term->cols) return;
|
2001-09-15 15:54:24 +00:00
|
|
|
|
|
|
|
/* Sanity checks ... */
|
|
|
|
{
|
2001-05-06 14:35:20 +00:00
|
|
|
static int first_time = 1;
|
|
|
|
static RECT ss;
|
|
|
|
|
|
|
|
switch (first_time) {
|
|
|
|
case 1:
|
|
|
|
/* Get the size of the screen */
|
2002-03-13 22:15:14 +00:00
|
|
|
if (get_fullscreen_rect(&ss))
|
2001-05-06 14:35:20 +00:00
|
|
|
/* first_time = 0 */ ;
|
|
|
|
else {
|
|
|
|
first_time = 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 0:
|
|
|
|
/* Make sure the values are sane */
|
2001-09-15 15:54:24 +00:00
|
|
|
width = (ss.right - ss.left - extra_width) / 4;
|
|
|
|
height = (ss.bottom - ss.top - extra_height) / 6;
|
2001-05-06 14:35:20 +00:00
|
|
|
|
2001-09-15 15:54:24 +00:00
|
|
|
if (w > width || h > height)
|
|
|
|
return;
|
2001-05-06 14:35:20 +00:00
|
|
|
if (w < 15)
|
|
|
|
w = 15;
|
|
|
|
if (h < 1)
|
2001-09-15 15:54:24 +00:00
|
|
|
h = 1;
|
2001-05-06 14:35:20 +00:00
|
|
|
}
|
2000-07-26 12:13:51 +00:00
|
|
|
}
|
2000-03-17 10:34:41 +00:00
|
|
|
|
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
|
|
|
term_size(term, h, w, conf_get_int(conf, CONF_savelines));
|
2001-09-15 15:54:24 +00:00
|
|
|
|
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
|
|
|
if (conf_get_int(conf, CONF_resize_action) != RESIZE_FONT &&
|
|
|
|
!IsZoomed(hwnd)) {
|
2001-09-15 15:54:24 +00:00
|
|
|
width = extra_width + font_width * w;
|
|
|
|
height = extra_height + font_height * h;
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2001-09-15 15:54:24 +00:00
|
|
|
SetWindowPos(hwnd, NULL, 0, 0, width, height,
|
|
|
|
SWP_NOACTIVATE | SWP_NOCOPYBITS |
|
|
|
|
SWP_NOMOVE | SWP_NOZORDER);
|
|
|
|
} else
|
|
|
|
reset_window(0);
|
|
|
|
|
|
|
|
InvalidateRect(hwnd, NULL, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void reset_window(int reinit) {
|
|
|
|
/*
|
|
|
|
* This function decides how to resize or redraw when the
|
|
|
|
* user changes something.
|
|
|
|
*
|
|
|
|
* This function doesn't like to change the terminal size but if the
|
|
|
|
* font size is locked that may be it's only soluion.
|
|
|
|
*/
|
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
|
|
|
int win_width, win_height, resize_action, window_border;
|
2001-09-15 15:54:24 +00:00
|
|
|
RECT cr, wr;
|
|
|
|
|
|
|
|
#ifdef RDB_DEBUG_PATCH
|
|
|
|
debug((27, "reset_window()"));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Current window sizes ... */
|
|
|
|
GetWindowRect(hwnd, &wr);
|
|
|
|
GetClientRect(hwnd, &cr);
|
|
|
|
|
|
|
|
win_width = cr.right - cr.left;
|
|
|
|
win_height = cr.bottom - cr.top;
|
|
|
|
|
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
|
|
|
resize_action = conf_get_int(conf, CONF_resize_action);
|
|
|
|
window_border = conf_get_int(conf, CONF_window_border);
|
|
|
|
|
|
|
|
if (resize_action == RESIZE_DISABLED)
|
|
|
|
reinit = 2;
|
2001-11-25 18:39:57 +00:00
|
|
|
|
2001-09-15 15:54:24 +00:00
|
|
|
/* Are we being forced to reload the fonts ? */
|
|
|
|
if (reinit>1) {
|
|
|
|
#ifdef RDB_DEBUG_PATCH
|
|
|
|
debug((27, "reset_window() -- Forced deinit"));
|
|
|
|
#endif
|
|
|
|
deinit_fonts();
|
|
|
|
init_fonts(0,0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Oh, looks like we're minimised */
|
|
|
|
if (win_width == 0 || win_height == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Is the window out of position ? */
|
|
|
|
if ( !reinit &&
|
2002-10-22 16:11:33 +00:00
|
|
|
(offset_width != (win_width-font_width*term->cols)/2 ||
|
|
|
|
offset_height != (win_height-font_height*term->rows)/2) ){
|
|
|
|
offset_width = (win_width-font_width*term->cols)/2;
|
|
|
|
offset_height = (win_height-font_height*term->rows)/2;
|
2001-09-15 15:54:24 +00:00
|
|
|
InvalidateRect(hwnd, NULL, TRUE);
|
|
|
|
#ifdef RDB_DEBUG_PATCH
|
|
|
|
debug((27, "reset_window() -> Reposition terminal"));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2001-11-04 16:41:26 +00:00
|
|
|
if (IsZoomed(hwnd)) {
|
2001-09-15 15:54:24 +00:00
|
|
|
/* We're fullscreen, this means we must not change the size of
|
|
|
|
* the window so it's the font size or the terminal itself.
|
|
|
|
*/
|
|
|
|
|
|
|
|
extra_width = wr.right - wr.left - cr.right + cr.left;
|
|
|
|
extra_height = wr.bottom - wr.top - cr.bottom + cr.top;
|
|
|
|
|
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
|
|
|
if (resize_action != RESIZE_TERM) {
|
|
|
|
if (font_width != win_width/term->cols ||
|
|
|
|
font_height != win_height/term->rows) {
|
2001-09-15 15:54:24 +00:00
|
|
|
deinit_fonts();
|
2002-10-22 16:11:33 +00:00
|
|
|
init_fonts(win_width/term->cols, win_height/term->rows);
|
|
|
|
offset_width = (win_width-font_width*term->cols)/2;
|
|
|
|
offset_height = (win_height-font_height*term->rows)/2;
|
2001-09-15 15:54:24 +00:00
|
|
|
InvalidateRect(hwnd, NULL, TRUE);
|
|
|
|
#ifdef RDB_DEBUG_PATCH
|
|
|
|
debug((25, "reset_window() -> Z font resize to (%d, %d)",
|
|
|
|
font_width, font_height));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
} else {
|
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
|
|
|
if (font_width * term->cols != win_width ||
|
|
|
|
font_height * term->rows != win_height) {
|
2001-09-15 15:54:24 +00:00
|
|
|
/* Our only choice at this point is to change the
|
|
|
|
* size of the terminal; Oh well.
|
|
|
|
*/
|
2002-10-22 16:11:33 +00:00
|
|
|
term_size(term, win_height/font_height, win_width/font_width,
|
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
|
|
|
conf_get_int(conf, CONF_savelines));
|
2002-10-22 16:11:33 +00:00
|
|
|
offset_width = (win_width-font_width*term->cols)/2;
|
|
|
|
offset_height = (win_height-font_height*term->rows)/2;
|
2001-09-15 15:54:24 +00:00
|
|
|
InvalidateRect(hwnd, NULL, TRUE);
|
|
|
|
#ifdef RDB_DEBUG_PATCH
|
|
|
|
debug((27, "reset_window() -> Zoomed term_size"));
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Hmm, a force re-init means we should ignore the current window
|
|
|
|
* so we resize to the default font size.
|
|
|
|
*/
|
|
|
|
if (reinit>0) {
|
|
|
|
#ifdef RDB_DEBUG_PATCH
|
|
|
|
debug((27, "reset_window() -> Forced re-init"));
|
|
|
|
#endif
|
|
|
|
|
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
|
|
|
offset_width = offset_height = window_border;
|
2001-09-15 15:54:24 +00:00
|
|
|
extra_width = wr.right - wr.left - cr.right + cr.left + offset_width*2;
|
|
|
|
extra_height = wr.bottom - wr.top - cr.bottom + cr.top +offset_height*2;
|
|
|
|
|
2002-10-22 16:11:33 +00:00
|
|
|
if (win_width != font_width*term->cols + offset_width*2 ||
|
|
|
|
win_height != font_height*term->rows + offset_height*2) {
|
2001-09-15 15:54:24 +00:00
|
|
|
|
|
|
|
/* If this is too large windows will resize it to the maximum
|
|
|
|
* allowed window size, we will then be back in here and resize
|
|
|
|
* the font or terminal to fit.
|
|
|
|
*/
|
|
|
|
SetWindowPos(hwnd, NULL, 0, 0,
|
2002-10-22 16:11:33 +00:00
|
|
|
font_width*term->cols + extra_width,
|
|
|
|
font_height*term->rows + extra_height,
|
2001-09-15 15:54:24 +00:00
|
|
|
SWP_NOMOVE | SWP_NOZORDER);
|
|
|
|
}
|
2001-11-25 18:39:57 +00:00
|
|
|
|
|
|
|
InvalidateRect(hwnd, NULL, TRUE);
|
2001-09-15 15:54:24 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Okay the user doesn't want us to change the font so we try the
|
|
|
|
* window. But that may be too big for the screen which forces us
|
|
|
|
* to change the terminal.
|
|
|
|
*/
|
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
|
|
|
if ((resize_action == RESIZE_TERM && reinit<=0) ||
|
|
|
|
(resize_action == RESIZE_EITHER && reinit<0) ||
|
2001-11-25 18:39:57 +00:00
|
|
|
reinit>0) {
|
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
|
|
|
offset_width = offset_height = window_border;
|
2001-09-15 15:54:24 +00:00
|
|
|
extra_width = wr.right - wr.left - cr.right + cr.left + offset_width*2;
|
|
|
|
extra_height = wr.bottom - wr.top - cr.bottom + cr.top +offset_height*2;
|
|
|
|
|
2002-10-22 16:11:33 +00:00
|
|
|
if (win_width != font_width*term->cols + offset_width*2 ||
|
|
|
|
win_height != font_height*term->rows + offset_height*2) {
|
2001-09-15 15:54:24 +00:00
|
|
|
|
|
|
|
static RECT ss;
|
|
|
|
int width, height;
|
2002-03-13 22:15:14 +00:00
|
|
|
|
|
|
|
get_fullscreen_rect(&ss);
|
2001-09-15 15:54:24 +00:00
|
|
|
|
|
|
|
width = (ss.right - ss.left - extra_width) / font_width;
|
|
|
|
height = (ss.bottom - ss.top - extra_height) / font_height;
|
|
|
|
|
|
|
|
/* Grrr too big */
|
2002-10-22 16:11:33 +00:00
|
|
|
if ( term->rows > height || term->cols > width ) {
|
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
|
|
|
if (resize_action == RESIZE_EITHER) {
|
2001-11-25 18:39:57 +00:00
|
|
|
/* Make the font the biggest we can */
|
2002-10-22 16:11:33 +00:00
|
|
|
if (term->cols > width)
|
|
|
|
font_width = (ss.right - ss.left - extra_width)
|
|
|
|
/ term->cols;
|
|
|
|
if (term->rows > height)
|
|
|
|
font_height = (ss.bottom - ss.top - extra_height)
|
|
|
|
/ term->rows;
|
2001-11-25 18:39:57 +00:00
|
|
|
|
|
|
|
deinit_fonts();
|
|
|
|
init_fonts(font_width, font_height);
|
|
|
|
|
|
|
|
width = (ss.right - ss.left - extra_width) / font_width;
|
|
|
|
height = (ss.bottom - ss.top - extra_height) / font_height;
|
|
|
|
} else {
|
2002-10-22 16:11:33 +00:00
|
|
|
if ( height > term->rows ) height = term->rows;
|
|
|
|
if ( width > term->cols ) width = term->cols;
|
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
|
|
|
term_size(term, height, width,
|
|
|
|
conf_get_int(conf, CONF_savelines));
|
2001-09-15 15:54:24 +00:00
|
|
|
#ifdef RDB_DEBUG_PATCH
|
2001-11-25 18:39:57 +00:00
|
|
|
debug((27, "reset_window() -> term resize to (%d,%d)",
|
|
|
|
height, width));
|
2001-09-15 15:54:24 +00:00
|
|
|
#endif
|
2001-11-25 18:39:57 +00:00
|
|
|
}
|
2001-09-15 15:54:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
SetWindowPos(hwnd, NULL, 0, 0,
|
2002-10-22 16:11:33 +00:00
|
|
|
font_width*term->cols + extra_width,
|
|
|
|
font_height*term->rows + extra_height,
|
2001-09-15 15:54:24 +00:00
|
|
|
SWP_NOMOVE | SWP_NOZORDER);
|
|
|
|
|
|
|
|
InvalidateRect(hwnd, NULL, TRUE);
|
|
|
|
#ifdef RDB_DEBUG_PATCH
|
|
|
|
debug((27, "reset_window() -> window resize to (%d,%d)",
|
2002-10-22 16:11:33 +00:00
|
|
|
font_width*term->cols + extra_width,
|
|
|
|
font_height*term->rows + extra_height));
|
2001-09-15 15:54:24 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We're allowed to or must change the font but do we want to ? */
|
|
|
|
|
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
|
|
|
if (font_width != (win_width-window_border*2)/term->cols ||
|
|
|
|
font_height != (win_height-window_border*2)/term->rows) {
|
2001-09-15 15:54:24 +00:00
|
|
|
|
|
|
|
deinit_fonts();
|
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
|
|
|
init_fonts((win_width-window_border*2)/term->cols,
|
|
|
|
(win_height-window_border*2)/term->rows);
|
2002-10-22 16:11:33 +00:00
|
|
|
offset_width = (win_width-font_width*term->cols)/2;
|
|
|
|
offset_height = (win_height-font_height*term->rows)/2;
|
2001-09-15 15:54:24 +00:00
|
|
|
|
|
|
|
extra_width = wr.right - wr.left - cr.right + cr.left +offset_width*2;
|
|
|
|
extra_height = wr.bottom - wr.top - cr.bottom + cr.top+offset_height*2;
|
|
|
|
|
|
|
|
InvalidateRect(hwnd, NULL, TRUE);
|
|
|
|
#ifdef RDB_DEBUG_PATCH
|
|
|
|
debug((25, "reset_window() -> font resize to (%d,%d)",
|
|
|
|
font_width, font_height));
|
|
|
|
#endif
|
|
|
|
}
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
2001-11-29 21:30:59 +00:00
|
|
|
static void set_input_locale(HKL kl)
|
|
|
|
{
|
|
|
|
char lbuf[20];
|
|
|
|
|
|
|
|
GetLocaleInfo(LOWORD(kl), LOCALE_IDEFAULTANSICODEPAGE,
|
|
|
|
lbuf, sizeof(lbuf));
|
|
|
|
|
|
|
|
kbd_codepage = atoi(lbuf);
|
|
|
|
}
|
|
|
|
|
2001-10-31 18:50:09 +00:00
|
|
|
static void click(Mouse_Button b, int x, int y, int shift, int ctrl, int alt)
|
2001-05-06 14:35:20 +00:00
|
|
|
{
|
1999-01-22 09:35:08 +00:00
|
|
|
int thistime = GetMessageTime();
|
|
|
|
|
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
|
|
|
if (send_raw_mouse &&
|
|
|
|
!(shift && conf_get_int(conf, CONF_mouse_override))) {
|
2001-09-07 20:35:38 +00:00
|
|
|
lastbtn = MBT_NOTHING;
|
2003-01-25 16:16:45 +00:00
|
|
|
term_mouse(term, b, translate_button(b), MA_CLICK,
|
|
|
|
x, y, shift, ctrl, alt);
|
2001-05-06 14:20:41 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
1999-01-22 09:35:08 +00:00
|
|
|
if (lastbtn == b && thistime - lasttime < dbltime) {
|
1999-01-08 13:02:13 +00:00
|
|
|
lastact = (lastact == MA_CLICK ? MA_2CLK :
|
|
|
|
lastact == MA_2CLK ? MA_3CLK :
|
|
|
|
lastact == MA_3CLK ? MA_CLICK : MA_NOTHING);
|
|
|
|
} else {
|
|
|
|
lastbtn = b;
|
|
|
|
lastact = MA_CLICK;
|
|
|
|
}
|
|
|
|
if (lastact != MA_NOTHING)
|
2003-01-25 16:16:45 +00:00
|
|
|
term_mouse(term, b, translate_button(b), lastact,
|
|
|
|
x, y, shift, ctrl, alt);
|
1999-01-22 09:35:08 +00:00
|
|
|
lasttime = thistime;
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
2001-05-06 14:20:41 +00:00
|
|
|
/*
|
|
|
|
* Translate a raw mouse button designation (LEFT, MIDDLE, RIGHT)
|
|
|
|
* into a cooked one (SELECT, EXTEND, PASTE).
|
|
|
|
*/
|
2003-01-25 16:22:49 +00:00
|
|
|
static Mouse_Button translate_button(Mouse_Button button)
|
2001-05-06 14:35:20 +00:00
|
|
|
{
|
2001-05-06 14:20:41 +00:00
|
|
|
if (button == MBT_LEFT)
|
|
|
|
return MBT_SELECT;
|
|
|
|
if (button == MBT_MIDDLE)
|
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
|
|
|
return conf_get_int(conf, CONF_mouse_is_xterm) == 1 ?
|
|
|
|
MBT_PASTE : MBT_EXTEND;
|
2001-05-06 14:20:41 +00:00
|
|
|
if (button == MBT_RIGHT)
|
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
|
|
|
return conf_get_int(conf, CONF_mouse_is_xterm) == 1 ?
|
|
|
|
MBT_EXTEND : MBT_PASTE;
|
2001-05-13 14:02:28 +00:00
|
|
|
return 0; /* shouldn't happen */
|
2001-05-06 14:20:41 +00:00
|
|
|
}
|
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
static void show_mouseptr(int show)
|
|
|
|
{
|
2005-02-15 17:05:58 +00:00
|
|
|
/* NB that the counter in ShowCursor() is also frobbed by
|
|
|
|
* update_mouse_pointer() */
|
2001-01-22 16:38:43 +00:00
|
|
|
static int cursor_visible = 1;
|
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
|
|
|
if (!conf_get_int(conf, CONF_hide_mouseptr))
|
|
|
|
show = 1; /* override if this feature disabled */
|
2001-01-22 16:38:43 +00:00
|
|
|
if (cursor_visible && !show)
|
2001-05-06 14:35:20 +00:00
|
|
|
ShowCursor(FALSE);
|
2001-01-22 16:38:43 +00:00
|
|
|
else if (!cursor_visible && show)
|
2001-05-06 14:35:20 +00:00
|
|
|
ShowCursor(TRUE);
|
2001-01-22 16:38:43 +00:00
|
|
|
cursor_visible = show;
|
|
|
|
}
|
|
|
|
|
2001-10-31 18:50:09 +00:00
|
|
|
static int is_alt_pressed(void)
|
|
|
|
{
|
|
|
|
BYTE keystate[256];
|
|
|
|
int r = GetKeyboardState(keystate);
|
|
|
|
if (!r)
|
|
|
|
return FALSE;
|
|
|
|
if (keystate[VK_MENU] & 0x80)
|
|
|
|
return TRUE;
|
|
|
|
if (keystate[VK_RMENU] & 0x80)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2001-11-25 15:21:25 +00:00
|
|
|
static int resizing;
|
|
|
|
|
2006-08-26 10:04:46 +00:00
|
|
|
void notify_remote_exit(void *fe)
|
|
|
|
{
|
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
|
|
|
int exitcode, close_on_exit;
|
2006-08-26 10:04:46 +00:00
|
|
|
|
|
|
|
if (!session_closed &&
|
|
|
|
(exitcode = back->exitcode(backhandle)) >= 0) {
|
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
|
|
|
close_on_exit = conf_get_int(conf, CONF_close_on_exit);
|
2006-08-26 10:04:46 +00:00
|
|
|
/* Abnormal exits will already have set session_closed and taken
|
|
|
|
* appropriate action. */
|
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
|
|
|
if (close_on_exit == FORCE_ON ||
|
|
|
|
(close_on_exit == AUTO && exitcode != INT_MAX)) {
|
2006-08-26 10:04:46 +00:00
|
|
|
PostQuitMessage(0);
|
|
|
|
} else {
|
|
|
|
must_close_session = TRUE;
|
|
|
|
session_closed = TRUE;
|
|
|
|
/* exitcode == INT_MAX indicates that the connection was closed
|
|
|
|
* by a fatal error, so an error box will be coming our way and
|
|
|
|
* we should not generate this informational one. */
|
|
|
|
if (exitcode != INT_MAX)
|
|
|
|
MessageBox(hwnd, "Connection closed by remote host",
|
|
|
|
appname, MB_OK | MB_ICONINFORMATION);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2004-11-27 13:20:21 +00:00
|
|
|
|
|
|
|
void timer_change_notify(long next)
|
|
|
|
{
|
|
|
|
long ticks = next - GETTICKCOUNT();
|
|
|
|
if (ticks <= 0) ticks = 1; /* just in case */
|
|
|
|
KillTimer(hwnd, TIMING_TIMER_ID);
|
|
|
|
SetTimer(hwnd, TIMING_TIMER_ID, ticks, NULL);
|
|
|
|
timing_next_time = next;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
static void conf_cache_data(void)
|
|
|
|
{
|
|
|
|
/* Cache some items from conf to speed lookups in very hot code */
|
|
|
|
cursor_type = conf_get_int(conf, CONF_cursor_type);
|
|
|
|
vtmode = conf_get_int(conf, CONF_vtmode);
|
|
|
|
}
|
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
static LRESULT CALLBACK WndProc(HWND hwnd, UINT message,
|
|
|
|
WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
1999-01-08 13:02:13 +00:00
|
|
|
HDC hdc;
|
|
|
|
static int ignore_clip = FALSE;
|
2001-01-07 17:18:24 +00:00
|
|
|
static int need_backend_resize = FALSE;
|
2001-12-07 21:21:03 +00:00
|
|
|
static int fullscr_on_max = FALSE;
|
2010-12-27 12:58:39 +00:00
|
|
|
static int processed_resize = FALSE;
|
2004-07-25 19:52:07 +00:00
|
|
|
static UINT last_mousemove = 0;
|
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
|
|
|
int resize_action;
|
1999-01-08 13:02:13 +00:00
|
|
|
|
|
|
|
switch (message) {
|
2000-03-17 10:34:41 +00:00
|
|
|
case WM_TIMER:
|
2004-11-27 13:20:21 +00:00
|
|
|
if ((UINT_PTR)wParam == TIMING_TIMER_ID) {
|
|
|
|
long next;
|
|
|
|
|
|
|
|
KillTimer(hwnd, TIMING_TIMER_ID);
|
|
|
|
if (run_timers(timing_next_time, &next)) {
|
|
|
|
timer_change_notify(next);
|
|
|
|
} else {
|
2001-05-06 14:35:20 +00:00
|
|
|
}
|
|
|
|
}
|
2000-03-17 10:34:41 +00:00
|
|
|
return 0;
|
1999-01-08 13:02:13 +00:00
|
|
|
case WM_CREATE:
|
|
|
|
break;
|
1999-11-04 13:44:21 +00:00
|
|
|
case WM_CLOSE:
|
2003-04-06 14:11:33 +00:00
|
|
|
{
|
|
|
|
char *str;
|
|
|
|
show_mouseptr(1);
|
|
|
|
str = dupprintf("%s Exit Confirmation", appname);
|
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
|
|
|
if (session_closed || !conf_get_int(conf, CONF_warn_on_close) ||
|
2003-04-06 14:11:33 +00:00
|
|
|
MessageBox(hwnd,
|
|
|
|
"Are you sure you want to close this session?",
|
2005-02-20 23:26:47 +00:00
|
|
|
str, MB_ICONWARNING | MB_OKCANCEL | MB_DEFBUTTON1)
|
2005-02-15 19:22:47 +00:00
|
|
|
== IDOK)
|
2003-04-06 14:11:33 +00:00
|
|
|
DestroyWindow(hwnd);
|
|
|
|
sfree(str);
|
|
|
|
}
|
1999-11-04 13:44:21 +00:00
|
|
|
return 0;
|
1999-01-08 13:02:13 +00:00
|
|
|
case WM_DESTROY:
|
2001-05-06 14:35:20 +00:00
|
|
|
show_mouseptr(1);
|
|
|
|
PostQuitMessage(0);
|
1999-01-08 13:02:13 +00:00
|
|
|
return 0;
|
2005-04-07 01:36:28 +00:00
|
|
|
case WM_INITMENUPOPUP:
|
|
|
|
if ((HMENU)wParam == savedsess_menu) {
|
|
|
|
/* About to pop up Saved Sessions sub-menu.
|
|
|
|
* Refresh the session list. */
|
|
|
|
get_sesslist(&sesslist, FALSE); /* free */
|
|
|
|
get_sesslist(&sesslist, TRUE);
|
|
|
|
update_savedsess_menu();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
2003-11-19 20:48:30 +00:00
|
|
|
case WM_COMMAND:
|
1999-10-28 16:29:06 +00:00
|
|
|
case WM_SYSCOMMAND:
|
|
|
|
switch (wParam & ~0xF) { /* low 4 bits reserved to Windows */
|
1999-01-08 13:02:13 +00:00
|
|
|
case IDM_SHOWLOG:
|
1999-11-09 11:10:04 +00:00
|
|
|
showeventlog(hwnd);
|
1999-01-08 13:02:13 +00:00
|
|
|
break;
|
|
|
|
case IDM_NEWSESS:
|
|
|
|
case IDM_DUPSESS:
|
1999-10-28 16:29:06 +00:00
|
|
|
case IDM_SAVEDSESS:
|
1999-01-08 13:02:13 +00:00
|
|
|
{
|
|
|
|
char b[2048];
|
|
|
|
char c[30], *cl;
|
1999-11-01 17:18:08 +00:00
|
|
|
int freecl = FALSE;
|
2005-03-08 23:06:15 +00:00
|
|
|
BOOL inherit_handles;
|
1999-01-08 13:02:13 +00:00
|
|
|
STARTUPINFO si;
|
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
HANDLE filemap = NULL;
|
|
|
|
|
|
|
|
if (wParam == IDM_DUPSESS) {
|
|
|
|
/*
|
|
|
|
* Allocate a file-mapping memory chunk for the
|
|
|
|
* config structure.
|
|
|
|
*/
|
|
|
|
SECURITY_ATTRIBUTES sa;
|
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
|
|
|
void *p;
|
|
|
|
int size;
|
|
|
|
|
|
|
|
size = conf_serialised_size(conf);
|
1999-01-08 13:02:13 +00:00
|
|
|
|
|
|
|
sa.nLength = sizeof(sa);
|
|
|
|
sa.lpSecurityDescriptor = NULL;
|
|
|
|
sa.bInheritHandle = TRUE;
|
2006-08-29 18:32:44 +00:00
|
|
|
filemap = CreateFileMapping(INVALID_HANDLE_VALUE,
|
1999-01-08 13:02:13 +00:00
|
|
|
&sa,
|
|
|
|
PAGE_READWRITE,
|
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
|
|
|
0, size, NULL);
|
2006-08-29 18:32:44 +00:00
|
|
|
if (filemap && filemap != INVALID_HANDLE_VALUE) {
|
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
|
|
|
p = MapViewOfFile(filemap, FILE_MAP_WRITE, 0, 0, size);
|
1999-01-08 13:02:13 +00:00
|
|
|
if (p) {
|
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
|
|
|
conf_serialise(conf, p);
|
1999-01-08 13:02:13 +00:00
|
|
|
UnmapViewOfFile(p);
|
|
|
|
}
|
|
|
|
}
|
2005-03-08 23:06:15 +00:00
|
|
|
inherit_handles = TRUE;
|
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
|
|
|
sprintf(c, "putty &%p:%u", filemap, (unsigned)size);
|
1999-01-08 13:02:13 +00:00
|
|
|
cl = c;
|
1999-10-28 16:07:25 +00:00
|
|
|
} else if (wParam == IDM_SAVEDSESS) {
|
2004-11-02 23:06:20 +00:00
|
|
|
unsigned int sessno = ((lParam - IDM_SAVED_MIN)
|
|
|
|
/ MENU_SAVED_STEP) + 1;
|
2007-01-09 18:24:07 +00:00
|
|
|
if (sessno < (unsigned)sesslist.nsessions) {
|
2004-11-02 17:44:06 +00:00
|
|
|
char *session = sesslist.sessions[sessno];
|
|
|
|
cl = dupprintf("putty @%s", session);
|
2005-03-08 23:06:15 +00:00
|
|
|
inherit_handles = FALSE;
|
2004-11-02 17:44:06 +00:00
|
|
|
freecl = TRUE;
|
2001-12-07 20:37:18 +00:00
|
|
|
} else
|
|
|
|
break;
|
2005-03-08 23:06:15 +00:00
|
|
|
} else /* IDM_NEWSESS */ {
|
1999-10-28 16:29:06 +00:00
|
|
|
cl = NULL;
|
2005-03-08 23:06:15 +00:00
|
|
|
inherit_handles = FALSE;
|
|
|
|
}
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
GetModuleFileName(NULL, b, sizeof(b) - 1);
|
1999-01-08 13:02:13 +00:00
|
|
|
si.cb = sizeof(si);
|
|
|
|
si.lpReserved = NULL;
|
|
|
|
si.lpDesktop = NULL;
|
|
|
|
si.lpTitle = NULL;
|
|
|
|
si.dwFlags = 0;
|
|
|
|
si.cbReserved2 = 0;
|
|
|
|
si.lpReserved2 = NULL;
|
2005-03-08 23:06:15 +00:00
|
|
|
CreateProcess(b, cl, NULL, NULL, inherit_handles,
|
2001-05-06 14:35:20 +00:00
|
|
|
NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi);
|
1999-01-08 13:02:13 +00:00
|
|
|
|
|
|
|
if (filemap)
|
|
|
|
CloseHandle(filemap);
|
1999-11-01 17:18:08 +00:00
|
|
|
if (freecl)
|
2000-12-12 10:33:13 +00:00
|
|
|
sfree(cl);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
2004-08-14 13:04:18 +00:00
|
|
|
break;
|
|
|
|
case IDM_RESTART:
|
|
|
|
if (!back) {
|
|
|
|
logevent(NULL, "----- Session restarted -----");
|
2006-02-19 14:59:48 +00:00
|
|
|
term_pwron(term, FALSE);
|
2004-08-14 13:04:18 +00:00
|
|
|
start_backend();
|
|
|
|
}
|
|
|
|
|
1999-01-08 13:02:13 +00:00
|
|
|
break;
|
2001-05-06 14:35:20 +00:00
|
|
|
case IDM_RECONF:
|
|
|
|
{
|
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
|
|
|
Conf *prev_conf;
|
2001-09-15 15:54:24 +00:00
|
|
|
int init_lvl = 1;
|
2005-03-21 22:20:22 +00:00
|
|
|
int reconfig_result;
|
2001-09-15 15:54:24 +00:00
|
|
|
|
2005-03-15 20:34:08 +00:00
|
|
|
if (reconfiguring)
|
2005-03-21 22:20:22 +00:00
|
|
|
break;
|
2005-03-15 20:34:08 +00:00
|
|
|
else
|
2005-03-21 22:20:22 +00:00
|
|
|
reconfiguring = TRUE;
|
2005-03-15 20:34:08 +00:00
|
|
|
|
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
|
|
|
/*
|
|
|
|
* Copy the current window title into the stored
|
|
|
|
* previous configuration, so that doing nothing to
|
|
|
|
* the window title field in the config box doesn't
|
|
|
|
* reset the title to its startup state.
|
|
|
|
*/
|
|
|
|
conf_set_str(conf, CONF_wintitle, window_name);
|
|
|
|
|
|
|
|
prev_conf = conf_copy(conf);
|
2001-01-07 18:24:59 +00:00
|
|
|
|
2005-03-21 22:20:22 +00:00
|
|
|
reconfig_result =
|
2005-03-22 23:25:21 +00:00
|
|
|
do_reconfig(hwnd, back ? back->cfg_info(backhandle) : 0);
|
2005-03-21 22:20:22 +00:00
|
|
|
reconfiguring = FALSE;
|
|
|
|
if (!reconfig_result)
|
2001-05-06 14:35:20 +00:00
|
|
|
break;
|
2001-01-07 18:24:59 +00:00
|
|
|
|
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
|
|
|
conf_cache_data();
|
|
|
|
|
|
|
|
resize_action = conf_get_int(conf, CONF_resize_action);
|
2001-11-25 10:24:29 +00:00
|
|
|
{
|
|
|
|
/* Disable full-screen if resizing forbidden */
|
2009-08-15 17:45:17 +00:00
|
|
|
int i;
|
|
|
|
for (i = 0; i < lenof(popup_menus); i++)
|
|
|
|
EnableMenuItem(popup_menus[i].menu, IDM_FULLSCREEN,
|
|
|
|
MF_BYCOMMAND |
|
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
|
|
|
(resize_action == RESIZE_DISABLED)
|
2009-08-15 17:45:17 +00:00
|
|
|
? MF_GRAYED : MF_ENABLED);
|
2001-11-25 10:24:29 +00:00
|
|
|
/* Gracefully unzoom if necessary */
|
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
|
|
|
if (IsZoomed(hwnd) && (resize_action == RESIZE_DISABLED))
|
2001-12-07 21:21:03 +00:00
|
|
|
ShowWindow(hwnd, SW_RESTORE);
|
2001-10-17 21:21:03 +00:00
|
|
|
}
|
|
|
|
|
2003-01-12 15:10:27 +00:00
|
|
|
/* Pass new config data to the logging module */
|
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
|
|
|
log_reconfig(logctx, conf);
|
2001-01-07 18:24:59 +00:00
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
sfree(logpal);
|
|
|
|
/*
|
|
|
|
* Flush the line discipline's edit buffer in the
|
|
|
|
* case where local editing has just been disabled.
|
|
|
|
*/
|
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
|
|
|
ldisc_configure(ldisc, conf);
|
2004-08-14 13:04:18 +00:00
|
|
|
if (ldisc)
|
|
|
|
ldisc_send(ldisc, NULL, 0, 0);
|
2001-05-06 14:35:20 +00:00
|
|
|
if (pal)
|
|
|
|
DeleteObject(pal);
|
|
|
|
logpal = NULL;
|
|
|
|
pal = NULL;
|
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
|
|
|
conftopalette();
|
2001-05-06 14:35:20 +00:00
|
|
|
init_palette();
|
|
|
|
|
2003-01-12 14:30:02 +00:00
|
|
|
/* Pass new config data to the terminal */
|
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
|
|
|
term_reconfig(term, conf);
|
2002-03-06 23:04:20 +00:00
|
|
|
|
2003-01-12 14:48:29 +00:00
|
|
|
/* Pass new config data to the back end */
|
2004-08-14 13:04:18 +00:00
|
|
|
if (back)
|
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
|
|
|
back->reconfig(backhandle, conf);
|
2003-01-12 14:48:29 +00:00
|
|
|
|
2001-09-15 15:54:24 +00:00
|
|
|
/* Screen size changed ? */
|
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
|
|
|
if (conf_get_int(conf, CONF_height) !=
|
|
|
|
conf_get_int(prev_conf, CONF_height) ||
|
|
|
|
conf_get_int(conf, CONF_width) !=
|
|
|
|
conf_get_int(prev_conf, CONF_width) ||
|
|
|
|
conf_get_int(conf, CONF_savelines) !=
|
|
|
|
conf_get_int(prev_conf, CONF_savelines) ||
|
|
|
|
resize_action == RESIZE_FONT ||
|
|
|
|
(resize_action == RESIZE_EITHER && IsZoomed(hwnd)) ||
|
|
|
|
resize_action == RESIZE_DISABLED)
|
|
|
|
term_size(term, conf_get_int(conf, CONF_height),
|
|
|
|
conf_get_int(conf, CONF_width),
|
|
|
|
conf_get_int(conf, CONF_savelines));
|
2001-09-15 15:54:24 +00:00
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
/* Enable or disable the scroll bar, etc */
|
|
|
|
{
|
2005-05-21 14:16:43 +00:00
|
|
|
LONG nflg, flag = GetWindowLongPtr(hwnd, GWL_STYLE);
|
2001-05-06 14:35:20 +00:00
|
|
|
LONG nexflag, exflag =
|
2005-05-21 14:16:43 +00:00
|
|
|
GetWindowLongPtr(hwnd, GWL_EXSTYLE);
|
2001-05-06 14:35:20 +00:00
|
|
|
|
|
|
|
nexflag = exflag;
|
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
|
|
|
if (conf_get_int(conf, CONF_alwaysontop) !=
|
|
|
|
conf_get_int(prev_conf, CONF_alwaysontop)) {
|
|
|
|
if (conf_get_int(conf, CONF_alwaysontop)) {
|
2001-05-06 14:35:20 +00:00
|
|
|
nexflag |= WS_EX_TOPMOST;
|
|
|
|
SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0,
|
|
|
|
SWP_NOMOVE | SWP_NOSIZE);
|
|
|
|
} else {
|
|
|
|
nexflag &= ~(WS_EX_TOPMOST);
|
|
|
|
SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0,
|
|
|
|
SWP_NOMOVE | SWP_NOSIZE);
|
|
|
|
}
|
|
|
|
}
|
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
|
|
|
if (conf_get_int(conf, CONF_sunken_edge))
|
2001-05-06 14:35:20 +00:00
|
|
|
nexflag |= WS_EX_CLIENTEDGE;
|
|
|
|
else
|
|
|
|
nexflag &= ~(WS_EX_CLIENTEDGE);
|
|
|
|
|
|
|
|
nflg = flag;
|
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
|
|
|
if (conf_get_int(conf, is_full_screen() ?
|
|
|
|
CONF_scrollbar_in_fullscreen :
|
|
|
|
CONF_scrollbar))
|
2001-05-06 14:35:20 +00:00
|
|
|
nflg |= WS_VSCROLL;
|
|
|
|
else
|
|
|
|
nflg &= ~WS_VSCROLL;
|
2001-12-11 18:47:55 +00:00
|
|
|
|
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
|
|
|
if (resize_action == RESIZE_DISABLED ||
|
2001-12-11 18:47:55 +00:00
|
|
|
is_full_screen())
|
|
|
|
nflg &= ~WS_THICKFRAME;
|
|
|
|
else
|
|
|
|
nflg |= WS_THICKFRAME;
|
|
|
|
|
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
|
|
|
if (resize_action == RESIZE_DISABLED)
|
2001-12-11 18:47:55 +00:00
|
|
|
nflg &= ~WS_MAXIMIZEBOX;
|
2001-05-06 14:35:20 +00:00
|
|
|
else
|
2001-12-11 18:47:55 +00:00
|
|
|
nflg |= WS_MAXIMIZEBOX;
|
2001-05-06 14:35:20 +00:00
|
|
|
|
|
|
|
if (nflg != flag || nexflag != exflag) {
|
|
|
|
if (nflg != flag)
|
2005-05-21 14:16:43 +00:00
|
|
|
SetWindowLongPtr(hwnd, GWL_STYLE, nflg);
|
2001-05-06 14:35:20 +00:00
|
|
|
if (nexflag != exflag)
|
2005-05-21 14:16:43 +00:00
|
|
|
SetWindowLongPtr(hwnd, GWL_EXSTYLE, nexflag);
|
2001-05-06 14:35:20 +00:00
|
|
|
|
|
|
|
SetWindowPos(hwnd, NULL, 0, 0, 0, 0,
|
|
|
|
SWP_NOACTIVATE | SWP_NOCOPYBITS |
|
2001-09-15 15:54:24 +00:00
|
|
|
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
|
|
|
|
SWP_FRAMECHANGED);
|
2000-07-26 12:13:51 +00:00
|
|
|
|
2001-09-15 15:54:24 +00:00
|
|
|
init_lvl = 2;
|
2001-05-09 13:03:16 +00:00
|
|
|
}
|
2001-05-06 14:35:20 +00:00
|
|
|
}
|
2001-09-15 15:54:24 +00:00
|
|
|
|
2001-05-09 13:03:16 +00:00
|
|
|
/* Oops */
|
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
|
|
|
if (resize_action == RESIZE_DISABLED && IsZoomed(hwnd)) {
|
2001-05-09 13:03:16 +00:00
|
|
|
force_normal(hwnd);
|
2001-09-15 15:54:24 +00:00
|
|
|
init_lvl = 2;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
set_title(NULL, conf_get_str(conf, CONF_wintitle));
|
2001-05-06 14:35:20 +00:00
|
|
|
if (IsIconic(hwnd)) {
|
|
|
|
SetWindowText(hwnd,
|
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
|
|
|
conf_get_int(conf, CONF_win_name_always) ?
|
|
|
|
window_name : icon_name);
|
2001-01-07 16:27:48 +00:00
|
|
|
}
|
2001-09-15 15:54:24 +00:00
|
|
|
|
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
|
|
|
{
|
|
|
|
FontSpec *font = conf_get_fontspec(conf, CONF_font);
|
|
|
|
FontSpec *prev_font = conf_get_fontspec(prev_conf,
|
|
|
|
CONF_font);
|
|
|
|
|
|
|
|
if (!strcmp(font->name, prev_font->name) ||
|
|
|
|
!strcmp(conf_get_str(conf, CONF_line_codepage),
|
|
|
|
conf_get_str(prev_conf, CONF_line_codepage)) ||
|
|
|
|
font->isbold != prev_font->isbold ||
|
|
|
|
font->height != prev_font->height ||
|
|
|
|
font->charset != prev_font->charset ||
|
|
|
|
conf_get_int(conf, CONF_font_quality) !=
|
|
|
|
conf_get_int(prev_conf, CONF_font_quality) ||
|
|
|
|
conf_get_int(conf, CONF_vtmode) !=
|
|
|
|
conf_get_int(prev_conf, CONF_vtmode) ||
|
|
|
|
conf_get_int(conf, CONF_bold_colour) !=
|
|
|
|
conf_get_int(prev_conf, CONF_bold_colour) ||
|
|
|
|
resize_action == RESIZE_DISABLED ||
|
|
|
|
resize_action == RESIZE_EITHER ||
|
|
|
|
resize_action != conf_get_int(prev_conf,
|
|
|
|
CONF_resize_action))
|
|
|
|
init_lvl = 2;
|
|
|
|
}
|
2001-09-15 15:54:24 +00:00
|
|
|
|
|
|
|
InvalidateRect(hwnd, NULL, TRUE);
|
|
|
|
reset_window(init_lvl);
|
2001-10-28 09:57:47 +00:00
|
|
|
net_pending_errors();
|
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
|
|
|
|
|
|
|
conf_free(prev_conf);
|
2001-05-06 14:35:20 +00:00
|
|
|
}
|
|
|
|
break;
|
2000-11-21 19:28:25 +00:00
|
|
|
case IDM_COPYALL:
|
2002-10-22 16:11:33 +00:00
|
|
|
term_copyall(term);
|
2000-11-21 19:28:25 +00:00
|
|
|
break;
|
2003-11-19 20:48:30 +00:00
|
|
|
case IDM_PASTE:
|
2008-12-29 20:04:42 +00:00
|
|
|
request_paste(NULL);
|
2003-11-19 20:48:30 +00:00
|
|
|
break;
|
2001-05-06 14:35:20 +00:00
|
|
|
case IDM_CLRSB:
|
2002-10-22 16:11:33 +00:00
|
|
|
term_clrsb(term);
|
2001-05-06 14:35:20 +00:00
|
|
|
break;
|
|
|
|
case IDM_RESET:
|
2006-02-19 14:59:48 +00:00
|
|
|
term_pwron(term, TRUE);
|
2004-08-14 13:04:18 +00:00
|
|
|
if (ldisc)
|
|
|
|
ldisc_send(ldisc, NULL, 0, 0);
|
2001-05-06 14:35:20 +00:00
|
|
|
break;
|
1999-01-08 13:02:13 +00:00
|
|
|
case IDM_ABOUT:
|
2001-05-06 14:35:20 +00:00
|
|
|
showabout(hwnd);
|
1999-01-08 13:02:13 +00:00
|
|
|
break;
|
2001-12-06 13:28:02 +00:00
|
|
|
case IDM_HELP:
|
2006-12-17 11:16:07 +00:00
|
|
|
launch_help(hwnd, NULL);
|
2001-12-06 13:28:02 +00:00
|
|
|
break;
|
2001-11-21 22:31:05 +00:00
|
|
|
case SC_MOUSEMENU:
|
|
|
|
/*
|
|
|
|
* We get this if the System menu has been activated
|
|
|
|
* using the mouse.
|
|
|
|
*/
|
|
|
|
show_mouseptr(1);
|
|
|
|
break;
|
2001-09-07 21:39:03 +00:00
|
|
|
case SC_KEYMENU:
|
|
|
|
/*
|
2001-11-21 22:31:05 +00:00
|
|
|
* We get this if the System menu has been activated
|
|
|
|
* using the keyboard. This might happen from within
|
|
|
|
* TranslateKey, in which case it really wants to be
|
|
|
|
* followed by a `space' character to actually _bring
|
|
|
|
* the menu up_ rather than just sitting there in
|
|
|
|
* `ready to appear' state.
|
2001-09-07 21:39:03 +00:00
|
|
|
*/
|
2001-11-21 22:31:05 +00:00
|
|
|
show_mouseptr(1); /* make sure pointer is visible */
|
2001-09-07 21:39:03 +00:00
|
|
|
if( lParam == 0 )
|
|
|
|
PostMessage(hwnd, WM_CHAR, ' ', 0);
|
|
|
|
break;
|
2001-10-17 21:21:03 +00:00
|
|
|
case IDM_FULLSCREEN:
|
2001-12-07 21:21:03 +00:00
|
|
|
flip_full_screen();
|
|
|
|
break;
|
2001-05-06 14:35:20 +00:00
|
|
|
default:
|
2004-11-02 17:44:06 +00:00
|
|
|
if (wParam >= IDM_SAVED_MIN && wParam < IDM_SAVED_MAX) {
|
2001-05-06 14:35:20 +00:00
|
|
|
SendMessage(hwnd, WM_SYSCOMMAND, IDM_SAVEDSESS, wParam);
|
|
|
|
}
|
2003-04-04 20:21:05 +00:00
|
|
|
if (wParam >= IDM_SPECIAL_MIN && wParam <= IDM_SPECIAL_MAX) {
|
|
|
|
int i = (wParam - IDM_SPECIAL_MIN) / 0x10;
|
|
|
|
/*
|
|
|
|
* Ensure we haven't been sent a bogus SYSCOMMAND
|
|
|
|
* which would cause us to reference invalid memory
|
|
|
|
* and crash. Perhaps I'm just too paranoid here.
|
|
|
|
*/
|
2004-10-17 21:22:22 +00:00
|
|
|
if (i >= n_specials)
|
|
|
|
break;
|
|
|
|
if (back)
|
|
|
|
back->special(backhandle, specials[i].code);
|
|
|
|
net_pending_errors();
|
2003-04-04 20:21:05 +00:00
|
|
|
}
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
break;
|
1999-01-08 13:10:19 +00:00
|
|
|
|
|
|
|
#define X_POS(l) ((int)(short)LOWORD(l))
|
|
|
|
#define Y_POS(l) ((int)(short)HIWORD(l))
|
|
|
|
|
2001-09-15 15:54:24 +00:00
|
|
|
#define TO_CHR_X(x) ((((x)<0 ? (x)-font_width+1 : (x))-offset_width) / font_width)
|
|
|
|
#define TO_CHR_Y(y) ((((y)<0 ? (y)-font_height+1: (y))-offset_height) / font_height)
|
1999-01-08 13:02:13 +00:00
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
case WM_RBUTTONDOWN:
|
2001-05-06 14:20:41 +00:00
|
|
|
case WM_LBUTTONUP:
|
|
|
|
case WM_MBUTTONUP:
|
1999-01-08 13:02:13 +00:00
|
|
|
case WM_RBUTTONUP:
|
2003-11-20 18:41:12 +00:00
|
|
|
if (message == WM_RBUTTONDOWN &&
|
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
|
|
|
((wParam & MK_CONTROL) ||
|
|
|
|
(conf_get_int(conf, CONF_mouse_is_xterm) == 2))) {
|
2003-11-19 20:48:30 +00:00
|
|
|
POINT cursorpos;
|
|
|
|
|
2003-11-20 18:41:12 +00:00
|
|
|
show_mouseptr(1); /* make sure pointer is visible */
|
2003-11-19 20:48:30 +00:00
|
|
|
GetCursorPos(&cursorpos);
|
|
|
|
TrackPopupMenu(popup_menus[CTXMENU].menu,
|
|
|
|
TPM_LEFTALIGN | TPM_TOPALIGN | TPM_RIGHTBUTTON,
|
|
|
|
cursorpos.x, cursorpos.y,
|
|
|
|
0, hwnd, NULL);
|
|
|
|
break;
|
|
|
|
}
|
2001-05-06 14:20:41 +00:00
|
|
|
{
|
|
|
|
int button, press;
|
2001-10-31 18:50:09 +00:00
|
|
|
|
2001-05-06 14:20:41 +00:00
|
|
|
switch (message) {
|
2001-05-06 14:35:20 +00:00
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
button = MBT_LEFT;
|
2009-01-21 18:47:03 +00:00
|
|
|
wParam |= MK_LBUTTON;
|
2001-05-06 14:35:20 +00:00
|
|
|
press = 1;
|
|
|
|
break;
|
|
|
|
case WM_MBUTTONDOWN:
|
|
|
|
button = MBT_MIDDLE;
|
2009-01-21 18:47:03 +00:00
|
|
|
wParam |= MK_MBUTTON;
|
2001-05-06 14:35:20 +00:00
|
|
|
press = 1;
|
|
|
|
break;
|
|
|
|
case WM_RBUTTONDOWN:
|
|
|
|
button = MBT_RIGHT;
|
2009-01-21 18:47:03 +00:00
|
|
|
wParam |= MK_RBUTTON;
|
2001-05-06 14:35:20 +00:00
|
|
|
press = 1;
|
|
|
|
break;
|
|
|
|
case WM_LBUTTONUP:
|
|
|
|
button = MBT_LEFT;
|
2009-01-21 18:47:03 +00:00
|
|
|
wParam &= ~MK_LBUTTON;
|
2001-05-06 14:35:20 +00:00
|
|
|
press = 0;
|
|
|
|
break;
|
|
|
|
case WM_MBUTTONUP:
|
|
|
|
button = MBT_MIDDLE;
|
2009-01-21 18:47:03 +00:00
|
|
|
wParam &= ~MK_MBUTTON;
|
2001-05-06 14:35:20 +00:00
|
|
|
press = 0;
|
|
|
|
break;
|
|
|
|
case WM_RBUTTONUP:
|
|
|
|
button = MBT_RIGHT;
|
2009-01-21 18:47:03 +00:00
|
|
|
wParam &= ~MK_RBUTTON;
|
2001-05-06 14:35:20 +00:00
|
|
|
press = 0;
|
|
|
|
break;
|
2001-05-13 14:02:28 +00:00
|
|
|
default:
|
|
|
|
button = press = 0; /* shouldn't happen */
|
2001-05-06 14:20:41 +00:00
|
|
|
}
|
|
|
|
show_mouseptr(1);
|
2001-11-25 10:24:29 +00:00
|
|
|
/*
|
|
|
|
* Special case: in full-screen mode, if the left
|
|
|
|
* button is clicked in the very top left corner of the
|
|
|
|
* window, we put up the System menu instead of doing
|
|
|
|
* selection.
|
|
|
|
*/
|
2004-01-20 19:41:43 +00:00
|
|
|
{
|
|
|
|
char mouse_on_hotspot = 0;
|
|
|
|
POINT pt;
|
|
|
|
|
|
|
|
GetCursorPos(&pt);
|
|
|
|
#ifndef NO_MULTIMON
|
|
|
|
{
|
|
|
|
HMONITOR mon;
|
|
|
|
MONITORINFO mi;
|
|
|
|
|
|
|
|
mon = MonitorFromPoint(pt, MONITOR_DEFAULTTONULL);
|
|
|
|
|
|
|
|
if (mon != NULL) {
|
|
|
|
mi.cbSize = sizeof(MONITORINFO);
|
|
|
|
GetMonitorInfo(mon, &mi);
|
|
|
|
|
|
|
|
if (mi.rcMonitor.left == pt.x &&
|
|
|
|
mi.rcMonitor.top == pt.y) {
|
|
|
|
mouse_on_hotspot = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
if (pt.x == 0 && pt.y == 0) {
|
|
|
|
mouse_on_hotspot = 1;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
if (is_full_screen() && press &&
|
|
|
|
button == MBT_LEFT && mouse_on_hotspot) {
|
|
|
|
SendMessage(hwnd, WM_SYSCOMMAND, SC_MOUSEMENU,
|
|
|
|
MAKELPARAM(pt.x, pt.y));
|
|
|
|
return 0;
|
|
|
|
}
|
2001-11-25 10:24:29 +00:00
|
|
|
}
|
2004-01-20 19:41:43 +00:00
|
|
|
|
2001-05-06 14:20:41 +00:00
|
|
|
if (press) {
|
2001-05-06 14:35:20 +00:00
|
|
|
click(button,
|
|
|
|
TO_CHR_X(X_POS(lParam)), TO_CHR_Y(Y_POS(lParam)),
|
2001-10-31 18:50:09 +00:00
|
|
|
wParam & MK_SHIFT, wParam & MK_CONTROL,
|
|
|
|
is_alt_pressed());
|
2001-05-06 14:20:41 +00:00
|
|
|
SetCapture(hwnd);
|
|
|
|
} else {
|
2003-01-25 16:16:45 +00:00
|
|
|
term_mouse(term, button, translate_button(button), MA_RELEASE,
|
2001-05-06 14:35:20 +00:00
|
|
|
TO_CHR_X(X_POS(lParam)),
|
|
|
|
TO_CHR_Y(Y_POS(lParam)), wParam & MK_SHIFT,
|
2001-10-31 18:50:09 +00:00
|
|
|
wParam & MK_CONTROL, is_alt_pressed());
|
2009-01-21 18:47:03 +00:00
|
|
|
if (!(wParam & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON)))
|
|
|
|
ReleaseCapture();
|
2001-05-06 14:20:41 +00:00
|
|
|
}
|
|
|
|
}
|
1999-01-08 13:02:13 +00:00
|
|
|
return 0;
|
|
|
|
case WM_MOUSEMOVE:
|
2004-07-25 19:52:07 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Windows seems to like to occasionally send MOUSEMOVE
|
|
|
|
* events even if the mouse hasn't moved. Don't unhide
|
|
|
|
* the mouse pointer in this case.
|
|
|
|
*/
|
|
|
|
static WPARAM wp = 0;
|
|
|
|
static LPARAM lp = 0;
|
|
|
|
if (wParam != wp || lParam != lp ||
|
|
|
|
last_mousemove != WM_MOUSEMOVE) {
|
|
|
|
show_mouseptr(1);
|
|
|
|
wp = wParam; lp = lParam;
|
|
|
|
last_mousemove = WM_MOUSEMOVE;
|
|
|
|
}
|
|
|
|
}
|
1999-01-08 13:02:13 +00:00
|
|
|
/*
|
|
|
|
* Add the mouse position and message time to the random
|
2000-10-23 15:20:05 +00:00
|
|
|
* number noise.
|
1999-01-08 13:02:13 +00:00
|
|
|
*/
|
2001-05-06 14:35:20 +00:00
|
|
|
noise_ultralight(lParam);
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2001-12-29 14:05:07 +00:00
|
|
|
if (wParam & (MK_LBUTTON | MK_MBUTTON | MK_RBUTTON) &&
|
|
|
|
GetCapture() == hwnd) {
|
1999-01-08 13:02:13 +00:00
|
|
|
Mouse_Button b;
|
|
|
|
if (wParam & MK_LBUTTON)
|
2001-05-13 15:01:36 +00:00
|
|
|
b = MBT_LEFT;
|
1999-01-08 13:02:13 +00:00
|
|
|
else if (wParam & MK_MBUTTON)
|
2001-05-13 15:01:36 +00:00
|
|
|
b = MBT_MIDDLE;
|
1999-01-08 13:02:13 +00:00
|
|
|
else
|
2001-05-13 15:01:36 +00:00
|
|
|
b = MBT_RIGHT;
|
2003-01-25 16:16:45 +00:00
|
|
|
term_mouse(term, b, translate_button(b), MA_DRAG,
|
|
|
|
TO_CHR_X(X_POS(lParam)),
|
2001-05-06 14:35:20 +00:00
|
|
|
TO_CHR_Y(Y_POS(lParam)), wParam & MK_SHIFT,
|
2001-10-31 18:50:09 +00:00
|
|
|
wParam & MK_CONTROL, is_alt_pressed());
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
return 0;
|
2001-03-02 09:25:14 +00:00
|
|
|
case WM_NCMOUSEMOVE:
|
2004-07-25 19:52:07 +00:00
|
|
|
{
|
|
|
|
static WPARAM wp = 0;
|
|
|
|
static LPARAM lp = 0;
|
|
|
|
if (wParam != wp || lParam != lp ||
|
|
|
|
last_mousemove != WM_NCMOUSEMOVE) {
|
|
|
|
show_mouseptr(1);
|
|
|
|
wp = wParam; lp = lParam;
|
|
|
|
last_mousemove = WM_NCMOUSEMOVE;
|
|
|
|
}
|
|
|
|
}
|
2001-05-06 14:35:20 +00:00
|
|
|
noise_ultralight(lParam);
|
2003-11-06 14:17:56 +00:00
|
|
|
break;
|
1999-01-08 13:02:13 +00:00
|
|
|
case WM_IGNORE_CLIP:
|
|
|
|
ignore_clip = wParam; /* don't panic on DESTROYCLIPBOARD */
|
|
|
|
break;
|
|
|
|
case WM_DESTROYCLIPBOARD:
|
|
|
|
if (!ignore_clip)
|
2002-10-22 16:11:33 +00:00
|
|
|
term_deselect(term);
|
1999-01-08 13:02:13 +00:00
|
|
|
ignore_clip = FALSE;
|
|
|
|
return 0;
|
|
|
|
case WM_PAINT:
|
|
|
|
{
|
|
|
|
PAINTSTRUCT p;
|
2004-11-27 13:20:21 +00:00
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
HideCaret(hwnd);
|
|
|
|
hdc = BeginPaint(hwnd, &p);
|
1999-01-08 13:02:13 +00:00
|
|
|
if (pal) {
|
2001-05-06 14:35:20 +00:00
|
|
|
SelectPalette(hdc, pal, TRUE);
|
|
|
|
RealizePalette(hdc);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
2004-11-27 13:20:21 +00:00
|
|
|
|
2005-03-17 20:01:28 +00:00
|
|
|
/*
|
|
|
|
* We have to be careful about term_paint(). It will
|
|
|
|
* set a bunch of character cells to INVALID and then
|
|
|
|
* call do_paint(), which will redraw those cells and
|
|
|
|
* _then mark them as done_. This may not be accurate:
|
|
|
|
* when painting in WM_PAINT context we are restricted
|
|
|
|
* to the rectangle which has just been exposed - so if
|
|
|
|
* that only covers _part_ of a character cell and the
|
|
|
|
* rest of it was already visible, that remainder will
|
|
|
|
* not be redrawn at all. Accordingly, we must not
|
|
|
|
* paint any character cell in a WM_PAINT context which
|
|
|
|
* already has a pending update due to terminal output.
|
|
|
|
* The simplest solution to this - and many, many
|
|
|
|
* thanks to Hung-Te Lin for working all this out - is
|
|
|
|
* not to do any actual painting at _all_ if there's a
|
|
|
|
* pending terminal update: just mark the relevant
|
|
|
|
* character cells as INVALID and wait for the
|
|
|
|
* scheduled full update to sort it out.
|
|
|
|
*
|
|
|
|
* I have a suspicion this isn't the _right_ solution.
|
|
|
|
* An alternative approach would be to have terminal.c
|
|
|
|
* separately track what _should_ be on the terminal
|
|
|
|
* screen and what _is_ on the terminal screen, and
|
|
|
|
* have two completely different types of redraw (one
|
|
|
|
* for full updates, which syncs the former with the
|
|
|
|
* terminal itself, and one for WM_PAINT which syncs
|
|
|
|
* the latter with the former); yet another possibility
|
|
|
|
* would be to have the Windows front end do what the
|
|
|
|
* GTK one already does, and maintain a bitmap of the
|
|
|
|
* current terminal appearance so that WM_PAINT becomes
|
|
|
|
* completely trivial. However, this should do for now.
|
|
|
|
*/
|
2002-10-22 16:11:33 +00:00
|
|
|
term_paint(term, hdc,
|
2001-09-15 15:54:24 +00:00
|
|
|
(p.rcPaint.left-offset_width)/font_width,
|
|
|
|
(p.rcPaint.top-offset_height)/font_height,
|
|
|
|
(p.rcPaint.right-offset_width-1)/font_width,
|
2002-10-26 14:06:52 +00:00
|
|
|
(p.rcPaint.bottom-offset_height-1)/font_height,
|
2005-03-17 20:01:28 +00:00
|
|
|
!term->window_update_pending);
|
2001-09-15 15:54:24 +00:00
|
|
|
|
|
|
|
if (p.fErase ||
|
|
|
|
p.rcPaint.left < offset_width ||
|
|
|
|
p.rcPaint.top < offset_height ||
|
2002-10-22 16:11:33 +00:00
|
|
|
p.rcPaint.right >= offset_width + font_width*term->cols ||
|
|
|
|
p.rcPaint.bottom>= offset_height + font_height*term->rows)
|
2001-09-15 15:54:24 +00:00
|
|
|
{
|
|
|
|
HBRUSH fillcolour, oldbrush;
|
|
|
|
HPEN edge, oldpen;
|
|
|
|
fillcolour = CreateSolidBrush (
|
2004-12-19 23:37:30 +00:00
|
|
|
colours[ATTR_DEFBG>>ATTR_BGSHIFT]);
|
2001-09-15 15:54:24 +00:00
|
|
|
oldbrush = SelectObject(hdc, fillcolour);
|
|
|
|
edge = CreatePen(PS_SOLID, 0,
|
2004-12-19 23:37:30 +00:00
|
|
|
colours[ATTR_DEFBG>>ATTR_BGSHIFT]);
|
2001-09-15 15:54:24 +00:00
|
|
|
oldpen = SelectObject(hdc, edge);
|
|
|
|
|
2002-09-15 22:18:02 +00:00
|
|
|
/*
|
|
|
|
* Jordan Russell reports that this apparently
|
|
|
|
* ineffectual IntersectClipRect() call masks a
|
|
|
|
* Windows NT/2K bug causing strange display
|
|
|
|
* problems when the PuTTY window is taller than
|
|
|
|
* the primary monitor. It seems harmless enough...
|
|
|
|
*/
|
|
|
|
IntersectClipRect(hdc,
|
|
|
|
p.rcPaint.left, p.rcPaint.top,
|
|
|
|
p.rcPaint.right, p.rcPaint.bottom);
|
|
|
|
|
2001-09-15 15:54:24 +00:00
|
|
|
ExcludeClipRect(hdc,
|
|
|
|
offset_width, offset_height,
|
2002-10-22 16:11:33 +00:00
|
|
|
offset_width+font_width*term->cols,
|
|
|
|
offset_height+font_height*term->rows);
|
2001-09-15 15:54:24 +00:00
|
|
|
|
|
|
|
Rectangle(hdc, p.rcPaint.left, p.rcPaint.top,
|
|
|
|
p.rcPaint.right, p.rcPaint.bottom);
|
|
|
|
|
2004-12-30 15:29:38 +00:00
|
|
|
/* SelectClipRgn(hdc, NULL); */
|
2001-09-15 15:54:24 +00:00
|
|
|
|
|
|
|
SelectObject(hdc, oldbrush);
|
|
|
|
DeleteObject(fillcolour);
|
|
|
|
SelectObject(hdc, oldpen);
|
|
|
|
DeleteObject(edge);
|
|
|
|
}
|
2001-05-06 14:35:20 +00:00
|
|
|
SelectObject(hdc, GetStockObject(SYSTEM_FONT));
|
|
|
|
SelectObject(hdc, GetStockObject(WHITE_PEN));
|
|
|
|
EndPaint(hwnd, &p);
|
|
|
|
ShowCaret(hwnd);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
case WM_NETEVENT:
|
2007-01-07 12:40:21 +00:00
|
|
|
/* Notice we can get multiple netevents, FD_READ, FD_WRITE etc
|
|
|
|
* but the only one that's likely to try to overload us is FD_READ.
|
|
|
|
* This means buffering just one is fine.
|
|
|
|
*/
|
|
|
|
if (pending_netevent)
|
|
|
|
enact_pending_netevent();
|
|
|
|
|
|
|
|
pending_netevent = TRUE;
|
|
|
|
pend_netevent_wParam = wParam;
|
|
|
|
pend_netevent_lParam = lParam;
|
|
|
|
if (WSAGETSELECTEVENT(lParam) != FD_READ)
|
|
|
|
enact_pending_netevent();
|
|
|
|
|
2004-11-27 13:20:21 +00:00
|
|
|
net_pending_errors();
|
1999-01-08 13:02:13 +00:00
|
|
|
return 0;
|
|
|
|
case WM_SETFOCUS:
|
2004-11-27 19:34:45 +00:00
|
|
|
term_set_focus(term, TRUE);
|
2001-05-06 14:35:20 +00:00
|
|
|
CreateCaret(hwnd, caretbm, font_width, font_height);
|
|
|
|
ShowCaret(hwnd);
|
2001-05-13 14:42:17 +00:00
|
|
|
flash_window(0); /* stop */
|
2001-05-06 14:35:20 +00:00
|
|
|
compose_state = 0;
|
2002-10-22 16:11:33 +00:00
|
|
|
term_update(term);
|
1999-01-08 13:02:13 +00:00
|
|
|
break;
|
|
|
|
case WM_KILLFOCUS:
|
2001-05-06 14:35:20 +00:00
|
|
|
show_mouseptr(1);
|
2004-11-27 19:34:45 +00:00
|
|
|
term_set_focus(term, FALSE);
|
2001-05-06 14:35:20 +00:00
|
|
|
DestroyCaret();
|
2001-12-20 14:18:01 +00:00
|
|
|
caret_x = caret_y = -1; /* ensure caret is replaced next time */
|
2002-10-22 16:11:33 +00:00
|
|
|
term_update(term);
|
1999-01-08 13:02:13 +00:00
|
|
|
break;
|
1999-11-03 14:08:26 +00:00
|
|
|
case WM_ENTERSIZEMOVE:
|
2001-09-15 15:54:24 +00:00
|
|
|
#ifdef RDB_DEBUG_PATCH
|
|
|
|
debug((27, "WM_ENTERSIZEMOVE"));
|
|
|
|
#endif
|
2001-05-06 14:35:20 +00:00
|
|
|
EnableSizeTip(1);
|
|
|
|
resizing = TRUE;
|
2001-01-07 17:18:24 +00:00
|
|
|
need_backend_resize = FALSE;
|
2001-05-06 14:35:20 +00:00
|
|
|
break;
|
1999-11-03 14:08:26 +00:00
|
|
|
case WM_EXITSIZEMOVE:
|
2001-05-06 14:35:20 +00:00
|
|
|
EnableSizeTip(0);
|
|
|
|
resizing = FALSE;
|
2001-09-15 15:54:24 +00:00
|
|
|
#ifdef RDB_DEBUG_PATCH
|
|
|
|
debug((27, "WM_EXITSIZEMOVE"));
|
|
|
|
#endif
|
|
|
|
if (need_backend_resize) {
|
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
|
|
|
term_size(term, conf_get_int(conf, CONF_height),
|
|
|
|
conf_get_int(conf, CONF_width),
|
|
|
|
conf_get_int(conf, CONF_savelines));
|
2001-09-15 15:54:24 +00:00
|
|
|
InvalidateRect(hwnd, NULL, TRUE);
|
|
|
|
}
|
2001-05-06 14:35:20 +00:00
|
|
|
break;
|
1999-01-08 13:02:13 +00:00
|
|
|
case WM_SIZING:
|
2001-09-15 15:54:24 +00:00
|
|
|
/*
|
|
|
|
* This does two jobs:
|
|
|
|
* 1) Keep the sizetip uptodate
|
|
|
|
* 2) Make sure the window size is _stepped_ in units of the font size.
|
|
|
|
*/
|
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
|
|
|
resize_action = conf_get_int(conf, CONF_resize_action);
|
|
|
|
if (resize_action == RESIZE_TERM ||
|
|
|
|
(resize_action == RESIZE_EITHER && !is_alt_pressed())) {
|
1999-01-08 13:02:13 +00:00
|
|
|
int width, height, w, h, ew, eh;
|
2001-05-06 14:35:20 +00:00
|
|
|
LPRECT r = (LPRECT) lParam;
|
1999-01-08 13:02:13 +00:00
|
|
|
|
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
|
|
|
if (!need_backend_resize && resize_action == RESIZE_EITHER &&
|
|
|
|
(conf_get_int(conf, CONF_height) != term->rows ||
|
|
|
|
conf_get_int(conf, CONF_width) != term->cols)) {
|
2001-09-15 15:54:24 +00:00
|
|
|
/*
|
2001-11-25 18:39:57 +00:00
|
|
|
* Great! It seems that both the terminal size and the
|
|
|
|
* font size have been changed and the user is now dragging.
|
|
|
|
*
|
|
|
|
* It will now be difficult to get back to the configured
|
|
|
|
* font size!
|
|
|
|
*
|
|
|
|
* This would be easier but it seems to be too confusing.
|
|
|
|
*/
|
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
|
|
|
conf_set_int(conf, CONF_height, term->rows);
|
|
|
|
conf_set_int(conf, CONF_width, term->cols);
|
2001-11-25 18:39:57 +00:00
|
|
|
|
2001-09-15 15:54:24 +00:00
|
|
|
InvalidateRect(hwnd, NULL, TRUE);
|
|
|
|
need_backend_resize = TRUE;
|
|
|
|
}
|
|
|
|
|
1999-01-08 13:02:13 +00:00
|
|
|
width = r->right - r->left - extra_width;
|
|
|
|
height = r->bottom - r->top - extra_height;
|
2001-05-06 14:35:20 +00:00
|
|
|
w = (width + font_width / 2) / font_width;
|
|
|
|
if (w < 1)
|
|
|
|
w = 1;
|
|
|
|
h = (height + font_height / 2) / font_height;
|
|
|
|
if (h < 1)
|
|
|
|
h = 1;
|
|
|
|
UpdateSizeTip(hwnd, w, h);
|
1999-01-08 13:02:13 +00:00
|
|
|
ew = width - w * font_width;
|
|
|
|
eh = height - h * font_height;
|
|
|
|
if (ew != 0) {
|
|
|
|
if (wParam == WMSZ_LEFT ||
|
2001-05-06 14:35:20 +00:00
|
|
|
wParam == WMSZ_BOTTOMLEFT || wParam == WMSZ_TOPLEFT)
|
1999-01-08 13:02:13 +00:00
|
|
|
r->left += ew;
|
|
|
|
else
|
|
|
|
r->right -= ew;
|
|
|
|
}
|
|
|
|
if (eh != 0) {
|
|
|
|
if (wParam == WMSZ_TOP ||
|
2001-05-06 14:35:20 +00:00
|
|
|
wParam == WMSZ_TOPRIGHT || wParam == WMSZ_TOPLEFT)
|
1999-01-08 13:02:13 +00:00
|
|
|
r->top += eh;
|
|
|
|
else
|
|
|
|
r->bottom -= eh;
|
|
|
|
}
|
|
|
|
if (ew || eh)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0;
|
2001-09-15 15:54:24 +00:00
|
|
|
} else {
|
|
|
|
int width, height, w, h, rv = 0;
|
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
|
|
|
int window_border = conf_get_int(conf, CONF_window_border);
|
|
|
|
int ex_width = extra_width + (window_border - offset_width) * 2;
|
|
|
|
int ex_height = extra_height + (window_border - offset_height) * 2;
|
2001-09-15 15:54:24 +00:00
|
|
|
LPRECT r = (LPRECT) lParam;
|
|
|
|
|
|
|
|
width = r->right - r->left - ex_width;
|
|
|
|
height = r->bottom - r->top - ex_height;
|
|
|
|
|
2002-10-22 16:11:33 +00:00
|
|
|
w = (width + term->cols/2)/term->cols;
|
|
|
|
h = (height + term->rows/2)/term->rows;
|
|
|
|
if ( r->right != r->left + w*term->cols + ex_width)
|
2001-09-15 15:54:24 +00:00
|
|
|
rv = 1;
|
|
|
|
|
|
|
|
if (wParam == WMSZ_LEFT ||
|
|
|
|
wParam == WMSZ_BOTTOMLEFT || wParam == WMSZ_TOPLEFT)
|
2002-10-22 16:11:33 +00:00
|
|
|
r->left = r->right - w*term->cols - ex_width;
|
2001-09-15 15:54:24 +00:00
|
|
|
else
|
2002-10-22 16:11:33 +00:00
|
|
|
r->right = r->left + w*term->cols + ex_width;
|
2001-09-15 15:54:24 +00:00
|
|
|
|
2002-10-22 16:11:33 +00:00
|
|
|
if (r->bottom != r->top + h*term->rows + ex_height)
|
2001-09-15 15:54:24 +00:00
|
|
|
rv = 1;
|
|
|
|
|
|
|
|
if (wParam == WMSZ_TOP ||
|
|
|
|
wParam == WMSZ_TOPRIGHT || wParam == WMSZ_TOPLEFT)
|
2002-10-22 16:11:33 +00:00
|
|
|
r->top = r->bottom - h*term->rows - ex_height;
|
2001-09-15 15:54:24 +00:00
|
|
|
else
|
2002-10-22 16:11:33 +00:00
|
|
|
r->bottom = r->top + h*term->rows + ex_height;
|
2001-09-15 15:54:24 +00:00
|
|
|
|
|
|
|
return rv;
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
2001-05-06 14:35:20 +00:00
|
|
|
/* break; (never reached) */
|
2001-12-07 21:21:03 +00:00
|
|
|
case WM_FULLSCR_ON_MAX:
|
|
|
|
fullscr_on_max = TRUE;
|
|
|
|
break;
|
2001-12-20 14:18:01 +00:00
|
|
|
case WM_MOVE:
|
|
|
|
sys_cursor_update();
|
|
|
|
break;
|
1999-01-08 13:02:13 +00:00
|
|
|
case WM_SIZE:
|
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
|
|
|
resize_action = conf_get_int(conf, CONF_resize_action);
|
2001-09-15 15:54:24 +00:00
|
|
|
#ifdef RDB_DEBUG_PATCH
|
|
|
|
debug((27, "WM_SIZE %s (%d,%d)",
|
|
|
|
(wParam == SIZE_MINIMIZED) ? "SIZE_MINIMIZED":
|
|
|
|
(wParam == SIZE_MAXIMIZED) ? "SIZE_MAXIMIZED":
|
|
|
|
(wParam == SIZE_RESTORED && resizing) ? "to":
|
|
|
|
(wParam == SIZE_RESTORED) ? "SIZE_RESTORED":
|
|
|
|
"...",
|
|
|
|
LOWORD(lParam), HIWORD(lParam)));
|
|
|
|
#endif
|
2001-11-25 18:39:57 +00:00
|
|
|
if (wParam == SIZE_MINIMIZED)
|
2001-05-06 14:35:20 +00:00
|
|
|
SetWindowText(hwnd,
|
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
|
|
|
conf_get_int(conf, CONF_win_name_always) ?
|
|
|
|
window_name : icon_name);
|
1999-01-08 13:02:13 +00:00
|
|
|
if (wParam == SIZE_RESTORED || wParam == SIZE_MAXIMIZED)
|
2001-05-06 14:35:20 +00:00
|
|
|
SetWindowText(hwnd, window_name);
|
2010-12-27 12:58:39 +00:00
|
|
|
if (wParam == SIZE_RESTORED) {
|
|
|
|
processed_resize = FALSE;
|
2001-12-11 18:47:55 +00:00
|
|
|
clear_full_screen();
|
2010-12-27 12:58:39 +00:00
|
|
|
if (processed_resize) {
|
|
|
|
/*
|
|
|
|
* Inhibit normal processing of this WM_SIZE; a
|
|
|
|
* secondary one was triggered just now by
|
|
|
|
* clear_full_screen which contained the correct
|
|
|
|
* client area size.
|
|
|
|
*/
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
2001-12-11 18:47:55 +00:00
|
|
|
if (wParam == SIZE_MAXIMIZED && fullscr_on_max) {
|
|
|
|
fullscr_on_max = FALSE;
|
2010-12-27 12:58:39 +00:00
|
|
|
processed_resize = FALSE;
|
2002-03-13 22:15:14 +00:00
|
|
|
make_full_screen();
|
2010-12-27 12:58:39 +00:00
|
|
|
if (processed_resize) {
|
|
|
|
/*
|
|
|
|
* Inhibit normal processing of this WM_SIZE; a
|
|
|
|
* secondary one was triggered just now by
|
|
|
|
* make_full_screen which contained the correct client
|
|
|
|
* area size.
|
|
|
|
*/
|
|
|
|
return 0;
|
|
|
|
}
|
2001-12-11 18:47:55 +00:00
|
|
|
}
|
2001-09-15 15:54:24 +00:00
|
|
|
|
2010-12-27 12:58:39 +00:00
|
|
|
processed_resize = TRUE;
|
|
|
|
|
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
|
|
|
if (resize_action == RESIZE_DISABLED) {
|
2001-09-15 15:54:24 +00:00
|
|
|
/* A resize, well it better be a minimize. */
|
|
|
|
reset_window(-1);
|
|
|
|
} else {
|
|
|
|
|
1999-02-10 11:11:11 +00:00
|
|
|
int width, height, w, h;
|
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
|
|
|
int window_border = conf_get_int(conf, CONF_window_border);
|
1999-01-08 13:02:13 +00:00
|
|
|
|
|
|
|
width = LOWORD(lParam);
|
|
|
|
height = HIWORD(lParam);
|
2001-09-15 15:54:24 +00:00
|
|
|
|
2010-12-22 15:49:33 +00:00
|
|
|
if (wParam == SIZE_MAXIMIZED && !was_zoomed) {
|
|
|
|
was_zoomed = 1;
|
|
|
|
prev_rows = term->rows;
|
|
|
|
prev_cols = term->cols;
|
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
|
|
|
if (resize_action == RESIZE_TERM) {
|
2010-12-22 15:49:33 +00:00
|
|
|
w = width / font_width;
|
|
|
|
if (w < 1) w = 1;
|
|
|
|
h = height / font_height;
|
|
|
|
if (h < 1) h = 1;
|
|
|
|
|
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
|
|
|
term_size(term, h, w, conf_get_int(conf, CONF_savelines));
|
2010-12-22 15:49:33 +00:00
|
|
|
}
|
|
|
|
reset_window(0);
|
|
|
|
} else if (wParam == SIZE_RESTORED && was_zoomed) {
|
|
|
|
was_zoomed = 0;
|
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
|
|
|
if (resize_action == RESIZE_TERM) {
|
|
|
|
w = (width-window_border*2) / font_width;
|
2010-12-22 16:14:11 +00:00
|
|
|
if (w < 1) w = 1;
|
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
|
|
|
h = (height-window_border*2) / font_height;
|
2010-12-22 16:14:11 +00:00
|
|
|
if (h < 1) h = 1;
|
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
|
|
|
term_size(term, h, w, conf_get_int(conf, CONF_savelines));
|
2010-12-23 15:44:20 +00:00
|
|
|
reset_window(2);
|
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
|
|
|
} else if (resize_action != RESIZE_FONT)
|
2010-12-22 15:49:33 +00:00
|
|
|
reset_window(2);
|
|
|
|
else
|
|
|
|
reset_window(0);
|
|
|
|
} else if (wParam == SIZE_MINIMIZED) {
|
|
|
|
/* do nothing */
|
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
|
|
|
} else if (resize_action == RESIZE_TERM ||
|
|
|
|
(resize_action == RESIZE_EITHER &&
|
2010-12-23 17:16:19 +00:00
|
|
|
!is_alt_pressed())) {
|
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
|
|
|
w = (width-window_border*2) / font_width;
|
2010-12-22 15:49:33 +00:00
|
|
|
if (w < 1) w = 1;
|
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
|
|
|
h = (height-window_border*2) / font_height;
|
2010-12-22 15:49:33 +00:00
|
|
|
if (h < 1) h = 1;
|
|
|
|
|
|
|
|
if (resizing) {
|
|
|
|
/*
|
|
|
|
* Don't call back->size in mid-resize. (To
|
|
|
|
* prevent massive numbers of resize events
|
|
|
|
* getting sent down the connection during an NT
|
|
|
|
* opaque drag.)
|
|
|
|
*/
|
2001-01-07 17:18:24 +00:00
|
|
|
need_backend_resize = TRUE;
|
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
|
|
|
conf_set_int(conf, CONF_height, h);
|
2011-07-17 22:35:08 +00:00
|
|
|
conf_set_int(conf, CONF_width, w);
|
2010-12-22 15:49:33 +00:00
|
|
|
} else {
|
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
|
|
|
term_size(term, h, w, conf_get_int(conf, CONF_savelines));
|
2010-12-22 15:49:33 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
reset_window(0);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
}
|
2001-12-20 14:18:01 +00:00
|
|
|
sys_cursor_update();
|
1999-01-08 13:02:13 +00:00
|
|
|
return 0;
|
|
|
|
case WM_VSCROLL:
|
|
|
|
switch (LOWORD(wParam)) {
|
2001-05-06 14:35:20 +00:00
|
|
|
case SB_BOTTOM:
|
2002-10-22 16:11:33 +00:00
|
|
|
term_scroll(term, -1, 0);
|
2001-05-06 14:35:20 +00:00
|
|
|
break;
|
|
|
|
case SB_TOP:
|
2002-10-22 16:11:33 +00:00
|
|
|
term_scroll(term, +1, 0);
|
2001-05-06 14:35:20 +00:00
|
|
|
break;
|
|
|
|
case SB_LINEDOWN:
|
2002-10-22 16:11:33 +00:00
|
|
|
term_scroll(term, 0, +1);
|
2001-05-06 14:35:20 +00:00
|
|
|
break;
|
|
|
|
case SB_LINEUP:
|
2002-10-22 16:11:33 +00:00
|
|
|
term_scroll(term, 0, -1);
|
2001-05-06 14:35:20 +00:00
|
|
|
break;
|
|
|
|
case SB_PAGEDOWN:
|
2002-10-22 16:11:33 +00:00
|
|
|
term_scroll(term, 0, +term->rows / 2);
|
2001-05-06 14:35:20 +00:00
|
|
|
break;
|
|
|
|
case SB_PAGEUP:
|
2002-10-22 16:11:33 +00:00
|
|
|
term_scroll(term, 0, -term->rows / 2);
|
2001-05-06 14:35:20 +00:00
|
|
|
break;
|
|
|
|
case SB_THUMBPOSITION:
|
|
|
|
case SB_THUMBTRACK:
|
2002-10-22 16:11:33 +00:00
|
|
|
term_scroll(term, 1, HIWORD(wParam));
|
2001-05-06 14:35:20 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_PALETTECHANGED:
|
1999-01-08 13:02:13 +00:00
|
|
|
if ((HWND) wParam != hwnd && pal != NULL) {
|
2002-10-26 12:58:13 +00:00
|
|
|
HDC hdc = get_ctx(NULL);
|
1999-01-08 13:02:13 +00:00
|
|
|
if (hdc) {
|
2001-05-06 14:35:20 +00:00
|
|
|
if (RealizePalette(hdc) > 0)
|
|
|
|
UpdateColors(hdc);
|
|
|
|
free_ctx(hdc);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_QUERYNEWPALETTE:
|
|
|
|
if (pal != NULL) {
|
2002-10-26 12:58:13 +00:00
|
|
|
HDC hdc = get_ctx(NULL);
|
1999-01-08 13:02:13 +00:00
|
|
|
if (hdc) {
|
2001-05-06 14:35:20 +00:00
|
|
|
if (RealizePalette(hdc) > 0)
|
|
|
|
UpdateColors(hdc);
|
|
|
|
free_ctx(hdc);
|
1999-01-08 13:02:13 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
case WM_KEYDOWN:
|
|
|
|
case WM_SYSKEYDOWN:
|
2000-07-26 12:13:51 +00:00
|
|
|
case WM_KEYUP:
|
|
|
|
case WM_SYSKEYUP:
|
1999-01-08 13:02:13 +00:00
|
|
|
/*
|
|
|
|
* Add the scan code and keypress timing to the random
|
2000-10-23 15:20:05 +00:00
|
|
|
* number noise.
|
1999-01-08 13:02:13 +00:00
|
|
|
*/
|
2001-05-06 14:35:20 +00:00
|
|
|
noise_ultralight(lParam);
|
1999-01-08 13:02:13 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We don't do TranslateMessage since it disassociates the
|
|
|
|
* resulting CHAR message from the KEYDOWN that sparked it,
|
|
|
|
* which we occasionally don't want. Instead, we process
|
|
|
|
* KEYDOWN, and call the Win32 translator functions so that
|
|
|
|
* we get the translations under _our_ control.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
unsigned char buf[20];
|
|
|
|
int len;
|
|
|
|
|
2005-03-23 01:08:18 +00:00
|
|
|
if (wParam == VK_PROCESSKEY) { /* IME PROCESS key */
|
|
|
|
if (message == WM_KEYDOWN) {
|
|
|
|
MSG m;
|
|
|
|
m.hwnd = hwnd;
|
|
|
|
m.message = WM_KEYDOWN;
|
|
|
|
m.wParam = wParam;
|
|
|
|
m.lParam = lParam & 0xdfff;
|
|
|
|
TranslateMessage(&m);
|
|
|
|
} else break; /* pass to Windows for default processing */
|
2001-05-06 14:35:20 +00:00
|
|
|
} else {
|
|
|
|
len = TranslateKey(message, wParam, lParam, buf);
|
2000-10-20 18:36:15 +00:00
|
|
|
if (len == -1)
|
2001-05-06 14:35:20 +00:00
|
|
|
return DefWindowProc(hwnd, message, wParam, lParam);
|
2001-08-25 17:09:23 +00:00
|
|
|
|
2001-09-07 20:32:33 +00:00
|
|
|
if (len != 0) {
|
2001-09-21 17:54:29 +00:00
|
|
|
/*
|
|
|
|
* Interrupt an ongoing paste. I'm not sure
|
|
|
|
* this is sensible, but for the moment it's
|
|
|
|
* preferable to having to faff about buffering
|
|
|
|
* things.
|
|
|
|
*/
|
2002-10-22 16:11:33 +00:00
|
|
|
term_nopaste(term);
|
2001-09-21 17:54:29 +00:00
|
|
|
|
2001-09-07 20:18:55 +00:00
|
|
|
/*
|
|
|
|
* We need not bother about stdin backlogs
|
|
|
|
* here, because in GUI PuTTY we can't do
|
|
|
|
* anything about it anyway; there's no means
|
|
|
|
* of asking Windows to hold off on KEYDOWN
|
|
|
|
* messages. We _have_ to buffer everything
|
|
|
|
* we're sent.
|
|
|
|
*/
|
2002-10-22 16:11:33 +00:00
|
|
|
term_seen_key_event(term);
|
2004-08-14 13:04:18 +00:00
|
|
|
if (ldisc)
|
|
|
|
ldisc_send(ldisc, buf, len, 1);
|
2001-05-06 14:35:20 +00:00
|
|
|
show_mouseptr(0);
|
2001-09-07 20:18:55 +00:00
|
|
|
}
|
2000-10-20 18:36:15 +00:00
|
|
|
}
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
2001-10-28 09:57:47 +00:00
|
|
|
net_pending_errors();
|
1999-01-08 13:02:13 +00:00
|
|
|
return 0;
|
2001-05-10 08:34:20 +00:00
|
|
|
case WM_INPUTLANGCHANGE:
|
2001-11-29 21:30:59 +00:00
|
|
|
/* wParam == Font number */
|
|
|
|
/* lParam == Locale */
|
|
|
|
set_input_locale((HKL)lParam);
|
2001-12-20 14:18:01 +00:00
|
|
|
sys_cursor_update();
|
2001-05-10 08:34:20 +00:00
|
|
|
break;
|
2005-03-21 01:05:38 +00:00
|
|
|
case WM_IME_STARTCOMPOSITION:
|
|
|
|
{
|
2001-11-24 11:56:24 +00:00
|
|
|
HIMC hImc = ImmGetContext(hwnd);
|
|
|
|
ImmSetCompositionFont(hImc, &lfont);
|
|
|
|
ImmReleaseContext(hwnd, hImc);
|
|
|
|
}
|
|
|
|
break;
|
2001-08-04 15:15:07 +00:00
|
|
|
case WM_IME_COMPOSITION:
|
|
|
|
{
|
|
|
|
HIMC hIMC;
|
|
|
|
int n;
|
|
|
|
char *buff;
|
2001-12-15 11:10:19 +00:00
|
|
|
|
2001-08-04 15:15:07 +00:00
|
|
|
if(osVersion.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ||
|
|
|
|
osVersion.dwPlatformId == VER_PLATFORM_WIN32s) break; /* no Unicode */
|
|
|
|
|
|
|
|
if ((lParam & GCS_RESULTSTR) == 0) /* Composition unfinished. */
|
|
|
|
break; /* fall back to DefWindowProc */
|
|
|
|
|
|
|
|
hIMC = ImmGetContext(hwnd);
|
|
|
|
n = ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, NULL, 0);
|
|
|
|
|
|
|
|
if (n > 0) {
|
2001-12-15 11:10:19 +00:00
|
|
|
int i;
|
2003-03-29 16:14:26 +00:00
|
|
|
buff = snewn(n, char);
|
2001-08-04 15:15:07 +00:00
|
|
|
ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, buff, n);
|
2001-12-15 11:10:19 +00:00
|
|
|
/*
|
|
|
|
* Jaeyoun Chung reports that Korean character
|
|
|
|
* input doesn't work correctly if we do a single
|
|
|
|
* luni_send() covering the whole of buff. So
|
|
|
|
* instead we luni_send the characters one by one.
|
|
|
|
*/
|
2002-10-22 16:11:33 +00:00
|
|
|
term_seen_key_event(term);
|
2002-10-20 13:23:30 +00:00
|
|
|
for (i = 0; i < n; i += 2) {
|
2004-08-14 13:04:18 +00:00
|
|
|
if (ldisc)
|
|
|
|
luni_send(ldisc, (unsigned short *)(buff+i), 1, 1);
|
2002-10-20 13:23:30 +00:00
|
|
|
}
|
2001-08-04 15:15:07 +00:00
|
|
|
free(buff);
|
|
|
|
}
|
|
|
|
ImmReleaseContext(hwnd, hIMC);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2001-05-10 08:34:20 +00:00
|
|
|
case WM_IME_CHAR:
|
|
|
|
if (wParam & 0xFF00) {
|
2000-10-20 18:36:15 +00:00
|
|
|
unsigned char buf[2];
|
|
|
|
|
|
|
|
buf[1] = wParam;
|
|
|
|
buf[0] = wParam >> 8;
|
2002-10-22 16:11:33 +00:00
|
|
|
term_seen_key_event(term);
|
2004-08-14 13:04:18 +00:00
|
|
|
if (ldisc)
|
|
|
|
lpage_send(ldisc, kbd_codepage, buf, 2, 1);
|
2001-05-10 08:34:20 +00:00
|
|
|
} else {
|
|
|
|
char c = (unsigned char) wParam;
|
2002-10-22 16:11:33 +00:00
|
|
|
term_seen_key_event(term);
|
2004-08-14 13:04:18 +00:00
|
|
|
if (ldisc)
|
|
|
|
lpage_send(ldisc, kbd_codepage, &c, 1, 1);
|
2000-10-20 18:36:15 +00:00
|
|
|
}
|
2001-05-10 08:34:20 +00:00
|
|
|
return (0);
|
1999-01-08 13:02:13 +00:00
|
|
|
case WM_CHAR:
|
|
|
|
case WM_SYSCHAR:
|
|
|
|
/*
|
|
|
|
* Nevertheless, we are prepared to deal with WM_CHAR
|
|
|
|
* messages, should they crop up. So if someone wants to
|
|
|
|
* post the things to us as part of a macro manoeuvre,
|
|
|
|
* we're ready to cope.
|
|
|
|
*/
|
2001-05-06 14:35:20 +00:00
|
|
|
{
|
2001-05-10 08:34:20 +00:00
|
|
|
char c = (unsigned char)wParam;
|
2002-10-22 16:11:33 +00:00
|
|
|
term_seen_key_event(term);
|
2004-08-14 13:04:18 +00:00
|
|
|
if (ldisc)
|
|
|
|
lpage_send(ldisc, CP_ACP, &c, 1, 1);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
return 0;
|
2004-08-27 12:24:08 +00:00
|
|
|
case WM_SYSCOLORCHANGE:
|
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
|
|
|
if (conf_get_int(conf, CONF_system_colour)) {
|
2004-08-27 12:24:08 +00:00
|
|
|
/* Refresh palette from system colours. */
|
|
|
|
/* XXX actually this zaps the entire palette. */
|
|
|
|
systopalette();
|
|
|
|
init_palette();
|
|
|
|
/* Force a repaint of the terminal window. */
|
|
|
|
term_invalidate(term);
|
|
|
|
}
|
|
|
|
break;
|
2003-04-28 13:59:32 +00:00
|
|
|
case WM_AGENT_CALLBACK:
|
|
|
|
{
|
|
|
|
struct agent_callback *c = (struct agent_callback *)lParam;
|
|
|
|
c->callback(c->callback_ctx, c->data, c->len);
|
|
|
|
sfree(c);
|
|
|
|
}
|
|
|
|
return 0;
|
2008-11-28 18:28:23 +00:00
|
|
|
case WM_GOT_CLIPDATA:
|
|
|
|
if (process_clipdata((HGLOBAL)lParam, wParam))
|
|
|
|
term_do_paste(term);
|
|
|
|
return 0;
|
2001-12-15 14:30:58 +00:00
|
|
|
default:
|
2002-01-17 12:22:26 +00:00
|
|
|
if (message == wm_mousewheel || message == WM_MOUSEWHEEL) {
|
2002-10-26 14:06:52 +00:00
|
|
|
int shift_pressed=0, control_pressed=0;
|
2001-12-15 14:30:58 +00:00
|
|
|
|
|
|
|
if (message == WM_MOUSEWHEEL) {
|
|
|
|
wheel_accumulator += (short)HIWORD(wParam);
|
|
|
|
shift_pressed=LOWORD(wParam) & MK_SHIFT;
|
|
|
|
control_pressed=LOWORD(wParam) & MK_CONTROL;
|
|
|
|
} else {
|
|
|
|
BYTE keys[256];
|
|
|
|
wheel_accumulator += (int)wParam;
|
|
|
|
if (GetKeyboardState(keys)!=0) {
|
|
|
|
shift_pressed=keys[VK_SHIFT]&0x80;
|
|
|
|
control_pressed=keys[VK_CONTROL]&0x80;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* process events when the threshold is reached */
|
|
|
|
while (abs(wheel_accumulator) >= WHEEL_DELTA) {
|
|
|
|
int b;
|
|
|
|
|
|
|
|
/* reduce amount for next time */
|
|
|
|
if (wheel_accumulator > 0) {
|
|
|
|
b = MBT_WHEEL_UP;
|
|
|
|
wheel_accumulator -= WHEEL_DELTA;
|
|
|
|
} else if (wheel_accumulator < 0) {
|
|
|
|
b = MBT_WHEEL_DOWN;
|
|
|
|
wheel_accumulator += WHEEL_DELTA;
|
|
|
|
} else
|
|
|
|
break;
|
|
|
|
|
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
|
|
|
if (send_raw_mouse && shift_pressed &&
|
|
|
|
!(conf_get_int(conf, CONF_mouse_override))) {
|
2008-12-20 19:02:09 +00:00
|
|
|
/* Mouse wheel position is in screen coordinates for
|
|
|
|
* some reason */
|
|
|
|
POINT p;
|
|
|
|
p.x = X_POS(lParam); p.y = Y_POS(lParam);
|
|
|
|
if (ScreenToClient(hwnd, &p)) {
|
|
|
|
/* send a mouse-down followed by a mouse up */
|
|
|
|
term_mouse(term, b, translate_button(b),
|
|
|
|
MA_CLICK,
|
|
|
|
TO_CHR_X(p.x),
|
|
|
|
TO_CHR_Y(p.y), shift_pressed,
|
|
|
|
control_pressed, is_alt_pressed());
|
|
|
|
term_mouse(term, b, translate_button(b),
|
|
|
|
MA_RELEASE, TO_CHR_X(p.x),
|
|
|
|
TO_CHR_Y(p.y), shift_pressed,
|
|
|
|
control_pressed, is_alt_pressed());
|
|
|
|
} /* else: not sure when this can fail */
|
2001-12-15 14:30:58 +00:00
|
|
|
} else {
|
|
|
|
/* trigger a scroll */
|
2002-10-22 16:11:33 +00:00
|
|
|
term_scroll(term, 0,
|
|
|
|
b == MBT_WHEEL_UP ?
|
|
|
|
-term->rows / 2 : term->rows / 2);
|
2001-12-15 14:30:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
2005-03-20 22:28:13 +00:00
|
|
|
/*
|
|
|
|
* Any messages we don't process completely above are passed through to
|
|
|
|
* DefWindowProc() for default processing.
|
|
|
|
*/
|
2001-05-06 14:35:20 +00:00
|
|
|
return DefWindowProc(hwnd, message, wParam, lParam);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
2000-09-25 16:17:53 +00:00
|
|
|
/*
|
|
|
|
* Move the system caret. (We maintain one, even though it's
|
|
|
|
* invisible, for the benefit of blind people: apparently some
|
|
|
|
* helper software tracks the system caret, so we should arrange to
|
|
|
|
* have one.)
|
|
|
|
*/
|
2002-10-26 12:58:13 +00:00
|
|
|
void sys_cursor(void *frontend, int x, int y)
|
2001-12-20 14:18:01 +00:00
|
|
|
{
|
|
|
|
int cx, cy;
|
|
|
|
|
2002-10-22 16:11:33 +00:00
|
|
|
if (!term->has_focus) return;
|
2001-12-20 14:18:01 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Avoid gratuitously re-updating the cursor position and IMM
|
|
|
|
* window if there's no actual change required.
|
|
|
|
*/
|
|
|
|
cx = x * font_width + offset_width;
|
|
|
|
cy = y * font_height + offset_height;
|
|
|
|
if (cx == caret_x && cy == caret_y)
|
|
|
|
return;
|
|
|
|
caret_x = cx;
|
|
|
|
caret_y = cy;
|
|
|
|
|
|
|
|
sys_cursor_update();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sys_cursor_update(void)
|
2001-05-06 14:35:20 +00:00
|
|
|
{
|
2001-08-04 15:15:07 +00:00
|
|
|
COMPOSITIONFORM cf;
|
|
|
|
HIMC hIMC;
|
|
|
|
|
2002-10-22 16:11:33 +00:00
|
|
|
if (!term->has_focus) return;
|
2001-12-20 14:18:01 +00:00
|
|
|
|
|
|
|
if (caret_x < 0 || caret_y < 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
SetCaretPos(caret_x, caret_y);
|
2001-08-04 15:15:07 +00:00
|
|
|
|
|
|
|
/* IMM calls on Win98 and beyond only */
|
|
|
|
if(osVersion.dwPlatformId == VER_PLATFORM_WIN32s) return; /* 3.11 */
|
|
|
|
|
|
|
|
if(osVersion.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS &&
|
|
|
|
osVersion.dwMinorVersion == 0) return; /* 95 */
|
|
|
|
|
|
|
|
/* we should have the IMM functions */
|
|
|
|
hIMC = ImmGetContext(hwnd);
|
|
|
|
cf.dwStyle = CFS_POINT;
|
2001-12-20 14:18:01 +00:00
|
|
|
cf.ptCurrentPos.x = caret_x;
|
|
|
|
cf.ptCurrentPos.y = caret_y;
|
2001-08-04 15:15:07 +00:00
|
|
|
ImmSetCompositionWindow(hIMC, &cf);
|
|
|
|
|
|
|
|
ImmReleaseContext(hwnd, hIMC);
|
2000-09-25 16:17:53 +00:00
|
|
|
}
|
|
|
|
|
1999-01-08 13:02:13 +00:00
|
|
|
/*
|
|
|
|
* Draw a line of text in the window, at given character
|
|
|
|
* coordinates, in given attributes.
|
|
|
|
*
|
|
|
|
* We are allowed to fiddle with the contents of `text'.
|
|
|
|
*/
|
2004-10-14 16:42:43 +00:00
|
|
|
void do_text_internal(Context ctx, int x, int y, wchar_t *text, int len,
|
|
|
|
unsigned long attr, int lattr)
|
2001-05-06 14:35:20 +00:00
|
|
|
{
|
1999-01-08 13:02:13 +00:00
|
|
|
COLORREF fg, bg, t;
|
|
|
|
int nfg, nbg, nfont;
|
|
|
|
HDC hdc = ctx;
|
2000-03-17 10:34:41 +00:00
|
|
|
RECT line_box;
|
|
|
|
int force_manual_underline = 0;
|
Re-engineering of terminal emulator, phase 1.
The active terminal screen is no longer an array of `unsigned long'
encoding 16-bit Unicode plus 16 attribute bits. Now it's an array of
`termchar' structures, which currently have 32-bit Unicode and 32
attribute bits but which will probably expand further in future.
To prevent bloat of the memory footprint, I've introduced a mostly
RLE-like compression scheme for storing scrollback: each line is
compressed into a compact (but hard to modify) form when it moves
into the term->scrollback tree, and is temporarily decompressed when
the user wants to scroll back over it. My initial tests suggest that
this compression averages about 1/4 of the previous (32 bits per
character cell) data size in typical output, which means this is an
improvement even without counting the new ability to extend the
information stored in each character cell.
Another beneficial side effect is that the insane format in which
Unicode was passed to front ends through do_text() has now been
rendered sane.
Testing is incomplete; this _may_ still have instabilities. Windows
and Unix front ends both seem to work as far as I've looked, but I
haven't yet looked very hard. The Mac front end I've edited (it
seemed obvious how to change it) but I can't compile or test it.
As an immediate functional effect, the terminal emulator now
supports full 32-bit Unicode to whatever extent the host platform
allows it to. For example, if you output a 4-or-more-byte UTF-8
character in Unix pterm, it will not display it properly, but it
will correctly paste it back out in a UTF8_STRING selection. Windows
is more restricted, sadly.
[originally from svn r4609]
2004-10-13 11:50:16 +00:00
|
|
|
int fnt_width, char_width;
|
2001-05-10 08:34:20 +00:00
|
|
|
int text_adjust = 0;
|
2010-12-29 14:11:25 +00:00
|
|
|
int xoffset = 0;
|
|
|
|
int maxlen, remaining, opaque;
|
2010-12-29 23:48:54 +00:00
|
|
|
static int *lpDx = NULL;
|
|
|
|
static int lpDx_len = 0;
|
|
|
|
int *lpDx_maybe;
|
2001-05-10 08:34:20 +00:00
|
|
|
|
Re-engineering of terminal emulator, phase 1.
The active terminal screen is no longer an array of `unsigned long'
encoding 16-bit Unicode plus 16 attribute bits. Now it's an array of
`termchar' structures, which currently have 32-bit Unicode and 32
attribute bits but which will probably expand further in future.
To prevent bloat of the memory footprint, I've introduced a mostly
RLE-like compression scheme for storing scrollback: each line is
compressed into a compact (but hard to modify) form when it moves
into the term->scrollback tree, and is temporarily decompressed when
the user wants to scroll back over it. My initial tests suggest that
this compression averages about 1/4 of the previous (32 bits per
character cell) data size in typical output, which means this is an
improvement even without counting the new ability to extend the
information stored in each character cell.
Another beneficial side effect is that the insane format in which
Unicode was passed to front ends through do_text() has now been
rendered sane.
Testing is incomplete; this _may_ still have instabilities. Windows
and Unix front ends both seem to work as far as I've looked, but I
haven't yet looked very hard. The Mac front end I've edited (it
seemed obvious how to change it) but I can't compile or test it.
As an immediate functional effect, the terminal emulator now
supports full 32-bit Unicode to whatever extent the host platform
allows it to. For example, if you output a 4-or-more-byte UTF-8
character in Unix pterm, it will not display it properly, but it
will correctly paste it back out in a UTF8_STRING selection. Windows
is more restricted, sadly.
[originally from svn r4609]
2004-10-13 11:50:16 +00:00
|
|
|
lattr &= LATTR_MODE;
|
|
|
|
|
|
|
|
char_width = fnt_width = font_width * (1 + (lattr != LATTR_NORM));
|
|
|
|
|
2001-05-10 08:34:20 +00:00
|
|
|
if (attr & ATTR_WIDE)
|
|
|
|
char_width *= 2;
|
2000-03-17 10:34:41 +00:00
|
|
|
|
2001-09-15 15:54:24 +00:00
|
|
|
/* Only want the left half of double width lines */
|
2002-10-22 16:11:33 +00:00
|
|
|
if (lattr != LATTR_NORM && x*2 >= term->cols)
|
2001-09-15 15:54:24 +00:00
|
|
|
return;
|
|
|
|
|
2000-07-26 12:13:51 +00:00
|
|
|
x *= fnt_width;
|
1999-01-08 13:02:13 +00:00
|
|
|
y *= font_height;
|
2001-09-15 15:54:24 +00:00
|
|
|
x += offset_width;
|
|
|
|
y += offset_height;
|
1999-01-08 13:02:13 +00:00
|
|
|
|
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
|
|
|
if ((attr & TATTR_ACTCURS) && (cursor_type == 0 || term->big_cursor)) {
|
2004-11-28 15:13:34 +00:00
|
|
|
attr &= ~(ATTR_REVERSE|ATTR_BLINK|ATTR_COLOURS);
|
|
|
|
if (bold_mode == BOLD_COLOURS)
|
|
|
|
attr &= ~ATTR_BOLD;
|
|
|
|
|
|
|
|
/* cursor fg and bg */
|
|
|
|
attr |= (260 << ATTR_FGSHIFT) | (261 << ATTR_BGSHIFT);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
nfont = 0;
|
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
|
|
|
if (vtmode == VT_POORMAN && lattr != LATTR_NORM) {
|
2001-05-10 08:34:20 +00:00
|
|
|
/* Assume a poorman font is borken in other ways too. */
|
|
|
|
lattr = LATTR_WIDE;
|
|
|
|
} else
|
|
|
|
switch (lattr) {
|
|
|
|
case LATTR_NORM:
|
|
|
|
break;
|
|
|
|
case LATTR_WIDE:
|
|
|
|
nfont |= FONT_WIDE;
|
1999-01-08 13:02:13 +00:00
|
|
|
break;
|
2001-05-10 08:34:20 +00:00
|
|
|
default:
|
|
|
|
nfont |= FONT_WIDE + FONT_HIGH;
|
|
|
|
break;
|
|
|
|
}
|
2001-09-15 15:54:24 +00:00
|
|
|
if (attr & ATTR_NARROW)
|
|
|
|
nfont |= FONT_NARROW;
|
2001-05-10 08:34:20 +00:00
|
|
|
|
|
|
|
/* Special hack for the VT100 linedraw glyphs. */
|
Re-engineering of terminal emulator, phase 1.
The active terminal screen is no longer an array of `unsigned long'
encoding 16-bit Unicode plus 16 attribute bits. Now it's an array of
`termchar' structures, which currently have 32-bit Unicode and 32
attribute bits but which will probably expand further in future.
To prevent bloat of the memory footprint, I've introduced a mostly
RLE-like compression scheme for storing scrollback: each line is
compressed into a compact (but hard to modify) form when it moves
into the term->scrollback tree, and is temporarily decompressed when
the user wants to scroll back over it. My initial tests suggest that
this compression averages about 1/4 of the previous (32 bits per
character cell) data size in typical output, which means this is an
improvement even without counting the new ability to extend the
information stored in each character cell.
Another beneficial side effect is that the insane format in which
Unicode was passed to front ends through do_text() has now been
rendered sane.
Testing is incomplete; this _may_ still have instabilities. Windows
and Unix front ends both seem to work as far as I've looked, but I
haven't yet looked very hard. The Mac front end I've edited (it
seemed obvious how to change it) but I can't compile or test it.
As an immediate functional effect, the terminal emulator now
supports full 32-bit Unicode to whatever extent the host platform
allows it to. For example, if you output a 4-or-more-byte UTF-8
character in Unix pterm, it will not display it properly, but it
will correctly paste it back out in a UTF8_STRING selection. Windows
is more restricted, sadly.
[originally from svn r4609]
2004-10-13 11:50:16 +00:00
|
|
|
if (text[0] >= 0x23BA && text[0] <= 0x23BD) {
|
|
|
|
switch ((unsigned char) (text[0])) {
|
|
|
|
case 0xBA:
|
|
|
|
text_adjust = -2 * font_height / 5;
|
|
|
|
break;
|
|
|
|
case 0xBB:
|
|
|
|
text_adjust = -1 * font_height / 5;
|
|
|
|
break;
|
|
|
|
case 0xBC:
|
|
|
|
text_adjust = font_height / 5;
|
|
|
|
break;
|
|
|
|
case 0xBD:
|
|
|
|
text_adjust = 2 * font_height / 5;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (lattr == LATTR_TOP || lattr == LATTR_BOT)
|
|
|
|
text_adjust *= 2;
|
|
|
|
text[0] = ucsdata.unitab_xterm['q'];
|
|
|
|
if (attr & ATTR_UNDER) {
|
|
|
|
attr &= ~ATTR_UNDER;
|
|
|
|
force_manual_underline = 1;
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-10 08:34:20 +00:00
|
|
|
/* Anything left as an original character set is unprintable. */
|
Re-engineering of terminal emulator, phase 1.
The active terminal screen is no longer an array of `unsigned long'
encoding 16-bit Unicode plus 16 attribute bits. Now it's an array of
`termchar' structures, which currently have 32-bit Unicode and 32
attribute bits but which will probably expand further in future.
To prevent bloat of the memory footprint, I've introduced a mostly
RLE-like compression scheme for storing scrollback: each line is
compressed into a compact (but hard to modify) form when it moves
into the term->scrollback tree, and is temporarily decompressed when
the user wants to scroll back over it. My initial tests suggest that
this compression averages about 1/4 of the previous (32 bits per
character cell) data size in typical output, which means this is an
improvement even without counting the new ability to extend the
information stored in each character cell.
Another beneficial side effect is that the insane format in which
Unicode was passed to front ends through do_text() has now been
rendered sane.
Testing is incomplete; this _may_ still have instabilities. Windows
and Unix front ends both seem to work as far as I've looked, but I
haven't yet looked very hard. The Mac front end I've edited (it
seemed obvious how to change it) but I can't compile or test it.
As an immediate functional effect, the terminal emulator now
supports full 32-bit Unicode to whatever extent the host platform
allows it to. For example, if you output a 4-or-more-byte UTF-8
character in Unix pterm, it will not display it properly, but it
will correctly paste it back out in a UTF8_STRING selection. Windows
is more restricted, sadly.
[originally from svn r4609]
2004-10-13 11:50:16 +00:00
|
|
|
if (DIRECT_CHAR(text[0])) {
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
text[i] = 0xFFFD;
|
2001-05-10 08:34:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* OEM CP */
|
Re-engineering of terminal emulator, phase 1.
The active terminal screen is no longer an array of `unsigned long'
encoding 16-bit Unicode plus 16 attribute bits. Now it's an array of
`termchar' structures, which currently have 32-bit Unicode and 32
attribute bits but which will probably expand further in future.
To prevent bloat of the memory footprint, I've introduced a mostly
RLE-like compression scheme for storing scrollback: each line is
compressed into a compact (but hard to modify) form when it moves
into the term->scrollback tree, and is temporarily decompressed when
the user wants to scroll back over it. My initial tests suggest that
this compression averages about 1/4 of the previous (32 bits per
character cell) data size in typical output, which means this is an
improvement even without counting the new ability to extend the
information stored in each character cell.
Another beneficial side effect is that the insane format in which
Unicode was passed to front ends through do_text() has now been
rendered sane.
Testing is incomplete; this _may_ still have instabilities. Windows
and Unix front ends both seem to work as far as I've looked, but I
haven't yet looked very hard. The Mac front end I've edited (it
seemed obvious how to change it) but I can't compile or test it.
As an immediate functional effect, the terminal emulator now
supports full 32-bit Unicode to whatever extent the host platform
allows it to. For example, if you output a 4-or-more-byte UTF-8
character in Unix pterm, it will not display it properly, but it
will correctly paste it back out in a UTF8_STRING selection. Windows
is more restricted, sadly.
[originally from svn r4609]
2004-10-13 11:50:16 +00:00
|
|
|
if ((text[0] & CSET_MASK) == CSET_OEMCP)
|
2001-05-10 08:34:20 +00:00
|
|
|
nfont |= FONT_OEM;
|
|
|
|
|
2003-01-27 23:03:31 +00:00
|
|
|
nfg = ((attr & ATTR_FGMASK) >> ATTR_FGSHIFT);
|
|
|
|
nbg = ((attr & ATTR_BGMASK) >> ATTR_BGSHIFT);
|
1999-01-08 13:02:13 +00:00
|
|
|
if (bold_mode == BOLD_FONT && (attr & ATTR_BOLD))
|
|
|
|
nfont |= FONT_BOLD;
|
|
|
|
if (und_mode == UND_FONT && (attr & ATTR_UNDER))
|
|
|
|
nfont |= FONT_UNDERLINE;
|
2001-05-10 08:34:20 +00:00
|
|
|
another_font(nfont);
|
2001-05-06 14:35:20 +00:00
|
|
|
if (!fonts[nfont]) {
|
|
|
|
if (nfont & FONT_UNDERLINE)
|
2000-03-17 10:34:41 +00:00
|
|
|
force_manual_underline = 1;
|
|
|
|
/* Don't do the same for manual bold, it could be bad news. */
|
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
nfont &= ~(FONT_BOLD | FONT_UNDERLINE);
|
2000-03-17 10:34:41 +00:00
|
|
|
}
|
2001-05-10 08:34:20 +00:00
|
|
|
another_font(nfont);
|
|
|
|
if (!fonts[nfont])
|
|
|
|
nfont = FONT_NORMAL;
|
1999-01-08 13:02:13 +00:00
|
|
|
if (attr & ATTR_REVERSE) {
|
2001-05-06 14:35:20 +00:00
|
|
|
t = nfg;
|
|
|
|
nfg = nbg;
|
|
|
|
nbg = t;
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
2004-11-28 15:13:34 +00:00
|
|
|
if (bold_mode == BOLD_COLOURS && (attr & ATTR_BOLD)) {
|
|
|
|
if (nfg < 16) nfg |= 8;
|
|
|
|
else if (nfg >= 256) nfg |= 1;
|
|
|
|
}
|
|
|
|
if (bold_mode == BOLD_COLOURS && (attr & ATTR_BLINK)) {
|
|
|
|
if (nbg < 16) nbg |= 8;
|
|
|
|
else if (nbg >= 256) nbg |= 1;
|
|
|
|
}
|
1999-01-08 13:02:13 +00:00
|
|
|
fg = colours[nfg];
|
|
|
|
bg = colours[nbg];
|
2001-05-06 14:35:20 +00:00
|
|
|
SelectObject(hdc, fonts[nfont]);
|
|
|
|
SetTextColor(hdc, fg);
|
|
|
|
SetBkColor(hdc, bg);
|
2004-10-14 16:42:43 +00:00
|
|
|
if (attr & TATTR_COMBINING)
|
|
|
|
SetBkMode(hdc, TRANSPARENT);
|
|
|
|
else
|
|
|
|
SetBkMode(hdc, OPAQUE);
|
2001-05-06 14:35:20 +00:00
|
|
|
line_box.left = x;
|
|
|
|
line_box.top = y;
|
2001-05-10 08:34:20 +00:00
|
|
|
line_box.right = x + char_width * len;
|
2001-05-06 14:35:20 +00:00
|
|
|
line_box.bottom = y + font_height;
|
2001-05-10 08:34:20 +00:00
|
|
|
|
2001-09-15 15:54:24 +00:00
|
|
|
/* Only want the left half of double width lines */
|
2002-10-22 16:11:33 +00:00
|
|
|
if (line_box.right > font_width*term->cols+offset_width)
|
|
|
|
line_box.right = font_width*term->cols+offset_width;
|
2001-09-15 15:54:24 +00:00
|
|
|
|
2010-12-29 14:11:25 +00:00
|
|
|
if (font_varpitch) {
|
|
|
|
/*
|
|
|
|
* If we're using a variable-pitch font, we unconditionally
|
|
|
|
* draw the glyphs one at a time and centre them in their
|
|
|
|
* character cells (which means in particular that we must
|
2010-12-29 23:48:54 +00:00
|
|
|
* disable the lpDx mechanism). This gives slightly odd but
|
2010-12-29 14:11:25 +00:00
|
|
|
* generally reasonable results.
|
|
|
|
*/
|
|
|
|
xoffset = char_width / 2;
|
|
|
|
SetTextAlign(hdc, TA_TOP | TA_CENTER | TA_NOUPDATECP);
|
2010-12-29 23:48:54 +00:00
|
|
|
lpDx_maybe = NULL;
|
2010-12-29 14:11:25 +00:00
|
|
|
maxlen = 1;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* In a fixed-pitch font, we draw the whole string in one go
|
|
|
|
* in the normal way.
|
|
|
|
*/
|
|
|
|
xoffset = 0;
|
|
|
|
SetTextAlign(hdc, TA_TOP | TA_LEFT | TA_NOUPDATECP);
|
2010-12-29 23:48:54 +00:00
|
|
|
lpDx_maybe = lpDx;
|
2010-12-29 14:11:25 +00:00
|
|
|
maxlen = len;
|
|
|
|
}
|
|
|
|
|
|
|
|
opaque = TRUE; /* start by erasing the rectangle */
|
|
|
|
for (remaining = len; remaining > 0;
|
|
|
|
text += len, remaining -= len, x += char_width * len) {
|
|
|
|
len = (maxlen < remaining ? maxlen : remaining);
|
|
|
|
|
2010-12-29 23:48:54 +00:00
|
|
|
if (len > lpDx_len) {
|
|
|
|
if (len > lpDx_len) {
|
|
|
|
lpDx_len = len * 9 / 8 + 16;
|
|
|
|
lpDx = sresize(lpDx, lpDx_len, int);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
lpDx[i] = char_width;
|
|
|
|
}
|
|
|
|
|
2010-12-29 14:11:25 +00:00
|
|
|
/* We're using a private area for direct to font. (512 chars.) */
|
|
|
|
if (ucsdata.dbcs_screenfont && (text[0] & CSET_MASK) == CSET_ACP) {
|
|
|
|
/* Ho Hum, dbcs fonts are a PITA! */
|
|
|
|
/* To display on W9x I have to convert to UCS */
|
|
|
|
static wchar_t *uni_buf = 0;
|
|
|
|
static int uni_len = 0;
|
|
|
|
int nlen, mptr;
|
|
|
|
if (len > uni_len) {
|
|
|
|
sfree(uni_buf);
|
|
|
|
uni_len = len;
|
|
|
|
uni_buf = snewn(uni_len, wchar_t);
|
|
|
|
}
|
Re-engineering of terminal emulator, phase 1.
The active terminal screen is no longer an array of `unsigned long'
encoding 16-bit Unicode plus 16 attribute bits. Now it's an array of
`termchar' structures, which currently have 32-bit Unicode and 32
attribute bits but which will probably expand further in future.
To prevent bloat of the memory footprint, I've introduced a mostly
RLE-like compression scheme for storing scrollback: each line is
compressed into a compact (but hard to modify) form when it moves
into the term->scrollback tree, and is temporarily decompressed when
the user wants to scroll back over it. My initial tests suggest that
this compression averages about 1/4 of the previous (32 bits per
character cell) data size in typical output, which means this is an
improvement even without counting the new ability to extend the
information stored in each character cell.
Another beneficial side effect is that the insane format in which
Unicode was passed to front ends through do_text() has now been
rendered sane.
Testing is incomplete; this _may_ still have instabilities. Windows
and Unix front ends both seem to work as far as I've looked, but I
haven't yet looked very hard. The Mac front end I've edited (it
seemed obvious how to change it) but I can't compile or test it.
As an immediate functional effect, the terminal emulator now
supports full 32-bit Unicode to whatever extent the host platform
allows it to. For example, if you output a 4-or-more-byte UTF-8
character in Unix pterm, it will not display it properly, but it
will correctly paste it back out in a UTF8_STRING selection. Windows
is more restricted, sadly.
[originally from svn r4609]
2004-10-13 11:50:16 +00:00
|
|
|
|
2010-12-29 14:11:25 +00:00
|
|
|
for(nlen = mptr = 0; mptr<len; mptr++) {
|
|
|
|
uni_buf[nlen] = 0xFFFD;
|
|
|
|
if (IsDBCSLeadByteEx(ucsdata.font_codepage,
|
|
|
|
(BYTE) text[mptr])) {
|
|
|
|
char dbcstext[2];
|
|
|
|
dbcstext[0] = text[mptr] & 0xFF;
|
|
|
|
dbcstext[1] = text[mptr+1] & 0xFF;
|
2010-12-29 23:48:54 +00:00
|
|
|
lpDx[nlen] += char_width;
|
2010-12-29 14:11:25 +00:00
|
|
|
MultiByteToWideChar(ucsdata.font_codepage, MB_USEGLYPHCHARS,
|
|
|
|
dbcstext, 2, uni_buf+nlen, 1);
|
|
|
|
mptr++;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
char dbcstext[1];
|
|
|
|
dbcstext[0] = text[mptr] & 0xFF;
|
|
|
|
MultiByteToWideChar(ucsdata.font_codepage, MB_USEGLYPHCHARS,
|
|
|
|
dbcstext, 1, uni_buf+nlen, 1);
|
|
|
|
}
|
|
|
|
nlen++;
|
|
|
|
}
|
|
|
|
if (nlen <= 0)
|
|
|
|
return; /* Eeek! */
|
|
|
|
|
|
|
|
ExtTextOutW(hdc, x + xoffset,
|
|
|
|
y - font_height * (lattr == LATTR_BOT) + text_adjust,
|
|
|
|
ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0),
|
|
|
|
&line_box, uni_buf, nlen,
|
2010-12-29 23:48:54 +00:00
|
|
|
lpDx_maybe);
|
2010-12-29 14:11:25 +00:00
|
|
|
if (bold_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
|
|
|
|
SetBkMode(hdc, TRANSPARENT);
|
|
|
|
ExtTextOutW(hdc, x + xoffset - 1,
|
|
|
|
y - font_height * (lattr ==
|
|
|
|
LATTR_BOT) + text_adjust,
|
2010-12-29 23:48:54 +00:00
|
|
|
ETO_CLIPPED, &line_box, uni_buf, nlen, lpDx_maybe);
|
2010-12-29 14:11:25 +00:00
|
|
|
}
|
Re-engineering of terminal emulator, phase 1.
The active terminal screen is no longer an array of `unsigned long'
encoding 16-bit Unicode plus 16 attribute bits. Now it's an array of
`termchar' structures, which currently have 32-bit Unicode and 32
attribute bits but which will probably expand further in future.
To prevent bloat of the memory footprint, I've introduced a mostly
RLE-like compression scheme for storing scrollback: each line is
compressed into a compact (but hard to modify) form when it moves
into the term->scrollback tree, and is temporarily decompressed when
the user wants to scroll back over it. My initial tests suggest that
this compression averages about 1/4 of the previous (32 bits per
character cell) data size in typical output, which means this is an
improvement even without counting the new ability to extend the
information stored in each character cell.
Another beneficial side effect is that the insane format in which
Unicode was passed to front ends through do_text() has now been
rendered sane.
Testing is incomplete; this _may_ still have instabilities. Windows
and Unix front ends both seem to work as far as I've looked, but I
haven't yet looked very hard. The Mac front end I've edited (it
seemed obvious how to change it) but I can't compile or test it.
As an immediate functional effect, the terminal emulator now
supports full 32-bit Unicode to whatever extent the host platform
allows it to. For example, if you output a 4-or-more-byte UTF-8
character in Unix pterm, it will not display it properly, but it
will correctly paste it back out in a UTF8_STRING selection. Windows
is more restricted, sadly.
[originally from svn r4609]
2004-10-13 11:50:16 +00:00
|
|
|
|
2010-12-29 23:48:54 +00:00
|
|
|
lpDx[0] = -1;
|
2010-12-29 14:11:25 +00:00
|
|
|
} else if (DIRECT_FONT(text[0])) {
|
|
|
|
static char *directbuf = NULL;
|
|
|
|
static int directlen = 0;
|
|
|
|
int i;
|
|
|
|
if (len > directlen) {
|
|
|
|
directlen = len;
|
|
|
|
directbuf = sresize(directbuf, directlen, char);
|
|
|
|
}
|
2001-05-10 08:34:20 +00:00
|
|
|
|
2010-12-29 14:11:25 +00:00
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
directbuf[i] = text[i] & 0xFF;
|
|
|
|
|
|
|
|
ExtTextOut(hdc, x + xoffset,
|
|
|
|
y - font_height * (lattr == LATTR_BOT) + text_adjust,
|
|
|
|
ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0),
|
2010-12-29 23:48:54 +00:00
|
|
|
&line_box, directbuf, len, lpDx_maybe);
|
2010-12-29 14:11:25 +00:00
|
|
|
if (bold_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
|
|
|
|
SetBkMode(hdc, TRANSPARENT);
|
|
|
|
|
|
|
|
/* GRR: This draws the character outside its box and
|
|
|
|
* can leave 'droppings' even with the clip box! I
|
|
|
|
* suppose I could loop it one character at a time ...
|
|
|
|
* yuk.
|
|
|
|
*
|
|
|
|
* Or ... I could do a test print with "W", and use +1
|
|
|
|
* or -1 for this shift depending on if the leftmost
|
|
|
|
* column is blank...
|
|
|
|
*/
|
|
|
|
ExtTextOut(hdc, x + xoffset - 1,
|
|
|
|
y - font_height * (lattr ==
|
|
|
|
LATTR_BOT) + text_adjust,
|
2010-12-29 23:48:54 +00:00
|
|
|
ETO_CLIPPED, &line_box, directbuf, len, lpDx_maybe);
|
2010-12-29 14:11:25 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* And 'normal' unicode characters */
|
|
|
|
static WCHAR *wbuf = NULL;
|
|
|
|
static int wlen = 0;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (wlen < len) {
|
|
|
|
sfree(wbuf);
|
|
|
|
wlen = len;
|
|
|
|
wbuf = snewn(wlen, WCHAR);
|
|
|
|
}
|
2004-10-14 16:42:43 +00:00
|
|
|
|
2010-12-29 14:11:25 +00:00
|
|
|
for (i = 0; i < len; i++)
|
|
|
|
wbuf[i] = text[i];
|
|
|
|
|
|
|
|
/* print Glyphs as they are, without Windows' Shaping*/
|
|
|
|
general_textout(hdc, x + xoffset,
|
|
|
|
y - font_height * (lattr==LATTR_BOT) + text_adjust,
|
2010-12-29 23:48:54 +00:00
|
|
|
&line_box, wbuf, len, lpDx,
|
2010-12-29 14:11:25 +00:00
|
|
|
opaque && !(attr & TATTR_COMBINING));
|
|
|
|
|
|
|
|
/* And the shadow bold hack. */
|
|
|
|
if (bold_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
|
|
|
|
SetBkMode(hdc, TRANSPARENT);
|
|
|
|
ExtTextOutW(hdc, x + xoffset - 1,
|
|
|
|
y - font_height * (lattr ==
|
|
|
|
LATTR_BOT) + text_adjust,
|
2010-12-29 23:48:54 +00:00
|
|
|
ETO_CLIPPED, &line_box, wbuf, len, lpDx_maybe);
|
2010-12-29 14:11:25 +00:00
|
|
|
}
|
|
|
|
}
|
2004-10-14 16:42:43 +00:00
|
|
|
|
2010-12-29 14:11:25 +00:00
|
|
|
/*
|
|
|
|
* If we're looping round again, stop erasing the background
|
|
|
|
* rectangle.
|
|
|
|
*/
|
|
|
|
SetBkMode(hdc, TRANSPARENT);
|
|
|
|
opaque = FALSE;
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
2001-05-10 08:34:20 +00:00
|
|
|
if (lattr != LATTR_TOP && (force_manual_underline ||
|
|
|
|
(und_mode == UND_LINE
|
|
|
|
&& (attr & ATTR_UNDER)))) {
|
2001-05-06 14:35:20 +00:00
|
|
|
HPEN oldpen;
|
2001-05-10 08:34:20 +00:00
|
|
|
int dec = descent;
|
|
|
|
if (lattr == LATTR_BOT)
|
|
|
|
dec = dec * 2 - font_height;
|
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
oldpen = SelectObject(hdc, CreatePen(PS_SOLID, 0, fg));
|
2011-07-15 16:03:06 +00:00
|
|
|
MoveToEx(hdc, line_box.left, line_box.top + dec, NULL);
|
|
|
|
LineTo(hdc, line_box.right, line_box.top + dec);
|
2001-05-06 14:35:20 +00:00
|
|
|
oldpen = SelectObject(hdc, oldpen);
|
|
|
|
DeleteObject(oldpen);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
2001-05-10 08:34:20 +00:00
|
|
|
}
|
|
|
|
|
2004-10-14 16:42:43 +00:00
|
|
|
/*
|
|
|
|
* Wrapper that handles combining characters.
|
|
|
|
*/
|
|
|
|
void do_text(Context ctx, int x, int y, wchar_t *text, int len,
|
|
|
|
unsigned long attr, int lattr)
|
|
|
|
{
|
|
|
|
if (attr & TATTR_COMBINING) {
|
|
|
|
unsigned long a = 0;
|
|
|
|
attr &= ~TATTR_COMBINING;
|
|
|
|
while (len--) {
|
|
|
|
do_text_internal(ctx, x, y, text, 1, attr | a, lattr);
|
|
|
|
text++;
|
|
|
|
a = TATTR_COMBINING;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
do_text_internal(ctx, x, y, text, len, attr, lattr);
|
|
|
|
}
|
|
|
|
|
Re-engineering of terminal emulator, phase 1.
The active terminal screen is no longer an array of `unsigned long'
encoding 16-bit Unicode plus 16 attribute bits. Now it's an array of
`termchar' structures, which currently have 32-bit Unicode and 32
attribute bits but which will probably expand further in future.
To prevent bloat of the memory footprint, I've introduced a mostly
RLE-like compression scheme for storing scrollback: each line is
compressed into a compact (but hard to modify) form when it moves
into the term->scrollback tree, and is temporarily decompressed when
the user wants to scroll back over it. My initial tests suggest that
this compression averages about 1/4 of the previous (32 bits per
character cell) data size in typical output, which means this is an
improvement even without counting the new ability to extend the
information stored in each character cell.
Another beneficial side effect is that the insane format in which
Unicode was passed to front ends through do_text() has now been
rendered sane.
Testing is incomplete; this _may_ still have instabilities. Windows
and Unix front ends both seem to work as far as I've looked, but I
haven't yet looked very hard. The Mac front end I've edited (it
seemed obvious how to change it) but I can't compile or test it.
As an immediate functional effect, the terminal emulator now
supports full 32-bit Unicode to whatever extent the host platform
allows it to. For example, if you output a 4-or-more-byte UTF-8
character in Unix pterm, it will not display it properly, but it
will correctly paste it back out in a UTF8_STRING selection. Windows
is more restricted, sadly.
[originally from svn r4609]
2004-10-13 11:50:16 +00:00
|
|
|
void do_cursor(Context ctx, int x, int y, wchar_t *text, int len,
|
2001-05-10 08:34:20 +00:00
|
|
|
unsigned long attr, int lattr)
|
|
|
|
{
|
|
|
|
|
|
|
|
int fnt_width;
|
|
|
|
int char_width;
|
|
|
|
HDC hdc = ctx;
|
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
|
|
|
int ctype = cursor_type;
|
2001-05-10 08:34:20 +00:00
|
|
|
|
2004-11-11 09:40:50 +00:00
|
|
|
lattr &= LATTR_MODE;
|
|
|
|
|
2002-10-22 16:11:33 +00:00
|
|
|
if ((attr & TATTR_ACTCURS) && (ctype == 0 || term->big_cursor)) {
|
Re-engineering of terminal emulator, phase 1.
The active terminal screen is no longer an array of `unsigned long'
encoding 16-bit Unicode plus 16 attribute bits. Now it's an array of
`termchar' structures, which currently have 32-bit Unicode and 32
attribute bits but which will probably expand further in future.
To prevent bloat of the memory footprint, I've introduced a mostly
RLE-like compression scheme for storing scrollback: each line is
compressed into a compact (but hard to modify) form when it moves
into the term->scrollback tree, and is temporarily decompressed when
the user wants to scroll back over it. My initial tests suggest that
this compression averages about 1/4 of the previous (32 bits per
character cell) data size in typical output, which means this is an
improvement even without counting the new ability to extend the
information stored in each character cell.
Another beneficial side effect is that the insane format in which
Unicode was passed to front ends through do_text() has now been
rendered sane.
Testing is incomplete; this _may_ still have instabilities. Windows
and Unix front ends both seem to work as far as I've looked, but I
haven't yet looked very hard. The Mac front end I've edited (it
seemed obvious how to change it) but I can't compile or test it.
As an immediate functional effect, the terminal emulator now
supports full 32-bit Unicode to whatever extent the host platform
allows it to. For example, if you output a 4-or-more-byte UTF-8
character in Unix pterm, it will not display it properly, but it
will correctly paste it back out in a UTF8_STRING selection. Windows
is more restricted, sadly.
[originally from svn r4609]
2004-10-13 11:50:16 +00:00
|
|
|
if (*text != UCSWIDE) {
|
2001-05-10 08:34:20 +00:00
|
|
|
do_text(ctx, x, y, text, len, attr, lattr);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
ctype = 2;
|
|
|
|
attr |= TATTR_RIGHTCURS;
|
|
|
|
}
|
|
|
|
|
|
|
|
fnt_width = char_width = font_width * (1 + (lattr != LATTR_NORM));
|
|
|
|
if (attr & ATTR_WIDE)
|
|
|
|
char_width *= 2;
|
|
|
|
x *= fnt_width;
|
|
|
|
y *= font_height;
|
2001-09-15 15:54:24 +00:00
|
|
|
x += offset_width;
|
|
|
|
y += offset_height;
|
2001-05-10 08:34:20 +00:00
|
|
|
|
2002-10-22 16:11:33 +00:00
|
|
|
if ((attr & TATTR_PASCURS) && (ctype == 0 || term->big_cursor)) {
|
1999-01-08 13:02:13 +00:00
|
|
|
POINT pts[5];
|
2001-05-06 14:35:20 +00:00
|
|
|
HPEN oldpen;
|
1999-01-08 13:02:13 +00:00
|
|
|
pts[0].x = pts[1].x = pts[4].x = x;
|
2001-05-10 08:34:20 +00:00
|
|
|
pts[2].x = pts[3].x = x + char_width - 1;
|
1999-01-08 13:02:13 +00:00
|
|
|
pts[0].y = pts[3].y = pts[4].y = y;
|
2001-05-06 14:35:20 +00:00
|
|
|
pts[1].y = pts[2].y = y + font_height - 1;
|
2004-11-28 15:13:34 +00:00
|
|
|
oldpen = SelectObject(hdc, CreatePen(PS_SOLID, 0, colours[261]));
|
2001-05-06 14:35:20 +00:00
|
|
|
Polyline(hdc, pts, 5);
|
|
|
|
oldpen = SelectObject(hdc, oldpen);
|
|
|
|
DeleteObject(oldpen);
|
2001-05-10 08:34:20 +00:00
|
|
|
} else if ((attr & (TATTR_ACTCURS | TATTR_PASCURS)) && ctype != 0) {
|
2001-05-06 14:35:20 +00:00
|
|
|
int startx, starty, dx, dy, length, i;
|
2001-05-10 08:34:20 +00:00
|
|
|
if (ctype == 1) {
|
2001-05-06 14:35:20 +00:00
|
|
|
startx = x;
|
|
|
|
starty = y + descent;
|
|
|
|
dx = 1;
|
|
|
|
dy = 0;
|
2001-05-10 08:34:20 +00:00
|
|
|
length = char_width;
|
2001-05-06 14:35:20 +00:00
|
|
|
} else {
|
2001-01-17 16:57:33 +00:00
|
|
|
int xadjust = 0;
|
2001-05-10 08:34:20 +00:00
|
|
|
if (attr & TATTR_RIGHTCURS)
|
|
|
|
xadjust = char_width - 1;
|
2001-05-06 14:35:20 +00:00
|
|
|
startx = x + xadjust;
|
|
|
|
starty = y;
|
|
|
|
dx = 0;
|
|
|
|
dy = 1;
|
|
|
|
length = font_height;
|
|
|
|
}
|
2001-05-10 08:34:20 +00:00
|
|
|
if (attr & TATTR_ACTCURS) {
|
2001-05-06 14:35:20 +00:00
|
|
|
HPEN oldpen;
|
|
|
|
oldpen =
|
2004-12-19 22:37:05 +00:00
|
|
|
SelectObject(hdc, CreatePen(PS_SOLID, 0, colours[261]));
|
2001-05-06 14:35:20 +00:00
|
|
|
MoveToEx(hdc, startx, starty, NULL);
|
|
|
|
LineTo(hdc, startx + dx * length, starty + dy * length);
|
|
|
|
oldpen = SelectObject(hdc, oldpen);
|
|
|
|
DeleteObject(oldpen);
|
|
|
|
} else {
|
|
|
|
for (i = 0; i < length; i++) {
|
|
|
|
if (i % 2 == 0) {
|
2004-12-19 22:37:05 +00:00
|
|
|
SetPixel(hdc, startx, starty, colours[261]);
|
2001-05-06 14:35:20 +00:00
|
|
|
}
|
|
|
|
startx += dx;
|
|
|
|
starty += dy;
|
|
|
|
}
|
|
|
|
}
|
2001-01-17 16:57:33 +00:00
|
|
|
}
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
2001-09-15 15:54:24 +00:00
|
|
|
/* This function gets the actual width of a character in the normal font.
|
|
|
|
*/
|
2002-11-09 21:46:21 +00:00
|
|
|
int char_width(Context ctx, int uc) {
|
2001-09-15 15:54:24 +00:00
|
|
|
HDC hdc = ctx;
|
|
|
|
int ibuf = 0;
|
|
|
|
|
|
|
|
/* If the font max is the same as the font ave width then this
|
|
|
|
* function is a no-op.
|
|
|
|
*/
|
|
|
|
if (!font_dualwidth) return 1;
|
|
|
|
|
|
|
|
switch (uc & CSET_MASK) {
|
Re-engineering of terminal emulator, phase 1.
The active terminal screen is no longer an array of `unsigned long'
encoding 16-bit Unicode plus 16 attribute bits. Now it's an array of
`termchar' structures, which currently have 32-bit Unicode and 32
attribute bits but which will probably expand further in future.
To prevent bloat of the memory footprint, I've introduced a mostly
RLE-like compression scheme for storing scrollback: each line is
compressed into a compact (but hard to modify) form when it moves
into the term->scrollback tree, and is temporarily decompressed when
the user wants to scroll back over it. My initial tests suggest that
this compression averages about 1/4 of the previous (32 bits per
character cell) data size in typical output, which means this is an
improvement even without counting the new ability to extend the
information stored in each character cell.
Another beneficial side effect is that the insane format in which
Unicode was passed to front ends through do_text() has now been
rendered sane.
Testing is incomplete; this _may_ still have instabilities. Windows
and Unix front ends both seem to work as far as I've looked, but I
haven't yet looked very hard. The Mac front end I've edited (it
seemed obvious how to change it) but I can't compile or test it.
As an immediate functional effect, the terminal emulator now
supports full 32-bit Unicode to whatever extent the host platform
allows it to. For example, if you output a 4-or-more-byte UTF-8
character in Unix pterm, it will not display it properly, but it
will correctly paste it back out in a UTF8_STRING selection. Windows
is more restricted, sadly.
[originally from svn r4609]
2004-10-13 11:50:16 +00:00
|
|
|
case CSET_ASCII:
|
2003-01-14 18:28:23 +00:00
|
|
|
uc = ucsdata.unitab_line[uc & 0xFF];
|
2001-09-15 15:54:24 +00:00
|
|
|
break;
|
Re-engineering of terminal emulator, phase 1.
The active terminal screen is no longer an array of `unsigned long'
encoding 16-bit Unicode plus 16 attribute bits. Now it's an array of
`termchar' structures, which currently have 32-bit Unicode and 32
attribute bits but which will probably expand further in future.
To prevent bloat of the memory footprint, I've introduced a mostly
RLE-like compression scheme for storing scrollback: each line is
compressed into a compact (but hard to modify) form when it moves
into the term->scrollback tree, and is temporarily decompressed when
the user wants to scroll back over it. My initial tests suggest that
this compression averages about 1/4 of the previous (32 bits per
character cell) data size in typical output, which means this is an
improvement even without counting the new ability to extend the
information stored in each character cell.
Another beneficial side effect is that the insane format in which
Unicode was passed to front ends through do_text() has now been
rendered sane.
Testing is incomplete; this _may_ still have instabilities. Windows
and Unix front ends both seem to work as far as I've looked, but I
haven't yet looked very hard. The Mac front end I've edited (it
seemed obvious how to change it) but I can't compile or test it.
As an immediate functional effect, the terminal emulator now
supports full 32-bit Unicode to whatever extent the host platform
allows it to. For example, if you output a 4-or-more-byte UTF-8
character in Unix pterm, it will not display it properly, but it
will correctly paste it back out in a UTF8_STRING selection. Windows
is more restricted, sadly.
[originally from svn r4609]
2004-10-13 11:50:16 +00:00
|
|
|
case CSET_LINEDRW:
|
2003-01-14 18:28:23 +00:00
|
|
|
uc = ucsdata.unitab_xterm[uc & 0xFF];
|
2001-09-15 15:54:24 +00:00
|
|
|
break;
|
Re-engineering of terminal emulator, phase 1.
The active terminal screen is no longer an array of `unsigned long'
encoding 16-bit Unicode plus 16 attribute bits. Now it's an array of
`termchar' structures, which currently have 32-bit Unicode and 32
attribute bits but which will probably expand further in future.
To prevent bloat of the memory footprint, I've introduced a mostly
RLE-like compression scheme for storing scrollback: each line is
compressed into a compact (but hard to modify) form when it moves
into the term->scrollback tree, and is temporarily decompressed when
the user wants to scroll back over it. My initial tests suggest that
this compression averages about 1/4 of the previous (32 bits per
character cell) data size in typical output, which means this is an
improvement even without counting the new ability to extend the
information stored in each character cell.
Another beneficial side effect is that the insane format in which
Unicode was passed to front ends through do_text() has now been
rendered sane.
Testing is incomplete; this _may_ still have instabilities. Windows
and Unix front ends both seem to work as far as I've looked, but I
haven't yet looked very hard. The Mac front end I've edited (it
seemed obvious how to change it) but I can't compile or test it.
As an immediate functional effect, the terminal emulator now
supports full 32-bit Unicode to whatever extent the host platform
allows it to. For example, if you output a 4-or-more-byte UTF-8
character in Unix pterm, it will not display it properly, but it
will correctly paste it back out in a UTF8_STRING selection. Windows
is more restricted, sadly.
[originally from svn r4609]
2004-10-13 11:50:16 +00:00
|
|
|
case CSET_SCOACS:
|
2003-01-14 18:28:23 +00:00
|
|
|
uc = ucsdata.unitab_scoacs[uc & 0xFF];
|
2001-09-15 15:54:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (DIRECT_FONT(uc)) {
|
2003-01-14 18:28:23 +00:00
|
|
|
if (ucsdata.dbcs_screenfont) return 1;
|
2001-09-15 15:54:24 +00:00
|
|
|
|
|
|
|
/* Speedup, I know of no font where ascii is the wrong width */
|
Re-engineering of terminal emulator, phase 1.
The active terminal screen is no longer an array of `unsigned long'
encoding 16-bit Unicode plus 16 attribute bits. Now it's an array of
`termchar' structures, which currently have 32-bit Unicode and 32
attribute bits but which will probably expand further in future.
To prevent bloat of the memory footprint, I've introduced a mostly
RLE-like compression scheme for storing scrollback: each line is
compressed into a compact (but hard to modify) form when it moves
into the term->scrollback tree, and is temporarily decompressed when
the user wants to scroll back over it. My initial tests suggest that
this compression averages about 1/4 of the previous (32 bits per
character cell) data size in typical output, which means this is an
improvement even without counting the new ability to extend the
information stored in each character cell.
Another beneficial side effect is that the insane format in which
Unicode was passed to front ends through do_text() has now been
rendered sane.
Testing is incomplete; this _may_ still have instabilities. Windows
and Unix front ends both seem to work as far as I've looked, but I
haven't yet looked very hard. The Mac front end I've edited (it
seemed obvious how to change it) but I can't compile or test it.
As an immediate functional effect, the terminal emulator now
supports full 32-bit Unicode to whatever extent the host platform
allows it to. For example, if you output a 4-or-more-byte UTF-8
character in Unix pterm, it will not display it properly, but it
will correctly paste it back out in a UTF8_STRING selection. Windows
is more restricted, sadly.
[originally from svn r4609]
2004-10-13 11:50:16 +00:00
|
|
|
if ((uc&~CSET_MASK) >= ' ' && (uc&~CSET_MASK)<= '~')
|
2001-09-15 15:54:24 +00:00
|
|
|
return 1;
|
|
|
|
|
Re-engineering of terminal emulator, phase 1.
The active terminal screen is no longer an array of `unsigned long'
encoding 16-bit Unicode plus 16 attribute bits. Now it's an array of
`termchar' structures, which currently have 32-bit Unicode and 32
attribute bits but which will probably expand further in future.
To prevent bloat of the memory footprint, I've introduced a mostly
RLE-like compression scheme for storing scrollback: each line is
compressed into a compact (but hard to modify) form when it moves
into the term->scrollback tree, and is temporarily decompressed when
the user wants to scroll back over it. My initial tests suggest that
this compression averages about 1/4 of the previous (32 bits per
character cell) data size in typical output, which means this is an
improvement even without counting the new ability to extend the
information stored in each character cell.
Another beneficial side effect is that the insane format in which
Unicode was passed to front ends through do_text() has now been
rendered sane.
Testing is incomplete; this _may_ still have instabilities. Windows
and Unix front ends both seem to work as far as I've looked, but I
haven't yet looked very hard. The Mac front end I've edited (it
seemed obvious how to change it) but I can't compile or test it.
As an immediate functional effect, the terminal emulator now
supports full 32-bit Unicode to whatever extent the host platform
allows it to. For example, if you output a 4-or-more-byte UTF-8
character in Unix pterm, it will not display it properly, but it
will correctly paste it back out in a UTF8_STRING selection. Windows
is more restricted, sadly.
[originally from svn r4609]
2004-10-13 11:50:16 +00:00
|
|
|
if ( (uc & CSET_MASK) == CSET_ACP ) {
|
2001-09-15 15:54:24 +00:00
|
|
|
SelectObject(hdc, fonts[FONT_NORMAL]);
|
Re-engineering of terminal emulator, phase 1.
The active terminal screen is no longer an array of `unsigned long'
encoding 16-bit Unicode plus 16 attribute bits. Now it's an array of
`termchar' structures, which currently have 32-bit Unicode and 32
attribute bits but which will probably expand further in future.
To prevent bloat of the memory footprint, I've introduced a mostly
RLE-like compression scheme for storing scrollback: each line is
compressed into a compact (but hard to modify) form when it moves
into the term->scrollback tree, and is temporarily decompressed when
the user wants to scroll back over it. My initial tests suggest that
this compression averages about 1/4 of the previous (32 bits per
character cell) data size in typical output, which means this is an
improvement even without counting the new ability to extend the
information stored in each character cell.
Another beneficial side effect is that the insane format in which
Unicode was passed to front ends through do_text() has now been
rendered sane.
Testing is incomplete; this _may_ still have instabilities. Windows
and Unix front ends both seem to work as far as I've looked, but I
haven't yet looked very hard. The Mac front end I've edited (it
seemed obvious how to change it) but I can't compile or test it.
As an immediate functional effect, the terminal emulator now
supports full 32-bit Unicode to whatever extent the host platform
allows it to. For example, if you output a 4-or-more-byte UTF-8
character in Unix pterm, it will not display it properly, but it
will correctly paste it back out in a UTF8_STRING selection. Windows
is more restricted, sadly.
[originally from svn r4609]
2004-10-13 11:50:16 +00:00
|
|
|
} else if ( (uc & CSET_MASK) == CSET_OEMCP ) {
|
2001-09-15 15:54:24 +00:00
|
|
|
another_font(FONT_OEM);
|
|
|
|
if (!fonts[FONT_OEM]) return 0;
|
|
|
|
|
|
|
|
SelectObject(hdc, fonts[FONT_OEM]);
|
|
|
|
} else
|
|
|
|
return 0;
|
|
|
|
|
Re-engineering of terminal emulator, phase 1.
The active terminal screen is no longer an array of `unsigned long'
encoding 16-bit Unicode plus 16 attribute bits. Now it's an array of
`termchar' structures, which currently have 32-bit Unicode and 32
attribute bits but which will probably expand further in future.
To prevent bloat of the memory footprint, I've introduced a mostly
RLE-like compression scheme for storing scrollback: each line is
compressed into a compact (but hard to modify) form when it moves
into the term->scrollback tree, and is temporarily decompressed when
the user wants to scroll back over it. My initial tests suggest that
this compression averages about 1/4 of the previous (32 bits per
character cell) data size in typical output, which means this is an
improvement even without counting the new ability to extend the
information stored in each character cell.
Another beneficial side effect is that the insane format in which
Unicode was passed to front ends through do_text() has now been
rendered sane.
Testing is incomplete; this _may_ still have instabilities. Windows
and Unix front ends both seem to work as far as I've looked, but I
haven't yet looked very hard. The Mac front end I've edited (it
seemed obvious how to change it) but I can't compile or test it.
As an immediate functional effect, the terminal emulator now
supports full 32-bit Unicode to whatever extent the host platform
allows it to. For example, if you output a 4-or-more-byte UTF-8
character in Unix pterm, it will not display it properly, but it
will correctly paste it back out in a UTF8_STRING selection. Windows
is more restricted, sadly.
[originally from svn r4609]
2004-10-13 11:50:16 +00:00
|
|
|
if ( GetCharWidth32(hdc, uc&~CSET_MASK, uc&~CSET_MASK, &ibuf) != 1 &&
|
|
|
|
GetCharWidth(hdc, uc&~CSET_MASK, uc&~CSET_MASK, &ibuf) != 1)
|
2001-09-15 15:54:24 +00:00
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
/* Speedup, I know of no font where ascii is the wrong width */
|
|
|
|
if (uc >= ' ' && uc <= '~') return 1;
|
|
|
|
|
|
|
|
SelectObject(hdc, fonts[FONT_NORMAL]);
|
|
|
|
if ( GetCharWidth32W(hdc, uc, uc, &ibuf) == 1 )
|
|
|
|
/* Okay that one worked */ ;
|
|
|
|
else if ( GetCharWidthW(hdc, uc, uc, &ibuf) == 1 )
|
|
|
|
/* This should work on 9x too, but it's "less accurate" */ ;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
ibuf += font_width / 2 -1;
|
|
|
|
ibuf /= font_width;
|
|
|
|
|
|
|
|
return ibuf;
|
|
|
|
}
|
|
|
|
|
1999-01-08 13:02:13 +00:00
|
|
|
/*
|
2000-07-26 12:13:51 +00:00
|
|
|
* Translate a WM_(SYS)?KEY(UP|DOWN) message into a string of ASCII
|
2007-02-18 14:02:39 +00:00
|
|
|
* codes. Returns number of bytes used, zero to drop the message,
|
|
|
|
* -1 to forward the message to Windows, or another negative number
|
|
|
|
* to indicate a NUL-terminated "special" string.
|
1999-01-08 13:02:13 +00:00
|
|
|
*/
|
2000-10-20 18:36:15 +00:00
|
|
|
static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
|
2001-05-06 14:35:20 +00:00
|
|
|
unsigned char *output)
|
|
|
|
{
|
1999-01-08 13:02:13 +00:00
|
|
|
BYTE keystate[256];
|
2001-05-06 14:35:20 +00:00
|
|
|
int scan, left_alt = 0, key_down, shift_state;
|
|
|
|
int r, i, code;
|
|
|
|
unsigned char *p = output;
|
2001-05-10 08:34:20 +00:00
|
|
|
static int alt_sum = 0;
|
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
|
|
|
int funky_type = conf_get_int(conf, CONF_funky_type);
|
|
|
|
int no_applic_k = conf_get_int(conf, CONF_no_applic_k);
|
|
|
|
int ctrlaltkeys = conf_get_int(conf, CONF_ctrlaltkeys);
|
|
|
|
int nethack_keypad = conf_get_int(conf, CONF_nethack_keypad);
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2001-01-07 18:28:01 +00:00
|
|
|
HKL kbd_layout = GetKeyboardLayout(0);
|
|
|
|
|
2004-03-26 15:18:42 +00:00
|
|
|
/* keys is for ToAsciiEx. There's some ick here, see below. */
|
|
|
|
static WORD keys[3];
|
2000-10-07 08:10:32 +00:00
|
|
|
static int compose_char = 0;
|
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
|
|
|
static WPARAM compose_keycode = 0;
|
2001-05-06 14:35:20 +00:00
|
|
|
|
2000-07-26 12:13:51 +00:00
|
|
|
r = GetKeyboardState(keystate);
|
2001-05-06 14:35:20 +00:00
|
|
|
if (!r)
|
|
|
|
memset(keystate, 0, sizeof(keystate));
|
|
|
|
else {
|
2000-10-09 12:53:32 +00:00
|
|
|
#if 0
|
2001-05-10 08:34:20 +00:00
|
|
|
#define SHOW_TOASCII_RESULT
|
2001-05-06 14:35:20 +00:00
|
|
|
{ /* Tell us all about key events */
|
|
|
|
static BYTE oldstate[256];
|
|
|
|
static int first = 1;
|
|
|
|
static int scan;
|
|
|
|
int ch;
|
|
|
|
if (first)
|
|
|
|
memcpy(oldstate, keystate, sizeof(oldstate));
|
|
|
|
first = 0;
|
|
|
|
|
|
|
|
if ((HIWORD(lParam) & (KF_UP | KF_REPEAT)) == KF_REPEAT) {
|
|
|
|
debug(("+"));
|
|
|
|
} else if ((HIWORD(lParam) & KF_UP)
|
|
|
|
&& scan == (HIWORD(lParam) & 0xFF)) {
|
|
|
|
debug((". U"));
|
|
|
|
} else {
|
|
|
|
debug((".\n"));
|
|
|
|
if (wParam >= VK_F1 && wParam <= VK_F20)
|
|
|
|
debug(("K_F%d", wParam + 1 - VK_F1));
|
|
|
|
else
|
|
|
|
switch (wParam) {
|
|
|
|
case VK_SHIFT:
|
|
|
|
debug(("SHIFT"));
|
|
|
|
break;
|
|
|
|
case VK_CONTROL:
|
|
|
|
debug(("CTRL"));
|
|
|
|
break;
|
|
|
|
case VK_MENU:
|
|
|
|
debug(("ALT"));
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
debug(("VK_%02x", wParam));
|
|
|
|
}
|
|
|
|
if (message == WM_SYSKEYDOWN || message == WM_SYSKEYUP)
|
|
|
|
debug(("*"));
|
|
|
|
debug((", S%02x", scan = (HIWORD(lParam) & 0xFF)));
|
|
|
|
|
|
|
|
ch = MapVirtualKeyEx(wParam, 2, kbd_layout);
|
|
|
|
if (ch >= ' ' && ch <= '~')
|
|
|
|
debug((", '%c'", ch));
|
|
|
|
else if (ch)
|
|
|
|
debug((", $%02x", ch));
|
|
|
|
|
|
|
|
if (keys[0])
|
|
|
|
debug((", KB0=%02x", keys[0]));
|
|
|
|
if (keys[1])
|
|
|
|
debug((", KB1=%02x", keys[1]));
|
|
|
|
if (keys[2])
|
|
|
|
debug((", KB2=%02x", keys[2]));
|
|
|
|
|
|
|
|
if ((keystate[VK_SHIFT] & 0x80) != 0)
|
|
|
|
debug((", S"));
|
|
|
|
if ((keystate[VK_CONTROL] & 0x80) != 0)
|
|
|
|
debug((", C"));
|
|
|
|
if ((HIWORD(lParam) & KF_EXTENDED))
|
|
|
|
debug((", E"));
|
|
|
|
if ((HIWORD(lParam) & KF_UP))
|
|
|
|
debug((", U"));
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((HIWORD(lParam) & (KF_UP | KF_REPEAT)) == KF_REPEAT);
|
|
|
|
else if ((HIWORD(lParam) & KF_UP))
|
|
|
|
oldstate[wParam & 0xFF] ^= 0x80;
|
|
|
|
else
|
|
|
|
oldstate[wParam & 0xFF] ^= 0x81;
|
|
|
|
|
|
|
|
for (ch = 0; ch < 256; ch++)
|
|
|
|
if (oldstate[ch] != keystate[ch])
|
|
|
|
debug((", M%02x=%02x", ch, keystate[ch]));
|
|
|
|
|
|
|
|
memcpy(oldstate, keystate, sizeof(oldstate));
|
|
|
|
}
|
2000-10-09 12:53:32 +00:00
|
|
|
#endif
|
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
if (wParam == VK_MENU && (HIWORD(lParam) & KF_EXTENDED)) {
|
2001-01-07 14:30:00 +00:00
|
|
|
keystate[VK_RMENU] = keystate[VK_MENU];
|
|
|
|
}
|
|
|
|
|
2000-07-26 12:13:51 +00:00
|
|
|
|
|
|
|
/* Nastyness with NUMLock - Shift-NUMLock is left alone though */
|
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
|
|
|
if ((funky_type == FUNKY_VT400 ||
|
|
|
|
(funky_type <= FUNKY_LINUX && term->app_keypad_keys &&
|
|
|
|
!no_applic_k))
|
2001-05-06 14:35:20 +00:00
|
|
|
&& wParam == VK_NUMLOCK && !(keystate[VK_SHIFT] & 0x80)) {
|
2000-07-26 12:13:51 +00:00
|
|
|
|
|
|
|
wParam = VK_EXECUTE;
|
|
|
|
|
|
|
|
/* UnToggle NUMLock */
|
2001-05-06 14:35:20 +00:00
|
|
|
if ((HIWORD(lParam) & (KF_UP | KF_REPEAT)) == 0)
|
|
|
|
keystate[VK_NUMLOCK] ^= 1;
|
2000-07-26 12:13:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* And write back the 'adjusted' state */
|
2001-05-06 14:35:20 +00:00
|
|
|
SetKeyboardState(keystate);
|
2000-07-26 12:13:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Disable Auto repeat if required */
|
2002-10-22 16:11:33 +00:00
|
|
|
if (term->repeat_off &&
|
|
|
|
(HIWORD(lParam) & (KF_UP | KF_REPEAT)) == KF_REPEAT)
|
2001-05-06 14:35:20 +00:00
|
|
|
return 0;
|
2000-07-26 12:13:51 +00:00
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
if ((HIWORD(lParam) & KF_ALTDOWN) && (keystate[VK_RMENU] & 0x80) == 0)
|
2000-07-26 12:13:51 +00:00
|
|
|
left_alt = 1;
|
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
key_down = ((HIWORD(lParam) & KF_UP) == 0);
|
2000-07-26 12:13:51 +00:00
|
|
|
|
2001-04-09 12:52:43 +00:00
|
|
|
/* Make sure Ctrl-ALT is not the same as AltGr for ToAscii unless told. */
|
2001-05-06 14:35:20 +00:00
|
|
|
if (left_alt && (keystate[VK_CONTROL] & 0x80)) {
|
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
|
|
|
if (ctrlaltkeys)
|
2001-04-09 12:52:43 +00:00
|
|
|
keystate[VK_MENU] = 0;
|
|
|
|
else {
|
|
|
|
keystate[VK_RMENU] = 0x80;
|
|
|
|
left_alt = 0;
|
|
|
|
}
|
|
|
|
}
|
2000-07-26 12:13:51 +00:00
|
|
|
|
|
|
|
scan = (HIWORD(lParam) & (KF_UP | KF_EXTENDED | 0xFF));
|
2001-05-06 14:35:20 +00:00
|
|
|
shift_state = ((keystate[VK_SHIFT] & 0x80) != 0)
|
|
|
|
+ ((keystate[VK_CONTROL] & 0x80) != 0) * 2;
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2001-04-09 12:52:43 +00:00
|
|
|
/* Note if AltGr was pressed and if it was used as a compose key */
|
|
|
|
if (!compose_state) {
|
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
|
|
|
compose_keycode = 0x100;
|
|
|
|
if (conf_get_int(conf, CONF_compose_key)) {
|
2001-05-06 14:35:20 +00:00
|
|
|
if (wParam == VK_MENU && (HIWORD(lParam) & KF_EXTENDED))
|
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
|
|
|
compose_keycode = wParam;
|
2001-04-09 12:52:43 +00:00
|
|
|
}
|
|
|
|
if (wParam == VK_APPS)
|
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
|
|
|
compose_keycode = wParam;
|
2001-04-09 12:52:43 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
if (wParam == compose_keycode) {
|
2001-05-06 14:35:20 +00:00
|
|
|
if (compose_state == 0
|
|
|
|
&& (HIWORD(lParam) & (KF_UP | KF_REPEAT)) == 0) compose_state =
|
|
|
|
1;
|
|
|
|
else if (compose_state == 1 && (HIWORD(lParam) & KF_UP))
|
2001-04-09 12:52:43 +00:00
|
|
|
compose_state = 2;
|
|
|
|
else
|
|
|
|
compose_state = 0;
|
2001-05-06 14:35:20 +00:00
|
|
|
} else if (compose_state == 1 && wParam != VK_CONTROL)
|
2001-04-09 12:52:43 +00:00
|
|
|
compose_state = 0;
|
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
if (compose_state > 1 && left_alt)
|
|
|
|
compose_state = 0;
|
1999-03-12 17:14:06 +00:00
|
|
|
|
2000-07-26 12:13:51 +00:00
|
|
|
/* Sanitize the number pad if not using a PC NumPad */
|
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
|
|
|
if (left_alt || (term->app_keypad_keys && !no_applic_k
|
|
|
|
&& funky_type != FUNKY_XTERM)
|
|
|
|
|| funky_type == FUNKY_VT400 || nethack_keypad || compose_state) {
|
2001-05-06 14:35:20 +00:00
|
|
|
if ((HIWORD(lParam) & KF_EXTENDED) == 0) {
|
2000-07-26 12:13:51 +00:00
|
|
|
int nParam = 0;
|
2001-05-06 14:35:20 +00:00
|
|
|
switch (wParam) {
|
|
|
|
case VK_INSERT:
|
|
|
|
nParam = VK_NUMPAD0;
|
|
|
|
break;
|
|
|
|
case VK_END:
|
|
|
|
nParam = VK_NUMPAD1;
|
|
|
|
break;
|
|
|
|
case VK_DOWN:
|
|
|
|
nParam = VK_NUMPAD2;
|
|
|
|
break;
|
|
|
|
case VK_NEXT:
|
|
|
|
nParam = VK_NUMPAD3;
|
|
|
|
break;
|
|
|
|
case VK_LEFT:
|
|
|
|
nParam = VK_NUMPAD4;
|
|
|
|
break;
|
|
|
|
case VK_CLEAR:
|
|
|
|
nParam = VK_NUMPAD5;
|
|
|
|
break;
|
|
|
|
case VK_RIGHT:
|
|
|
|
nParam = VK_NUMPAD6;
|
|
|
|
break;
|
|
|
|
case VK_HOME:
|
|
|
|
nParam = VK_NUMPAD7;
|
|
|
|
break;
|
|
|
|
case VK_UP:
|
|
|
|
nParam = VK_NUMPAD8;
|
|
|
|
break;
|
|
|
|
case VK_PRIOR:
|
|
|
|
nParam = VK_NUMPAD9;
|
|
|
|
break;
|
|
|
|
case VK_DELETE:
|
|
|
|
nParam = VK_DECIMAL;
|
|
|
|
break;
|
2000-07-26 12:13:51 +00:00
|
|
|
}
|
2001-05-06 14:35:20 +00:00
|
|
|
if (nParam) {
|
|
|
|
if (keystate[VK_NUMLOCK] & 1)
|
|
|
|
shift_state |= 1;
|
2000-07-26 12:13:51 +00:00
|
|
|
wParam = nParam;
|
|
|
|
}
|
1999-11-09 11:19:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-07-26 12:13:51 +00:00
|
|
|
/* If a key is pressed and AltGr is not active */
|
2001-05-06 14:35:20 +00:00
|
|
|
if (key_down && (keystate[VK_RMENU] & 0x80) == 0 && !compose_state) {
|
|
|
|
/* Okay, prepare for most alts then ... */
|
|
|
|
if (left_alt)
|
|
|
|
*p++ = '\033';
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2000-07-26 12:13:51 +00:00
|
|
|
/* Lets see if it's a pattern we know all about ... */
|
|
|
|
if (wParam == VK_PRIOR && shift_state == 1) {
|
2001-05-06 14:35:20 +00:00
|
|
|
SendMessage(hwnd, WM_VSCROLL, SB_PAGEUP, 0);
|
|
|
|
return 0;
|
2000-07-26 12:13:51 +00:00
|
|
|
}
|
2003-01-14 11:24:26 +00:00
|
|
|
if (wParam == VK_PRIOR && shift_state == 2) {
|
|
|
|
SendMessage(hwnd, WM_VSCROLL, SB_LINEUP, 0);
|
|
|
|
return 0;
|
|
|
|
}
|
2000-07-26 12:13:51 +00:00
|
|
|
if (wParam == VK_NEXT && shift_state == 1) {
|
2001-05-06 14:35:20 +00:00
|
|
|
SendMessage(hwnd, WM_VSCROLL, SB_PAGEDOWN, 0);
|
|
|
|
return 0;
|
|
|
|
}
|
2003-01-14 11:24:26 +00:00
|
|
|
if (wParam == VK_NEXT && shift_state == 2) {
|
|
|
|
SendMessage(hwnd, WM_VSCROLL, SB_LINEDOWN, 0);
|
|
|
|
return 0;
|
|
|
|
}
|
2010-04-23 18:32:15 +00:00
|
|
|
if ((wParam == VK_PRIOR || wParam == VK_NEXT) && shift_state == 3) {
|
|
|
|
term_scroll_to_selection(term, (wParam == VK_PRIOR ? 0 : 1));
|
|
|
|
return 0;
|
|
|
|
}
|
2001-05-06 14:35:20 +00:00
|
|
|
if (wParam == VK_INSERT && shift_state == 1) {
|
2008-12-29 20:04:42 +00:00
|
|
|
request_paste(NULL);
|
2001-05-06 14:35:20 +00:00
|
|
|
return 0;
|
|
|
|
}
|
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
|
|
|
if (left_alt && wParam == VK_F4 && conf_get_int(conf, CONF_alt_f4)) {
|
2001-05-06 14:35:20 +00:00
|
|
|
return -1;
|
2000-07-26 12:13:51 +00:00
|
|
|
}
|
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
|
|
|
if (left_alt && wParam == VK_SPACE && conf_get_int(conf,
|
|
|
|
CONF_alt_space)) {
|
2001-05-06 14:35:20 +00:00
|
|
|
SendMessage(hwnd, WM_SYSCOMMAND, SC_KEYMENU, 0);
|
|
|
|
return -1;
|
2000-07-26 12:13:51 +00:00
|
|
|
}
|
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
|
|
|
if (left_alt && wParam == VK_RETURN &&
|
|
|
|
conf_get_int(conf, CONF_fullscreenonaltenter) &&
|
|
|
|
(conf_get_int(conf, CONF_resize_action) != RESIZE_DISABLED)) {
|
2001-11-25 18:39:57 +00:00
|
|
|
if ((HIWORD(lParam) & (KF_UP | KF_REPEAT)) != KF_REPEAT)
|
|
|
|
flip_full_screen();
|
2001-09-13 18:24:51 +00:00
|
|
|
return -1;
|
|
|
|
}
|
2000-10-09 12:53:32 +00:00
|
|
|
/* Control-Numlock for app-keypad mode switch */
|
|
|
|
if (wParam == VK_PAUSE && shift_state == 2) {
|
2002-10-22 16:11:33 +00:00
|
|
|
term->app_keypad_keys ^= 1;
|
2000-10-09 12:53:32 +00:00
|
|
|
return 0;
|
|
|
|
}
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2000-07-26 12:13:51 +00:00
|
|
|
/* Nethack keypad */
|
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
|
|
|
if (nethack_keypad && !left_alt) {
|
2001-05-06 14:35:20 +00:00
|
|
|
switch (wParam) {
|
|
|
|
case VK_NUMPAD1:
|
2006-03-08 18:10:12 +00:00
|
|
|
*p++ = "bB\002\002"[shift_state & 3];
|
2001-05-06 14:35:20 +00:00
|
|
|
return p - output;
|
|
|
|
case VK_NUMPAD2:
|
2006-03-08 18:10:12 +00:00
|
|
|
*p++ = "jJ\012\012"[shift_state & 3];
|
2001-05-06 14:35:20 +00:00
|
|
|
return p - output;
|
|
|
|
case VK_NUMPAD3:
|
2006-03-08 18:10:12 +00:00
|
|
|
*p++ = "nN\016\016"[shift_state & 3];
|
2001-05-06 14:35:20 +00:00
|
|
|
return p - output;
|
|
|
|
case VK_NUMPAD4:
|
2006-03-08 18:10:12 +00:00
|
|
|
*p++ = "hH\010\010"[shift_state & 3];
|
2001-05-06 14:35:20 +00:00
|
|
|
return p - output;
|
|
|
|
case VK_NUMPAD5:
|
|
|
|
*p++ = shift_state ? '.' : '.';
|
|
|
|
return p - output;
|
|
|
|
case VK_NUMPAD6:
|
2006-03-08 18:10:12 +00:00
|
|
|
*p++ = "lL\014\014"[shift_state & 3];
|
2001-05-06 14:35:20 +00:00
|
|
|
return p - output;
|
|
|
|
case VK_NUMPAD7:
|
2006-03-08 18:10:12 +00:00
|
|
|
*p++ = "yY\031\031"[shift_state & 3];
|
2001-05-06 14:35:20 +00:00
|
|
|
return p - output;
|
|
|
|
case VK_NUMPAD8:
|
2006-03-08 18:10:12 +00:00
|
|
|
*p++ = "kK\013\013"[shift_state & 3];
|
2001-05-06 14:35:20 +00:00
|
|
|
return p - output;
|
|
|
|
case VK_NUMPAD9:
|
2006-03-08 18:10:12 +00:00
|
|
|
*p++ = "uU\025\025"[shift_state & 3];
|
2001-05-06 14:35:20 +00:00
|
|
|
return p - output;
|
|
|
|
}
|
2000-07-26 12:13:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Application Keypad */
|
|
|
|
if (!left_alt) {
|
2001-05-06 14:35:20 +00:00
|
|
|
int xkey = 0;
|
|
|
|
|
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
|
|
|
if (funky_type == FUNKY_VT400 ||
|
|
|
|
(funky_type <= FUNKY_LINUX &&
|
|
|
|
term->app_keypad_keys && !no_applic_k)) switch (wParam) {
|
2001-05-06 14:35:20 +00:00
|
|
|
case VK_EXECUTE:
|
|
|
|
xkey = 'P';
|
|
|
|
break;
|
|
|
|
case VK_DIVIDE:
|
|
|
|
xkey = 'Q';
|
|
|
|
break;
|
|
|
|
case VK_MULTIPLY:
|
|
|
|
xkey = 'R';
|
|
|
|
break;
|
|
|
|
case VK_SUBTRACT:
|
|
|
|
xkey = 'S';
|
|
|
|
break;
|
|
|
|
}
|
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
|
|
|
if (term->app_keypad_keys && !no_applic_k)
|
2001-05-06 14:35:20 +00:00
|
|
|
switch (wParam) {
|
|
|
|
case VK_NUMPAD0:
|
|
|
|
xkey = 'p';
|
|
|
|
break;
|
|
|
|
case VK_NUMPAD1:
|
|
|
|
xkey = 'q';
|
|
|
|
break;
|
|
|
|
case VK_NUMPAD2:
|
|
|
|
xkey = 'r';
|
|
|
|
break;
|
|
|
|
case VK_NUMPAD3:
|
|
|
|
xkey = 's';
|
|
|
|
break;
|
|
|
|
case VK_NUMPAD4:
|
|
|
|
xkey = 't';
|
|
|
|
break;
|
|
|
|
case VK_NUMPAD5:
|
|
|
|
xkey = 'u';
|
|
|
|
break;
|
|
|
|
case VK_NUMPAD6:
|
|
|
|
xkey = 'v';
|
|
|
|
break;
|
|
|
|
case VK_NUMPAD7:
|
|
|
|
xkey = 'w';
|
|
|
|
break;
|
|
|
|
case VK_NUMPAD8:
|
|
|
|
xkey = 'x';
|
|
|
|
break;
|
|
|
|
case VK_NUMPAD9:
|
|
|
|
xkey = 'y';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_DECIMAL:
|
|
|
|
xkey = 'n';
|
|
|
|
break;
|
|
|
|
case VK_ADD:
|
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
|
|
|
if (funky_type == FUNKY_XTERM) {
|
2001-05-06 14:35:20 +00:00
|
|
|
if (shift_state)
|
|
|
|
xkey = 'l';
|
|
|
|
else
|
|
|
|
xkey = 'k';
|
|
|
|
} else if (shift_state)
|
|
|
|
xkey = 'm';
|
2000-07-26 12:13:51 +00:00
|
|
|
else
|
2001-05-06 14:35:20 +00:00
|
|
|
xkey = 'l';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_DIVIDE:
|
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
|
|
|
if (funky_type == FUNKY_XTERM)
|
2001-05-06 14:35:20 +00:00
|
|
|
xkey = 'o';
|
|
|
|
break;
|
|
|
|
case VK_MULTIPLY:
|
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
|
|
|
if (funky_type == FUNKY_XTERM)
|
2001-05-06 14:35:20 +00:00
|
|
|
xkey = 'j';
|
|
|
|
break;
|
|
|
|
case VK_SUBTRACT:
|
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
|
|
|
if (funky_type == FUNKY_XTERM)
|
2001-05-06 14:35:20 +00:00
|
|
|
xkey = 'm';
|
|
|
|
break;
|
|
|
|
|
|
|
|
case VK_RETURN:
|
|
|
|
if (HIWORD(lParam) & KF_EXTENDED)
|
|
|
|
xkey = 'M';
|
|
|
|
break;
|
2000-07-26 12:13:51 +00:00
|
|
|
}
|
2001-05-06 14:35:20 +00:00
|
|
|
if (xkey) {
|
2002-10-22 16:11:33 +00:00
|
|
|
if (term->vt52_mode) {
|
2001-05-06 14:35:20 +00:00
|
|
|
if (xkey >= 'P' && xkey <= 'S')
|
|
|
|
p += sprintf((char *) p, "\x1B%c", xkey);
|
|
|
|
else
|
|
|
|
p += sprintf((char *) p, "\x1B?%c", xkey);
|
|
|
|
} else
|
|
|
|
p += sprintf((char *) p, "\x1BO%c", xkey);
|
|
|
|
return p - output;
|
2000-07-26 12:13:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
if (wParam == VK_BACK && shift_state == 0) { /* Backspace */
|
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
|
|
|
*p++ = (conf_get_int(conf, CONF_bksp_is_delete) ? 0x7F : 0x08);
|
2001-05-09 15:12:26 +00:00
|
|
|
*p++ = 0;
|
|
|
|
return -2;
|
2000-07-26 12:13:51 +00:00
|
|
|
}
|
2002-10-16 09:40:36 +00:00
|
|
|
if (wParam == VK_BACK && shift_state == 1) { /* Shift Backspace */
|
|
|
|
/* We do the opposite of what is configured */
|
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
|
|
|
*p++ = (conf_get_int(conf, CONF_bksp_is_delete) ? 0x08 : 0x7F);
|
2002-10-16 09:40:36 +00:00
|
|
|
*p++ = 0;
|
|
|
|
return -2;
|
|
|
|
}
|
2001-05-06 14:35:20 +00:00
|
|
|
if (wParam == VK_TAB && shift_state == 1) { /* Shift tab */
|
|
|
|
*p++ = 0x1B;
|
|
|
|
*p++ = '[';
|
|
|
|
*p++ = 'Z';
|
|
|
|
return p - output;
|
2000-07-26 12:13:51 +00:00
|
|
|
}
|
2001-05-06 14:35:20 +00:00
|
|
|
if (wParam == VK_SPACE && shift_state == 2) { /* Ctrl-Space */
|
|
|
|
*p++ = 0;
|
|
|
|
return p - output;
|
2000-07-26 12:13:51 +00:00
|
|
|
}
|
2001-05-06 14:35:20 +00:00
|
|
|
if (wParam == VK_SPACE && shift_state == 3) { /* Ctrl-Shift-Space */
|
|
|
|
*p++ = 160;
|
|
|
|
return p - output;
|
2000-07-26 12:13:51 +00:00
|
|
|
}
|
2001-05-06 14:35:20 +00:00
|
|
|
if (wParam == VK_CANCEL && shift_state == 2) { /* Ctrl-Break */
|
2007-02-18 14:02:39 +00:00
|
|
|
if (back)
|
|
|
|
back->special(backhandle, TS_BRK);
|
|
|
|
return 0;
|
2000-07-26 12:13:51 +00:00
|
|
|
}
|
2001-05-06 14:35:20 +00:00
|
|
|
if (wParam == VK_PAUSE) { /* Break/Pause */
|
|
|
|
*p++ = 26;
|
|
|
|
*p++ = 0;
|
|
|
|
return -2;
|
2001-04-09 12:52:43 +00:00
|
|
|
}
|
2000-07-26 12:13:51 +00:00
|
|
|
/* Control-2 to Control-8 are special */
|
2001-05-06 14:35:20 +00:00
|
|
|
if (shift_state == 2 && wParam >= '2' && wParam <= '8') {
|
|
|
|
*p++ = "\000\033\034\035\036\037\177"[wParam - '2'];
|
2000-07-26 12:13:51 +00:00
|
|
|
return p - output;
|
|
|
|
}
|
2003-01-13 15:06:56 +00:00
|
|
|
if (shift_state == 2 && (wParam == 0xBD || wParam == 0xBF)) {
|
2000-07-26 12:13:51 +00:00
|
|
|
*p++ = 0x1F;
|
|
|
|
return p - output;
|
|
|
|
}
|
2008-09-14 15:11:42 +00:00
|
|
|
if (shift_state == 2 && (wParam == 0xDF || wParam == 0xDC)) {
|
2000-07-26 12:13:51 +00:00
|
|
|
*p++ = 0x1C;
|
|
|
|
return p - output;
|
|
|
|
}
|
2003-06-28 07:52:19 +00:00
|
|
|
if (shift_state == 3 && wParam == 0xDE) {
|
|
|
|
*p++ = 0x1E; /* Ctrl-~ == Ctrl-^ in xterm at least */
|
|
|
|
return p - output;
|
|
|
|
}
|
2002-10-22 16:11:33 +00:00
|
|
|
if (shift_state == 0 && wParam == VK_RETURN && term->cr_lf_return) {
|
2001-05-06 14:35:20 +00:00
|
|
|
*p++ = '\r';
|
|
|
|
*p++ = '\n';
|
2000-07-26 12:13:51 +00:00
|
|
|
return p - output;
|
|
|
|
}
|
1999-01-08 13:02:13 +00:00
|
|
|
|
1999-11-09 11:10:04 +00:00
|
|
|
/*
|
2000-07-26 12:13:51 +00:00
|
|
|
* Next, all the keys that do tilde codes. (ESC '[' nn '~',
|
|
|
|
* for integer decimal nn.)
|
|
|
|
*
|
|
|
|
* We also deal with the weird ones here. Linux VCs replace F1
|
|
|
|
* to F5 by ESC [ [ A to ESC [ [ E. rxvt doesn't do _that_, but
|
|
|
|
* does replace Home and End (1~ and 4~) by ESC [ H and ESC O w
|
|
|
|
* respectively.
|
1999-11-09 11:10:04 +00:00
|
|
|
*/
|
2000-07-26 12:13:51 +00:00
|
|
|
code = 0;
|
|
|
|
switch (wParam) {
|
2001-05-06 14:35:20 +00:00
|
|
|
case VK_F1:
|
|
|
|
code = (keystate[VK_SHIFT] & 0x80 ? 23 : 11);
|
|
|
|
break;
|
|
|
|
case VK_F2:
|
|
|
|
code = (keystate[VK_SHIFT] & 0x80 ? 24 : 12);
|
|
|
|
break;
|
|
|
|
case VK_F3:
|
|
|
|
code = (keystate[VK_SHIFT] & 0x80 ? 25 : 13);
|
|
|
|
break;
|
|
|
|
case VK_F4:
|
|
|
|
code = (keystate[VK_SHIFT] & 0x80 ? 26 : 14);
|
|
|
|
break;
|
|
|
|
case VK_F5:
|
|
|
|
code = (keystate[VK_SHIFT] & 0x80 ? 28 : 15);
|
|
|
|
break;
|
|
|
|
case VK_F6:
|
|
|
|
code = (keystate[VK_SHIFT] & 0x80 ? 29 : 17);
|
|
|
|
break;
|
|
|
|
case VK_F7:
|
|
|
|
code = (keystate[VK_SHIFT] & 0x80 ? 31 : 18);
|
|
|
|
break;
|
|
|
|
case VK_F8:
|
|
|
|
code = (keystate[VK_SHIFT] & 0x80 ? 32 : 19);
|
|
|
|
break;
|
|
|
|
case VK_F9:
|
|
|
|
code = (keystate[VK_SHIFT] & 0x80 ? 33 : 20);
|
|
|
|
break;
|
|
|
|
case VK_F10:
|
|
|
|
code = (keystate[VK_SHIFT] & 0x80 ? 34 : 21);
|
|
|
|
break;
|
|
|
|
case VK_F11:
|
|
|
|
code = 23;
|
|
|
|
break;
|
|
|
|
case VK_F12:
|
|
|
|
code = 24;
|
|
|
|
break;
|
|
|
|
case VK_F13:
|
|
|
|
code = 25;
|
|
|
|
break;
|
|
|
|
case VK_F14:
|
|
|
|
code = 26;
|
|
|
|
break;
|
|
|
|
case VK_F15:
|
|
|
|
code = 28;
|
|
|
|
break;
|
|
|
|
case VK_F16:
|
|
|
|
code = 29;
|
|
|
|
break;
|
|
|
|
case VK_F17:
|
|
|
|
code = 31;
|
|
|
|
break;
|
|
|
|
case VK_F18:
|
|
|
|
code = 32;
|
|
|
|
break;
|
|
|
|
case VK_F19:
|
|
|
|
code = 33;
|
|
|
|
break;
|
|
|
|
case VK_F20:
|
|
|
|
code = 34;
|
|
|
|
break;
|
2001-09-07 21:39:03 +00:00
|
|
|
}
|
|
|
|
if ((shift_state&2) == 0) switch (wParam) {
|
2001-05-06 14:35:20 +00:00
|
|
|
case VK_HOME:
|
|
|
|
code = 1;
|
|
|
|
break;
|
|
|
|
case VK_INSERT:
|
|
|
|
code = 2;
|
|
|
|
break;
|
|
|
|
case VK_DELETE:
|
|
|
|
code = 3;
|
|
|
|
break;
|
|
|
|
case VK_END:
|
|
|
|
code = 4;
|
|
|
|
break;
|
|
|
|
case VK_PRIOR:
|
|
|
|
code = 5;
|
|
|
|
break;
|
|
|
|
case VK_NEXT:
|
|
|
|
code = 6;
|
|
|
|
break;
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
2000-10-09 12:53:32 +00:00
|
|
|
/* Reorder edit keys to physical order */
|
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
|
|
|
if (funky_type == FUNKY_VT400 && code <= 6)
|
2001-05-06 14:35:20 +00:00
|
|
|
code = "\0\2\1\4\5\3\6"[code];
|
2000-10-09 12:53:32 +00:00
|
|
|
|
2002-10-22 16:11:33 +00:00
|
|
|
if (term->vt52_mode && code > 0 && code <= 6) {
|
2001-05-06 14:35:20 +00:00
|
|
|
p += sprintf((char *) p, "\x1B%c", " HLMEIG"[code]);
|
2001-04-16 16:16:52 +00:00
|
|
|
return p - output;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
if (funky_type == FUNKY_SCO && code >= 11 && code <= 34) {
|
|
|
|
/* SCO function keys */
|
2001-05-13 10:58:51 +00:00
|
|
|
char codes[] = "MNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@[\\]^_`{";
|
|
|
|
int index = 0;
|
|
|
|
switch (wParam) {
|
|
|
|
case VK_F1: index = 0; break;
|
|
|
|
case VK_F2: index = 1; break;
|
|
|
|
case VK_F3: index = 2; break;
|
|
|
|
case VK_F4: index = 3; break;
|
|
|
|
case VK_F5: index = 4; break;
|
|
|
|
case VK_F6: index = 5; break;
|
|
|
|
case VK_F7: index = 6; break;
|
|
|
|
case VK_F8: index = 7; break;
|
|
|
|
case VK_F9: index = 8; break;
|
|
|
|
case VK_F10: index = 9; break;
|
|
|
|
case VK_F11: index = 10; break;
|
|
|
|
case VK_F12: index = 11; break;
|
|
|
|
}
|
|
|
|
if (keystate[VK_SHIFT] & 0x80) index += 12;
|
|
|
|
if (keystate[VK_CONTROL] & 0x80) index += 24;
|
|
|
|
p += sprintf((char *) p, "\x1B[%c", codes[index]);
|
2001-04-16 16:16:52 +00:00
|
|
|
return p - output;
|
|
|
|
}
|
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
|
|
|
if (funky_type == FUNKY_SCO && /* SCO small keypad */
|
2001-08-04 14:35:58 +00:00
|
|
|
code >= 1 && code <= 6) {
|
|
|
|
char codes[] = "HL.FIG";
|
|
|
|
if (code == 3) {
|
|
|
|
*p++ = '\x7F';
|
|
|
|
} else {
|
|
|
|
p += sprintf((char *) p, "\x1B[%c", codes[code-1]);
|
|
|
|
}
|
|
|
|
return p - output;
|
|
|
|
}
|
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
|
|
|
if ((term->vt52_mode || funky_type == FUNKY_VT100P) && code >= 11 && code <= 24) {
|
2001-04-16 16:16:52 +00:00
|
|
|
int offt = 0;
|
2001-05-06 14:35:20 +00:00
|
|
|
if (code > 15)
|
|
|
|
offt++;
|
|
|
|
if (code > 21)
|
|
|
|
offt++;
|
2002-10-22 16:11:33 +00:00
|
|
|
if (term->vt52_mode)
|
2001-05-06 14:35:20 +00:00
|
|
|
p += sprintf((char *) p, "\x1B%c", code + 'P' - 11 - offt);
|
2001-04-16 16:16:52 +00:00
|
|
|
else
|
2001-05-06 14:35:20 +00:00
|
|
|
p +=
|
|
|
|
sprintf((char *) p, "\x1BO%c", code + 'P' - 11 - offt);
|
2001-04-16 16:16:52 +00:00
|
|
|
return p - output;
|
|
|
|
}
|
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
|
|
|
if (funky_type == FUNKY_LINUX && code >= 11 && code <= 15) {
|
2001-05-06 14:35:20 +00:00
|
|
|
p += sprintf((char *) p, "\x1B[[%c", code + 'A' - 11);
|
2000-07-26 12:13:51 +00:00
|
|
|
return p - output;
|
|
|
|
}
|
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
|
|
|
if (funky_type == FUNKY_XTERM && code >= 11 && code <= 14) {
|
2002-10-22 16:11:33 +00:00
|
|
|
if (term->vt52_mode)
|
2001-05-06 14:35:20 +00:00
|
|
|
p += sprintf((char *) p, "\x1B%c", code + 'P' - 11);
|
2000-10-09 12:53:32 +00:00
|
|
|
else
|
2001-05-06 14:35:20 +00:00
|
|
|
p += sprintf((char *) p, "\x1BO%c", code + 'P' - 11);
|
2000-07-26 12:13:51 +00:00
|
|
|
return p - output;
|
|
|
|
}
|
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
|
|
|
if ((code == 1 || code == 4) &&
|
|
|
|
conf_get_int(conf, CONF_rxvt_homeend)) {
|
2001-05-06 14:35:20 +00:00
|
|
|
p += sprintf((char *) p, code == 1 ? "\x1B[H" : "\x1BOw");
|
2000-07-26 12:13:51 +00:00
|
|
|
return p - output;
|
|
|
|
}
|
|
|
|
if (code) {
|
2001-05-06 14:35:20 +00:00
|
|
|
p += sprintf((char *) p, "\x1B[%d~", code);
|
1999-01-08 13:02:13 +00:00
|
|
|
return p - output;
|
|
|
|
}
|
2000-03-13 14:45:32 +00:00
|
|
|
|
2000-07-26 12:13:51 +00:00
|
|
|
/*
|
|
|
|
* Now the remaining keys (arrows and Keypad 5. Keypad 5 for
|
|
|
|
* some reason seems to send VK_CLEAR to Windows...).
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
char xkey = 0;
|
|
|
|
switch (wParam) {
|
2001-05-06 14:35:20 +00:00
|
|
|
case VK_UP:
|
|
|
|
xkey = 'A';
|
|
|
|
break;
|
|
|
|
case VK_DOWN:
|
|
|
|
xkey = 'B';
|
|
|
|
break;
|
|
|
|
case VK_RIGHT:
|
|
|
|
xkey = 'C';
|
|
|
|
break;
|
|
|
|
case VK_LEFT:
|
|
|
|
xkey = 'D';
|
|
|
|
break;
|
|
|
|
case VK_CLEAR:
|
|
|
|
xkey = 'G';
|
|
|
|
break;
|
2000-07-26 12:13:51 +00:00
|
|
|
}
|
2001-05-06 14:35:20 +00:00
|
|
|
if (xkey) {
|
2010-03-06 15:50:26 +00:00
|
|
|
p += format_arrow_key(p, term, xkey, shift_state);
|
2000-07-26 12:13:51 +00:00
|
|
|
return p - output;
|
|
|
|
}
|
|
|
|
}
|
2000-10-07 08:10:32 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Finally, deal with Return ourselves. (Win95 seems to
|
|
|
|
* foul it up when Alt is pressed, for some reason.)
|
|
|
|
*/
|
2001-05-06 14:35:20 +00:00
|
|
|
if (wParam == VK_RETURN) { /* Return */
|
2000-10-07 08:10:32 +00:00
|
|
|
*p++ = 0x0D;
|
2001-05-09 15:12:26 +00:00
|
|
|
*p++ = 0;
|
|
|
|
return -2;
|
2000-10-07 08:10:32 +00:00
|
|
|
}
|
2001-05-10 08:34:20 +00:00
|
|
|
|
|
|
|
if (left_alt && wParam >= VK_NUMPAD0 && wParam <= VK_NUMPAD9)
|
|
|
|
alt_sum = alt_sum * 10 + wParam - VK_NUMPAD0;
|
|
|
|
else
|
|
|
|
alt_sum = 0;
|
1999-03-12 17:14:06 +00:00
|
|
|
}
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2000-07-26 12:13:51 +00:00
|
|
|
/* Okay we've done everything interesting; let windows deal with
|
|
|
|
* the boring stuff */
|
|
|
|
{
|
2001-09-18 18:51:10 +00:00
|
|
|
BOOL capsOn=0;
|
|
|
|
|
|
|
|
/* helg: clear CAPS LOCK state if caps lock switches to cyrillic */
|
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
|
|
|
if(keystate[VK_CAPITAL] != 0 &&
|
|
|
|
conf_get_int(conf, CONF_xlat_capslockcyr)) {
|
2001-09-18 18:51:10 +00:00
|
|
|
capsOn= !left_alt;
|
|
|
|
keystate[VK_CAPITAL] = 0;
|
|
|
|
}
|
|
|
|
|
2004-03-26 15:18:42 +00:00
|
|
|
/* XXX how do we know what the max size of the keys array should
|
|
|
|
* be is? There's indication on MS' website of an Inquire/InquireEx
|
|
|
|
* functioning returning a KBINFO structure which tells us. */
|
|
|
|
if (osVersion.dwPlatformId == VER_PLATFORM_WIN32_NT) {
|
|
|
|
/* XXX 'keys' parameter is declared in MSDN documentation as
|
|
|
|
* 'LPWORD lpChar'.
|
|
|
|
* The experience of a French user indicates that on
|
|
|
|
* Win98, WORD[] should be passed in, but on Win2K, it should
|
|
|
|
* be BYTE[]. German WinXP and my Win2K with "US International"
|
|
|
|
* driver corroborate this.
|
|
|
|
* Experimentally I've conditionalised the behaviour on the
|
|
|
|
* Win9x/NT split, but I suspect it's worse than that.
|
|
|
|
* See wishlist item `win-dead-keys' for more horrible detail
|
|
|
|
* and speculations. */
|
|
|
|
BYTE keybs[3];
|
|
|
|
int i;
|
|
|
|
r = ToAsciiEx(wParam, scan, keystate, (LPWORD)keybs, 0, kbd_layout);
|
|
|
|
for (i=0; i<3; i++) keys[i] = keybs[i];
|
|
|
|
} else {
|
|
|
|
r = ToAsciiEx(wParam, scan, keystate, keys, 0, kbd_layout);
|
|
|
|
}
|
2001-05-10 08:34:20 +00:00
|
|
|
#ifdef SHOW_TOASCII_RESULT
|
|
|
|
if (r == 1 && !key_down) {
|
|
|
|
if (alt_sum) {
|
2003-01-14 18:28:23 +00:00
|
|
|
if (in_utf(term) || ucsdata.dbcs_screenfont)
|
2001-05-10 08:34:20 +00:00
|
|
|
debug((", (U+%04x)", alt_sum));
|
|
|
|
else
|
|
|
|
debug((", LCH(%d)", alt_sum));
|
|
|
|
} else {
|
|
|
|
debug((", ACH(%d)", keys[0]));
|
|
|
|
}
|
|
|
|
} else if (r > 0) {
|
|
|
|
int r1;
|
|
|
|
debug((", ASC("));
|
|
|
|
for (r1 = 0; r1 < r; r1++) {
|
|
|
|
debug(("%s%d", r1 ? "," : "", keys[r1]));
|
|
|
|
}
|
|
|
|
debug((")"));
|
|
|
|
}
|
|
|
|
#endif
|
2001-05-06 14:35:20 +00:00
|
|
|
if (r > 0) {
|
2001-05-10 08:34:20 +00:00
|
|
|
WCHAR keybuf;
|
2001-09-21 17:54:29 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Interrupt an ongoing paste. I'm not sure this is
|
|
|
|
* sensible, but for the moment it's preferable to
|
|
|
|
* having to faff about buffering things.
|
|
|
|
*/
|
2002-10-22 16:11:33 +00:00
|
|
|
term_nopaste(term);
|
2001-09-21 17:54:29 +00:00
|
|
|
|
2000-07-26 12:13:51 +00:00
|
|
|
p = output;
|
2001-05-06 14:35:20 +00:00
|
|
|
for (i = 0; i < r; i++) {
|
|
|
|
unsigned char ch = (unsigned char) keys[i];
|
1999-11-08 11:08:09 +00:00
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
if (compose_state == 2 && (ch & 0x80) == 0 && ch > ' ') {
|
2000-07-26 12:13:51 +00:00
|
|
|
compose_char = ch;
|
2001-05-06 14:35:20 +00:00
|
|
|
compose_state++;
|
2000-07-26 12:13:51 +00:00
|
|
|
continue;
|
|
|
|
}
|
2001-05-06 14:35:20 +00:00
|
|
|
if (compose_state == 3 && (ch & 0x80) == 0 && ch > ' ') {
|
2000-07-26 12:13:51 +00:00
|
|
|
int nc;
|
|
|
|
compose_state = 0;
|
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
if ((nc = check_compose(compose_char, ch)) == -1) {
|
2000-10-20 13:51:46 +00:00
|
|
|
MessageBeep(MB_ICONHAND);
|
2000-07-26 12:13:51 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2001-05-10 08:34:20 +00:00
|
|
|
keybuf = nc;
|
2002-10-22 16:11:33 +00:00
|
|
|
term_seen_key_event(term);
|
2004-08-14 13:04:18 +00:00
|
|
|
if (ldisc)
|
|
|
|
luni_send(ldisc, &keybuf, 1, 1);
|
2001-05-10 08:34:20 +00:00
|
|
|
continue;
|
2000-07-26 12:13:51 +00:00
|
|
|
}
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2000-07-26 12:13:51 +00:00
|
|
|
compose_state = 0;
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2001-05-10 08:34:20 +00:00
|
|
|
if (!key_down) {
|
|
|
|
if (alt_sum) {
|
2003-01-14 18:28:23 +00:00
|
|
|
if (in_utf(term) || ucsdata.dbcs_screenfont) {
|
2001-05-10 08:34:20 +00:00
|
|
|
keybuf = alt_sum;
|
2002-10-22 16:11:33 +00:00
|
|
|
term_seen_key_event(term);
|
2004-08-14 13:04:18 +00:00
|
|
|
if (ldisc)
|
|
|
|
luni_send(ldisc, &keybuf, 1, 1);
|
2001-05-10 08:34:20 +00:00
|
|
|
} else {
|
|
|
|
ch = (char) alt_sum;
|
2001-08-25 17:09:23 +00:00
|
|
|
/*
|
|
|
|
* We need not bother about stdin
|
|
|
|
* backlogs here, because in GUI PuTTY
|
|
|
|
* we can't do anything about it
|
|
|
|
* anyway; there's no means of asking
|
|
|
|
* Windows to hold off on KEYDOWN
|
|
|
|
* messages. We _have_ to buffer
|
|
|
|
* everything we're sent.
|
|
|
|
*/
|
2002-10-22 16:11:33 +00:00
|
|
|
term_seen_key_event(term);
|
2004-08-14 13:04:18 +00:00
|
|
|
if (ldisc)
|
|
|
|
ldisc_send(ldisc, &ch, 1, 1);
|
2001-05-10 08:34:20 +00:00
|
|
|
}
|
|
|
|
alt_sum = 0;
|
2003-06-19 20:42:32 +00:00
|
|
|
} else {
|
2002-10-22 16:11:33 +00:00
|
|
|
term_seen_key_event(term);
|
2004-08-14 13:04:18 +00:00
|
|
|
if (ldisc)
|
|
|
|
lpage_send(ldisc, kbd_codepage, &ch, 1, 1);
|
2003-06-19 20:42:32 +00:00
|
|
|
}
|
2001-05-10 08:34:20 +00:00
|
|
|
} else {
|
2001-09-18 18:51:10 +00:00
|
|
|
if(capsOn && ch < 0x80) {
|
|
|
|
WCHAR cbuf[2];
|
|
|
|
cbuf[0] = 27;
|
|
|
|
cbuf[1] = xlat_uskbd2cyrllic(ch);
|
2002-10-22 16:11:33 +00:00
|
|
|
term_seen_key_event(term);
|
2004-08-14 13:04:18 +00:00
|
|
|
if (ldisc)
|
|
|
|
luni_send(ldisc, cbuf+!left_alt, 1+!!left_alt, 1);
|
2001-09-18 18:51:10 +00:00
|
|
|
} else {
|
|
|
|
char cbuf[2];
|
|
|
|
cbuf[0] = '\033';
|
|
|
|
cbuf[1] = ch;
|
2002-10-22 16:11:33 +00:00
|
|
|
term_seen_key_event(term);
|
2004-08-14 13:04:18 +00:00
|
|
|
if (ldisc)
|
|
|
|
lpage_send(ldisc, kbd_codepage,
|
|
|
|
cbuf+!left_alt, 1+!!left_alt, 1);
|
2001-09-18 18:51:10 +00:00
|
|
|
}
|
2000-07-26 12:13:51 +00:00
|
|
|
}
|
2001-09-07 20:18:55 +00:00
|
|
|
show_mouseptr(0);
|
2000-07-26 12:13:51 +00:00
|
|
|
}
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2000-07-26 12:13:51 +00:00
|
|
|
/* This is so the ALT-Numpad and dead keys work correctly. */
|
|
|
|
keys[0] = 0;
|
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
return p - output;
|
2000-07-26 12:13:51 +00:00
|
|
|
}
|
2001-04-16 12:08:37 +00:00
|
|
|
/* If we're definitly not building up an ALT-54321 then clear it */
|
2001-05-06 14:35:20 +00:00
|
|
|
if (!left_alt)
|
|
|
|
keys[0] = 0;
|
2001-05-10 08:34:20 +00:00
|
|
|
/* If we will be using alt_sum fix the 256s */
|
2003-01-14 18:28:23 +00:00
|
|
|
else if (keys[0] && (in_utf(term) || ucsdata.dbcs_screenfont))
|
2001-05-10 08:34:20 +00:00
|
|
|
keys[0] = 10;
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
2001-09-07 21:39:03 +00:00
|
|
|
/*
|
|
|
|
* ALT alone may or may not want to bring up the System menu.
|
|
|
|
* If it's not meant to, we return 0 on presses or releases of
|
|
|
|
* ALT, to show that we've swallowed the keystroke. Otherwise
|
|
|
|
* we return -1, which means Windows will give the keystroke
|
|
|
|
* its default handling (i.e. bring up the System menu).
|
|
|
|
*/
|
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
|
|
|
if (wParam == VK_MENU && !conf_get_int(conf, CONF_alt_only))
|
2001-09-07 21:39:03 +00:00
|
|
|
return 0;
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2000-07-26 12:13:51 +00:00
|
|
|
return -1;
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
2002-10-26 12:58:13 +00:00
|
|
|
void set_title(void *frontend, char *title)
|
2001-05-06 14:35:20 +00:00
|
|
|
{
|
|
|
|
sfree(window_name);
|
2003-03-29 16:14:26 +00:00
|
|
|
window_name = snewn(1 + strlen(title), char);
|
2001-05-06 14:35:20 +00:00
|
|
|
strcpy(window_name, title);
|
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
|
|
|
if (conf_get_int(conf, CONF_win_name_always) || !IsIconic(hwnd))
|
2001-05-06 14:35:20 +00:00
|
|
|
SetWindowText(hwnd, title);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
2002-10-26 12:58:13 +00:00
|
|
|
void set_icon(void *frontend, char *title)
|
2001-05-06 14:35:20 +00:00
|
|
|
{
|
|
|
|
sfree(icon_name);
|
2003-03-29 16:14:26 +00:00
|
|
|
icon_name = snewn(1 + strlen(title), char);
|
2001-05-06 14:35:20 +00:00
|
|
|
strcpy(icon_name, title);
|
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
|
|
|
if (!conf_get_int(conf, CONF_win_name_always) && IsIconic(hwnd))
|
2001-05-06 14:35:20 +00:00
|
|
|
SetWindowText(hwnd, title);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
2002-10-26 12:58:13 +00:00
|
|
|
void set_sbar(void *frontend, int total, int start, int page)
|
2001-05-06 14:35:20 +00:00
|
|
|
{
|
1999-01-08 13:02:13 +00:00
|
|
|
SCROLLINFO si;
|
2000-07-26 12:13:51 +00:00
|
|
|
|
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
|
|
|
if (!conf_get_int(conf, is_full_screen() ?
|
|
|
|
CONF_scrollbar_in_fullscreen : CONF_scrollbar))
|
2001-05-06 14:35:20 +00:00
|
|
|
return;
|
2000-07-26 12:13:51 +00:00
|
|
|
|
1999-01-08 13:02:13 +00:00
|
|
|
si.cbSize = sizeof(si);
|
2000-07-26 12:13:51 +00:00
|
|
|
si.fMask = SIF_ALL | SIF_DISABLENOSCROLL;
|
1999-01-08 13:02:13 +00:00
|
|
|
si.nMin = 0;
|
|
|
|
si.nMax = total - 1;
|
|
|
|
si.nPage = page;
|
|
|
|
si.nPos = start;
|
1999-02-09 15:39:08 +00:00
|
|
|
if (hwnd)
|
2001-05-06 14:35:20 +00:00
|
|
|
SetScrollInfo(hwnd, SB_VERT, &si, TRUE);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
2002-10-26 12:58:13 +00:00
|
|
|
Context get_ctx(void *frontend)
|
2001-05-06 14:35:20 +00:00
|
|
|
{
|
1999-01-08 13:02:13 +00:00
|
|
|
HDC hdc;
|
|
|
|
if (hwnd) {
|
2001-05-06 14:35:20 +00:00
|
|
|
hdc = GetDC(hwnd);
|
1999-01-08 13:02:13 +00:00
|
|
|
if (hdc && pal)
|
2001-05-06 14:35:20 +00:00
|
|
|
SelectPalette(hdc, pal, FALSE);
|
1999-01-08 13:02:13 +00:00
|
|
|
return hdc;
|
|
|
|
} else
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
void free_ctx(Context ctx)
|
|
|
|
{
|
|
|
|
SelectPalette(ctx, GetStockObject(DEFAULT_PALETTE), FALSE);
|
|
|
|
ReleaseDC(hwnd, ctx);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
static void real_palette_set(int n, int r, int g, int b)
|
|
|
|
{
|
1999-01-08 13:02:13 +00:00
|
|
|
if (pal) {
|
|
|
|
logpal->palPalEntry[n].peRed = r;
|
|
|
|
logpal->palPalEntry[n].peGreen = g;
|
|
|
|
logpal->palPalEntry[n].peBlue = b;
|
|
|
|
logpal->palPalEntry[n].peFlags = PC_NOCOLLAPSE;
|
|
|
|
colours[n] = PALETTERGB(r, g, b);
|
2004-11-28 15:13:34 +00:00
|
|
|
SetPaletteEntries(pal, 0, NALLCOLOURS, logpal->palPalEntry);
|
1999-01-08 13:02:13 +00:00
|
|
|
} else
|
|
|
|
colours[n] = RGB(r, g, b);
|
|
|
|
}
|
|
|
|
|
2002-10-26 12:58:13 +00:00
|
|
|
void palette_set(void *frontend, int n, int r, int g, int b)
|
2001-05-06 14:35:20 +00:00
|
|
|
{
|
2004-11-28 15:13:34 +00:00
|
|
|
if (n >= 16)
|
|
|
|
n += 256 - 16;
|
|
|
|
if (n > NALLCOLOURS)
|
|
|
|
return;
|
|
|
|
real_palette_set(n, r, g, b);
|
1999-01-08 13:02:13 +00:00
|
|
|
if (pal) {
|
2002-10-26 12:58:13 +00:00
|
|
|
HDC hdc = get_ctx(frontend);
|
2001-05-06 14:35:20 +00:00
|
|
|
UnrealizeObject(pal);
|
|
|
|
RealizePalette(hdc);
|
|
|
|
free_ctx(hdc);
|
2006-02-25 14:13:46 +00:00
|
|
|
} else {
|
|
|
|
if (n == (ATTR_DEFBG>>ATTR_BGSHIFT))
|
|
|
|
/* If Default Background changes, we need to ensure any
|
|
|
|
* space between the text area and the window border is
|
|
|
|
* redrawn. */
|
|
|
|
InvalidateRect(hwnd, NULL, TRUE);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-26 12:58:13 +00:00
|
|
|
void palette_reset(void *frontend)
|
2001-05-06 14:35:20 +00:00
|
|
|
{
|
1999-01-08 13:02:13 +00:00
|
|
|
int i;
|
|
|
|
|
2004-11-28 15:13:34 +00:00
|
|
|
/* And this */
|
|
|
|
for (i = 0; i < NALLCOLOURS; i++) {
|
1999-01-08 13:02:13 +00:00
|
|
|
if (pal) {
|
|
|
|
logpal->palPalEntry[i].peRed = defpal[i].rgbtRed;
|
|
|
|
logpal->palPalEntry[i].peGreen = defpal[i].rgbtGreen;
|
|
|
|
logpal->palPalEntry[i].peBlue = defpal[i].rgbtBlue;
|
|
|
|
logpal->palPalEntry[i].peFlags = 0;
|
|
|
|
colours[i] = PALETTERGB(defpal[i].rgbtRed,
|
|
|
|
defpal[i].rgbtGreen,
|
|
|
|
defpal[i].rgbtBlue);
|
|
|
|
} else
|
|
|
|
colours[i] = RGB(defpal[i].rgbtRed,
|
2001-05-06 14:35:20 +00:00
|
|
|
defpal[i].rgbtGreen, defpal[i].rgbtBlue);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pal) {
|
|
|
|
HDC hdc;
|
2004-11-28 15:13:34 +00:00
|
|
|
SetPaletteEntries(pal, 0, NALLCOLOURS, logpal->palPalEntry);
|
2002-10-26 12:58:13 +00:00
|
|
|
hdc = get_ctx(frontend);
|
2001-05-06 14:35:20 +00:00
|
|
|
RealizePalette(hdc);
|
|
|
|
free_ctx(hdc);
|
2006-02-25 14:13:46 +00:00
|
|
|
} else {
|
|
|
|
/* Default Background may have changed. Ensure any space between
|
|
|
|
* text area and window border is redrawn. */
|
|
|
|
InvalidateRect(hwnd, NULL, TRUE);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-26 12:58:13 +00:00
|
|
|
void write_aclip(void *frontend, char *data, int len, int must_deselect)
|
2001-05-06 14:35:20 +00:00
|
|
|
{
|
1999-01-08 13:02:13 +00:00
|
|
|
HGLOBAL clipdata;
|
|
|
|
void *lock;
|
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
clipdata = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, len + 1);
|
1999-01-08 13:02:13 +00:00
|
|
|
if (!clipdata)
|
|
|
|
return;
|
2001-05-06 14:35:20 +00:00
|
|
|
lock = GlobalLock(clipdata);
|
1999-01-08 13:02:13 +00:00
|
|
|
if (!lock)
|
|
|
|
return;
|
2001-05-06 14:35:20 +00:00
|
|
|
memcpy(lock, data, len);
|
|
|
|
((unsigned char *) lock)[len] = 0;
|
|
|
|
GlobalUnlock(clipdata);
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2000-10-06 12:32:25 +00:00
|
|
|
if (!must_deselect)
|
2001-05-06 14:35:20 +00:00
|
|
|
SendMessage(hwnd, WM_IGNORE_CLIP, TRUE, 0);
|
2000-10-06 12:32:25 +00:00
|
|
|
|
2001-05-06 14:35:20 +00:00
|
|
|
if (OpenClipboard(hwnd)) {
|
1999-01-08 13:02:13 +00:00
|
|
|
EmptyClipboard();
|
2001-05-06 14:35:20 +00:00
|
|
|
SetClipboardData(CF_TEXT, clipdata);
|
1999-01-08 13:02:13 +00:00
|
|
|
CloseClipboard();
|
|
|
|
} else
|
2001-05-06 14:35:20 +00:00
|
|
|
GlobalFree(clipdata);
|
2000-10-06 12:32:25 +00:00
|
|
|
|
|
|
|
if (!must_deselect)
|
2001-05-06 14:35:20 +00:00
|
|
|
SendMessage(hwnd, WM_IGNORE_CLIP, FALSE, 0);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
2001-05-10 08:34:20 +00:00
|
|
|
/*
|
|
|
|
* Note: unlike write_aclip() this will not append a nul.
|
|
|
|
*/
|
2006-02-13 22:18:17 +00:00
|
|
|
void write_clip(void *frontend, wchar_t * data, int *attr, int len, int must_deselect)
|
2001-05-10 08:34:20 +00:00
|
|
|
{
|
2001-11-07 22:22:53 +00:00
|
|
|
HGLOBAL clipdata, clipdata2, clipdata3;
|
2001-05-10 08:34:20 +00:00
|
|
|
int len2;
|
2001-11-07 22:22:53 +00:00
|
|
|
void *lock, *lock2, *lock3;
|
2001-05-10 08:34:20 +00:00
|
|
|
|
|
|
|
len2 = WideCharToMultiByte(CP_ACP, 0, data, len, 0, 0, NULL, NULL);
|
|
|
|
|
|
|
|
clipdata = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE,
|
|
|
|
len * sizeof(wchar_t));
|
|
|
|
clipdata2 = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, len2);
|
|
|
|
|
2001-12-11 18:47:35 +00:00
|
|
|
if (!clipdata || !clipdata2) {
|
2001-05-10 08:34:20 +00:00
|
|
|
if (clipdata)
|
|
|
|
GlobalFree(clipdata);
|
|
|
|
if (clipdata2)
|
|
|
|
GlobalFree(clipdata2);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (!(lock = GlobalLock(clipdata)))
|
|
|
|
return;
|
|
|
|
if (!(lock2 = GlobalLock(clipdata2)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
memcpy(lock, data, len * sizeof(wchar_t));
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, data, len, lock2, len2, NULL, NULL);
|
|
|
|
|
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
|
|
|
if (conf_get_int(conf, CONF_rtf_paste)) {
|
2001-11-07 22:22:53 +00:00
|
|
|
wchar_t unitab[256];
|
|
|
|
char *rtf = NULL;
|
|
|
|
unsigned char *tdata = (unsigned char *)lock2;
|
|
|
|
wchar_t *udata = (wchar_t *)lock;
|
|
|
|
int rtflen = 0, uindex = 0, tindex = 0;
|
|
|
|
int rtfsize = 0;
|
|
|
|
int multilen, blen, alen, totallen, i;
|
|
|
|
char before[16], after[4];
|
2006-02-13 22:18:17 +00:00
|
|
|
int fgcolour, lastfgcolour = 0;
|
|
|
|
int bgcolour, lastbgcolour = 0;
|
|
|
|
int attrBold, lastAttrBold = 0;
|
|
|
|
int attrUnder, lastAttrUnder = 0;
|
|
|
|
int palette[NALLCOLOURS];
|
|
|
|
int numcolours;
|
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
|
|
|
FontSpec *font = conf_get_fontspec(conf, CONF_font);
|
2001-11-07 22:22:53 +00:00
|
|
|
|
|
|
|
get_unitab(CP_ACP, unitab, 0);
|
|
|
|
|
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
|
|
|
rtfsize = 100 + strlen(font->name);
|
2003-03-29 16:14:26 +00:00
|
|
|
rtf = snewn(rtfsize, char);
|
2006-02-13 22:18:17 +00:00
|
|
|
rtflen = sprintf(rtf, "{\\rtf1\\ansi\\deff0{\\fonttbl\\f0\\fmodern %s;}\\f0\\fs%d",
|
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
|
|
|
font->name, font->height*2);
|
2006-02-13 22:18:17 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Add colour palette
|
|
|
|
* {\colortbl ;\red255\green0\blue0;\red0\green0\blue128;}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* First - Determine all colours in use
|
|
|
|
* o Foregound and background colours share the same palette
|
|
|
|
*/
|
|
|
|
if (attr) {
|
|
|
|
memset(palette, 0, sizeof(palette));
|
|
|
|
for (i = 0; i < (len-1); i++) {
|
|
|
|
fgcolour = ((attr[i] & ATTR_FGMASK) >> ATTR_FGSHIFT);
|
|
|
|
bgcolour = ((attr[i] & ATTR_BGMASK) >> ATTR_BGSHIFT);
|
|
|
|
|
|
|
|
if (attr[i] & ATTR_REVERSE) {
|
|
|
|
int tmpcolour = fgcolour; /* Swap foreground and background */
|
|
|
|
fgcolour = bgcolour;
|
|
|
|
bgcolour = tmpcolour;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bold_mode == BOLD_COLOURS && (attr[i] & ATTR_BOLD)) {
|
|
|
|
if (fgcolour < 8) /* ANSI colours */
|
|
|
|
fgcolour += 8;
|
|
|
|
else if (fgcolour >= 256) /* Default colours */
|
|
|
|
fgcolour ++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attr[i] & ATTR_BLINK) {
|
|
|
|
if (bgcolour < 8) /* ANSI colours */
|
|
|
|
bgcolour += 8;
|
|
|
|
else if (bgcolour >= 256) /* Default colours */
|
|
|
|
bgcolour ++;
|
|
|
|
}
|
|
|
|
|
|
|
|
palette[fgcolour]++;
|
|
|
|
palette[bgcolour]++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Next - Create a reduced palette
|
|
|
|
*/
|
|
|
|
numcolours = 0;
|
|
|
|
for (i = 0; i < NALLCOLOURS; i++) {
|
|
|
|
if (palette[i] != 0)
|
|
|
|
palette[i] = ++numcolours;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Finally - Write the colour table
|
|
|
|
*/
|
|
|
|
rtf = sresize(rtf, rtfsize + (numcolours * 25), char);
|
|
|
|
strcat(rtf, "{\\colortbl ;");
|
|
|
|
rtflen = strlen(rtf);
|
|
|
|
|
|
|
|
for (i = 0; i < NALLCOLOURS; i++) {
|
|
|
|
if (palette[i] != 0) {
|
|
|
|
rtflen += sprintf(&rtf[rtflen], "\\red%d\\green%d\\blue%d;", defpal[i].rgbtRed, defpal[i].rgbtGreen, defpal[i].rgbtBlue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
strcpy(&rtf[rtflen], "}");
|
|
|
|
rtflen ++;
|
|
|
|
}
|
2001-11-07 22:22:53 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* We want to construct a piece of RTF that specifies the
|
|
|
|
* same Unicode text. To do this we will read back in
|
|
|
|
* parallel from the Unicode data in `udata' and the
|
|
|
|
* non-Unicode data in `tdata'. For each character in
|
|
|
|
* `tdata' which becomes the right thing in `udata' when
|
|
|
|
* looked up in `unitab', we just copy straight over from
|
|
|
|
* tdata. For each one that doesn't, we must WCToMB it
|
|
|
|
* individually and produce a \u escape sequence.
|
|
|
|
*
|
|
|
|
* It would probably be more robust to just bite the bullet
|
|
|
|
* and WCToMB each individual Unicode character one by one,
|
|
|
|
* then MBToWC each one back to see if it was an accurate
|
|
|
|
* translation; but that strikes me as a horrifying number
|
|
|
|
* of Windows API calls so I want to see if this faster way
|
|
|
|
* will work. If it screws up badly we can always revert to
|
|
|
|
* the simple and slow way.
|
|
|
|
*/
|
|
|
|
while (tindex < len2 && uindex < len &&
|
|
|
|
tdata[tindex] && udata[uindex]) {
|
|
|
|
if (tindex + 1 < len2 &&
|
|
|
|
tdata[tindex] == '\r' &&
|
|
|
|
tdata[tindex+1] == '\n') {
|
|
|
|
tindex++;
|
|
|
|
uindex++;
|
2006-02-13 22:18:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set text attributes
|
|
|
|
*/
|
|
|
|
if (attr) {
|
|
|
|
if (rtfsize < rtflen + 64) {
|
|
|
|
rtfsize = rtflen + 512;
|
|
|
|
rtf = sresize(rtf, rtfsize, char);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Determine foreground and background colours
|
|
|
|
*/
|
|
|
|
fgcolour = ((attr[tindex] & ATTR_FGMASK) >> ATTR_FGSHIFT);
|
|
|
|
bgcolour = ((attr[tindex] & ATTR_BGMASK) >> ATTR_BGSHIFT);
|
|
|
|
|
|
|
|
if (attr[tindex] & ATTR_REVERSE) {
|
|
|
|
int tmpcolour = fgcolour; /* Swap foreground and background */
|
|
|
|
fgcolour = bgcolour;
|
|
|
|
bgcolour = tmpcolour;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bold_mode == BOLD_COLOURS && (attr[tindex] & ATTR_BOLD)) {
|
|
|
|
if (fgcolour < 8) /* ANSI colours */
|
|
|
|
fgcolour += 8;
|
|
|
|
else if (fgcolour >= 256) /* Default colours */
|
|
|
|
fgcolour ++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (attr[tindex] & ATTR_BLINK) {
|
|
|
|
if (bgcolour < 8) /* ANSI colours */
|
|
|
|
bgcolour += 8;
|
|
|
|
else if (bgcolour >= 256) /* Default colours */
|
|
|
|
bgcolour ++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Collect other attributes
|
|
|
|
*/
|
|
|
|
if (bold_mode != BOLD_COLOURS)
|
|
|
|
attrBold = attr[tindex] & ATTR_BOLD;
|
|
|
|
else
|
|
|
|
attrBold = 0;
|
|
|
|
|
|
|
|
attrUnder = attr[tindex] & ATTR_UNDER;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Reverse video
|
|
|
|
* o If video isn't reversed, ignore colour attributes for default foregound
|
|
|
|
* or background.
|
|
|
|
* o Special case where bolded text is displayed using the default foregound
|
|
|
|
* and background colours - force to bolded RTF.
|
|
|
|
*/
|
|
|
|
if (!(attr[tindex] & ATTR_REVERSE)) {
|
|
|
|
if (bgcolour >= 256) /* Default color */
|
|
|
|
bgcolour = -1; /* No coloring */
|
|
|
|
|
|
|
|
if (fgcolour >= 256) { /* Default colour */
|
|
|
|
if (bold_mode == BOLD_COLOURS && (fgcolour & 1) && bgcolour == -1)
|
|
|
|
attrBold = ATTR_BOLD; /* Emphasize text with bold attribute */
|
|
|
|
|
|
|
|
fgcolour = -1; /* No coloring */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Write RTF text attributes
|
|
|
|
*/
|
|
|
|
if (lastfgcolour != fgcolour) {
|
|
|
|
lastfgcolour = fgcolour;
|
|
|
|
rtflen += sprintf(&rtf[rtflen], "\\cf%d ", (fgcolour >= 0) ? palette[fgcolour] : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lastbgcolour != bgcolour) {
|
|
|
|
lastbgcolour = bgcolour;
|
|
|
|
rtflen += sprintf(&rtf[rtflen], "\\highlight%d ", (bgcolour >= 0) ? palette[bgcolour] : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lastAttrBold != attrBold) {
|
|
|
|
lastAttrBold = attrBold;
|
|
|
|
rtflen += sprintf(&rtf[rtflen], "%s", attrBold ? "\\b " : "\\b0 ");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (lastAttrUnder != attrUnder) {
|
|
|
|
lastAttrUnder = attrUnder;
|
|
|
|
rtflen += sprintf(&rtf[rtflen], "%s", attrUnder ? "\\ul " : "\\ulnone ");
|
|
|
|
}
|
2001-11-07 22:22:53 +00:00
|
|
|
}
|
2006-02-13 22:18:17 +00:00
|
|
|
|
2001-11-07 22:22:53 +00:00
|
|
|
if (unitab[tdata[tindex]] == udata[uindex]) {
|
|
|
|
multilen = 1;
|
|
|
|
before[0] = '\0';
|
|
|
|
after[0] = '\0';
|
|
|
|
blen = alen = 0;
|
|
|
|
} else {
|
|
|
|
multilen = WideCharToMultiByte(CP_ACP, 0, unitab+uindex, 1,
|
|
|
|
NULL, 0, NULL, NULL);
|
|
|
|
if (multilen != 1) {
|
2001-11-08 09:20:36 +00:00
|
|
|
blen = sprintf(before, "{\\uc%d\\u%d", multilen,
|
|
|
|
udata[uindex]);
|
2001-11-07 22:22:53 +00:00
|
|
|
alen = 1; strcpy(after, "}");
|
|
|
|
} else {
|
|
|
|
blen = sprintf(before, "\\u%d", udata[uindex]);
|
|
|
|
alen = 0; after[0] = '\0';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
assert(tindex + multilen <= len2);
|
|
|
|
totallen = blen + alen;
|
|
|
|
for (i = 0; i < multilen; i++) {
|
|
|
|
if (tdata[tindex+i] == '\\' ||
|
|
|
|
tdata[tindex+i] == '{' ||
|
|
|
|
tdata[tindex+i] == '}')
|
|
|
|
totallen += 2;
|
|
|
|
else if (tdata[tindex+i] == 0x0D || tdata[tindex+i] == 0x0A)
|
|
|
|
totallen += 6; /* \par\r\n */
|
|
|
|
else if (tdata[tindex+i] > 0x7E || tdata[tindex+i] < 0x20)
|
|
|
|
totallen += 4;
|
|
|
|
else
|
|
|
|
totallen++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (rtfsize < rtflen + totallen + 3) {
|
|
|
|
rtfsize = rtflen + totallen + 512;
|
2003-03-29 16:14:26 +00:00
|
|
|
rtf = sresize(rtf, rtfsize, char);
|
2001-11-07 22:22:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
strcpy(rtf + rtflen, before); rtflen += blen;
|
|
|
|
for (i = 0; i < multilen; i++) {
|
|
|
|
if (tdata[tindex+i] == '\\' ||
|
|
|
|
tdata[tindex+i] == '{' ||
|
|
|
|
tdata[tindex+i] == '}') {
|
|
|
|
rtf[rtflen++] = '\\';
|
|
|
|
rtf[rtflen++] = tdata[tindex+i];
|
|
|
|
} else if (tdata[tindex+i] == 0x0D || tdata[tindex+i] == 0x0A) {
|
|
|
|
rtflen += sprintf(rtf+rtflen, "\\par\r\n");
|
|
|
|
} else if (tdata[tindex+i] > 0x7E || tdata[tindex+i] < 0x20) {
|
|
|
|
rtflen += sprintf(rtf+rtflen, "\\'%02x", tdata[tindex+i]);
|
|
|
|
} else {
|
|
|
|
rtf[rtflen++] = tdata[tindex+i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
strcpy(rtf + rtflen, after); rtflen += alen;
|
|
|
|
|
|
|
|
tindex += multilen;
|
|
|
|
uindex++;
|
|
|
|
}
|
|
|
|
|
2006-02-13 22:18:17 +00:00
|
|
|
rtf[rtflen++] = '}'; /* Terminate RTF stream */
|
|
|
|
rtf[rtflen++] = '\0';
|
|
|
|
rtf[rtflen++] = '\0';
|
2001-11-07 22:22:53 +00:00
|
|
|
|
|
|
|
clipdata3 = GlobalAlloc(GMEM_DDESHARE | GMEM_MOVEABLE, rtflen);
|
|
|
|
if (clipdata3 && (lock3 = GlobalLock(clipdata3)) != NULL) {
|
2006-02-13 22:18:17 +00:00
|
|
|
memcpy(lock3, rtf, rtflen);
|
2001-11-07 22:22:53 +00:00
|
|
|
GlobalUnlock(clipdata3);
|
|
|
|
}
|
|
|
|
sfree(rtf);
|
|
|
|
} else
|
|
|
|
clipdata3 = NULL;
|
|
|
|
|
2001-05-10 08:34:20 +00:00
|
|
|
GlobalUnlock(clipdata);
|
|
|
|
GlobalUnlock(clipdata2);
|
|
|
|
|
|
|
|
if (!must_deselect)
|
|
|
|
SendMessage(hwnd, WM_IGNORE_CLIP, TRUE, 0);
|
|
|
|
|
|
|
|
if (OpenClipboard(hwnd)) {
|
|
|
|
EmptyClipboard();
|
|
|
|
SetClipboardData(CF_UNICODETEXT, clipdata);
|
|
|
|
SetClipboardData(CF_TEXT, clipdata2);
|
2001-11-07 22:22:53 +00:00
|
|
|
if (clipdata3)
|
|
|
|
SetClipboardData(RegisterClipboardFormat(CF_RTF), clipdata3);
|
2001-05-10 08:34:20 +00:00
|
|
|
CloseClipboard();
|
|
|
|
} else {
|
|
|
|
GlobalFree(clipdata);
|
|
|
|
GlobalFree(clipdata2);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!must_deselect)
|
|
|
|
SendMessage(hwnd, WM_IGNORE_CLIP, FALSE, 0);
|
|
|
|
}
|
|
|
|
|
2008-11-28 18:28:23 +00:00
|
|
|
static DWORD WINAPI clipboard_read_threadfunc(void *param)
|
2001-05-06 14:35:20 +00:00
|
|
|
{
|
2008-11-28 18:28:23 +00:00
|
|
|
HWND hwnd = (HWND)param;
|
|
|
|
HGLOBAL clipdata;
|
1999-01-08 13:02:13 +00:00
|
|
|
|
2008-11-28 18:28:23 +00:00
|
|
|
if (OpenClipboard(NULL)) {
|
2001-05-13 14:02:28 +00:00
|
|
|
if ((clipdata = GetClipboardData(CF_UNICODETEXT))) {
|
2008-11-28 18:28:23 +00:00
|
|
|
SendMessage(hwnd, WM_GOT_CLIPDATA, (WPARAM)1, (LPARAM)clipdata);
|
|
|
|
} else if ((clipdata = GetClipboardData(CF_TEXT))) {
|
|
|
|
SendMessage(hwnd, WM_GOT_CLIPDATA, (WPARAM)0, (LPARAM)clipdata);
|
|
|
|
}
|
|
|
|
CloseClipboard();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int process_clipdata(HGLOBAL clipdata, int unicode)
|
|
|
|
{
|
|
|
|
sfree(clipboard_contents);
|
|
|
|
clipboard_contents = NULL;
|
|
|
|
clipboard_length = 0;
|
|
|
|
|
|
|
|
if (unicode) {
|
|
|
|
wchar_t *p = GlobalLock(clipdata);
|
|
|
|
wchar_t *p2;
|
|
|
|
|
|
|
|
if (p) {
|
|
|
|
/* Unwilling to rely on Windows having wcslen() */
|
|
|
|
for (p2 = p; *p2; p2++);
|
|
|
|
clipboard_length = p2 - p;
|
|
|
|
clipboard_contents = snewn(clipboard_length + 1, wchar_t);
|
|
|
|
memcpy(clipboard_contents, p, clipboard_length * sizeof(wchar_t));
|
|
|
|
clipboard_contents[clipboard_length] = L'\0';
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
char *s = GlobalLock(clipdata);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (s) {
|
2001-05-10 08:34:20 +00:00
|
|
|
i = MultiByteToWideChar(CP_ACP, 0, s, strlen(s) + 1, 0, 0);
|
2008-11-28 18:28:23 +00:00
|
|
|
clipboard_contents = snewn(i, wchar_t);
|
|
|
|
MultiByteToWideChar(CP_ACP, 0, s, strlen(s) + 1,
|
|
|
|
clipboard_contents, i);
|
|
|
|
clipboard_length = i - 1;
|
|
|
|
clipboard_contents[clipboard_length] = L'\0';
|
|
|
|
return TRUE;
|
|
|
|
}
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
2008-11-28 18:28:23 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
void request_paste(void *frontend)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* I always thought pasting was synchronous in Windows; the
|
|
|
|
* clipboard access functions certainly _look_ synchronous,
|
|
|
|
* unlike the X ones. But in fact it seems that in some
|
|
|
|
* situations the contents of the clipboard might not be
|
|
|
|
* immediately available, and the clipboard-reading functions
|
|
|
|
* may block. This leads to trouble if the application
|
|
|
|
* delivering the clipboard data has to get hold of it by -
|
|
|
|
* for example - talking over a network connection which is
|
|
|
|
* forwarded through this very PuTTY.
|
|
|
|
*
|
|
|
|
* Hence, we spawn a subthread to read the clipboard, and do
|
|
|
|
* our paste when it's finished. The thread will send a
|
|
|
|
* message back to our main window when it terminates, and
|
|
|
|
* that tells us it's OK to paste.
|
|
|
|
*/
|
|
|
|
DWORD in_threadid; /* required for Win9x */
|
|
|
|
CreateThread(NULL, 0, clipboard_read_threadfunc,
|
|
|
|
hwnd, 0, &in_threadid);
|
|
|
|
}
|
|
|
|
|
|
|
|
void get_clip(void *frontend, wchar_t **p, int *len)
|
|
|
|
{
|
|
|
|
if (p) {
|
|
|
|
*p = clipboard_contents;
|
|
|
|
*len = clipboard_length;
|
|
|
|
}
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
2001-05-10 08:34:20 +00:00
|
|
|
#if 0
|
1999-01-08 13:02:13 +00:00
|
|
|
/*
|
|
|
|
* Move `lines' lines from position `from' to position `to' in the
|
|
|
|
* window.
|
|
|
|
*/
|
2002-10-26 12:58:13 +00:00
|
|
|
void optimised_move(void *frontend, int to, int from, int lines)
|
2001-05-06 14:35:20 +00:00
|
|
|
{
|
1999-01-08 13:02:13 +00:00
|
|
|
RECT r;
|
1999-07-20 13:01:56 +00:00
|
|
|
int min, max;
|
1999-01-08 13:02:13 +00:00
|
|
|
|
|
|
|
min = (to < from ? to : from);
|
|
|
|
max = to + from - min;
|
|
|
|
|
2001-09-15 15:54:24 +00:00
|
|
|
r.left = offset_width;
|
2002-10-22 16:11:33 +00:00
|
|
|
r.right = offset_width + term->cols * font_width;
|
2001-09-15 15:54:24 +00:00
|
|
|
r.top = offset_height + min * font_height;
|
|
|
|
r.bottom = offset_height + (max + lines) * font_height;
|
2001-05-06 14:35:20 +00:00
|
|
|
ScrollWindow(hwnd, 0, (to - from) * font_height, &r, &r);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
2001-05-10 08:34:20 +00:00
|
|
|
#endif
|
1999-01-08 13:02:13 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Print a message box and perform a fatal exit.
|
|
|
|
*/
|
2001-05-06 14:35:20 +00:00
|
|
|
void fatalbox(char *fmt, ...)
|
|
|
|
{
|
1999-01-08 13:02:13 +00:00
|
|
|
va_list ap;
|
2003-05-04 14:14:10 +00:00
|
|
|
char *stuff, morestuff[100];
|
1999-01-08 13:02:13 +00:00
|
|
|
|
|
|
|
va_start(ap, fmt);
|
2003-05-04 14:14:10 +00:00
|
|
|
stuff = dupvprintf(fmt, ap);
|
1999-01-08 13:02:13 +00:00
|
|
|
va_end(ap);
|
2003-04-06 14:11:33 +00:00
|
|
|
sprintf(morestuff, "%.70s Fatal Error", appname);
|
|
|
|
MessageBox(hwnd, stuff, morestuff, MB_ICONERROR | MB_OK);
|
2003-05-04 14:14:10 +00:00
|
|
|
sfree(stuff);
|
2002-03-06 20:13:22 +00:00
|
|
|
cleanup_exit(1);
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
|
|
|
|
2002-10-09 18:09:42 +00:00
|
|
|
/*
|
|
|
|
* Print a modal (Really Bad) message box and perform a fatal exit.
|
|
|
|
*/
|
|
|
|
void modalfatalbox(char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
2003-05-04 14:14:10 +00:00
|
|
|
char *stuff, morestuff[100];
|
2002-10-09 18:09:42 +00:00
|
|
|
|
|
|
|
va_start(ap, fmt);
|
2003-05-04 14:14:10 +00:00
|
|
|
stuff = dupvprintf(fmt, ap);
|
2002-10-09 18:09:42 +00:00
|
|
|
va_end(ap);
|
2003-04-06 14:11:33 +00:00
|
|
|
sprintf(morestuff, "%.70s Fatal Error", appname);
|
|
|
|
MessageBox(hwnd, stuff, morestuff,
|
2002-10-09 18:09:42 +00:00
|
|
|
MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
|
2003-05-04 14:14:10 +00:00
|
|
|
sfree(stuff);
|
2002-10-09 18:09:42 +00:00
|
|
|
cleanup_exit(1);
|
|
|
|
}
|
|
|
|
|
2009-11-08 19:22:28 +00:00
|
|
|
DECL_WINDOWS_FUNCTION(static, BOOL, FlashWindowEx, (PFLASHWINFO));
|
2007-01-16 20:54:58 +00:00
|
|
|
|
|
|
|
static void init_flashwindow(void)
|
|
|
|
{
|
2010-09-13 08:29:45 +00:00
|
|
|
HMODULE user32_module = load_system32_dll("user32.dll");
|
2009-11-08 19:22:28 +00:00
|
|
|
GET_WINDOWS_FUNCTION(user32_module, FlashWindowEx);
|
2007-01-16 20:54:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL flash_window_ex(DWORD dwFlags, UINT uCount, DWORD dwTimeout)
|
|
|
|
{
|
|
|
|
if (p_FlashWindowEx) {
|
|
|
|
FLASHWINFO fi;
|
|
|
|
fi.cbSize = sizeof(fi);
|
|
|
|
fi.hwnd = hwnd;
|
|
|
|
fi.dwFlags = dwFlags;
|
|
|
|
fi.uCount = uCount;
|
|
|
|
fi.dwTimeout = dwTimeout;
|
|
|
|
return (*p_FlashWindowEx)(&fi);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return FALSE; /* shrug */
|
|
|
|
}
|
|
|
|
|
2004-11-27 13:20:21 +00:00
|
|
|
static void flash_window(int mode);
|
|
|
|
static long next_flash;
|
|
|
|
static int flashing = 0;
|
|
|
|
|
2007-01-16 20:54:58 +00:00
|
|
|
/*
|
|
|
|
* Timer for platforms where we must maintain window flashing manually
|
|
|
|
* (e.g., Win95).
|
|
|
|
*/
|
2004-11-27 13:20:21 +00:00
|
|
|
static void flash_window_timer(void *ctx, long now)
|
|
|
|
{
|
|
|
|
if (flashing && now - next_flash >= 0) {
|
|
|
|
flash_window(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-05-13 14:42:17 +00:00
|
|
|
/*
|
|
|
|
* Manage window caption / taskbar flashing, if enabled.
|
|
|
|
* 0 = stop, 1 = maintain, 2 = start
|
|
|
|
*/
|
|
|
|
static void flash_window(int mode)
|
|
|
|
{
|
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
|
|
|
int beep_ind = conf_get_int(conf, CONF_beep_ind);
|
|
|
|
if ((mode == 0) || (beep_ind == B_IND_DISABLED)) {
|
2001-05-13 14:42:17 +00:00
|
|
|
/* stop */
|
|
|
|
if (flashing) {
|
|
|
|
flashing = 0;
|
2007-01-16 20:54:58 +00:00
|
|
|
if (p_FlashWindowEx)
|
|
|
|
flash_window_ex(FLASHW_STOP, 0, 0);
|
|
|
|
else
|
|
|
|
FlashWindow(hwnd, FALSE);
|
2001-05-13 14:42:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} else if (mode == 2) {
|
|
|
|
/* start */
|
|
|
|
if (!flashing) {
|
|
|
|
flashing = 1;
|
2007-01-16 20:54:58 +00:00
|
|
|
if (p_FlashWindowEx) {
|
|
|
|
/* For so-called "steady" mode, we use uCount=2, which
|
|
|
|
* seems to be the traditional number of flashes used
|
|
|
|
* by user notifications (e.g., by Explorer).
|
|
|
|
* uCount=0 appears to enable continuous flashing, per
|
|
|
|
* "flashing" mode, although I haven't seen this
|
|
|
|
* documented. */
|
|
|
|
flash_window_ex(FLASHW_ALL | FLASHW_TIMER,
|
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
|
|
|
(beep_ind == B_IND_FLASH ? 0 : 2),
|
2007-01-16 20:54:58 +00:00
|
|
|
0 /* system cursor blink rate */);
|
|
|
|
/* No need to schedule timer */
|
|
|
|
} else {
|
|
|
|
FlashWindow(hwnd, TRUE);
|
|
|
|
next_flash = schedule_timer(450, flash_window_timer, hwnd);
|
|
|
|
}
|
2001-05-13 14:42:17 +00:00
|
|
|
}
|
|
|
|
|
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
|
|
|
} else if ((mode == 1) && (beep_ind == B_IND_FLASH)) {
|
2001-05-13 14:42:17 +00:00
|
|
|
/* maintain */
|
2007-01-16 20:54:58 +00:00
|
|
|
if (flashing && !p_FlashWindowEx) {
|
2004-11-27 13:20:21 +00:00
|
|
|
FlashWindow(hwnd, TRUE); /* toggle */
|
|
|
|
next_flash = schedule_timer(450, flash_window_timer, hwnd);
|
2001-05-13 14:42:17 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-01-08 13:02:13 +00:00
|
|
|
/*
|
|
|
|
* Beep.
|
|
|
|
*/
|
2005-12-09 20:04:19 +00:00
|
|
|
void do_beep(void *frontend, int mode)
|
2001-05-06 14:35:20 +00:00
|
|
|
{
|
2001-04-14 11:37:47 +00:00
|
|
|
if (mode == BELL_DEFAULT) {
|
2001-04-16 21:29:12 +00:00
|
|
|
/*
|
|
|
|
* For MessageBeep style bells, we want to be careful of
|
|
|
|
* timing, because they don't have the nice property of
|
|
|
|
* PlaySound bells that each one cancels the previous
|
|
|
|
* active one. So we limit the rate to one per 50ms or so.
|
|
|
|
*/
|
|
|
|
static long lastbeep = 0;
|
2001-05-06 16:18:58 +00:00
|
|
|
long beepdiff;
|
2001-04-16 21:29:12 +00:00
|
|
|
|
2001-05-06 16:18:58 +00:00
|
|
|
beepdiff = GetTickCount() - lastbeep;
|
2001-04-16 21:29:12 +00:00
|
|
|
if (beepdiff >= 0 && beepdiff < 50)
|
|
|
|
return;
|
2001-04-13 10:52:36 +00:00
|
|
|
MessageBeep(MB_OK);
|
2001-05-06 16:18:58 +00:00
|
|
|
/*
|
|
|
|
* The above MessageBeep call takes time, so we record the
|
|
|
|
* time _after_ it finishes rather than before it starts.
|
|
|
|
*/
|
|
|
|
lastbeep = GetTickCount();
|
2001-04-14 11:37:47 +00:00
|
|
|
} else if (mode == BELL_WAVEFILE) {
|
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
|
|
|
Filename *bell_wavefile = conf_get_filename(conf, CONF_bell_wavefile);
|
|
|
|
if (!PlaySound(bell_wavefile->path, NULL,
|
2003-02-01 12:54:40 +00:00
|
|
|
SND_ASYNC | SND_FILENAME)) {
|
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
|
|
|
char buf[sizeof(bell_wavefile->path) + 80];
|
2003-04-06 14:11:33 +00:00
|
|
|
char otherbuf[100];
|
2001-04-14 11:37:47 +00:00
|
|
|
sprintf(buf, "Unable to play sound file\n%s\n"
|
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
|
|
|
"Using default sound instead", bell_wavefile->path);
|
2003-04-06 14:11:33 +00:00
|
|
|
sprintf(otherbuf, "%.70s Sound Error", appname);
|
|
|
|
MessageBox(hwnd, buf, otherbuf,
|
2001-05-06 14:35:20 +00:00
|
|
|
MB_OK | MB_ICONEXCLAMATION);
|
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
|
|
|
conf_set_int(conf, CONF_beep, BELL_DEFAULT);
|
2001-04-14 11:37:47 +00:00
|
|
|
}
|
2003-05-24 12:31:32 +00:00
|
|
|
} else if (mode == BELL_PCSPEAKER) {
|
|
|
|
static long lastbeep = 0;
|
|
|
|
long beepdiff;
|
|
|
|
|
|
|
|
beepdiff = GetTickCount() - lastbeep;
|
|
|
|
if (beepdiff >= 0 && beepdiff < 50)
|
|
|
|
return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* We must beep in different ways depending on whether this
|
|
|
|
* is a 95-series or NT-series OS.
|
|
|
|
*/
|
|
|
|
if(osVersion.dwPlatformId == VER_PLATFORM_WIN32_NT)
|
|
|
|
Beep(800, 100);
|
|
|
|
else
|
|
|
|
MessageBeep(-1);
|
|
|
|
lastbeep = GetTickCount();
|
2001-04-14 11:37:47 +00:00
|
|
|
}
|
2001-05-13 14:42:17 +00:00
|
|
|
/* Otherwise, either visual bell or disabled; do nothing here */
|
2002-10-22 16:11:33 +00:00
|
|
|
if (!term->has_focus) {
|
2001-05-13 14:42:17 +00:00
|
|
|
flash_window(2); /* start */
|
|
|
|
}
|
1999-01-08 13:02:13 +00:00
|
|
|
}
|
2001-09-13 18:24:51 +00:00
|
|
|
|
2001-11-25 15:21:25 +00:00
|
|
|
/*
|
|
|
|
* Minimise or restore the window in response to a server-side
|
|
|
|
* request.
|
|
|
|
*/
|
2002-10-26 12:58:13 +00:00
|
|
|
void set_iconic(void *frontend, int iconic)
|
2001-11-25 15:21:25 +00:00
|
|
|
{
|
|
|
|
if (IsIconic(hwnd)) {
|
|
|
|
if (!iconic)
|
|
|
|
ShowWindow(hwnd, SW_RESTORE);
|
|
|
|
} else {
|
|
|
|
if (iconic)
|
|
|
|
ShowWindow(hwnd, SW_MINIMIZE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Move the window in response to a server-side request.
|
|
|
|
*/
|
2002-10-26 12:58:13 +00:00
|
|
|
void move_window(void *frontend, int x, int y)
|
2001-11-25 15:21:25 +00:00
|
|
|
{
|
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
|
|
|
int resize_action = conf_get_int(conf, CONF_resize_action);
|
|
|
|
if (resize_action == RESIZE_DISABLED ||
|
|
|
|
resize_action == RESIZE_FONT ||
|
2002-01-08 09:56:06 +00:00
|
|
|
IsZoomed(hwnd))
|
|
|
|
return;
|
|
|
|
|
2001-11-25 15:21:25 +00:00
|
|
|
SetWindowPos(hwnd, NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Move the window to the top or bottom of the z-order in response
|
|
|
|
* to a server-side request.
|
|
|
|
*/
|
2002-10-26 12:58:13 +00:00
|
|
|
void set_zorder(void *frontend, int top)
|
2001-11-25 15:21:25 +00:00
|
|
|
{
|
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
|
|
|
if (conf_get_int(conf, CONF_alwaysontop))
|
2001-11-25 15:21:25 +00:00
|
|
|
return; /* ignore */
|
|
|
|
SetWindowPos(hwnd, top ? HWND_TOP : HWND_BOTTOM, 0, 0, 0, 0,
|
|
|
|
SWP_NOMOVE | SWP_NOSIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Refresh the window in response to a server-side request.
|
|
|
|
*/
|
2002-10-26 12:58:13 +00:00
|
|
|
void refresh_window(void *frontend)
|
2001-11-25 15:21:25 +00:00
|
|
|
{
|
|
|
|
InvalidateRect(hwnd, NULL, TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Maximise or restore the window in response to a server-side
|
|
|
|
* request.
|
|
|
|
*/
|
2002-10-26 12:58:13 +00:00
|
|
|
void set_zoomed(void *frontend, int zoomed)
|
2001-11-25 15:21:25 +00:00
|
|
|
{
|
2001-12-07 21:21:03 +00:00
|
|
|
if (IsZoomed(hwnd)) {
|
|
|
|
if (!zoomed)
|
|
|
|
ShowWindow(hwnd, SW_RESTORE);
|
2001-11-25 15:21:25 +00:00
|
|
|
} else {
|
|
|
|
if (zoomed)
|
|
|
|
ShowWindow(hwnd, SW_MAXIMIZE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Report whether the window is iconic, for terminal reports.
|
|
|
|
*/
|
2002-10-26 12:58:13 +00:00
|
|
|
int is_iconic(void *frontend)
|
2001-11-25 15:21:25 +00:00
|
|
|
{
|
|
|
|
return IsIconic(hwnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Report the window's position, for terminal reports.
|
|
|
|
*/
|
2002-10-26 12:58:13 +00:00
|
|
|
void get_window_pos(void *frontend, int *x, int *y)
|
2001-11-25 15:21:25 +00:00
|
|
|
{
|
|
|
|
RECT r;
|
|
|
|
GetWindowRect(hwnd, &r);
|
|
|
|
*x = r.left;
|
|
|
|
*y = r.top;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Report the window's pixel size, for terminal reports.
|
|
|
|
*/
|
2002-10-26 12:58:13 +00:00
|
|
|
void get_window_pixels(void *frontend, int *x, int *y)
|
2001-11-25 15:21:25 +00:00
|
|
|
{
|
|
|
|
RECT r;
|
|
|
|
GetWindowRect(hwnd, &r);
|
|
|
|
*x = r.right - r.left;
|
|
|
|
*y = r.bottom - r.top;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the window or icon title.
|
|
|
|
*/
|
2002-10-26 12:58:13 +00:00
|
|
|
char *get_window_title(void *frontend, int icon)
|
2001-11-25 15:21:25 +00:00
|
|
|
{
|
|
|
|
return icon ? icon_name : window_name;
|
|
|
|
}
|
2001-12-07 21:21:03 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* See if we're in full-screen mode.
|
|
|
|
*/
|
2004-01-20 20:35:27 +00:00
|
|
|
static int is_full_screen()
|
2001-12-07 21:21:03 +00:00
|
|
|
{
|
|
|
|
if (!IsZoomed(hwnd))
|
|
|
|
return FALSE;
|
2005-05-21 14:16:43 +00:00
|
|
|
if (GetWindowLongPtr(hwnd, GWL_STYLE) & WS_CAPTION)
|
2001-12-07 21:21:03 +00:00
|
|
|
return FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-03-13 22:15:14 +00:00
|
|
|
/* Get the rect/size of a full screen window using the nearest available
|
|
|
|
* monitor in multimon systems; default to something sensible if only
|
|
|
|
* one monitor is present. */
|
|
|
|
static int get_fullscreen_rect(RECT * ss)
|
|
|
|
{
|
2003-12-16 18:28:43 +00:00
|
|
|
#if defined(MONITOR_DEFAULTTONEAREST) && !defined(NO_MULTIMON)
|
2002-03-13 22:15:14 +00:00
|
|
|
HMONITOR mon;
|
|
|
|
MONITORINFO mi;
|
|
|
|
mon = MonitorFromWindow(hwnd, MONITOR_DEFAULTTONEAREST);
|
|
|
|
mi.cbSize = sizeof(mi);
|
|
|
|
GetMonitorInfo(mon, &mi);
|
|
|
|
|
|
|
|
/* structure copy */
|
|
|
|
*ss = mi.rcMonitor;
|
|
|
|
return TRUE;
|
|
|
|
#else
|
|
|
|
/* could also use code like this:
|
|
|
|
ss->left = ss->top = 0;
|
|
|
|
ss->right = GetSystemMetrics(SM_CXSCREEN);
|
|
|
|
ss->bottom = GetSystemMetrics(SM_CYSCREEN);
|
|
|
|
*/
|
2002-03-20 22:16:00 +00:00
|
|
|
return GetClientRect(GetDesktopWindow(), ss);
|
2002-03-13 22:15:14 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-07 21:21:03 +00:00
|
|
|
/*
|
|
|
|
* Go full-screen. This should only be called when we are already
|
|
|
|
* maximised.
|
|
|
|
*/
|
2004-01-20 20:35:27 +00:00
|
|
|
static void make_full_screen()
|
2001-12-07 21:21:03 +00:00
|
|
|
{
|
|
|
|
DWORD style;
|
2002-03-13 22:15:14 +00:00
|
|
|
RECT ss;
|
2001-12-07 21:21:03 +00:00
|
|
|
|
|
|
|
assert(IsZoomed(hwnd));
|
|
|
|
|
2002-03-13 22:15:14 +00:00
|
|
|
if (is_full_screen())
|
|
|
|
return;
|
|
|
|
|
2001-12-07 21:21:03 +00:00
|
|
|
/* Remove the window furniture. */
|
2005-05-21 14:16:43 +00:00
|
|
|
style = GetWindowLongPtr(hwnd, GWL_STYLE);
|
2001-12-07 21:21:03 +00:00
|
|
|
style &= ~(WS_CAPTION | WS_BORDER | WS_THICKFRAME);
|
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
|
|
|
if (conf_get_int(conf, CONF_scrollbar_in_fullscreen))
|
2001-12-07 21:21:03 +00:00
|
|
|
style |= WS_VSCROLL;
|
|
|
|
else
|
|
|
|
style &= ~WS_VSCROLL;
|
2005-05-21 14:16:43 +00:00
|
|
|
SetWindowLongPtr(hwnd, GWL_STYLE, style);
|
2001-12-07 21:21:03 +00:00
|
|
|
|
|
|
|
/* Resize ourselves to exactly cover the nearest monitor. */
|
2002-03-13 22:15:14 +00:00
|
|
|
get_fullscreen_rect(&ss);
|
|
|
|
SetWindowPos(hwnd, HWND_TOP, ss.left, ss.top,
|
|
|
|
ss.right - ss.left,
|
|
|
|
ss.bottom - ss.top,
|
|
|
|
SWP_FRAMECHANGED);
|
2001-12-07 21:21:03 +00:00
|
|
|
|
2006-03-29 17:55:40 +00:00
|
|
|
/* We may have changed size as a result */
|
|
|
|
|
|
|
|
reset_window(0);
|
|
|
|
|
2009-08-15 17:45:17 +00:00
|
|
|
/* Tick the menu item in the System and context menus. */
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < lenof(popup_menus); i++)
|
|
|
|
CheckMenuItem(popup_menus[i].menu, IDM_FULLSCREEN, MF_CHECKED);
|
|
|
|
}
|
2001-12-07 21:21:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Clear the full-screen attributes.
|
|
|
|
*/
|
2004-01-20 20:35:27 +00:00
|
|
|
static void clear_full_screen()
|
2001-12-07 21:21:03 +00:00
|
|
|
{
|
|
|
|
DWORD oldstyle, style;
|
|
|
|
|
|
|
|
/* Reinstate the window furniture. */
|
2005-05-21 14:16:43 +00:00
|
|
|
style = oldstyle = GetWindowLongPtr(hwnd, GWL_STYLE);
|
2001-12-11 18:47:55 +00:00
|
|
|
style |= WS_CAPTION | WS_BORDER;
|
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
|
|
|
if (conf_get_int(conf, CONF_resize_action) == RESIZE_DISABLED)
|
2001-12-11 18:47:55 +00:00
|
|
|
style &= ~WS_THICKFRAME;
|
|
|
|
else
|
|
|
|
style |= WS_THICKFRAME;
|
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
|
|
|
if (conf_get_int(conf, CONF_scrollbar))
|
2001-12-07 21:21:03 +00:00
|
|
|
style |= WS_VSCROLL;
|
|
|
|
else
|
|
|
|
style &= ~WS_VSCROLL;
|
|
|
|
if (style != oldstyle) {
|
2005-05-21 14:16:43 +00:00
|
|
|
SetWindowLongPtr(hwnd, GWL_STYLE, style);
|
2001-12-07 21:21:03 +00:00
|
|
|
SetWindowPos(hwnd, NULL, 0, 0, 0, 0,
|
|
|
|
SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER |
|
|
|
|
SWP_FRAMECHANGED);
|
|
|
|
}
|
|
|
|
|
2009-08-15 17:45:17 +00:00
|
|
|
/* Untick the menu item in the System and context menus. */
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < lenof(popup_menus); i++)
|
|
|
|
CheckMenuItem(popup_menus[i].menu, IDM_FULLSCREEN, MF_UNCHECKED);
|
|
|
|
}
|
2001-12-07 21:21:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Toggle full-screen mode.
|
|
|
|
*/
|
2004-01-20 20:35:27 +00:00
|
|
|
static void flip_full_screen()
|
2001-12-07 21:21:03 +00:00
|
|
|
{
|
|
|
|
if (is_full_screen()) {
|
|
|
|
ShowWindow(hwnd, SW_RESTORE);
|
|
|
|
} else if (IsZoomed(hwnd)) {
|
|
|
|
make_full_screen();
|
|
|
|
} else {
|
|
|
|
SendMessage(hwnd, WM_FULLSCR_ON_MAX, 0, 0);
|
|
|
|
ShowWindow(hwnd, SW_MAXIMIZE);
|
|
|
|
}
|
|
|
|
}
|
2002-10-24 14:12:55 +00:00
|
|
|
|
2002-10-26 10:16:19 +00:00
|
|
|
void frontend_keypress(void *handle)
|
2002-10-24 14:12:55 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Keypress termination in non-Close-On-Exit mode is not
|
|
|
|
* currently supported in PuTTY proper, because the window
|
|
|
|
* always has a perfectly good Close button anyway. So we do
|
|
|
|
* nothing here.
|
|
|
|
*/
|
|
|
|
return;
|
|
|
|
}
|
Rationalisation of the system of frontend handles. Most modular bits
of PuTTY (terminal, backend, logctx etc) take a `void *' handle
passed to them from the frontend, and used as a context for all
their callbacks. Most of these point at the frontend structure
itself (on platforms where this is meaningful), except that the
handle passed to the backend has always pointed at the terminal
because from_backend() was implemented in terminal.c. This has
finally bitten Unix PuTTY, because both backend and logctx have
been passing their respective and very different frontend handles to
logevent(), so I've fixed it.
from_backend() is now a function supplied by the _frontend_ itself,
in all cases, and the frontend handle passed to backends must be the
same as that passed to everything else. What was from_backend() in
terminal.c is now called term_data(), and the typical implementation
of from_backend() in a GUI frontend will just extract the terminal
handle from the frontend structure and delegate to that.
This appears to work on Unix and Windows, but has most likely broken
the Mac build.
[originally from svn r3100]
2003-04-11 18:36:27 +00:00
|
|
|
|
|
|
|
int from_backend(void *frontend, int is_stderr, const char *data, int len)
|
|
|
|
{
|
|
|
|
return term_data(term, is_stderr, data, len);
|
|
|
|
}
|
2003-04-28 13:59:32 +00:00
|
|
|
|
2005-10-30 20:24:09 +00:00
|
|
|
int from_backend_untrusted(void *frontend, const char *data, int len)
|
|
|
|
{
|
|
|
|
return term_data_untrusted(term, data, len);
|
|
|
|
}
|
|
|
|
|
2011-09-13 11:44:03 +00:00
|
|
|
int from_backend_eof(void *frontend)
|
|
|
|
{
|
|
|
|
return TRUE; /* do respond to incoming EOF with outgoing */
|
|
|
|
}
|
|
|
|
|
2005-10-30 20:24:09 +00:00
|
|
|
int get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
ret = cmdline_get_passwd_input(p, in, inlen);
|
|
|
|
if (ret == -1)
|
|
|
|
ret = term_get_userpass_input(term, p, in, inlen);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2003-04-28 13:59:32 +00:00
|
|
|
void agent_schedule_callback(void (*callback)(void *, void *, int),
|
|
|
|
void *callback_ctx, void *data, int len)
|
|
|
|
{
|
|
|
|
struct agent_callback *c = snew(struct agent_callback);
|
|
|
|
c->callback = callback;
|
|
|
|
c->callback_ctx = callback_ctx;
|
|
|
|
c->data = data;
|
|
|
|
c->len = len;
|
|
|
|
PostMessage(hwnd, WM_AGENT_CALLBACK, 0, (LPARAM)c);
|
|
|
|
}
|