From c8119885faff23c8895cf6b278e28059b293e163 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Wed, 8 Jan 2014 19:22:58 +0000 Subject: [PATCH] Use Win32 MessageBox for asserts on cygwin --- src/assert.cc | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/assert.cc b/src/assert.cc index c58d8165..b36fc4e0 100644 --- a/src/assert.cc +++ b/src/assert.cc @@ -3,6 +3,10 @@ #include "exception.hh" #include "debug.hh" +#if defined(__CYGWIN__) +#include +#endif + #include #include @@ -24,8 +28,19 @@ void on_assert_failed(const char* message) String debug_info = "pid: " + to_string(getpid()); write_debug("assert failed: '"_str + message + "' " + debug_info); - int res = system(("xmessage -buttons 'quit:0,ignore:1' '"_str + - message + "\n[Debug Infos]\n" + debug_info + "'").c_str()); + const auto msg = message + "\n[Debug Infos]\n"_str + debug_info; +#if defined(__CYGWIN__) + int res = MessageBox(NULL, msg.c_str(), "Kakoune: assert failed", + MB_OKCANCEL | MB_ICONERROR); + switch (res) + { + case IDCANCEL: + throw assert_failed(message); + case IDOK: + return; + } +#else + int res = system(("xmessage -buttons 'quit:0,ignore:1' '" + msg + "'").c_str()); switch (res) { case -1: @@ -34,6 +49,7 @@ void on_assert_failed(const char* message) case 1: return; } +#endif } }