瀏覽代碼

Basic support the backspace key.

This doesn't mean we get any line editing just yet. But the keyboard device
now recognizes the backspace key, and the console device knows what to do
with the backspace characters.
Andreas Kling 6 年之前
父節點
當前提交
bd2b5327d0
共有 2 個文件被更改,包括 9 次插入1 次删除
  1. 8 0
      Kernel/Console.cpp
  2. 1 1
      Kernel/Keyboard.cpp

+ 8 - 0
Kernel/Console.cpp

@@ -303,6 +303,14 @@ void Console::putChar(char ch)
     case '\033':
         m_escState = ExpectBracket;
         return;
+    case 8: // Backspace
+        if (m_cursorColumn) {
+            --m_cursorColumn;\
+            vga_set_cursor(m_cursorRow, m_cursorColumn);
+            vga_putch_at(m_cursorRow, m_cursorColumn, ' ');
+            return;
+        }
+        break;
     case '\n':
         scrollup();
         vga_set_cursor(m_cursorRow, m_cursorColumn);

+ 1 - 1
Kernel/Keyboard.cpp

@@ -21,7 +21,7 @@
 
 static char map[0x100] =
 {
-    0, 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 0, 0,
+    0, 0, '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=', 0x08, 0,
     'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', '[', ']', 0, 0,
     'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', ';', '\'', '`', 0, '\\',
     'z', 'x', 'c', 'v', 'b', 'n', 'm', ',', '.', '/',