~mdw
/
sgt
/
puzzles
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Actually do what the comment says at the top of main() regarding not
[sgt/puzzles]
/
windows.c
diff --git
a/windows.c
b/windows.c
index
6249d55
..
7bdb5e2
100644
(file)
--- a/
windows.c
+++ b/
windows.c
@@
-154,11
+154,17
@@
void debug_printf(char *fmt, ...)
{
char buf[4096];
va_list ap;
{
char buf[4096];
va_list ap;
+ static int debugging = -1;
- va_start(ap, fmt);
- _vsnprintf(buf, 4095, fmt, ap);
- dputs(buf);
- va_end(ap);
+ if (debugging == -1)
+ debugging = getenv("DEBUG_PUZZLES") ? 1 : 0;
+
+ if (debugging) {
+ va_start(ap, fmt);
+ _vsnprintf(buf, 4095, fmt, ap);
+ dputs(buf);
+ va_end(ap);
+ }
}
#endif
}
#endif
@@
-239,6
+245,7
@@
void frontend_free(frontend *fe)
sfree(fe->brushes);
sfree(fe->pens);
sfree(fe->presets);
sfree(fe->brushes);
sfree(fe->pens);
sfree(fe->presets);
+ sfree(fe->fonts);
sfree(fe);
}
sfree(fe);
}
@@
-601,10
+608,8
@@
static void win_draw_text(void *handle, int x, int y, int fonttype,
HFONT oldfont;
TEXTMETRIC tm;
SIZE size;
HFONT oldfont;
TEXTMETRIC tm;
SIZE size;
-#ifdef _WIN32_WCE
TCHAR wText[256];
TCHAR wText[256];
- MultiByteToWideChar (CP_ACP, 0, text, -1, wText, 256);
-#endif
+ MultiByteToWideChar (CP_UTF8, 0, text, -1, wText, 256);
oldfont = SelectObject(fe->hdc, fe->fonts[i].font);
if (GetTextMetrics(fe->hdc, &tm)) {
oldfont = SelectObject(fe->hdc, fe->fonts[i].font);
if (GetTextMetrics(fe->hdc, &tm)) {
@@
-613,11
+618,7
@@
static void win_draw_text(void *handle, int x, int y, int fonttype,
else
xy.y -= tm.tmAscent;
}
else
xy.y -= tm.tmAscent;
}
-#ifndef _WIN32_WCE
- if (GetTextExtentPoint32(fe->hdc, text, strlen(text), &size))
-#else
- if (GetTextExtentPoint32(fe->hdc, wText, wcslen(wText), &size))
-#endif
+ if (GetTextExtentPoint32W(fe->hdc, wText, wcslen(wText), &size))
{
if (align & ALIGN_HCENTRE)
xy.x -= size.cx / 2;
{
if (align & ALIGN_HCENTRE)
xy.x -= size.cx / 2;
@@
-626,11
+627,7
@@
static void win_draw_text(void *handle, int x, int y, int fonttype,
}
SetBkMode(fe->hdc, TRANSPARENT);
win_text_colour(fe, colour);
}
SetBkMode(fe->hdc, TRANSPARENT);
win_text_colour(fe, colour);
-#ifndef _WIN32_WCE
- TextOut(fe->hdc, xy.x, xy.y, text, strlen(text));
-#else
- ExtTextOut(fe->hdc, xy.x, xy.y, 0, NULL, wText, wcslen(wText), NULL);
-#endif
+ ExtTextOutW(fe->hdc, xy.x, xy.y, 0, NULL, wText, wcslen(wText), NULL);
SelectObject(fe->hdc, oldfont);
}
}
SelectObject(fe->hdc, oldfont);
}
}
@@
-956,6
+953,15
@@
static void win_end_doc(void *handle)
}
}
}
}
+char *win_text_fallback(void *handle, const char *const *strings, int nstrings)
+{
+ /*
+ * We assume Windows can cope with any UTF-8 likely to be
+ * emitted by a puzzle.
+ */
+ return dupstr(strings[0]);
+}
+
const struct drawing_api win_drawing = {
win_draw_text,
win_draw_rect,
const struct drawing_api win_drawing = {
win_draw_text,
win_draw_rect,
@@
-980,6
+986,7
@@
const struct drawing_api win_drawing = {
win_end_doc,
win_line_width,
win_line_dotted,
win_end_doc,
win_line_width,
win_line_dotted,
+ win_text_fallback,
};
void print(frontend *fe)
};
void print(frontend *fe)
@@
-3397,6
+3404,7
@@
int WINAPI WinMain(HINSTANCE inst, HINSTANCE prev, LPSTR cmdline, int show)
DispatchMessage(&msg);
}
DispatchMessage(&msg);
}
+ DestroyWindow(fe->hwnd);
cleanup_help();
return msg.wParam;
cleanup_help();
return msg.wParam;