From 5eddc078e95d2f217c303025e4e5516b45374fa0 Mon Sep 17 00:00:00 2001 From: moitoius_cp <7bd20ad30720b36bd251fb928c419f8754d57bfcCkJyHhZD> Date: Wed, 2 Jan 2008 18:48:00 +0000 Subject: [PATCH] Backspace now supported. --- source/Cosmos/Cosmos.Kernel.Plugs/Console.cs | 23 ++++++++++++++- .../Cosmos/Cosmos.Kernel/FileSystem/Fat16.cs | 29 ++++++++++++++++++- source/Cosmos/Cosmos.Kernel/Keyboard.cs | 2 ++ 3 files changed, 52 insertions(+), 2 deletions(-) diff --git a/source/Cosmos/Cosmos.Kernel.Plugs/Console.cs b/source/Cosmos/Cosmos.Kernel.Plugs/Console.cs index 4d7a9b3a1..a6b85f302 100644 --- a/source/Cosmos/Cosmos.Kernel.Plugs/Console.cs +++ b/source/Cosmos/Cosmos.Kernel.Plugs/Console.cs @@ -32,6 +32,16 @@ namespace Cosmos.Kernel.Plugs { TextScreen.SetColors(_foreground, _background); } + public static int get_CursorLeft() + { + return TextScreen.CurrentChar; + } + + public static void set_CursorLeft(int x) + { + TextScreen.CurrentChar = x; + } + //TODO: Console uses TextWriter - intercept and plug it instead public static void Clear() { TextScreen.Clear(); @@ -67,7 +77,7 @@ namespace Cosmos.Kernel.Plugs { } public static string ReadLine() { - List chars = new List(32); + List chars = new List(); char current; // HACK: convert this to "while ((current = Keyboard.ReadChar()) != '\n') {" // MTW: SOmehow an invalid opcode exception is occurring. @@ -76,6 +86,17 @@ namespace Cosmos.Kernel.Plugs { if (current == '\n') { break; } + if (current == '\u0968') // Backspace + { + if (chars.Count != 0) + { + chars.RemoveAt(chars.Count); + TextScreen.CurrentChar--; + TextScreen.WriteChar(' '); + TextScreen.CurrentChar--; + } + continue; + } chars.Add(current); Write(current); } diff --git a/source/Cosmos/Cosmos.Kernel/FileSystem/Fat16.cs b/source/Cosmos/Cosmos.Kernel/FileSystem/Fat16.cs index fae0e5091..fccd9b2da 100644 --- a/source/Cosmos/Cosmos.Kernel/FileSystem/Fat16.cs +++ b/source/Cosmos/Cosmos.Kernel/FileSystem/Fat16.cs @@ -39,6 +39,14 @@ namespace Cosmos.Kernel.FileSystem // TODO: FAT32 #endregion + #region Util + public uint _rootDirSectors; + public uint _realFatSize; + public uint _firstDataSector; + public uint _realTotalSectors; + public uint _dataSectors; + #endregion + /// /// Reads the header from a byte source. /// @@ -75,6 +83,22 @@ namespace Cosmos.Kernel.FileSystem #region FAT 32 #endregion + + #region Util + /*_rootDirSectors = ((_rootEntryCount * 32) + (_bytesPerSector - 1)) / _bytesPerSector; + _fatSize = _fatSize; + _firstDataSector = _reservedSectorCount + (_allocationTables * _realFatSize) + _rootDirSectors; + if (_totalSectors == 0) + _realTotalSectors = _totalSectors32; + else + _realTotalSectors = _totalSectors; + _dataSectors = _realTotalSectors - (_reservedSectorCount + (_allocationTables * _realFatSize) + _rootDirSectors);*/ + #endregion + } + + public uint FirstSectorOfCluster(uint cluster) + { + return ((cluster - 2) * _sectorPerCluster) + _firstDataSector; } private ushort ReadShort(byte[] source, int pos, ushort mask) @@ -120,6 +144,7 @@ namespace Cosmos.Kernel.FileSystem } private ATA _ata; + private Header _header; public Fat16(ATA ata) { @@ -131,7 +156,9 @@ namespace Cosmos.Kernel.FileSystem public override void Open() { - + _header = new Header(); + + // TODO: Read the header. } public override void Dispose() diff --git a/source/Cosmos/Cosmos.Kernel/Keyboard.cs b/source/Cosmos/Cosmos.Kernel/Keyboard.cs index f914c6ce6..29db83a56 100644 --- a/source/Cosmos/Cosmos.Kernel/Keyboard.cs +++ b/source/Cosmos/Cosmos.Kernel/Keyboard.cs @@ -126,6 +126,8 @@ namespace Cosmos.Kernel { AddKey(0x1C0000, '\n'); AddKey(0x39, ' '); AddKey(0x390000, ' '); + AddKey(0x0E, '\u0968'); + AddKey(0x0E0000, '\u0968'); #endregion #region Punctuation