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; int len = 0;
static char lastc = 'x'; static char lastc = 'x';
*ptr = '\0';
while (len < maxlen) { while (len < maxlen) {
c = md_getc(); c = md_getc();
if (c == '\n' || c == '\0') { 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 (c == '\b' || c == 127) {
if (len > 0) { if (len > 0) {
md_printf("\x1b[D \x1b[D"); md_printf("\b \b");
len--; len--;
ptr[len] = '\0'; ptr[len] = '\0';
} }

View File

@ -1,6 +1,11 @@
#ifndef __MAGIDOOR_H__ #ifndef __MAGIDOOR_H__
#define __MAGIDOOR_H__ #define __MAGIDOOR_H__
#include <stdint.h>
#define MAGIDOOR_VERSION_MAJOR 1
#define MAGIDOOR_VERSION_MINOR 2
#define TRUE 1 #define TRUE 1
#define FALSE 0 #define FALSE 0