diff --git a/makefile b/makefile index 6486fa6..5e0aa9b 100644 --- a/makefile +++ b/makefile @@ -1,13 +1,13 @@ # makefile for text.c -CC=gcc -CFLAGS=-Wall -g +CC=i686-quinn-gcc +CFLAGS=-Wall OBJS=text.o page.o line.o prompt.o HEADERS=$(subst .o,.h,$(OBJS)) # text.h page.h ... -LIBS=-lncurses +LIBS=-lpdcurses -lSDL -lquinn -lfreetype -lpng -lz text: $(OBJS) - $(CC) $(CFLAGS) -o text $(OBJS) $(LIBS) + $(CC) $(CFLAGS) -o text.exe $(OBJS) $(LIBS) text.o: text.c $(HEADERS) $(CC) $(CFLAGS) -c text.c @@ -24,7 +24,7 @@ page.o: page.c page.h line.h cleanall: clean cleantxt clean: - rm -f $(OBJS) text + rm -f $(OBJS) text.exe cleantxt: rm -f *.txt diff --git a/page.h b/page.h index 62b5791..612a93e 100644 --- a/page.h +++ b/page.h @@ -2,7 +2,7 @@ #define PAGE_H /* PAGE struct definition and related functions */ -#include // might have to move this +#include // might have to move this #include "line.h" #define PAGE_SIZE 500 /* Default number of lines */ diff --git a/prompt.h b/prompt.h index d9aa85c..f11149b 100644 --- a/prompt.h +++ b/prompt.h @@ -1,7 +1,7 @@ #ifndef PROMPT_H #define PROMPT_H -#include +#include #include #define PROMPT_STRING_LINES 5 diff --git a/text.c b/text.c index 8d0edb7..bd550c4 100644 --- a/text.c +++ b/text.c @@ -11,7 +11,7 @@ int y_offset = 0; // TODO: move to local scope int tab_offset = 0; -#define DEBUG +// #define DEBUG void print_loc(int x, int y) { @@ -48,7 +48,7 @@ int main(int argc, char *argv[]) /* curses interface */ initscr(); noecho(); - keypad(stdscr, true); + keypad(stdscr, 1); int beg = 0; int end = WIN_SIZE; @@ -56,19 +56,18 @@ int main(int argc, char *argv[]) int i; - update_status("Press F4 to quit"); + update_status(page.filename, ""); print_page(&page, beg, end); getyx(stdscr, y, x); - char status[NAME_LIMIT + 10]; - while(true) + while(1) { print_loc(x, y); beg = 0 + y_offset; end = WIN_SIZE + y_offset; int ch = getch(); - update_status("Press F4 to quit"); // default text + update_status(page.filename, ""); // default text switch(ch) { case KEY_F(4): @@ -78,15 +77,13 @@ int main(int argc, char *argv[]) break; case KEY_F(5): save_file(&page); - sprintf(status, "Saved as \'%s\'", page.filename); - update_status(status); + update_status(page.filename, "Saved!"); break; case KEY_F(6): prompt_string("Save As:", page.filename, NAME_LIMIT); save_file(&page); - sprintf(status, "Saved as \'%s\'", page.filename); print_page(&page, beg, end); - update_status(status); + update_status(page.filename, "Saved!"); break; case KEY_UP: move_up(&page, &x, &y); @@ -103,6 +100,7 @@ int main(int argc, char *argv[]) case KEY_DC: case 127: // backspace key... case KEY_BACKSPACE: + case '\b': if(strlen(page.text[y + y_offset].line) == 0) { // can only delete blank lines for now remove_line(&page, y + y_offset); @@ -146,14 +144,17 @@ endnc: } // main // prints a message at the bottom of the window -void update_status(char *info) +void update_status(char *filename, char *info) { int oldy, oldx; getyx(stdscr, oldy, oldx); - + char status[81]; + + snprintf(status, 80, "F4: Quit F5: Save F6: Save As File: %-25.25s %s", filename, info); + attron(A_REVERSE); move(LINES - 1, 0); clrtoeol(); - printw(info); + printw(status); attroff(A_REVERSE); move(oldy, oldx); diff --git a/text.h b/text.h index 536a751..104fea4 100644 --- a/text.h +++ b/text.h @@ -5,12 +5,12 @@ #include // declared in line.h #include #include // declared in line.h -#include // -lncurses. declared in page.h +#include // -lncurses. declared in page.h #include "page.h" #include "prompt.h" -void update_status(char *info); +void update_status(char *filename, char *info); int count_lines(FILE *fp); void load_file(PAGE *p, char* filename);