Skip to content

Commit acae8a2

Browse files
committed
fix readline
1 parent 53260dd commit acae8a2

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

emulator/src/Logger.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ namespace casioemu {
99
namespace logger {
1010
void Info(const char *format, ...) {
1111
// * TODO may introduce race condition
12-
// if (RL_ISSTATE(RL_STATE_TERMPREPPED))
12+
if (RL_ISSTATE(RL_STATE_READCMD))
1313
rl_clear_visible_line();
1414
va_list args;
1515
va_start(args, format);
1616
vprintf(format, args);
1717
va_end(args);
18-
// if (RL_ISSTATE(RL_STATE_TERMPREPPED)) {
18+
if (RL_ISSTATE(RL_STATE_READCMD)) {
1919
rl_on_new_line();
2020
rl_redisplay();
21-
// }
21+
}
2222
}
2323
}
2424
} // namespace casioemu

emulator/src/casioemu.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,15 @@ int main(int argc, char *argv[]) {
8989
test_gui();
9090
std::thread console_input_thread([&] {
9191
struct terminate_thread {};
92+
rl_event_hook = []() {
93+
throw terminate_thread{};
94+
return 0;
95+
};
96+
try {
97+
(void)readline("");
98+
} catch (terminate_thread) {
99+
rl_cleanup_after_signal();
100+
} // an ugly hack to make readline not print a extranous line when calling rl_clear_visible_line
92101
rl_event_hook = []() {
93102
if (!running)
94103
throw terminate_thread{};

0 commit comments

Comments
 (0)