tux_mind

nGUI2.c diff

Apr 11th, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 6.74 KB | None | 0 0
  1. diff --git a/kernel_chooser/nGUI2.c b/kernel_chooser/nGUI2.c
  2. index 602e57f..17dc57c 100644
  3. --- a/kernel_chooser/nGUI2.c
  4. +++ b/kernel_chooser/nGUI2.c
  5. @@ -5,6 +5,8 @@
  6.  #include <stdlib.h>
  7.  #include <errno.h>
  8.  #include <wait.h>
  9. +#include <linux/input.h>
  10. +#include <stdint.h>
  11.  
  12.  #include "common3.h"
  13.  #include "menu3.h"
  14. @@ -284,6 +286,8 @@ int nc_compute_menu(menu_entry *list)
  15.         /* Print title */
  16.         mvprintw(0,0,"%s",HEADER_LEFT);
  17.         mvprintw(0,COLS-strlen(HEADER_RIGHT),"%s",HEADER_RIGHT);
  18. +       refresh();
  19. +       fb_crefresh(0,0,COLS,1);
  20.  
  21.         /* Create the window to be associated with the menu */
  22.         menu_window = newwin( menu_sizey, menu_sizex, 5, (COLS-menu_sizex)/2);
  23. @@ -333,9 +337,12 @@ int nc_compute_menu(menu_entry *list)
  24.         attroff(COLOR_PAIR(COLOR_MENU_BORDER));
  25.  
  26.         attron(COLOR_PAIR(COLOR_LOG_ERROR));
  27. -       mvprintw(7+menu_sizey,(COLS-ARRAY_SIZE(HELP_MESSAGE))/2,HELP_MESSAGE);
  28. +       mvprintw(7+menu_sizey,(COLS-strlen(HELP_MESSAGE))/2,HELP_MESSAGE);
  29.         attroff(COLOR_PAIR(COLOR_LOG_ERROR));
  30.         refresh();
  31. +       fb_crefresh((COLS-strlen(HELP_MESSAGE))/2,7+menu_sizey,strlen(HELP_MESSAGE),1);
  32. +
  33. +       //fb_crefresh(0,0,COLS,LINES); //redraw the whole background
  34.  
  35.         return 0;
  36.         error:
  37. @@ -393,7 +400,7 @@ void nc_help_popup()
  38.  
  39.         unpost_menu(menu[menu_i]); // E_POSTED from nc_get_user_choice
  40.         attron(COLOR_PAIR(COLOR_POPUP));                                                                                            
  41. -       create_box( menu_sizey+3, menu_sizex*(3/4)+1, y-1, x-2);                                                                    
  42. +       create_box( menu_sizey+3, menu_sizex+1, y-1, x-2);                                                                          
  43.         for(i=0;strings[i];i++)                                                                                                      
  44.         {                                                                                                                            
  45.                 mvprintw(y+i,x,strings[i]);                                                                                          
  46. @@ -421,6 +428,8 @@ int nc_get_user_choice()                                                                                        
  47.         wrefresh(messages_win);                                                                                                      
  48.         refresh();                                                                                                                  
  49.                                                                                                                                      
  50. +       //fb_crefresh((COLS-menu_sizex)/2-1, 2, menu_sizex+2, menu_sizey+4);                                                        
  51. +                                                                                                                                    
  52.         while((c = wgetch(menu_window)) != 10)                                                                                      
  53.         {                                                                                                                            
  54.                 DEBUG("key %i (%c)\n", c, c);                                                                                        
  55. @@ -440,17 +449,18 @@ int nc_get_user_choice()                                                                                      
  56.                         case KEY_PPAGE:                                                                                              
  57.                                 menu_driver(menu[menu_i], REQ_SCR_UPAGE);                                                            
  58.                                 break;                                                                                              
  59. +                       case KEY_POWER:                                                                                              
  60.                         case HELP_KEY:                                                                                              
  61.                                 nc_help_popup();                                                                                    
  62.                                 goto post_menu;                                                                                      
  63. -                       case 'r':                                                                                                    
  64. +                       case MENU_TOGGLE_KEY:                                                                                        
  65.                                 unpost_menu(menu[menu_i]);                                                                          
  66.                                 if (menu_i == MENU_POWER)                                                                            
  67.                                         menu_i = MENU_MAIN;                                                                          
  68.                                 else
  69.                                         menu_i = MENU_POWER;
  70.                                 goto post_menu;
  71. -                       case '=':
  72. +                       case SCREENSHOT_KEY:
  73.                                 return MENU_SCREENSHOT;
  74.                 }
  75.                 wrefresh(menu_window);
  76. @@ -475,6 +485,7 @@ int nc_get_user_choice()
  77.  int nc_push_message(int i, char *prefix, char *fmt,...)
  78.  {
  79.         va_list ap;
  80. +       int sizex, sizey;
  81.  
  82.         if(!messages_win)
  83.                 return ERR;
  84. @@ -486,6 +497,11 @@ int nc_push_message(int i, char *prefix, char *fmt,...)
  85.         vwprintw(messages_win,fmt,ap);
  86.         wrefresh(messages_win);
  87.         va_end(ap);
  88. +
  89. +       sizey = (LINES * MSG_HEIGHT_PERC)/100;
  90. +       sizex = (COLS * MSG_WIDTH_PERC)/100;
  91. +       fb_crefresh(0,(LINES-sizey)+2,sizex,sizey-2);
  92. +
  93.         return 0;
  94.  }
  95.  
  96. @@ -509,10 +525,12 @@ void nc_status(char *msg)
  97.   */
  98.  int nc_wait_for_keypress(void)
  99.  {
  100. -       int x,y,timeout;
  101. +       int x,y,timeout,len;
  102. +
  103. +       len = snprintf(NULL,0,WAIT_MESSAGE,0);
  104.  
  105.         y = (LINES/2)-1;
  106. -       x = (COLS - snprintf(NULL,0,WAIT_MESSAGE,0))/2;
  107. +       x = (COLS - len)/2;
  108.  
  109.         /* this set an internal timeout for the getch() call.
  110.          * 'man 3 timeout' for more info.
  111. @@ -523,6 +541,7 @@ int nc_wait_for_keypress(void)
  112.         for (timeout=TIMEOUT_BOOT; timeout>0; timeout--) {
  113.                 mvprintw(y,x,WAIT_MESSAGE, timeout);
  114.                 refresh();
  115. +               fb_crefresh(x,y,len,1);
  116.                 if (getch() != ERR) {
  117.                         mvprintw(y,x,"%*s",COLS-x-1," ");
  118.                         return 0;
Advertisement
Add Comment
Please, Sign In to add comment