From 280fb18ec69524ddc2f35a525e0f58e936b43d05 Mon Sep 17 00:00:00 2001 From: Adam Wardynski <award@.(win7-laptop)> Date: Sun, 28 Nov 2010 04:13:42 +0100 Subject: [PATCH] Windows compatibility for clear screen. --- wcclparser/main.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/wcclparser/main.cpp b/wcclparser/main.cpp index 4ba829e..1ee27d4 100644 --- a/wcclparser/main.cpp +++ b/wcclparser/main.cpp @@ -10,9 +10,9 @@ #include <antlr/MismatchedTokenException.hpp> // ---------------------------------------------------------------------------- -//#ifdef HAVE_LIBEDIT +#ifdef HAVE_LIBEDIT #include <histedit.h> -//#endif +#endif /** * @desc A simple command line tester for testing operators @@ -34,6 +34,15 @@ void std_read_loop(boost::function<bool (const std::string&)>& line_cb) } } +int clear_screen() +{ +#ifdef _WINDOWS + return std::system("cls"); +#else + return std::system("clear"); +#endif +} + #ifdef HAVE_LIBEDIT const char* query_prompt(EditLine*) { return _prompt; @@ -81,7 +90,7 @@ bool process_line(const std::string& line, Parser& parser) if (line.empty() || line == "exit" || line == "quit") { return true; } else if (line == "clear" || line == "cls") { - if (system("clear")) {} + if (clear_screen()) {} return false; } @@ -158,7 +167,7 @@ int main(int argc, char** argv) const Corpus2::Tagset& tagset = Corpus2::get_named_tagset(tagset_load); Parser parser(tagset); - if (system("clear")) { + if (clear_screen()) { // } -- GitLab