Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 77962
b: refs/heads/master
c: 09af091
h: refs/heads/master
v: v3
  • Loading branch information
Ladislav Michl authored and Sam Ravnborg committed Jan 28, 2008
1 parent b073e96 commit 407c04f
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 67 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0486bc9098f4556a0aa90d57f717d08164b7647e
refs/heads/master: 09af091f50409a60a72086c737b9a6224dde5ab8
5 changes: 2 additions & 3 deletions trunk/scripts/kconfig/lxdialog/dialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,9 @@ int item_is_tag(char tag);
int on_key_esc(WINDOW *win);
int on_key_resize(void);

void init_dialog(const char *backtitle);
int init_dialog(const char *backtitle);
void set_dialog_backtitle(const char *backtitle);
void reset_dialog(void);
void end_dialog(void);
void end_dialog(int x, int y);
void attr_clear(WINDOW * win, int height, int width, chtype attr);
void dialog_clear(void);
void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x);
Expand Down
32 changes: 21 additions & 11 deletions trunk/scripts/kconfig/lxdialog/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -266,31 +266,41 @@ void dialog_clear(void)
/*
* Do some initialization for dialog
*/
void init_dialog(const char *backtitle)
int init_dialog(const char *backtitle)
{
dlg.backtitle = backtitle;
color_setup(getenv("MENUCONFIG_COLOR"));
}
int height, width;

initscr(); /* Init curses */
getmaxyx(stdscr, height, width);
if (height < 19 || width < 80) {
endwin();
return -ERRDISPLAYTOOSMALL;
}

void set_dialog_backtitle(const char *backtitle)
{
dlg.backtitle = backtitle;
}
color_setup(getenv("MENUCONFIG_COLOR"));

void reset_dialog(void)
{
initscr(); /* Init curses */
keypad(stdscr, TRUE);
cbreak();
noecho();
dialog_clear();

return 0;
}

void set_dialog_backtitle(const char *backtitle)
{
dlg.backtitle = backtitle;
}

/*
* End using dialog functions.
*/
void end_dialog(void)
void end_dialog(int x, int y)
{
/* move cursor back to original position */
move(y, x);
refresh();
endwin();
}

Expand Down
61 changes: 9 additions & 52 deletions trunk/scripts/kconfig/mconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,13 @@
* i18n, 2005, Arnaldo Carvalho de Melo <acme@conectiva.com.br>
*/

#include <sys/ioctl.h>
#include <sys/wait.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <signal.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include <locale.h>

Expand Down Expand Up @@ -275,8 +271,6 @@ search_help[] = N_(
"\n");

static int indent;
static struct termios ios_org;
static int rows = 0, cols = 0;
static struct menu *current_menu;
static int child_count;
static int single_menu_mode;
Expand All @@ -290,41 +284,6 @@ static void show_textbox(const char *title, const char *text, int r, int c);
static void show_helptext(const char *title, const char *text);
static void show_help(struct menu *menu);

static void init_wsize(void)
{
struct winsize ws;
char *env;

if (!ioctl(STDIN_FILENO, TIOCGWINSZ, &ws)) {
rows = ws.ws_row;
cols = ws.ws_col;
}

if (!rows) {
env = getenv("LINES");
if (env)
rows = atoi(env);
if (!rows)
rows = 24;
}
if (!cols) {
env = getenv("COLUMNS");
if (env)
cols = atoi(env);
if (!cols)
cols = 80;
}

if (rows < 19 || cols < 80) {
fprintf(stderr, N_("Your display is too small to run Menuconfig!\n"));
fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n"));
exit(1);
}

rows -= 4;
cols -= 5;
}

static void get_prompt_str(struct gstr *r, struct property *prop)
{
int i, j;
Expand Down Expand Up @@ -900,13 +859,9 @@ static void conf_save(void)
}
}

static void conf_cleanup(void)
{
tcsetattr(1, TCSAFLUSH, &ios_org);
}

int main(int ac, char **av)
{
int saved_x, saved_y;
char *mode;
int res;

Expand All @@ -923,11 +878,13 @@ int main(int ac, char **av)
single_menu_mode = 1;
}

tcgetattr(1, &ios_org);
atexit(conf_cleanup);
init_wsize();
reset_dialog();
init_dialog(NULL);
getyx(stdscr, saved_y, saved_x);
if (init_dialog(NULL)) {
fprintf(stderr, N_("Your display is too small to run Menuconfig!\n"));
fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n"));
return 1;
}

set_config_filename(conf_get_configname());
do {
conf(&rootmenu);
Expand All @@ -941,7 +898,7 @@ int main(int ac, char **av)
else
res = -1;
} while (res == KEY_ESC);
end_dialog();
end_dialog(saved_x, saved_y);

switch (res) {
case 0:
Expand Down

0 comments on commit 407c04f

Please sign in to comment.