Add support for returnOpts without clearing the screen

modified:   src/libnms.c
This commit is contained in:
Brian Barto 2017-01-15 14:26:19 -05:00
parent e7ec1e9b9a
commit 4d7706c907

View File

@ -377,24 +377,31 @@ char nms_exec(char *string) {
// Flush any input up to this point // Flush any input up to this point
nms_clear_input(); nms_clear_input();
if (clearScr) { // Check if user must select from a set of options
if (returnOpts != NULL && strlen(returnOpts) > 0) {
// Position cursor // Position cursor if necessary
if (inputPositionY >= 0 && inputPositionX >= 0) { if (inputPositionY >= 0 && inputPositionX >= 0) {
CURSOR_MOVE(inputPositionY, inputPositionX); CURSOR_MOVE(inputPositionY, inputPositionX);
CURSOR_SHOW();
} }
// User must press a key to continue CURSOR_SHOW();
ret = nms_get_char();
if (returnOpts != NULL && strlen(returnOpts) > 0) { // Get and validate user selection
while (strchr(returnOpts, ret) == NULL) { while (strchr(returnOpts, ret = nms_get_char()) == NULL) {
BEEP(); BEEP();
ret = nms_get_char();
}
} }
// Restore screen and cursor }
// User must press a key to continue when clearSrc is set
// without returnOpts
else if (clearScr) {
nms_get_char();
}
// Restore screen and cursor is clearSrc is set
if (clearScr) {
SCREEN_RESTORE(); SCREEN_RESTORE();
CURSOR_SHOW(); CURSOR_SHOW();
CURSOR_RESTORE(); CURSOR_RESTORE();