I'm developing an Operating system with cosmos and I'm wondering if someone knew how to clear the console in Cosmos? I want to create a /clear command, and I've tried some solutions, but what is wrong with this code?
Console.Clear();
Asked
Active
Viewed 512 times
1

Dragon Softwares
- 80
- 15

Jacob Aulin
- 54
- 8
-
Youd expect that to work, but you could just send x numbers of blank lines and place the cursor at the top. – BugFinder Apr 30 '18 at 14:57
-
That may be working to... – Jacob Aulin Apr 30 '18 at 15:00
4 Answers
1
As you can't scroll as there is no mouse because the GUI is a console. You can just do this(Sorry if there are errors, i've not used c# in 2 weeks.):
if ((input == "clear"))
{
clear();
}
public static void clear()
{
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
Console.WriteLine("");
}

Dragon Softwares
- 80
- 15
-
ye but you don't scroll in the os so it will work, adding lines will clear it as the lines are "", it will work but just a larger *.iso file – Dragon Softwares May 12 '18 at 16:24
-
0
Console.clear();
This is the best way to clear the console.

DemoDev
- 11
-
1The question already mentions your code, so I guess this is what didn't work for him.. – Etamar Laron Oct 04 '20 at 08:29
0
Just doing in short what Dragon Softwares posted Use this Code
public static void clear()
{
Console.WriteLine("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
}
And call it using
clear();
Edit: The method
Console.Clear();
works in latest version of Cosmos OS tool now there is plug for that you can either update cosmos or use that plug in your cosmos template

Zahid Wadiwale
- 96
- 1
- 10