Made the command line debugger output “>” before inputs, added special magic sequence to break the debugger from stdin

This commit is contained in:
Lior Halphon 2020-05-31 20:32:00 +03:00
parent 0c0ca8e862
commit 08efb46d41
1 changed files with 9 additions and 0 deletions

View File

@ -62,6 +62,9 @@ static char *default_input_callback(GB_gameboy_t *gb)
{
char *expression = NULL;
size_t size = 0;
if (gb->debug_stopped) {
printf(">");
}
if (getline(&expression, &size, stdin) == -1) {
/* The user doesn't have STDIN or used ^D. We make sure the program keeps running. */
@ -77,6 +80,12 @@ static char *default_input_callback(GB_gameboy_t *gb)
if (expression[length - 1] == '\n') {
expression[length - 1] = 0;
}
if (expression[0] == '\x03') {
gb->debug_stopped = true;
free(expression);
return strdup("");
}
return expression;
}