--- /dev/null
+src = $(wildcard src/*.c) $(wildcard src/unix/*.c)
+obj = $(src:.c=.o)
+dep = $(src:.c=.d)
+bin = oftp
+
+warn = -pedantic -Wall
+dbg = -g
+incdir = -Isrc
+
+CFLAGS = $(warn) $(dbg) $(incdir) -MMD
+LDFLAGS = -lcurses
+
+$(bin): $(obj)
+ $(CC) -o $@ $(obj) $(LDFLAGS)
+
+-include $(dep)
+
+.PHONY: clean
+clean:
+ $(RM) $(obj) $(bin)
+
+.PHONY: cleandep
+cleandep:
+ $(RM) $(dep)
-obj = main.obj tgfx.obj tui.obj darray.obj util.obj
+obj = main.obj tgfx.obj tui.obj darray.obj util.obj input.obj
bin = oftp.exe
!ifdef __UNIX__
--- /dev/null
+#include <conio.h>
+#include "input.h"
+
+int init_input(void)
+{
+ return 0;
+}
+
+void cleanup_input(void)
+{
+}
+
+int wait_input(union event *ev)
+{
+ ev->type = EV_KEY;
+ ev->key.key = getch();
+ return 1;
+}
--- /dev/null
+#ifndef INPUT_H_
+#define INPUT_H_
+
+enum {
+ EV_KEY,
+ EV_MMOVE,
+ EV_MBUTTON
+};
+
+struct event_key {
+ int type;
+ int key;
+};
+
+struct event_mmove {
+ int type;
+ int x, y;
+};
+
+struct event_mbutton {
+ int type;
+ int x, y, bn, press;
+};
+
+union event {
+ int type;
+ struct event_key key;
+ struct event_mmove mmove;
+ struct event_mbutton mbutton;
+};
+
+
+int init_input(void);
+void cleanup_input(void);
+
+int wait_input(union event *ev);
+
+#endif /* INPUT_H_ */
-#include <conio.h>
#include "tgfx.h"
+#include "input.h"
int main(void)
{
+ union event ev;
+
+ init_input();
+
tg_bgchar(' ');
tg_clear();
tg_text(0, 24, "fooolalala bar");
/* tg_setcursor(2, 24);*/
- while(getch() != 27);
+ while(wait_input(&ev)) {
+ switch(ev.type) {
+ case EV_KEY:
+ if(ev.key.key == 27) goto done;
+ break;
+ default:
+ break;
+ }
+ }
+
+done:
tg_bgchar(' ');
tg_bgcolor(0);
tg_fgcolor(7);
tg_clear();
+
+ cleanup_input();
return 0;
}
--- /dev/null
+#include "input.h"
+
+int init_input(void)
+{
+ return 0;
+}
+
+void cleanup_input(void)
+{
+}
+
+int wait_input(union event *ev)
+{
+ return 0;
+}
--- /dev/null
+#include <curses.h>
+#include "tgfx.h"
+
+void tg_clear(void)
+{
+}
+
+
+void tg_fgcolor(int col)
+{
+}
+
+void tg_bgcolor(int col)
+{
+}
+
+void tg_color(int col)
+{
+}
+
+void tg_bgchar(int c)
+{
+}
+
+
+void tg_setcursor(int x, int y)
+{
+}
+
+
+void tg_text(int x, int y, const char *fmt, ...)
+{
+}
+
+
+void tg_rect(const char *label, int x, int y, int xsz, int ysz, unsigned int flags)
+{
+}