Last active
August 29, 2015 14:19
-
-
Save benaryorg/1f918a409e5a430793bd to your computer and use it in GitHub Desktop.
somthing with ncurses I think
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef HEADER_H | |
#define HEADER_H | |
#include <ncurses.h> | |
#include <wctype.h> | |
#define forever while(1) | |
#endif /*HEADER_H*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <header.h> | |
int mainloop(int,char **); | |
int main(int argc,char **argv) | |
{ | |
initscr(); | |
keypad(stdscr,TRUE); | |
cbreak(); | |
noecho(); | |
clear(); | |
int r=mainloop(argc,argv); | |
endwin(); | |
return r; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <header.h> | |
int mainloop(int argc,char **argv) | |
{ | |
halfdelay(1); | |
WINDOW *win=newwin(20,100,10,20); | |
box(win,0,0); | |
wmove(win,1,1); | |
forever | |
{ | |
int ch=getch(); | |
if(iswalpha(ch)) | |
{ | |
wprintw(win,"%c",ch); | |
} | |
else | |
{ | |
switch(ch) | |
{ | |
case 0x7f:wprintw(win,"\b \b");break; | |
} | |
} | |
wrefresh(win); | |
} | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SRCPATH:=. | |
SRCS=$(shell find $(SRCPATH) -regextype posix-extended -regex '^.+\.(c)$$') | |
OBJS=$(addprefix build,$(addsuffix .o,$(basename $(SRCS:$(SRCPATH)%=%)))) | |
CC:=gcc | |
LD:=gcc | |
LDFLAGS:=-lncurses | |
CFLAGS:=$(addprefix -I,$(SRCPATH)) | |
default: main | |
all: clean main | |
main: $(OBJS) | |
$(LD) $(LDFLAGS) -o $@ $^ | |
build/%.o: $(SRCPATH)/%.c | |
@mkdir -p $(dir $@) | |
$(CC) $(CFLAGS) -c -o $@ $^ | |
clean: | |
rm -f $(OBJS) | |
rm -f main | |
.PHONY: clean | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment