#define WHEEL_DELTA 120
#endif
-static Mouse_Button translate_button(void *frontend, Mouse_Button button);
+static Mouse_Button translate_button(Mouse_Button button);
static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
static int TranslateKey(UINT message, WPARAM wParam, LPARAM lParam,
unsigned char *output);
{
char *bits;
int size = (font_width + 15) / 16 * 2 * font_height;
- bits = smalloc(size);
+ bits = snewn(size, char);
memset(bits, 0, size);
caretbm = CreateBitmap(font_width, font_height, 1, 1, bits);
sfree(bits);
vsprintf(stuff, fmt, ap);
va_end(ap);
MessageBox(hwnd, stuff, "PuTTY Fatal Error", MB_ICONERROR | MB_OK);
- if (cfg.close_on_exit == COE_ALWAYS)
+ if (cfg.close_on_exit == FORCE_ON)
PostQuitMessage(1);
else {
session_closed = TRUE;
if (ret == 0 && !session_closed) {
/* Abnormal exits will already have set session_closed and taken
* appropriate action. */
- if (cfg.close_on_exit == COE_ALWAYS ||
- cfg.close_on_exit == COE_NORMAL) PostQuitMessage(0);
+ if (cfg.close_on_exit == FORCE_ON ||
+ cfg.close_on_exit == AUTO) PostQuitMessage(0);
else {
session_closed = TRUE;
set_icon(NULL, "PuTTY (inactive)");
HDC hdc = GetDC(hwnd);
if (hdc) {
if (cfg.try_palette && GetDeviceCaps(hdc, RASTERCAPS) & RC_PALETTE) {
+ /*
+ * This is a genuine case where we must use smalloc
+ * because the snew macros can't cope.
+ */
logpal = smalloc(sizeof(*logpal)
- sizeof(logpal->palPalEntry)
+ NCOLOURS * sizeof(PALETTEENTRY));
bold_mode = cfg.bold_colour ? BOLD_COLOURS : BOLD_FONT;
und_mode = UND_FONT;
- if (cfg.fontisbold) {
+ if (cfg.font.isbold) {
fw_dontcare = FW_BOLD;
fw_bold = FW_HEAVY;
} else {
if (pick_height)
font_height = pick_height;
else {
- font_height = cfg.fontheight;
+ font_height = cfg.font.height;
if (font_height > 0) {
font_height =
-MulDiv(font_height, GetDeviceCaps(hdc, LOGPIXELSY), 72);
fonts[i] = CreateFont (font_height, font_width, 0, 0, w, FALSE, u, FALSE, \
c, OUT_DEFAULT_PRECIS, \
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, \
- FIXED_PITCH | FF_DONTCARE, cfg.font)
+ FIXED_PITCH | FF_DONTCARE, cfg.font.name)
- f(FONT_NORMAL, cfg.fontcharset, fw_dontcare, FALSE);
+ f(FONT_NORMAL, cfg.font.charset, fw_dontcare, FALSE);
lfont.lfHeight = font_height;
lfont.lfWidth = font_width;
lfont.lfItalic = FALSE;
lfont.lfUnderline = FALSE;
lfont.lfStrikeOut = FALSE;
- lfont.lfCharSet = cfg.fontcharset;
+ lfont.lfCharSet = cfg.font.charset;
lfont.lfOutPrecision = OUT_DEFAULT_PRECIS;
lfont.lfClipPrecision = CLIP_DEFAULT_PRECIS;
lfont.lfQuality = DEFAULT_QUALITY;
lfont.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
- strncpy(lfont.lfFaceName, cfg.font, LF_FACESIZE);
+ strncpy(lfont.lfFaceName, cfg.font.name, LF_FACESIZE);
SelectObject(hdc, fonts[FONT_NORMAL]);
GetTextMetrics(hdc, &tm);
ucsdata.dbcs_screenfont = (cpinfo.MaxCharSize > 1);
}
- f(FONT_UNDERLINE, cfg.fontcharset, fw_dontcare, TRUE);
+ f(FONT_UNDERLINE, cfg.font.charset, fw_dontcare, TRUE);
/*
* Some fonts, e.g. 9-pt Courier, draw their underlines
}
if (bold_mode == BOLD_FONT) {
- f(FONT_BOLD, cfg.fontcharset, fw_bold, FALSE);
+ f(FONT_BOLD, cfg.font.charset, fw_bold, FALSE);
}
#undef f
if (basefont != fontno && !fontflag[basefont])
another_font(basefont);
- if (cfg.fontisbold) {
+ if (cfg.font.isbold) {
fw_dontcare = FW_BOLD;
fw_bold = FW_HEAVY;
} else {
fw_bold = FW_BOLD;
}
- c = cfg.fontcharset;
+ c = cfg.font.charset;
w = fw_dontcare;
u = FALSE;
- s = cfg.font;
+ s = cfg.font.name;
x = font_width;
if (fontno & FONT_WIDE)
* Translate a raw mouse button designation (LEFT, MIDDLE, RIGHT)
* into a cooked one (SELECT, EXTEND, PASTE).
*/
-static Mouse_Button translate_button(void *frontend, Mouse_Button button)
+static Mouse_Button translate_button(Mouse_Button button)
{
if (button == MBT_LEFT)
return MBT_SELECT;
if ((lParam - IDM_SAVED_MIN) / 16 < sesslist.nsessions) {
char *session =
sesslist.sessions[(lParam - IDM_SAVED_MIN) / 16];
- cl = smalloc(16 + strlen(session));
+ cl = snewn(16 + strlen(session), char);
/* 8, but play safe */
if (!cl)
cl = NULL;
icon_name);
}
- if (strcmp(cfg.font, prev_cfg.font) != 0 ||
+ if (strcmp(cfg.font.name, prev_cfg.font.name) != 0 ||
strcmp(cfg.line_codepage, prev_cfg.line_codepage) != 0 ||
- cfg.fontisbold != prev_cfg.fontisbold ||
- cfg.fontheight != prev_cfg.fontheight ||
- cfg.fontcharset != prev_cfg.fontcharset ||
+ cfg.font.isbold != prev_cfg.font.isbold ||
+ cfg.font.height != prev_cfg.font.height ||
+ cfg.font.charset != prev_cfg.font.charset ||
cfg.vtmode != prev_cfg.vtmode ||
cfg.bold_colour != prev_cfg.bold_colour ||
cfg.resize_action == RESIZE_DISABLED ||
if (n > 0) {
int i;
- buff = (char*) smalloc(n);
+ buff = snewn(n, char);
ImmGetCompositionStringW(hIMC, GCS_RESULTSTR, buff, n);
/*
* Jaeyoun Chung reports that Korean character
int i;
if (len > IpDxLEN) {
sfree(IpDx);
- IpDx = smalloc((len + 16) * sizeof(int));
+ IpDx = snewn(len + 16, int);
IpDxLEN = (len + 16);
}
for (i = 0; i < IpDxLEN; i++)
if ((attr & CSET_MASK) == ATTR_OEMCP)
nfont |= FONT_OEM;
- nfg = 2 * ((attr & ATTR_FGMASK) >> ATTR_FGSHIFT);
- nbg = 2 * ((attr & ATTR_BGMASK) >> ATTR_BGSHIFT);
+ nfg = ((attr & ATTR_FGMASK) >> ATTR_FGSHIFT);
+ nfg = 2 * (nfg & 0xF) + (nfg & 0x10 ? 1 : 0);
+ nbg = ((attr & ATTR_BGMASK) >> ATTR_BGSHIFT);
+ nbg = 2 * (nbg & 0xF) + (nbg & 0x10 ? 1 : 0);
if (bold_mode == BOLD_FONT && (attr & ATTR_BOLD))
nfont |= FONT_BOLD;
if (und_mode == UND_FONT && (attr & ATTR_UNDER))
nbg = t;
}
if (bold_mode == BOLD_COLOURS && (attr & ATTR_BOLD))
- nfg++;
+ nfg |= 1;
if (bold_mode == BOLD_COLOURS && (attr & ATTR_BLINK))
- nbg++;
+ nbg |= 1;
fg = colours[nfg];
bg = colours[nbg];
SelectObject(hdc, fonts[nfont]);
int nlen, mptr;
if (len > uni_len) {
sfree(uni_buf);
- uni_buf = smalloc((uni_len = len) * sizeof(wchar_t));
+ uni_len = len;
+ uni_buf = snewn(uni_len, wchar_t);
}
for(nlen = mptr = 0; mptr<len; mptr++) {
if (wlen < len) {
sfree(wbuf);
wlen = len;
- wbuf = smalloc(wlen * sizeof(WCHAR));
+ wbuf = snewn(wlen, WCHAR);
}
for (i = 0; i < len; i++)
wbuf[i] = (WCHAR) ((attr & CSET_MASK) + (text[i] & CHAR_MASK));
void set_title(void *frontend, char *title)
{
sfree(window_name);
- window_name = smalloc(1 + strlen(title));
+ window_name = snewn(1 + strlen(title), char);
strcpy(window_name, title);
if (cfg.win_name_always || !IsIconic(hwnd))
SetWindowText(hwnd, title);
void set_icon(void *frontend, char *title)
{
sfree(icon_name);
- icon_name = smalloc(1 + strlen(title));
+ icon_name = snewn(1 + strlen(title), char);
strcpy(icon_name, title);
if (!cfg.win_name_always && IsIconic(hwnd))
SetWindowText(hwnd, title);
get_unitab(CP_ACP, unitab, 0);
- rtfsize = 100 + strlen(cfg.font);
- rtf = smalloc(rtfsize);
+ rtfsize = 100 + strlen(cfg.font.name);
+ rtf = snewn(rtfsize, char);
sprintf(rtf, "{\\rtf1\\ansi%d{\\fonttbl\\f0\\fmodern %s;}\\f0",
- GetACP(), cfg.font);
+ GetACP(), cfg.font.name);
rtflen = strlen(rtf);
/*
if (rtfsize < rtflen + totallen + 3) {
rtfsize = rtflen + totallen + 512;
- rtf = srealloc(rtf, rtfsize);
+ rtf = sresize(rtf, rtfsize, char);
}
strcpy(rtf + rtflen, before); rtflen += blen;
CloseClipboard();
s = GlobalLock(clipdata);
i = MultiByteToWideChar(CP_ACP, 0, s, strlen(s) + 1, 0, 0);
- *p = converted = smalloc(i * sizeof(wchar_t));
+ *p = converted = snewn(i, wchar_t);
MultiByteToWideChar(CP_ACP, 0, s, strlen(s) + 1, converted, i);
*len = i - 1;
return;
*/
lastbeep = GetTickCount();
} else if (mode == BELL_WAVEFILE) {
- if (!PlaySound(cfg.bell_wavefile, NULL, SND_ASYNC | SND_FILENAME)) {
+ if (!PlaySound(cfg.bell_wavefile.path, NULL,
+ SND_ASYNC | SND_FILENAME)) {
char buf[sizeof(cfg.bell_wavefile) + 80];
sprintf(buf, "Unable to play sound file\n%s\n"
"Using default sound instead", cfg.bell_wavefile);