diff --git a/build/windows.o b/build/windows.o index 9a1144b..014ce38 100644 Binary files a/build/windows.o and b/build/windows.o differ diff --git a/include/windows.h b/include/windows.h index ab4f2c1..f500aa0 100644 --- a/include/windows.h +++ b/include/windows.h @@ -15,6 +15,6 @@ void status(char *msg); WINDOW *create_newwin(int height, int width, int starty, int startx); void destroy_win(WINDOW *local_win); void print_menu(WINDOW *menu_win, int y, int x, int highlight); -void word_wrap_print(WINDOW *win, int start_y, int start_x, int max_width, const char *str); +void wwrap_print(WINDOW *win, int start_y, int start_x, const char *str); -#endif \ No newline at end of file +#endif diff --git a/makefile b/makefile index c19a008..f2dddec 100644 --- a/makefile +++ b/makefile @@ -5,7 +5,7 @@ SRC_DIR = src BUILD_DIR = build SOURCES = $(wildcard $(SRC_DIR)/*.c) OBJECTS = $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SOURCES)) -EXEC = newCounter +EXEC = productManager DEPS = $(OBJECTS:.o=.d) @@ -23,4 +23,4 @@ $(BUILD_DIR)/%.o: $(SRC_DIR)/%.c clean: rm -rf $(BUILD_DIR) $(EXEC) -.PHONY: all clean \ No newline at end of file +.PHONY: all clean diff --git a/newCounter b/newCounter deleted file mode 100755 index 9536579..0000000 Binary files a/newCounter and /dev/null differ diff --git a/productManager b/productManager new file mode 100755 index 0000000..7f36848 Binary files /dev/null and b/productManager differ diff --git a/src/windows.c b/src/windows.c index a45b815..9508ada 100644 --- a/src/windows.c +++ b/src/windows.c @@ -33,14 +33,15 @@ int runMainMenu(){ int c; keypad(mainWin, TRUE); - mvwprintw(mainWin, 2, 2, "Usa le FRECCETTE ed INVIO per scegliere un'opzione!"); - mvwprintw(mainWin, 3, 2, "In alternativa ci sono J e K con SPAZIO!"); + wwrap_print(mainWin, 1, 2, "Usa le FRECCETTE ed INVIO per scegliere un'opzione,\nin alternativa ci sono i movement di vim e SPAZIO."); refresh(); - print_menu(mainWin, 6, width / 2 - 10, highlight); + print_menu(mainWin, height / 2 - 3, width / 2 - 9, highlight); while(1) { c = wgetch(mainWin); switch(c) { case KEY_UP: + case KEY_LEFT: + case 'h': case 'k': if(highlight == 1) highlight = n_mainMenu; @@ -48,6 +49,8 @@ int runMainMenu(){ --highlight; break; case KEY_DOWN: + case KEY_RIGHT: + case 'l': case 'j': if(highlight == n_mainMenu) highlight = 1; @@ -63,7 +66,7 @@ int runMainMenu(){ refresh(); break; } - print_menu(mainWin, 6, width / 2 - 10, highlight); + print_menu(mainWin, height / 2 - 3, width / 2 - 9, highlight); if(choice != 0) /* User did a choice come out of the infinite loop */ break; } @@ -143,7 +146,7 @@ void warningf(const char *fmt, ...) { void warning(char *string){ WINDOW *warningWin; int startx, starty, width, height; - height = LINES / 2 - 3; + height = LINES / 2 - 2; width = COLS / 2; starty = LINES / 2; startx = 0; @@ -151,7 +154,7 @@ void warning(char *string){ wbkgd(warningWin, COLOR_PAIR(1)); mvwprintw(warningWin, 2, 2, "ATTENZIONE!!! E' avvenuto un errore! "); - word_wrap_print(warningWin, 4, 3, width - 5, string); + wwrap_print(warningWin, 4, 3, string); mvwprintw(warningWin, height - 1, width /2, " Premi un tasto per continuare . . . "); wrefresh(warningWin); @@ -172,7 +175,7 @@ void statusf(const char *fmt, ...) { void status(char *msg) { attron(COLOR_PAIR(3)); - mvprintw(LINES -2, 0, " %-*s", COLS -1, msg); + mvprintw(LINES -2, 0, "%-*s", COLS, msg); attroff(COLOR_PAIR(3)); refresh(); } @@ -190,7 +193,7 @@ WINDOW *create_newwin(int height, int width, int starty, int startx) void destroy_win(WINDOW *local_win) { - wborder(local_win, ':', ':', '.', '.', ' ', ' ', ' ', ' '); + wborder(local_win, ':', ':', '.', '.', '.', '.', '.', '.'); wrefresh(local_win); delwin(local_win); } @@ -212,7 +215,8 @@ void print_menu(WINDOW *menu_win, int y, int x, int highlight) wrefresh(menu_win); } -void word_wrap_print(WINDOW *win, int start_y, int start_x, int max_width, const char *str) { +void wwrap_print(WINDOW *win, int start_y, int start_x, const char *str) { + int max_width = getmaxx(win) - (start_y + 1); int y = start_y; int x = start_x; int line_length = 0;