aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--scripts/kconfig/lxdialog/dialog.h5
-rw-r--r--scripts/kconfig/lxdialog/util.c32
-rw-r--r--scripts/kconfig/mconf.c61
3 files changed, 32 insertions, 66 deletions
diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h
index 7e17eba75ae8..c4ad37fd922c 100644
--- a/scripts/kconfig/lxdialog/dialog.h
+++ b/scripts/kconfig/lxdialog/dialog.h
@@ -187,10 +187,9 @@ int item_is_tag(char tag);
187int on_key_esc(WINDOW *win); 187int on_key_esc(WINDOW *win);
188int on_key_resize(void); 188int on_key_resize(void);
189 189
190void init_dialog(const char *backtitle); 190int init_dialog(const char *backtitle);
191void set_dialog_backtitle(const char *backtitle); 191void set_dialog_backtitle(const char *backtitle);
192void reset_dialog(void); 192void end_dialog(int x, int y);
193void end_dialog(void);
194void attr_clear(WINDOW * win, int height, int width, chtype attr); 193void attr_clear(WINDOW * win, int height, int width, chtype attr);
195void dialog_clear(void); 194void dialog_clear(void);
196void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x); 195void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x);
diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c
index a1bddefe73d0..86d95cca46a7 100644
--- a/scripts/kconfig/lxdialog/util.c
+++ b/scripts/kconfig/lxdialog/util.c
@@ -266,31 +266,41 @@ void dialog_clear(void)
266/* 266/*
267 * Do some initialization for dialog 267 * Do some initialization for dialog
268 */ 268 */
269void init_dialog(const char *backtitle) 269int init_dialog(const char *backtitle)
270{ 270{
271 dlg.backtitle = backtitle; 271 int height, width;
272 color_setup(getenv("MENUCONFIG_COLOR")); 272
273} 273 initscr(); /* Init curses */
274 getmaxyx(stdscr, height, width);
275 if (height < 19 || width < 80) {
276 endwin();
277 return -ERRDISPLAYTOOSMALL;
278 }
274 279
275void set_dialog_backtitle(const char *backtitle)
276{
277 dlg.backtitle = backtitle; 280 dlg.backtitle = backtitle;
278} 281 color_setup(getenv("MENUCONFIG_COLOR"));
279 282
280void reset_dialog(void)
281{
282 initscr(); /* Init curses */
283 keypad(stdscr, TRUE); 283 keypad(stdscr, TRUE);
284 cbreak(); 284 cbreak();
285 noecho(); 285 noecho();
286 dialog_clear(); 286 dialog_clear();
287
288 return 0;
289}
290
291void set_dialog_backtitle(const char *backtitle)
292{
293 dlg.backtitle = backtitle;
287} 294}
288 295
289/* 296/*
290 * End using dialog functions. 297 * End using dialog functions.
291 */ 298 */
292void end_dialog(void) 299void end_dialog(int x, int y)
293{ 300{
301 /* move cursor back to original position */
302 move(y, x);
303 refresh();
294 endwin(); 304 endwin();
295} 305}
296 306
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 47e226fdedd7..ee9ed3059472 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -8,17 +8,13 @@
8 * i18n, 2005, Arnaldo Carvalho de Melo <acme@conectiva.com.br> 8 * i18n, 2005, Arnaldo Carvalho de Melo <acme@conectiva.com.br>
9 */ 9 */
10 10
11#include <sys/ioctl.h>
12#include <sys/wait.h>
13#include <ctype.h> 11#include <ctype.h>
14#include <errno.h> 12#include <errno.h>
15#include <fcntl.h> 13#include <fcntl.h>
16#include <limits.h> 14#include <limits.h>
17#include <signal.h>
18#include <stdarg.h> 15#include <stdarg.h>
19#include <stdlib.h> 16#include <stdlib.h>
20#include <string.h> 17#include <string.h>
21#include <termios.h>
22#include <unistd.h> 18#include <unistd.h>
23#include <locale.h> 19#include <locale.h>
24 20
@@ -275,8 +271,6 @@ search_help[] = N_(
275 "\n"); 271 "\n");
276 272
277static int indent; 273static int indent;
278static struct termios ios_org;
279static int rows = 0, cols = 0;
280static struct menu *current_menu; 274static struct menu *current_menu;
281static int child_count; 275static int child_count;
282static int single_menu_mode; 276static int single_menu_mode;
@@ -290,41 +284,6 @@ static void show_textbox(const char *title, const char *text, int r, int c);
290static void show_helptext(const char *title, const char *text); 284static void show_helptext(const char *title, const char *text);
291static void show_help(struct menu *menu); 285static void show_help(struct menu *menu);
292 286
293static void init_wsize(void)
294{
295 struct winsize ws;
296 char *env;
297
298 if (!ioctl(STDIN_FILENO, TIOCGWINSZ, &ws)) {
299 rows = ws.ws_row;
300 cols = ws.ws_col;
301 }
302
303 if (!rows) {
304 env = getenv("LINES");
305 if (env)
306 rows = atoi(env);
307 if (!rows)
308 rows = 24;
309 }
310 if (!cols) {
311 env = getenv("COLUMNS");
312 if (env)
313 cols = atoi(env);
314 if (!cols)
315 cols = 80;
316 }
317
318 if (rows < 19 || cols < 80) {
319 fprintf(stderr, N_("Your display is too small to run Menuconfig!\n"));
320 fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n"));
321 exit(1);
322 }
323
324 rows -= 4;
325 cols -= 5;
326}
327
328static void get_prompt_str(struct gstr *r, struct property *prop) 287static void get_prompt_str(struct gstr *r, struct property *prop)
329{ 288{
330 int i, j; 289 int i, j;
@@ -900,13 +859,9 @@ static void conf_save(void)
900 } 859 }
901} 860}
902 861
903static void conf_cleanup(void)
904{
905 tcsetattr(1, TCSAFLUSH, &ios_org);
906}
907
908int main(int ac, char **av) 862int main(int ac, char **av)
909{ 863{
864 int saved_x, saved_y;
910 char *mode; 865 char *mode;
911 int res; 866 int res;
912 867
@@ -923,11 +878,13 @@ int main(int ac, char **av)
923 single_menu_mode = 1; 878 single_menu_mode = 1;
924 } 879 }
925 880
926 tcgetattr(1, &ios_org); 881 getyx(stdscr, saved_y, saved_x);
927 atexit(conf_cleanup); 882 if (init_dialog(NULL)) {
928 init_wsize(); 883 fprintf(stderr, N_("Your display is too small to run Menuconfig!\n"));
929 reset_dialog(); 884 fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n"));
930 init_dialog(NULL); 885 return 1;
886 }
887
931 set_config_filename(conf_get_configname()); 888 set_config_filename(conf_get_configname());
932 do { 889 do {
933 conf(&rootmenu); 890 conf(&rootmenu);
@@ -941,7 +898,7 @@ int main(int ac, char **av)
941 else 898 else
942 res = -1; 899 res = -1;
943 } while (res == KEY_ESC); 900 } while (res == KEY_ESC);
944 end_dialog(); 901 end_dialog(saved_x, saved_y);
945 902
946 switch (res) { 903 switch (res) {
947 case 0: 904 case 0: