util.h
Publicado por Hunz 10/12/2004
[ Hits: 7.348 ]
Homepage: http://tnegri.com/
Biblioteca com funcoes uteis..
int setcolor(int cor,int bk); --> Define cores da fonte (azul,laranja..)
int settype(int tipo); --> Define tipo da fonte (negrito,piscando..)
int setxy(int x, int y); --> Move o cursor para a posicao X,Y
int setecho(int echo); --> Liga/deliga o echo
int chartoint(char inteiro); --> Transforma char em int.
int clearscn(); --> Limpa a tela.
**No código vizualisado direto do site tem um exemplo de uso da biblioteca.
#include <stdio.h> // setecho(..); #define OFF 0 #define ON 1 // settype(..); #define RESET 0 #define BOLD 1 #define NEGRITO 1 #define BLINK 5 #define PISCAR 5 // setcolor(.. , ..); #define BLACK 0 #define PRETO 0 #define RED 1 #define VERMELHO 1 #define GREEN 2 #define VERDE 2 #define BROWN 3 #define MARROM 3 #define BLUE 4 #define AZUL 4 #define MAGENTA 5 #define ROSA 5 #define CYAN 6 #define CIANO 6 #define WHITE 7 #define BRANCO 7 #define DEFAULT 9 #define PADRAO 9 int setcolor(int cor,int bk); int settype(int tipo); int setxy(int x, int y); int setecho(int echo); int chartoint(char inteiro); int clearscn(); int setecho(int echo) { if (echo == 1) system("stty echo"); else if (echo == 0) system("stty -echo"); else return 0; return 1; } int chartoint(char inteiro) { int temp; temp = inteiro - '0'; return temp; } int setcolor(int cor, int bk) { cor = cor + 30; bk = bk + 40; printf("{FONTE}33[%d;%dm",cor,bk); return 1; } int settype(int tipo) { printf("{FONTE}33[%dm",tipo); return 1; } int setxy(int x, int y) { printf("{FONTE}33[%d;%dH",y,x); return 1; } int clearscn() { printf("{FONTE}33[2J"); return 1; } /////////////////////////////////////////////////////////////////////////////////////// ---------------------------- EXEMPLO DE USO DA BIBLIOTECA #include "util.h" int main() { int numero; clearscn(); setxy(5,5); setcolor(BRANCO,PRETO); printf("Ola mundo!"); setxy(1,1); setcolor(PRETO,BRANCO); settype(NEGRITO); printf("Ola mundo!!"); setcolor(MARROM,ROSA); setxy(15,3); settype(PISCAR); printf("OLA MUNDO!"); settype(RESET); setxy(3,3); printf("ola mundo.."); setxy(1,12); printf("digite um numero (sem echo): "); setecho(OFF); scanf("%d",&numero); setxy(6,13); printf("voce digitou %d ! :D",numero); setxy(1,14); setcolor(ROSA,PADRAO); printf("digite um numero (com echo): "); setcolor(ROSA,PRETO); setecho(ON); scanf("%d",&numero); setxy(6,15); settype(RESET); printf("voce digitou: %d ! ",numero); setcolor(AZUL,PADRAO); printf(":"); setcolor(VERMELHO,PADRAO); printf("D"); setxy(1,17); numero = chartoint('8'); printf(" -> %d",numero); setxy(1,19); settype(RESET); return 0; }
Calculo do número de Euler em C++
Nenhum comentário foi encontrado.
Descritores de Arquivos e Swappiness
tux-gpt - Assistente de IA para o Terminal
Instalação e configuração do Chrony
Programa IRPF - Guia de Instalação e Resolução de alguns Problemas
Como instalar no Linux Jogos da Steam só para Windows
Instalando o Team Viewer no Debian Trixie - problema no Policykit
O Que Fazer Após Instalar Ubuntu 25.04
O que você está ouvindo agora? [2] (175)
Copiar Layout do Teclado para aplicar em outra Distribuição (10)
Autenticação necessária. um aplicativo quer acesso ao chaveiro (2)