]> ncurses.scripts.mit.edu Git - ncurses.git/blobdiff - doc/html/NCURSES-Programming-HOWTO.html
ncurses 6.4 - patch 20231021
[ncurses.git] / doc / html / NCURSES-Programming-HOWTO.html
index f4680ca37b5a8d1fff663cb47c44a8272494eb51..9a3f078d2f1c697f9c68cb37fa12d1d766775d15 100644 (file)
@@ -2017,7 +2017,7 @@ int main(int argc, char *argv[])
     COLOR_PAIR(n)   Color-pair number n 
     </pre>
         <p>The last one is the most colorful one :-) Colors are
-        explained in the <a href="#COLOR" target="_top">next
+        explained in the <a href="#color" target="_top">next
         sections</a>.</p>
 
         <p>We can OR(|) any number of above attributes to get a
@@ -2937,7 +2937,7 @@ void print_menu(WINDOW *menu_win, int highlight)
 #include &lt;curses.h&gt;
 
 #define WIDTH 30
-#define HEIGHT 10 
+#define HEIGHT 10
 
 int startx = 0;
 int starty = 0;
@@ -2968,7 +2968,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();
@@ -2976,10 +2976,11 @@ int main()
 
         /* Print the menu for the first time */
         menu_win = newwin(HEIGHT, WIDTH, starty, startx);
+        keypad(menu_win, TRUE);
         print_menu(menu_win, 1);
         /* Get all the mouse events */
         mousemask(ALL_MOUSE_EVENTS, NULL);
-        
+
         while(1)
         {       c = wgetch(menu_win);
                 switch(c)
@@ -2991,13 +2992,13 @@ int main()
                                         if(choice == -1) //Exit chosen
                                                 goto end;
                                         mvprintw(22, 1, "Choice made is : %d String Chosen is \"%10s\"", choice, choices[choice - 1]);
-                                        refresh(); 
+                                        refresh();
                                 }
                         }
                         print_menu(menu_win, choice);
                         break;
                 }
-        }               
+        }
 end:
         endwin();
         return 0;
@@ -3005,14 +3006,14 @@ end:
 
 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 &lt; 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);
                 }
@@ -3029,13 +3030,13 @@ void report_choice(int mouse_x, int mouse_y, int *p_choice)
 
         i = startx + 2;
         j = starty + 3;
-        
+
         for(choice = 0; choice &lt; n_choices; ++choice)
                 if(mouse_y == j + choice &amp;&amp; mouse_x &gt;= i &amp;&amp; mouse_x &lt;= 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;
                 }
 }</span></pre>
@@ -4515,7 +4516,7 @@ int main()
         for(i = 0; i &lt; n_choices; ++i)
                 my_items[i] = new_item(choices[i], choices[i]);
 
-        /* Crate menu */
+        /* Create menu */
         my_menu = new_menu((ITEM **)my_items);
 
         /* Create the window to be associated with the menu */
@@ -4661,7 +4662,7 @@ int main()
         for(i = 0; i &lt; n_choices; ++i)
                 my_items[i] = new_item(choices[i], choices[i]);
 
-        /* Crate menu */
+        /* Create menu */
         my_menu = new_menu((ITEM **)my_items);
 
         /* Create the window to be associated with the menu */
@@ -4815,7 +4816,7 @@ int main()
         for(i = 0; i &lt; n_choices; ++i)
                 my_items[i] = new_item(choices[i], choices[i]);
 
-        /* Crate menu */
+        /* Create menu */
         my_menu = new_menu((ITEM **)my_items);
 
         /* Set menu option not to show the description */
@@ -5123,7 +5124,7 @@ int main()
 
         /* Post the menu */
         mvprintw(LINES - 3, 0, "Press &lt;ENTER&gt; 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();
 
@@ -5224,7 +5225,7 @@ int main()
 
         /* Post the menu */
         mvprintw(LINES - 3, 0, "Press &lt;ENTER&gt; 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();