Fix get string

This commit is contained in:
Andrew Pamment 2020-06-06 10:44:32 +10:00
parent b5bd8477e4
commit 318b385ce4
2 changed files with 10 additions and 3 deletions

View File

@ -60,6 +60,8 @@ int md_getstring(char *ptr, int maxlen, char minchar, char maxchar) {
int len = 0;
static char lastc = 'x';
*ptr = '\0';
while (len < maxlen) {
c = md_getc();
if (c == '\n' || c == '\0') {
@ -76,7 +78,7 @@ int md_getstring(char *ptr, int maxlen, char minchar, char maxchar) {
}
if (c == '\b' || c == 127) {
if (len > 0) {
md_printf("\x1b[D \x1b[D");
md_printf("\b \b");
len--;
ptr[len] = '\0';
}
@ -92,4 +94,4 @@ int md_getstring(char *ptr, int maxlen, char minchar, char maxchar) {
}
return len;
}
}

View File

@ -1,6 +1,11 @@
#ifndef __MAGIDOOR_H__
#define __MAGIDOOR_H__
#include <stdint.h>
#define MAGIDOOR_VERSION_MAJOR 1
#define MAGIDOOR_VERSION_MINOR 2
#define TRUE 1
#define FALSE 0
@ -28,4 +33,4 @@ extern void md_sendfile(const char *filename, int pause);
extern void md_clr_scr();
extern void md_set_cursor(int y, int x);
extern char md_get_answer(char *options);
#endif
#endif