Initial commit
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*~
|
||||
*.o
|
20
makefile
Normal file
20
makefile
Normal file
@@ -0,0 +1,20 @@
|
||||
#Infos: http://www.ijon.de/comp/tutorials/makefile.html
|
||||
|
||||
|
||||
VERSION = 1.0
|
||||
CC = cc
|
||||
CFLAGS = -Wall -O3 -D_REENTRANT -DVERSION=\"$(VERSION)\"
|
||||
#LDFLAGS = -lm -lpthread `gtk-config --cflags` `gtk-config --libs` -lgthread
|
||||
LDFLAGS = -lncurses
|
||||
|
||||
OBJ = nclock.o
|
||||
|
||||
all: $(OBJ)
|
||||
$(CC) $(CFLAGS) -o nclock $(OBJ) $(LDFLAGS)
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c $<
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
rm -r *.o
|
44
nclock.c
Normal file
44
nclock.c
Normal file
@@ -0,0 +1,44 @@
|
||||
#include <curses.h> //ncurses windows
|
||||
#include <stdlib.h> //atexit
|
||||
#include <string.h>
|
||||
#include <time.h>
|
||||
#include "nclock.h"
|
||||
#include "numbers.h"
|
||||
#include <time.h>
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
/* enable ncurses standard screen */
|
||||
initscr();
|
||||
atexit(quitProgram); //cleanup at exit
|
||||
|
||||
state s = {0};
|
||||
|
||||
initState(&s);
|
||||
//mvprintw(s.centery, s.centerx, number[5][0]);
|
||||
//mvprintw(20, 30, number[0][3]);
|
||||
drawNumber(10,10,4);
|
||||
getch();
|
||||
drawNumber(10,16,2);
|
||||
getch();
|
||||
}
|
||||
|
||||
void quitProgram(void) {
|
||||
endwin();
|
||||
}
|
||||
|
||||
void initState(state *s) {
|
||||
getmaxyx(stdscr, s->maxy, s->maxx);
|
||||
s->centery = --s->maxy / 2;
|
||||
s->centerx = --s->maxx / 2;
|
||||
}
|
||||
|
||||
void drawNumber(int starty, int startx, int num) {
|
||||
int i;
|
||||
for (i = 0; i < 5; i++) {
|
||||
mvprintw(starty + i, startx, number[num][i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
15
nclock.h
Normal file
15
nclock.h
Normal file
@@ -0,0 +1,15 @@
|
||||
typedef struct {
|
||||
int centerx;
|
||||
int centery;
|
||||
int maxy;
|
||||
int maxx;
|
||||
} state;
|
||||
|
||||
|
||||
|
||||
|
||||
/* Function prototypes */
|
||||
void quitProgram(void);
|
||||
void initState(state *s);
|
||||
void drawNumber(int starty, int startx, int num);
|
||||
void drawTime(state *s);
|
83
numbers.h
Normal file
83
numbers.h
Normal file
@@ -0,0 +1,83 @@
|
||||
const char number[10][5][6] = \
|
||||
{\
|
||||
{ \
|
||||
"#####", \
|
||||
"# #", \
|
||||
"# #", \
|
||||
"# #", \
|
||||
"#####", \
|
||||
}, \
|
||||
{ \
|
||||
" #", \
|
||||
" #", \
|
||||
" #", \
|
||||
" #", \
|
||||
" #",
|
||||
}, \
|
||||
{ \
|
||||
"#####",\
|
||||
" #",\
|
||||
"#####",\
|
||||
"# ",\
|
||||
"#####"\
|
||||
}, \
|
||||
{\
|
||||
"#####",\
|
||||
" #",\
|
||||
" ####",\
|
||||
" #",\
|
||||
"#####"\
|
||||
}, \
|
||||
{\
|
||||
"# #",\
|
||||
"# #", \
|
||||
"#####",\
|
||||
" #",\
|
||||
" #"\
|
||||
},\
|
||||
{\
|
||||
"#####",\
|
||||
"# ",\
|
||||
"#####",\
|
||||
" #",\
|
||||
"#####"\
|
||||
},\
|
||||
{\
|
||||
"#####",\
|
||||
"# ",\
|
||||
"#####",\
|
||||
"# #",\
|
||||
"#####"\
|
||||
},\
|
||||
{\
|
||||
"#####",\
|
||||
" #",\
|
||||
" #",\
|
||||
" #",\
|
||||
" #"\
|
||||
}, \
|
||||
{\
|
||||
"#####",\
|
||||
"# #",\
|
||||
"#####",\
|
||||
"# #",\
|
||||
"#####"\
|
||||
},\
|
||||
{\
|
||||
"#####",\
|
||||
"# #",\
|
||||
"#####",\
|
||||
" #",\
|
||||
"#####"\
|
||||
}\
|
||||
};
|
||||
|
||||
|
||||
const char *colon[5] = \
|
||||
{\
|
||||
" ",\
|
||||
" # ",\
|
||||
" ",\
|
||||
" # ",\
|
||||
" "\
|
||||
};
|
Reference in New Issue
Block a user