Skip to content

Commit c5a4cd5

Browse files
committed
true minor improvement
1 parent 2cb64a9 commit c5a4cd5

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

emulator/src/casioemu.cpp

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ int main(int argc, char *argv[]) {
7373
if (err && err != ENOENT)
7474
PANIC("error while reading history file: %s\n", std::strerror(err));
7575
}
76-
76+
77+
static std::atomic<bool> got_inp(false);
7778
{
7879
Emulator emulator(argv_map);
7980
m_emu = &emulator;
@@ -82,19 +83,22 @@ int main(int argc, char *argv[]) {
8283

8384
// Used to signal to the console input thread when to stop.
8485
static std::atomic<bool> running(true);
86+
static std::atomic<int> inp_cnt(0);
87+
static char pr[500];
8588

8689
test_gui();
8790
std::thread console_input_thread([&] {
8891
while (1) {
8992
char *console_input_c_str;
90-
bool got = false;
93+
got_inp = false;
9194
std::thread readline_thread([&] {
92-
console_input_c_str = readline("> ");
93-
got = true;
95+
sprintf(pr, "In [%d]: ", ++inp_cnt);
96+
console_input_c_str = readline(pr);
97+
got_inp = true;
9498
});
9599
readline_thread.detach();
96100

97-
while (!got)
101+
while (!got_inp)
98102
if (!running)
99103
return;
100104

@@ -194,7 +198,9 @@ int main(int argc, char *argv[]) {
194198
console_input_thread.join();
195199
}
196200

197-
std::cout << "\nGoodbye" << std::endl;
201+
if (!got_inp)
202+
std::cout << std::endl;
203+
std::cout << "Goodbye" << std::endl;
198204

199205
IMG_Quit();
200206
SDL_Quit();

0 commit comments

Comments
 (0)