1

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);
                }
            }
        }
TGnat
  • 3,903
  • 8
  • 35
  • 46
A user
  • 94
  • 8
  • 2
    The answer to "is it possible" is typically "yes". Would you like to ask a more precise question? – Caius Jard Apr 15 '20 at 19:52
  • Something similar to what you are describing: https://codereview.stackexchange.com/questions/191503/simple-console-text-editor – Bike_dotnet Apr 15 '20 at 19:53
  • This is far too broad for stackoverflow. Take a look online for some examples and tutorials, give them a try, and then come back if you get stuck on something specific! – Rufus L Apr 15 '20 at 19:59

0 Answers0