aboutsummaryrefslogtreecommitdiffhomepage
path: root/win32/PlatWin.cxx
diff options
context:
space:
mode:
authornyamatongwe <unknown>2000-10-03 11:31:47 +0000
committernyamatongwe <unknown>2000-10-03 11:31:47 +0000
commita67e810e17bcb5db90f2f0f53b90533c23cee8ed (patch)
tree815fb27f2ecc79464f6cc75a56789d3a43babe3e /win32/PlatWin.cxx
parent57e0eed5ab57d6e2607a41a33336e26cd7f11202 (diff)
downloadscintilla-mirror-a67e810e17bcb5db90f2f0f53b90533c23cee8ed.tar.gz
Added PLATFORM_ASSERT which is a verson of the standard assert which
can be directed wither to debug output or message boxes on Windows.
Diffstat (limited to 'win32/PlatWin.cxx')
-rw-r--r--win32/PlatWin.cxx30
1 files changed, 28 insertions, 2 deletions
diff --git a/win32/PlatWin.cxx b/win32/PlatWin.cxx
index 2eb2d12f0..654cf3a27 100644
--- a/win32/PlatWin.cxx
+++ b/win32/PlatWin.cxx
@@ -147,10 +147,10 @@ class FontCached : Font {
FontCached *next;
int usage;
LOGFONT lf;
- int hash;
+ int hash;
FontCached(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_);
~FontCached() {}
- bool SameAs(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_);
+ bool SameAs(const char *faceName_, int characterSet_, int size_, bool bold_, bool italic_);
virtual void Release();
static FontCached *first;
@@ -878,6 +878,32 @@ void Platform::DebugPrintf(const char *, ...) {
}
#endif
+static bool assertionPopUps = true;
+
+void Platform::ShowAssertionPopUps(bool assertionPopUps_) {
+ assertionPopUps = assertionPopUps_;
+}
+
+void Platform::Assert(const char *c, const char *file, int line) {
+ char buffer[2000];
+ sprintf(buffer, "Assertion [%s] failed at %s %d", c, file, line);
+ if (assertionPopUps) {
+ int idButton = ::MessageBox(0, buffer, "Assertion failure",
+ MB_ABORTRETRYIGNORE|MB_ICONHAND|MB_SETFOREGROUND|MB_TASKMODAL);
+ if (idButton == IDRETRY) {
+ ::DebugBreak();
+ } else if (idButton == IDIGNORE) {
+ // all OK
+ } else {
+ abort();
+ }
+ } else {
+ strcat(buffer, "\r\n");
+ Platform::DebugDisplay(buffer);
+ abort();
+ }
+}
+
int Platform::Clamp(int val, int minVal, int maxVal) {
if (val > maxVal)
val = maxVal;