InsertMenu(popup_menus[i].menu, IDM_DUPSESS, MF_BYCOMMAND | MF_ENABLED,
IDM_RESTART, "&Restart Session");
}
+
+ /*
+ * 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;
}
int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
CONST INT *lpDx, int opaque)
{
int i, j, xp, xn;
- RECT newrc;
-
-#ifdef FIXME_REMOVE_BEFORE_CHECKIN
-int k;
-debug(("general_textout: %d,%d", x, y));
-for(k=0;k<cbCount;k++)debug((" U+%04X", lpString[k]));
-debug(("\n rect: [%d,%d %d,%d]", lprc->left, lprc->top, lprc->right, lprc->bottom));
-debug(("\n"));
-#endif
+ int bkmode = 0, got_bkmode = FALSE;
xp = xn = x;
* function.
*/
if (rtl) {
- newrc.left = lprc->left + xp - x;
- newrc.right = lprc->left + xn - x;
- newrc.top = lprc->top;
- newrc.bottom = lprc->bottom;
-#ifdef FIXME_REMOVE_BEFORE_CHECKIN
-{
-int k;
-debug((" exact_textout: %d,%d", xp, y));
-for(k=0;k<j-i;k++)debug((" U+%04X", lpString[i+k]));
-debug(("\n rect: [%d,%d %d,%d]\n", newrc.left, newrc.top, newrc.right, newrc.bottom));
-}
-#endif
- exact_textout(hdc, xp, y, &newrc, lpString+i, j-i,
+ exact_textout(hdc, xp, y, lprc, lpString+i, j-i,
font_varpitch ? NULL : lpDx+i, opaque);
} else {
-#ifdef FIXME_REMOVE_BEFORE_CHECKIN
-{
-int k;
-debug((" ExtTextOut : %d,%d", xp, y));
-for(k=0;k<j-i;k++)debug((" U+%04X", lpString[i+k]));
-debug(("\n rect: [%d,%d %d,%d]\n", newrc.left, newrc.top, newrc.right, newrc.bottom));
-}
-#endif
- newrc.left = lprc->left + xp - x;
- newrc.right = lprc->left + xn - x;
- newrc.top = lprc->top;
- newrc.bottom = lprc->bottom;
ExtTextOutW(hdc, xp, y, ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0),
- &newrc, lpString+i, j-i,
+ lprc, lpString+i, j-i,
font_varpitch ? NULL : lpDx+i);
}
i = j;
xp = xn;
+
+ bkmode = GetBkMode(hdc);
+ got_bkmode = TRUE;
+ SetBkMode(hdc, TRANSPARENT);
+ opaque = FALSE;
}
-#ifdef FIXME_REMOVE_BEFORE_CHECKIN
-debug(("general_textout: done, xn=%d\n", xn));
-#endif
- assert(xn - x >= lprc->right - lprc->left);
+ if (got_bkmode)
+ SetBkMode(hdc, bkmode);
}
static int get_font_width(HDC hdc, const TEXTMETRIC *tm)
int text_adjust = 0;
int xoffset = 0;
int maxlen, remaining, opaque;
- static int *IpDx = 0, IpDxLEN = 0;
- int *IpDxReal;
+ static int *lpDx = NULL;
+ static int lpDx_len = 0;
+ int *lpDx_maybe;
lattr &= LATTR_MODE;
if (attr & ATTR_WIDE)
char_width *= 2;
- if (len > IpDxLEN || IpDx[0] != char_width) {
- int i;
- if (len > IpDxLEN) {
- sfree(IpDx);
- IpDx = snewn(len + 16, int);
- IpDxLEN = (len + 16);
- }
- for (i = 0; i < IpDxLEN; i++)
- IpDx[i] = char_width;
- }
-
/* Only want the left half of double width lines */
if (lattr != LATTR_NORM && x*2 >= term->cols)
return;
* 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
- * disable the IpDx mechanism). This gives slightly odd but
+ * disable the lpDx mechanism). This gives slightly odd but
* generally reasonable results.
*/
xoffset = char_width / 2;
SetTextAlign(hdc, TA_TOP | TA_CENTER | TA_NOUPDATECP);
- IpDxReal = NULL;
+ lpDx_maybe = NULL;
maxlen = 1;
} else {
/*
*/
xoffset = 0;
SetTextAlign(hdc, TA_TOP | TA_LEFT | TA_NOUPDATECP);
- IpDxReal = IpDx;
+ lpDx_maybe = lpDx;
maxlen = len;
}
text += len, remaining -= len, x += char_width * len) {
len = (maxlen < remaining ? maxlen : remaining);
+ 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;
+ }
+
/* 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! */
char dbcstext[2];
dbcstext[0] = text[mptr] & 0xFF;
dbcstext[1] = text[mptr+1] & 0xFF;
- IpDx[nlen] += char_width;
+ lpDx[nlen] += char_width;
MultiByteToWideChar(ucsdata.font_codepage, MB_USEGLYPHCHARS,
dbcstext, 2, uni_buf+nlen, 1);
mptr++;
y - font_height * (lattr == LATTR_BOT) + text_adjust,
ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0),
&line_box, uni_buf, nlen,
- IpDxReal);
+ lpDx_maybe);
if (bold_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
SetBkMode(hdc, TRANSPARENT);
ExtTextOutW(hdc, x + xoffset - 1,
y - font_height * (lattr ==
LATTR_BOT) + text_adjust,
- ETO_CLIPPED, &line_box, uni_buf, nlen, IpDxReal);
+ ETO_CLIPPED, &line_box, uni_buf, nlen, lpDx_maybe);
}
- IpDx[0] = -1;
+ lpDx[0] = -1;
} else if (DIRECT_FONT(text[0])) {
static char *directbuf = NULL;
static int directlen = 0;
ExtTextOut(hdc, x + xoffset,
y - font_height * (lattr == LATTR_BOT) + text_adjust,
ETO_CLIPPED | (opaque ? ETO_OPAQUE : 0),
- &line_box, directbuf, len, IpDxReal);
+ &line_box, directbuf, len, lpDx_maybe);
if (bold_mode == BOLD_SHADOW && (attr & ATTR_BOLD)) {
SetBkMode(hdc, TRANSPARENT);
ExtTextOut(hdc, x + xoffset - 1,
y - font_height * (lattr ==
LATTR_BOT) + text_adjust,
- ETO_CLIPPED, &line_box, directbuf, len, IpDxReal);
+ ETO_CLIPPED, &line_box, directbuf, len, lpDx_maybe);
}
} else {
/* And 'normal' unicode characters */
/* print Glyphs as they are, without Windows' Shaping*/
general_textout(hdc, x + xoffset,
y - font_height * (lattr==LATTR_BOT) + text_adjust,
- &line_box, wbuf, len, IpDx,
+ &line_box, wbuf, len, lpDx,
opaque && !(attr & TATTR_COMBINING));
/* And the shadow bold hack. */
ExtTextOutW(hdc, x + xoffset - 1,
y - font_height * (lattr ==
LATTR_BOT) + text_adjust,
- ETO_CLIPPED, &line_box, wbuf, len, IpDxReal);
+ ETO_CLIPPED, &line_box, wbuf, len, lpDx_maybe);
}
}