Make backspace work
This commit is contained in:
parent
e640c6e245
commit
6df5b8a703
@ -15,7 +15,6 @@ A simple kernel and userspace for the x86_64 platform, written mostly in C++ and
|
||||
|
||||
## Notes
|
||||
- The default user is named 'selene' and you can log into it with the password 'moon'.
|
||||
- Beware of backspace, as it looks like it works but it doesn't work except when entering shell commands. So if you make a mistake while entering a username or password, you'll have to try again.
|
||||
|
||||
## Setup
|
||||
To build and run Luna, you will need to build a [GCC Cross-Compiler](https://wiki.osdev.org/Why_do_I_need_a_Cross_Compiler%3F) and cross-binutils for `x86_64-luna`. (Yes, Luna is advanced enough that it can use its own [OS-Specific Toolchain](https://wiki.osdev.org/OS_Specific_Toolchain), instead of a bare metal target like `x86_64-elf`. It is the first of my OS projects to be able to do so. The patches for Binutils and GCC are [binutils.patch](tools/binutils.patch) and [gcc.patch](tools/gcc.patch)).
|
||||
|
@ -10,6 +10,7 @@ static char* echoing_fgets(char* buf, size_t size, FILE* stream)
|
||||
{
|
||||
char* s = buf;
|
||||
memset(buf, 0, size);
|
||||
size_t oldsize = size;
|
||||
while (size)
|
||||
{
|
||||
int c = fgetc(stream);
|
||||
@ -23,13 +24,25 @@ static char* echoing_fgets(char* buf, size_t size, FILE* stream)
|
||||
return NULL;
|
||||
};
|
||||
}
|
||||
if ((char)c == '\b')
|
||||
{
|
||||
if (size != oldsize)
|
||||
{
|
||||
buf--;
|
||||
size++;
|
||||
putchar('\b');
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
size--;
|
||||
*buf = (char)c;
|
||||
buf++;
|
||||
*buf = 0;
|
||||
putchar((char)c);
|
||||
if ((char)c == '\n') return s;
|
||||
}
|
||||
*buf = 0;
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
|
@ -154,9 +154,20 @@ extern "C"
|
||||
buf++;
|
||||
break;
|
||||
}
|
||||
if (*buf == '\b')
|
||||
{
|
||||
if (size != original_size)
|
||||
{
|
||||
buf--;
|
||||
size++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
buf++;
|
||||
size--;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
file_read_buf(stream);
|
||||
|
Loading…
Reference in New Issue
Block a user