diff --git a/.gitignore b/.gitignore index 80e89b1..12e8a4e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,36 +1,40 @@ -# Object files +.gitignore +*.layout +*.depend +*.save +*.cbp +bin/ +obj/ + +# Prerequisites +*.d + +# Compiled Object files +*.slo +*.lo *.o -*.ko *.obj -*.elf # Precompiled Headers *.gch *.pch -# Libraries -*.lib -*.a -*.la -*.lo - -# Shared objects (inc. Windows DLLs) -*.dll +# Compiled Dynamic libraries *.so -*.so.* *.dylib +*.dll + +# Fortran module files +*.mod +*.smod + +# Compiled Static libraries +*.lai +*.la +*.a +*.lib # Executables *.exe *.out *.app -*.i*86 -*.x86_64 -*.hex - -# Debug files -*.dSYM/ -*.su - -# CMake -/build/ diff --git a/12-mouse/main.c b/12-mouse/main.c index 19d4379..6acbc84 100644 --- a/12-mouse/main.c +++ b/12-mouse/main.c @@ -1,12 +1,13 @@ #include #define WIDTH 30 -#define HEIGHT 10 +#define HEIGHT 10 int startx = 0; int starty = 0; -char *choices[] = { "Choice 1", +char *choices[] = { + "Choice 1", "Choice 2", "Choice 3", "Choice 4", @@ -32,7 +33,7 @@ int main() /* Try to put the window in the middle of screen */ startx = (80 - WIDTH) / 2; starty = (24 - HEIGHT) / 2; - + attron(A_REVERSE); mvprintw(23, 1, "Click on Exit to quit (Works best in a virtual console)"); refresh(); @@ -43,7 +44,8 @@ int main() print_menu(menu_win, 1); /* Get all the mouse events */ mousemask(ALL_MOUSE_EVENTS, NULL); - + keypad(menu_win, TRUE); + while(1) { c = wgetch(menu_win); switch(c) @@ -54,14 +56,14 @@ int main() { report_choice(event.x + 1, event.y + 1, &choice); if(choice == -1) //Exit chosen goto end; - mvprintw(22, 1, "Choice made is : %d String Chosen is \"%10s\"", choice, choices[choice - 1]); - refresh(); + mvprintw(22, 1, "Choice made is: %d String Chosen is \"%10s\"", choice, choices[choice - 1]); + refresh(); } } print_menu(menu_win, choice); break; } - } + } end: endwin(); return 0; @@ -70,14 +72,14 @@ int main() void print_menu(WINDOW *menu_win, int highlight) { - int x, y, i; + int x, y, i; x = 2; y = 2; box(menu_win, 0, 0); for(i = 0; i < n_choices; ++i) { if(highlight == i + 1) - { wattron(menu_win, A_REVERSE); + { wattron(menu_win, A_REVERSE); mvwprintw(menu_win, y, x, "%s", choices[i]); wattroff(menu_win, A_REVERSE); } @@ -94,13 +96,13 @@ void report_choice(int mouse_x, int mouse_y, int *p_choice) i = startx + 2; j = starty + 3; - + for(choice = 0; choice < n_choices; ++choice) if(mouse_y == j + choice && mouse_x >= i && mouse_x <= i + strlen(choices[choice])) { if(choice == n_choices - 1) - *p_choice = -1; + *p_choice = -1; else - *p_choice = choice + 1; + *p_choice = choice + 1; break; } } diff --git a/16-panels/moving-resizing.c b/16-panels/moving-resizing.c index 804acae..82ad9c9 100644 --- a/16-panels/moving-resizing.c +++ b/16-panels/moving-resizing.c @@ -2,7 +2,7 @@ typedef struct _PANEL_DATA { int x, y, w, h; - char label[80]; + char label[80]; int label_color; PANEL *next; }PANEL_DATA; @@ -39,7 +39,7 @@ int main() init_pair(4, COLOR_CYAN, COLOR_BLACK); init_wins(my_wins, 3); - + /* Attach a panel to each window */ /* Order is bottom up */ my_panels[0] = new_panel(my_wins[0]); /* Push 0, order: stdscr-0 */ my_panels[1] = new_panel(my_wins[1]); /* Push 1, order: stdscr-0-1 */ @@ -77,7 +77,7 @@ int main() case 'r': /* Re-Size*/ size = TRUE; attron(COLOR_PAIR(4)); - mvprintw(LINES - 4, 0, "Entered Resizing :Use Arrow Keys to resize and press to end resizing"); + mvprintw(LINES - 4, 0, "Entered Resizing: Use Arrow Keys to resize and press to end resizing"); refresh(); attroff(COLOR_PAIR(4)); break; @@ -128,7 +128,7 @@ int main() { old_win = panel_window(stack_top); temp_win = newwin(newh, neww, newy, newx); replace_panel(stack_top, temp_win); - win_show(temp_win, top->label, top->label_color); + win_show(temp_win, top->label, top->label_color); delwin(old_win); size = FALSE; } @@ -137,13 +137,13 @@ int main() move = FALSE; } break; - + } attron(COLOR_PAIR(4)); mvprintw(LINES - 3, 0, "Use 'm' for moving, 'r' for resizing"); mvprintw(LINES - 2, 0, "Use tab to browse through the windows (F1 to Exit)"); attroff(COLOR_PAIR(4)); - refresh(); + refresh(); update_panels(); doupdate(); } @@ -173,7 +173,7 @@ void set_user_ptrs(PANEL **panels, int n) WINDOW *win; int x, y, w, h, i; char temp[80]; - + ptrs = (PANEL_DATA *)calloc(n, sizeof(PANEL_DATA)); for(i = 0;i < n; ++i) @@ -203,10 +203,10 @@ void win_show(WINDOW *win, char *label, int label_color) getmaxyx(win, height, width); box(win, 0, 0); - mvwaddch(win, 2, 0, ACS_LTEE); - mvwhline(win, 2, 1, ACS_HLINE, width - 2); - mvwaddch(win, 2, width - 1, ACS_RTEE); - + mvwaddch(win, 2, 0, ACS_LTEE); + mvwhline(win, 2, 1, ACS_HLINE, width - 2); + mvwaddch(win, 2, width - 1, ACS_RTEE); + print_in_middle(win, 1, 0, width, label, COLOR_PAIR(label_color)); } diff --git a/17-menus/options.c b/17-menus/options.c index 1388a7e..69e5092 100644 --- a/17-menus/options.c +++ b/17-menus/options.c @@ -16,12 +16,12 @@ char *choices[] = { int main() { ITEM **my_items; - int c; + int c; MENU *my_menu; int n_choices, i; ITEM *cur_item; - - /* Initialize curses */ + + /* Initialize curses */ initscr(); start_color(); cbreak(); @@ -50,7 +50,7 @@ int main() /* Post the menu */ mvprintw(LINES - 3, 0, "Press to see the option selected"); - mvprintw(LINES - 2, 0, "Up and Down arrow keys to naviage (F1 to Exit)"); + mvprintw(LINES - 2, 0, "Up and Down arrow keys to navigate (F1 to Exit)"); post_menu(my_menu); refresh(); @@ -65,12 +65,12 @@ int main() case 10: /* Enter */ move(20, 0); clrtoeol(); - mvprintw(20, 0, "Item selected is : %s", + mvprintw(20, 0, "Item selected is: %s", item_name(current_item(my_menu))); pos_menu_cursor(my_menu); break; } - } + } unpost_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); diff --git a/17-menus/user-pointer.c b/17-menus/user-pointer.c index 9c6c0ae..8d4a936 100644 --- a/17-menus/user-pointer.c +++ b/17-menus/user-pointer.c @@ -19,12 +19,12 @@ void func(char *name); int main() { ITEM **my_items; - int c; + int c; MENU *my_menu; int n_choices, i; ITEM *cur_item; - - /* Initialize curses */ + + /* Initialize curses */ initscr(); start_color(); cbreak(); @@ -49,7 +49,7 @@ int main() /* Post the menu */ mvprintw(LINES - 3, 0, "Press to see the option selected"); - mvprintw(LINES - 2, 0, "Up and Down arrow keys to naviage (F1 to Exit)"); + mvprintw(LINES - 2, 0, "Up and Down arrow keys to navigate (F1 to Exit)"); post_menu(my_menu); refresh(); @@ -73,7 +73,7 @@ int main() } break; } - } + } unpost_menu(my_menu); for(i = 0; i < n_choices; ++i) free_item(my_items[i]); @@ -84,5 +84,5 @@ int main() void func(char *name) { move(20, 0); clrtoeol(); - mvprintw(20, 0, "Item selected is : %s", name); -} + mvprintw(20, 0, "Item selected is: %s", name); +}