diff --git a/examples/simple_prompt.cc b/examples/simple_prompt.cc index 5935bc5..7986afe 100644 --- a/examples/simple_prompt.cc +++ b/examples/simple_prompt.cc @@ -1,22 +1,15 @@ #include "qupp/prompt/prompt.h" -#include -#include -#include - -void display_prompt() { std::cout << "Prompt from qupp!" << std::endl; } - -void move_cursor_down(int n) { std::cout << "\033[" << n << "B" << std::flush; } - -void move_cursor_up(int n) { std::cout << "\033[" << n << "A" << std::flush; } +#include // std::cout, std::endl int main() { - - display_prompt(); - move_cursor_down(1); - std::this_thread::sleep_for(std::chrono::seconds(1)); - move_cursor_up(1); - std::this_thread::sleep_for(std::chrono::seconds(1)); + qupp::prompt::Prompt prompt; + auto result = prompt.ask_for_input("This is a question:"); + if (result.has_value()) { + std::cout << "You answered: " << result.value() << std::endl; + } else { + std::cout << "You did not answer." << std::endl; + } return 0; } diff --git a/src/io/unix/io.cc b/src/io/unix/io.cc index 48a4a0d..69a7a56 100644 --- a/src/io/unix/io.cc +++ b/src/io/unix/io.cc @@ -8,7 +8,9 @@ Terminal &Terminal::get_instance() { return instance; } -void Terminal::print(const std::string &message) { std::cout << message; } +void Terminal::print(const std::string &message) { + std::cout << message << std::endl; +} std::string Terminal::read() { std::string input;