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
|
## Notes
|
||||||
- The default user is named 'selene' and you can log into it with the password 'moon'.
|
- 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
|
## 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)).
|
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;
|
char* s = buf;
|
||||||
memset(buf, 0, size);
|
memset(buf, 0, size);
|
||||||
|
size_t oldsize = size;
|
||||||
while (size)
|
while (size)
|
||||||
{
|
{
|
||||||
int c = fgetc(stream);
|
int c = fgetc(stream);
|
||||||
@ -23,13 +24,25 @@ static char* echoing_fgets(char* buf, size_t size, FILE* stream)
|
|||||||
return NULL;
|
return NULL;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
if ((char)c == '\b')
|
||||||
|
{
|
||||||
|
if (size != oldsize)
|
||||||
|
{
|
||||||
|
buf--;
|
||||||
|
size++;
|
||||||
|
putchar('\b');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
size--;
|
size--;
|
||||||
*buf = (char)c;
|
*buf = (char)c;
|
||||||
buf++;
|
buf++;
|
||||||
*buf = 0;
|
|
||||||
putchar((char)c);
|
putchar((char)c);
|
||||||
if ((char)c == '\n') return s;
|
if ((char)c == '\n') return s;
|
||||||
}
|
}
|
||||||
|
*buf = 0;
|
||||||
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -154,9 +154,20 @@ extern "C"
|
|||||||
buf++;
|
buf++;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (*buf == '\b')
|
||||||
|
{
|
||||||
|
if (size != original_size)
|
||||||
|
{
|
||||||
|
buf--;
|
||||||
|
size++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
buf++;
|
buf++;
|
||||||
size--;
|
size--;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
file_read_buf(stream);
|
file_read_buf(stream);
|
||||||
|
Loading…
Reference in New Issue
Block a user