CC=gcc
CFLAGS=-c -g
LDFLAGS=-lcurses
-OBJS=main.o errors.o screen.o buffer.o
+OBJS=main.o errors.o screen.o buffer.o keyb.o
te: $(OBJS)
$(CC) $(LDFLAGS) -o te $(OBJS)
buffer.o: buffer.c
$(CC) $(CFLAGS) buffer.c
+keyb.o: keyb.c
+ $(CC) $(CFLAGS) keyb.c
+
clean: $(OBJS)
rm $(OBJS)
rm te
\ No newline at end of file
{
init_buffers();
init_windows();
+
struct te_buffer *b = load_buffer("screen.c");
paint_buffer(b);
miniprintf("Over the top!");
- statusprintf("Reverse video !");
- while(1) {
- }
+
+
+ input_loop();
}
initscr();
cbreak();
noecho();
- scrollok(stdscr, FALSE);
+ scrollok(stdscr, TRUE);
keypad(stdscr, TRUE);
buffer_win = subwin(stdscr, LINES - 2, COLS, 0, 0);
if (signal(SIGWINCH, console_signal_handler) == SIG_ERR)
fail("Unable to set up the SIGWINCH signal handler");
+
+ atexit(&cleanup_windows);
}
void cleanup_windows(void)
void statusprintf(char *fmt, ...)
{
+ werase(status_win);
+ wmove(status_win, 0, 0);
+
va_list ap;
va_start(ap, fmt);
vwprintw(status_win, fmt, ap);
va_end(ap);
- wclrtoeol(status_win);
+ /* We have to clear the screen to the end of line because for some unexpected
+ reason, curses doesn't want to do it
+ */
+
+ int y, x;
+ getyx(stdscr, y, x);
+ while(x <= COLS) {
+ waddch(status_win, ' ');
+ x++;
+ }
+
wrefresh(status_win);
}