CC=gcc
CFLAGS=-c
LDFLAGS=-lcurses
-OBJS=main.o
+OBJS=main.o errors.o screen.o buffer.o
te: $(OBJS)
$(CC) $(LDFLAGS) -o te $(OBJS)
main.o: main.c
$(CC) $(CFLAGS) main.c
+error.o: error.c
+ $(CC) $(CFLAGS) error.c
+
+screen.o: screen.c
+ $(CC) $(CFLAGS) screen.c
+
+buffer.o: buffer.c
+ $(CC) $(CFLAGS) buffer.c
+
if (b == NULL || c == NULL)
fail("One of the parameters to free_char() is NULL");
- TAILQ_REMOVE(&b->chars, c, chars);
+ TAILQ_REMOVE(&b->chars_head, c, chars);
free(c);
}
TAILQ_HEAD(te_buffers_head, te_buffer) buffers_head;
-struct te_char *alloc_and_insert_char(struct te_buffer *buf);
-struct te_buffer *alloc_and_insert_buffer(void);
-void free_char(struct te_buffer *b, struct te_char *c);
-void free_buffer(struct te_buffer *b);
+struct te_char *alloc_and_insert_char(struct te_buffer *buf);
+struct te_buffer *alloc_and_insert_buffer(void);
+void free_char(struct te_buffer *b, struct te_char *c);
+void free_buffer(struct te_buffer *b);
+
+void init_buffers(void);
+void scroll_up(struct te_buffer *buf);
+void scroll_down(struct te_buffer *buf);
+void move_left(struct te_buffer *buf);
+void move_right(struct te_buffer *buf);
+void move_up(struct te_buffer *buf);
+void move_down(struct te_buffer *buf);
+
-void init_buffers();
#endif
int main(int argc, char **argv)
{
- puts("Over the top!");
+ init_windows();
+ miniprintf("Over the top!");
+ while(1) {
+
+ }
}
--- /dev/null
+#include "screen.h"
+
+void init_windows(void)
+{
+ initscr();
+ cbreak();
+ noecho();
+ keypad(stdscr, TRUE);
+
+ buffer_win = subwin(stdscr, LINES - 2, COLS - 2, 0, 0);
+ minibuffer_win = subwin(stdscr, 1, COLS, LINES - 1, 0);
+
+ if (signal(SIGWINCH, console_signal_handler) == SIG_ERR)
+ fail("Unable to set up the SIGWINCH signal handler");
+}
+
+void cleanup_windows(void)
+{
+ endwin();
+}
+
+void paint_buffer(struct te_buffer *buf)
+{
+
+}
+
+void screen_move_left(void)
+{
+
+}
+
+void screen_move_right(void)
+{
+
+}
+
+void screen_move_up(void)
+{
+
+}
+
+void screen_move_down(void)
+{
+
+}
+
+void miniprintf(char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ vwprintw(minibuffer_win, fmt, ap);
+ va_end(ap);
+
+ wrefresh(minibuffer_win);
+}
+
+void console_signal_handler(int sig)
+{
+ switch(sig) {
+ case SIGWINCH:
+ default:
+ refresh();
+ break;
+
+ }
+}
--- /dev/null
+#ifndef __SCREEN_H__
+#define __SCREEN_H__
+
+#include <stdarg.h>
+#include <signal.h>
+#include <curses.h>
+
+#include "buffer.h"
+
+WINDOW *buffer_win, *minibuffer_win;
+
+void init_windows(void);
+void cleanup_windows(void);
+
+void paint_buffer(struct te_buffer *buf);
+void screen_move_left(void);
+void screen_move_right(void);
+void screen_move_up(void);
+void screen_move_down(void);
+
+void miniprintf(char *fmt, ...);
+
+void console_signal_handler(int sig);
+
+#endif