mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Move print_pending_errors to text_io_handler
This commit is contained in:
+2
-10
@@ -99,7 +99,7 @@ bool run_script_file(String const& filename) {
|
||||
void CLISetInterface::run() {
|
||||
// show welcome logo
|
||||
if (!quiet) showWelcome();
|
||||
print_pending_errors();
|
||||
cli.print_pending_errors();
|
||||
// loop
|
||||
running = true;
|
||||
while (running) {
|
||||
@@ -112,7 +112,7 @@ void CLISetInterface::run() {
|
||||
String command = cli.getLine();
|
||||
if (command.empty() && !cli.canGetLine()) break;
|
||||
handleCommand(command);
|
||||
print_pending_errors();
|
||||
cli.print_pending_errors();
|
||||
cli.flush();
|
||||
cli.flushRaw();
|
||||
}
|
||||
@@ -260,11 +260,3 @@ void CLISetInterface::handleCommand(const String& command) {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void CLISetInterface::print_pending_errors() {
|
||||
MessageType type;
|
||||
String msg;
|
||||
while (get_queued_message(type,msg)) {
|
||||
cli.show_message(type,msg);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ private:
|
||||
#if USE_SCRIPT_PROFILING
|
||||
void showProfilingStats(const FunctionProfile& parent, int level = 0);
|
||||
#endif
|
||||
void print_pending_errors();
|
||||
|
||||
/// our own context, when no set is loaded
|
||||
Context& getContext();
|
||||
|
||||
@@ -152,9 +152,9 @@ void TextIOHandler::flushRaw() {
|
||||
if (!buffer.empty()) {
|
||||
#ifdef UNICODE
|
||||
wxCharBuffer buf = buffer.mb_str(wxConvUTF8);
|
||||
fputs(buf,stdout);
|
||||
fputs(buf,stream);
|
||||
#else
|
||||
fputs(buffer.c_str(),stdout);
|
||||
fputs(buffer.c_str(), stream);
|
||||
#endif
|
||||
}
|
||||
fflush(stdout);
|
||||
@@ -178,6 +178,20 @@ void TextIOHandler::show_message(MessageType type, String const& message) {
|
||||
if (raw_mode) raw_mode_status = max(raw_mode_status, type == MESSAGE_WARNING ? 1 : 2);
|
||||
}
|
||||
|
||||
void TextIOHandler::print_pending_errors() {
|
||||
MessageType type;
|
||||
String msg;
|
||||
while (get_queued_message(type, msg)) {
|
||||
if (haveConsole()) {
|
||||
show_message(type, msg);
|
||||
flush();
|
||||
} else {
|
||||
// no console, use a messagebox instead
|
||||
wxMessageBox(msg, wxMessageBoxCaptionStr, type == MESSAGE_INFO ? wxICON_INFORMATION : type == MESSAGE_WARNING ? wxICON_WARNING : wxICON_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool TextIOHandler::shown_errors() const {
|
||||
return encountered_errors;
|
||||
}
|
||||
|
||||
@@ -38,6 +38,7 @@ public:
|
||||
|
||||
/// Show an error or warning message
|
||||
void show_message(MessageType type, String const& message);
|
||||
void print_pending_errors();
|
||||
bool shown_errors() const;
|
||||
|
||||
/// Enable raw mode
|
||||
@@ -49,7 +50,7 @@ public:
|
||||
private:
|
||||
bool have_console;
|
||||
bool escapes;
|
||||
FILE* stream;
|
||||
FILE* stream; ///< Output stream
|
||||
String buffer; ///< Buffer when not writing to console
|
||||
bool raw_mode;
|
||||
int raw_mode_status;
|
||||
|
||||
Reference in New Issue
Block a user