Преглед изворни кода

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', ',', '.', '/',