From 3cb801a5df8d497959332f60f29b799f16060aad Mon Sep 17 00:00:00 2001 From: yhirose Date: Tue, 4 Aug 2015 18:02:42 -0400 Subject: [PATCH] Improved debugger display. --- language/main.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/language/main.cc b/language/main.cc index 311aa68..e723f7c 100644 --- a/language/main.cc +++ b/language/main.cc @@ -40,10 +40,17 @@ struct CommandLineDebugger } if (force_to_break) { + static auto show_initial_usage = true; + if (show_initial_usage) { + show_initial_usage = false; + usage(); + } + show_lines(ast); for (;;) { - cout << "debug> "; + cout << endl << "debug> "; + string s; std::getline(cin, s); @@ -51,7 +58,7 @@ struct CommandLineDebugger is >> command_; if (command_ == "h") { - cout << "(c)ontinue, (n)ext, (s)tep in, step (o)out, (p)ring, (l)ist, (q)uit" << endl; + usage(); } else if (command_ == "l") { is >> display_lines_; show_lines(ast); @@ -79,7 +86,7 @@ struct CommandLineDebugger void show_lines(const Ast& ast) { prepare_cache(ast.path); - cout << "break in " << ast.path << ":" << ast.line << endl; + cout << endl << "Break in " << ast.path << ":" << ast.line << endl; auto count = get_line_count(ast.path); @@ -194,6 +201,10 @@ struct CommandLineDebugger } } + void usage() { + cout << "Usage: (c)ontinue, (n)ext, (s)tep in, step (o)out, (p)ring, (l)ist, (q)uit" << endl; + } + bool quit = false; string command_; size_t level_ = 0;