Is it possible to make a C#-based text editor? I am working on an operating system with Cosmos.
Can someone provide an code example please?
The following code gives me runtime errors
This is my code:
public static void MEdit(String filename)
{
List<Char> chars = new List<Char>();
List<String> lines = new List<String>();
ConsoleKeyInfo info;
while (true)
{
info = Console.ReadKey(true);
if (info.Key == ConsoleKey.Escape)
{
return;
}
else if (info.Key == ConsoleKey.F1)
{
System.IO.File.WriteAllLines(filename, lines.ToArray());
}
else if (info.Key == ConsoleKey.F2)
{
System.IO.File.WriteAllLines(filename, lines.ToArray());
return;
}
else if (Char.IsLetterOrDigit(info.KeyChar))
{
chars.Add(info.KeyChar);
Console.CursorLeft++;
Console.Write(info.KeyChar);
}
}
}