This repository has been archived by the owner on Oct 23, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
/
Copy pathchange-the-terminal-corlors
98 lines (79 loc) · 1.91 KB
/
change-the-terminal-corlors
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
// to compile - gcc terminal-color.c -o prog -lncurses
// to execute - ./prog
#include <stdio.h>
#include <stdlib.h>
#include <curses.h>
#include <string.h>
#include <time.h>
//funções
int cores();
int sair();
int tempo();
//variáveis
int texto=0, fundo=0, troca=0, i=0, l=0;
char palavra[10],senha[10];
int main()
{
initscr();// inicializando janela
clear();
start_color();// habilitando utilização de cores
if (troca==2) { }
else
{
init_pair(1,COLOR_GREEN,COLOR_BLACK);
}
bkgd(COLOR_PAIR(1)); //Definifindo o init_pair a ser utilizado
move(1,1);
printw("Bem-Vindo!\nComandos <cor> <tempo> <sair>\n#");
scanw("%s", palavra);
if(strcmp(palavra,"cor")) { }
else { cores(); }
if(strcmp(palavra,"sair")){}
else { sair(); }
if(strcmp(palavra,"tempo")){}
else { tempo(); }
if(strcmp(palavra,"limpar")){}
else
{
clear();
main();
}
refresh();
move(23,1);
printw("Comando Inexistente!");
getch();
main();
return 0;
}
int cores(void)
{
printw("\n\n\n Cor do texto :\n\n 0 - Preto.\n 1 - Vermelho. \n 2 - Verde. \n 3 - Amarelo.\n 4 - Azul.\n 5 - Magenta.\n 6 - Ciano.\n 7 - Branco.\n\n Qual número de sua escolha :");
scanw("%d",&texto);
clear();
printw("\n\n\n Cor do fundo :\n\n 0 - Preto.\n 1 - Vermelho. \n 2 - Verde. \n 3 - Amarelo.\n 4 - Azul.\n 5 - Magenta.\n 6 - Ciano.\n 7 - Branco.\n\n Qual número de sua escolha :");
scanw("%d",&fundo);
if(texto==fundo)
{
printw("Cor do texto e fundo iguais, favor mudar!");
getch();
clear();
cores();
}
else { troca=2; }
init_pair(1,texto,fundo);
refresh();
clear();
main();
}
int tempo(void)
{
time_t clock = time(NULL);
printw("Current time is %s", ctime(&clock));
getch();
main();
}
int sair(void)
{
endwin(); //Finalizando janela
exit(1);
}