diff options
Diffstat (limited to 'engines/glk/alan3/readline.cpp')
| -rw-r--r-- | engines/glk/alan3/readline.cpp | 78 |
1 files changed, 38 insertions, 40 deletions
diff --git a/engines/glk/alan3/readline.cpp b/engines/glk/alan3/readline.cpp index 4fb7a8926a..2bd408f7cb 100644 --- a/engines/glk/alan3/readline.cpp +++ b/engines/glk/alan3/readline.cpp @@ -48,54 +48,52 @@ namespace Alan3 { */ /* TODO - length of user buffer should be used */ -bool readline(char buffer[]) -{ - event_t event; - static bool readingCommands = FALSE; - static frefid_t commandFileRef; - static strid_t commandFile; +bool readline(char buffer[]) { + event_t event; + static bool readingCommands = FALSE; + static frefid_t commandFileRef; + static strid_t commandFile; - if (readingCommands) { - if (g_vm->glk_get_line_stream(commandFile, buffer, 255) == 0) { + if (readingCommands) { + if (g_vm->glk_get_line_stream(commandFile, buffer, 255) == 0) { g_vm->glk_stream_close(commandFile, NULL); - readingCommands = FALSE; - } else { + readingCommands = FALSE; + } else { g_vm->glk_set_style(style_Input); - printf(buffer); + printf(buffer); g_vm->glk_set_style(style_Normal); - } - } else { + } + } else { g_vm->glk_request_line_event(glkMainWin, buffer, 255, 0); - /* FIXME: buffer size should be infallible: all existing calls use 256 or - 80 character buffers, except parse which uses LISTLEN (currently 100) - */ - do - { - g_vm->glk_select(&event); - switch (event.type) { - case evtype_Arrange: - statusline(); - break; + /* FIXME: buffer size should be infallible: all existing calls use 256 or + 80 character buffers, except parse which uses LISTLEN (currently 100) + */ + do { + g_vm->glk_select(&event); + switch (event.type) { + case evtype_Arrange: + statusline(); + break; - default: - break; - } - } while (event.type != evtype_LineInput); - if (buffer[0] == '@') { - buffer[event.val1] = 0; - commandFileRef = g_vm->glk_fileref_create_by_name(fileusage_InputRecord+fileusage_TextMode, &buffer[1], 0); - commandFile = g_vm->glk_stream_open_file(commandFileRef, filemode_Read, 0); - if (commandFile != NULL) - if (g_vm->glk_get_line_stream(commandFile, buffer, 255) != 0) { - readingCommands = TRUE; + default: + break; + } + } while (event.type != evtype_LineInput); + if (buffer[0] == '@') { + buffer[event.val1] = 0; + commandFileRef = g_vm->glk_fileref_create_by_name(fileusage_InputRecord + fileusage_TextMode, &buffer[1], 0); + commandFile = g_vm->glk_stream_open_file(commandFileRef, filemode_Read, 0); + if (commandFile != NULL) + if (g_vm->glk_get_line_stream(commandFile, buffer, 255) != 0) { + readingCommands = TRUE; g_vm->glk_set_style(style_Input); - printf(buffer); + printf(buffer); g_vm->glk_set_style(style_Normal); - } - } else - buffer[event.val1] = 0; - } - return TRUE; + } + } else + buffer[event.val1] = 0; + } + return TRUE; } } // End of namespace Alan3 |
