Compare commits

...

3 Commits

Author SHA1 Message Date
Bananymous fe192e07fb General: Update README feature list 2024-12-05 19:49:38 +02:00
Bananymous 51b6329c86 Kernel: Make backspace \b and delete 0x7F
This is what `vim` seems to expect and imo makes way more sense.
2024-12-05 17:34:37 +02:00
Bananymous 72d9e4c1e7 Kernel: Remove accidental debug prints from fcntl syscall 2024-12-05 17:34:32 +02:00
7 changed files with 26 additions and 35 deletions

View File

@ -20,7 +20,7 @@ You can find a live demo [here](https://bananymous.com/banan-os)
- [x] AML interpreter (partial) - [x] AML interpreter (partial)
- [x] Basic graphical environment - [x] Basic graphical environment
- [x] Terminal emulator - [x] Terminal emulator
- [ ] Task bar - [x] Status bar
- [ ] Program launcher - [ ] Program launcher
- [ ] Some nice apps - [ ] Some nice apps
- [x] ELF dynamic linking - [x] ELF dynamic linking
@ -32,13 +32,14 @@ You can find a live demo [here](https://bananymous.com/banan-os)
- [x] NVMe disks - [x] NVMe disks
- [x] ATA (IDE, SATA) disks - [x] ATA (IDE, SATA) disks
- [x] E1000 and E1000E NICs - [x] E1000 and E1000E NICs
- [x] RTL8111/8168/8211/8411 NICs
- [x] PS2 keyboard (all scancode sets) - [x] PS2 keyboard (all scancode sets)
- [x] PS2 mouse - [x] PS2 mouse
- [x] USB - [x] USB
- [x] Keyboard - [x] Keyboard
- [x] Mouse - [x] Mouse
- [x] Mass storage
- [ ] Hubs - [ ] Hubs
- [ ] Mass storage
- [ ] ... - [ ] ...
- [ ] virtio devices (network, storage) - [ ] virtio devices (network, storage)

View File

@ -202,8 +202,6 @@ namespace Kernel
{ {
TRY(validate_fd(fd)); TRY(validate_fd(fd));
dprintln("fcntl({} ('{}'), {}, {H})", fd, m_open_files[fd]->path(), cmd, extra);
switch (cmd) switch (cmd)
{ {
case F_GETFD: case F_GETFD:
@ -211,14 +209,12 @@ namespace Kernel
case F_SETFD: case F_SETFD:
m_open_files[fd]->flags &= ~FD_CLOEXEC; m_open_files[fd]->flags &= ~FD_CLOEXEC;
m_open_files[fd]->flags |= extra & FD_CLOEXEC; m_open_files[fd]->flags |= extra & FD_CLOEXEC;
dprintln(" set CLOEXEC to {}", !!(m_open_files[fd]->flags & FD_CLOEXEC));
return 0; return 0;
case F_GETFL: case F_GETFL:
return m_open_files[fd]->flags & ~(O_APPEND | O_DSYNC | O_NONBLOCK | O_RSYNC | O_SYNC | O_ACCMODE); return m_open_files[fd]->flags & ~(O_APPEND | O_DSYNC | O_NONBLOCK | O_RSYNC | O_SYNC | O_ACCMODE);
case F_SETFL: case F_SETFL:
m_open_files[fd]->flags &= ~O_NONBLOCK; m_open_files[fd]->flags &= ~O_NONBLOCK;
m_open_files[fd]->flags |= extra & O_NONBLOCK; m_open_files[fd]->flags |= extra & O_NONBLOCK;
dprintln(" set NONBLOCK to {}", !!(m_open_files[fd]->flags & O_NONBLOCK));
return 0; return 0;
default: default:
break; break;

View File

@ -210,6 +210,8 @@ namespace Kernel
void SerialTTY::handle_irq() void SerialTTY::handle_irq()
{ {
uint8_t ch = IO::inb(m_serial.port()); uint8_t ch = IO::inb(m_serial.port());
if (ch == 0x7F)
ch = '\b';
SpinLockGuard _(m_input_lock); SpinLockGuard _(m_input_lock);
if (m_input.full()) if (m_input.full())

View File

@ -285,14 +285,6 @@ namespace Kernel
void TTY::do_backspace() void TTY::do_backspace()
{ {
auto print_backspace =
[this]
{
putchar('\b');
putchar(' ');
putchar('\b');
};
if (m_output.bytes > 0) if (m_output.bytes > 0)
{ {
uint8_t last = m_output.buffer[m_output.bytes - 1]; uint8_t last = m_output.buffer[m_output.bytes - 1];
@ -308,20 +300,20 @@ namespace Kernel
} }
ASSERT(m_output.bytes > 0); ASSERT(m_output.bytes > 0);
m_output.bytes--; m_output.bytes--;
print_backspace(); putchar('\b');
} }
// Caret notation // Caret notation
else if (last < 32 || last == 127) else if (last < 32 || last == 127)
{ {
m_output.bytes--; m_output.bytes--;
print_backspace(); putchar('\b');
print_backspace(); putchar('\b');
} }
// Ascii // Ascii
else else
{ {
m_output.bytes--; m_output.bytes--;
print_backspace(); putchar('\b');
} }
} }
} }

View File

@ -461,7 +461,7 @@ namespace Kernel
break; break;
case BS: case BS:
if (m_column > 0) if (m_column > 0)
m_column--; putchar_at(' ', --m_column, m_row);
break; break;
case HT: case HT:
m_column++; m_column++;
@ -480,7 +480,7 @@ namespace Kernel
break; break;
case ESC: case ESC:
m_state = State::WaitingAnsiEscape; m_state = State::WaitingAnsiEscape;
break;; break;
default: default:
putchar_at(codepoint, m_column, m_row); putchar_at(codepoint, m_column, m_row);
m_last_graphic_char = codepoint; m_last_graphic_char = codepoint;

View File

@ -58,10 +58,10 @@ namespace LibInput
"å", "ä", "ö", "å", "ä", "ö",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
/*"Insert", "PrintScreen", "Delete", "Home", "End", "PageUp", "PageDown",*/ nullptr, nullptr, "\e[3~", nullptr, nullptr, nullptr, nullptr, "\n", " ", /*"Insert", "PrintScreen", "Delete", "Home", "End", "PageUp", "PageDown",*/ nullptr, nullptr, "\x7F", nullptr, nullptr, nullptr, nullptr, "\n", " ",
"!", "\"", "#", "¤", "%", "&", "/", "§", "½", "!", "\"", "#", "¤", "%", "&", "/", "§", "½",
"(", ")", "[", "]", "{", "}", "(", ")", "[", "]", "{", "}",
"=", "?", "+", "\\", "´", "`", "¨", "¸", "\x7F", "@", "£", "$", "", "=", "?", "+", "\\", "´", "`", "¨", "¸", "\b", "@", "£", "$", "",
"\e", "\t", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, "\e", "\t", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
"'", "*", "^", "~", "\e[A", "\e[B", "\e[D", "\e[C", "'", "*", "^", "~", "\e[A", "\e[B", "\e[D", "\e[C",
",", ";", ".", ":", "-", "_", nullptr, nullptr, "<", ">", "|", "¬", "¦", ",", ";", ".", ":", "-", "_", nullptr, nullptr, "<", ">", "|", "¬", "¦",
@ -77,10 +77,10 @@ namespace LibInput
"Å", "Ä", "Ö", "Å", "Ä", "Ö",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
/*"Insert", "PrintScreen", "Delete", "Home", "End", "PageUp", "PageDown",*/ nullptr, nullptr, "\e[3~", nullptr, nullptr, nullptr, nullptr, "\n", " ", /*"Insert", "PrintScreen", "Delete", "Home", "End", "PageUp", "PageDown",*/ nullptr, nullptr, "\x7F", nullptr, nullptr, nullptr, nullptr, "\n", " ",
"!", "\"", "#", "¤", "%", "&", "/", "§", "½", "!", "\"", "#", "¤", "%", "&", "/", "§", "½",
"(", ")", "[", "]", "{", "}", "(", ")", "[", "]", "{", "}",
"=", "?", "+", "\\", "´", "`", "¨", "¸", "\x7F", "@", "£", "$", "", "=", "?", "+", "\\", "´", "`", "¨", "¸", "\b", "@", "£", "$", "",
"\e", "\t", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, "\e", "\t", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
"'", "*", "^", "~", "\e[A", "\e[B", "\e[D", "\e[C", "'", "*", "^", "~", "\e[A", "\e[B", "\e[D", "\e[C",
",", ";", ".", ":", "-", "_", nullptr, nullptr, "<", ">", "|", "¬", "¦", ",", ";", ".", ":", "-", "_", nullptr, nullptr, "<", ">", "|", "¬", "¦",
@ -96,10 +96,10 @@ namespace LibInput
"Å", "Ä", "Ö", "Å", "Ä", "Ö",
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
/*"Insert", "PrintScreen", "Delete", "Home", "End", "PageUp", "PageDown",*/ nullptr, nullptr, "\e[3~", nullptr, nullptr, nullptr, nullptr, "\n", " ", /*"Insert", "PrintScreen", "Delete", "Home", "End", "PageUp", "PageDown",*/ nullptr, nullptr, "\x7F", nullptr, nullptr, nullptr, nullptr, "\n", " ",
"!", "\"", "#", "¤", "%", "&", "/", "§", "½", "!", "\"", "#", "¤", "%", "&", "/", "§", "½",
"(", ")", "[", "]", "{", "}", "(", ")", "[", "]", "{", "}",
"=", "?", "+", "\\", "´", "`", "¨", "¸", "\x7F", "@", "£", "$", "", "=", "?", "+", "\\", "´", "`", "¨", "¸", "\b", "@", "£", "$", "",
"\e", "\t", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, "\e", "\t", nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
"'", "*", "^", "~", "\e[A", "\e[B", "\e[D", "\e[C", "'", "*", "^", "~", "\e[A", "\e[B", "\e[D", "\e[C",
",", ";", ".", ":", "-", "_", nullptr, nullptr, "<", ">", "|", "¬", "¦", ",", ";", ".", ":", "-", "_", nullptr, nullptr, "<", ">", "|", "¬", "¦",

View File

@ -468,9 +468,9 @@ BAN::Optional<BAN::String> Input::get_input(BAN::Optional<BAN::StringView> custo
if (m_buffer_col <= 0) if (m_buffer_col <= 0)
break; break;
while ((m_buffers[m_buffer_index][m_buffer_col - 1] & 0xC0) == 0x80) while ((m_buffers[m_buffer_index][m_buffer_col - 1] & 0xC0) == 0x80)
m_buffer_col--; m_buffers[m_buffer_index].remove(--m_buffer_col);
m_buffer_col--; m_buffers[m_buffer_index].remove(--m_buffer_col);
printf("\e[D"); printf("\b\e[s%s \e[u", m_buffers[m_buffer_index].data() + m_buffer_col);
fflush(stdout); fflush(stdout);
break; break;
case '\x01': // ^A case '\x01': // ^A
@ -490,13 +490,13 @@ BAN::Optional<BAN::String> Input::get_input(BAN::Optional<BAN::StringView> custo
break; break;
putchar('\n'); putchar('\n');
return {}; return {};
case '\x7F': // backspace case '\x7F':
if (m_buffer_col <= 0) if (m_buffer_col >= m_buffers[m_buffer_index].size())
break; break;
while ((m_buffers[m_buffer_index][m_buffer_col - 1] & 0xC0) == 0x80) m_buffers[m_buffer_index].remove(m_buffer_col);
m_buffers[m_buffer_index].remove(--m_buffer_col); while (m_buffer_col < m_buffers[m_buffer_index].size() && (m_buffers[m_buffer_index][m_buffer_col] & 0xC0) == 0x80)
m_buffers[m_buffer_index].remove(--m_buffer_col); m_buffers[m_buffer_index].remove(m_buffer_col);
printf("\b\e[s%s \e[u", m_buffers[m_buffer_index].data() + m_buffer_col); printf("\e[s%s \e[u", m_buffers[m_buffer_index].data() + m_buffer_col);
fflush(stdout); fflush(stdout);
break; break;
case '\n': case '\n':