-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEditor.cs
70 lines (60 loc) · 2 KB
/
Editor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using System;
using System.Text;
using System.Threading;
namespace EditorHTML
{
public static class Editor
{
public static void Exibir()
{
Console.Clear();
Console.WriteLine("Modo Editor");
// Linha de separação
for (var i = 0; i <= 40; i++)
Console.Write("-");
Console.SetCursorPosition(1, 3);
Escrever();
}
public static StringBuilder Conteudo { get; private set; } = new(); // Tipo StringBuilder público
public static void Escrever()
{
do
{
Conteudo.Append(Console.ReadLine());
Conteudo.Append(Environment.NewLine);
} while (Console.ReadKey().Key != ConsoleKey.Escape);
Iniciar(Conteudo);
}
public static void Iniciar(StringBuilder arquivo)
{
// Linha de separação
for (var i = 0; i <= 40; i++)
Console.Write("-");
Console.WriteLine("Deseja salvar o arquivo? (S - Sim, N - Não)");
string resposta = Console.ReadLine() ?? "".ToLower();
if (!string.IsNullOrWhiteSpace(resposta))
{
switch (resposta)
{
case "s": Menu.Mostrar(); break;
case "n": Menu.Mostrar(); break;
default:
{
Console.Clear();
Console.WriteLine("Por favor, digite S ou N");
Thread.Sleep(2000);
Exibir();
break;
}
}
}
else
{
Console.Clear();
Console.WriteLine("Por favor, digite alguma opção");
Thread.Sleep(2000);
Exibir();
}
}
}
}