-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils.c
73 lines (60 loc) · 1.42 KB
/
utils.c
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
//
// Created by Vittorio Pinti on 5/19/17.
//
#include <stdio.h>
#include <ctype.h>
void printStrAt(int r, int c, char *s) {
printf("\033[%d;%dH%s", r, c, s);
}
void printIntAt(int r, int c, int n) {
printf("\033[%d;%dH%d", r, c, n);
}
void inputStrAt(int r, int c, char *s) {
printf("\033[%d;%dH",r, c);
scanf("%s", s);
}
void fInputStrAt(int r, int c, char *s) {
printf("\033[%d;%dH",r, c);
fgets(s, 60, stdin);
}
void inputDataAt(int r, int c, char *day, char *month, char* year) {
printf("\033[%d;%dH",r, c);
scanf("%s%s%s", day, month, year);
}
void inputIntAt(int r, int c, int *n) {
printf("\033[%d;%dH", r, c);
scanf("%d", n);
}
void cursorAt(int r, int c) {
printf("\033[%d;%dH", r, c);
}
void cls() {
printf("\033[2J");
}
void clsRow(int r1, int c1, int c2) {
int k;
for(k = c1; k <= c2; k++)
printf("\033[%d;%dH ",r1, k);
}
void separator(int r1, int c1, int c2) {
int k;
for(k = c1+1; k < c2; k++ )
printf("\033[%d;%dH-", r1, k);
}
void drawWall(int r1, int r2, int c) {
int k;
for(k = r1; k < r2; k++) {
printf("\033[%d;%dH|", k, c);
}
}
void box(int r1, int c1, int r2, int c2) {
int k;
for(k = r1; k<=r2; k++) {
printf("\033[%d;%dH!", k, c1);
printf("\033[%d;%dH!", k, c2);
}
for(k = c1+1; k < c2; k++) {
printf("\033[%d;%dH-", r1, k);
printf("\033[%d;%dH-", r2, k);
}
}