mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-11-18 07:35:12 +08:00
kconfig: make kconfig MinGW friendly
Kconfig is powerfull tool. So powerfull that more and more software
projects are using it for configuration. So instead of fixing some of
them one by one, lets fix it in kernel and wait for sync.
This work was originaly done for PTXdist - GPL licensed build system for
userlands and cross-compilers, but it will not hurt kernel kconfig
either. PTXdist menuconfig now works on Windows linked with PDCurses and
compiled using MinGW - there is no termios and signals.
* Do not include <sys/wait.h> and <signal.h> (comes from times when
lxdialog was separate process)
* Do not mess with termios directly and let curses tell screen size.
Comment to commit c8dc68ad0f
says
check for screen size could be removed later, but because it didn't
happen for more than year I left it here as well.
* Save cursor position added by Sam
Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: Roman Zippel <zippel@linux-m68k.org>
This commit is contained in:
parent
0486bc9098
commit
09af091f50
@ -187,10 +187,9 @@ int item_is_tag(char tag);
|
|||||||
int on_key_esc(WINDOW *win);
|
int on_key_esc(WINDOW *win);
|
||||||
int on_key_resize(void);
|
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 set_dialog_backtitle(const char *backtitle);
|
||||||
void reset_dialog(void);
|
void end_dialog(int x, int y);
|
||||||
void end_dialog(void);
|
|
||||||
void attr_clear(WINDOW * win, int height, int width, chtype attr);
|
void attr_clear(WINDOW * win, int height, int width, chtype attr);
|
||||||
void dialog_clear(void);
|
void dialog_clear(void);
|
||||||
void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x);
|
void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x);
|
||||||
|
@ -266,10 +266,26 @@ void dialog_clear(void)
|
|||||||
/*
|
/*
|
||||||
* Do some initialization for dialog
|
* Do some initialization for dialog
|
||||||
*/
|
*/
|
||||||
void init_dialog(const char *backtitle)
|
int init_dialog(const char *backtitle)
|
||||||
{
|
{
|
||||||
|
int height, width;
|
||||||
|
|
||||||
|
initscr(); /* Init curses */
|
||||||
|
getmaxyx(stdscr, height, width);
|
||||||
|
if (height < 19 || width < 80) {
|
||||||
|
endwin();
|
||||||
|
return -ERRDISPLAYTOOSMALL;
|
||||||
|
}
|
||||||
|
|
||||||
dlg.backtitle = backtitle;
|
dlg.backtitle = backtitle;
|
||||||
color_setup(getenv("MENUCONFIG_COLOR"));
|
color_setup(getenv("MENUCONFIG_COLOR"));
|
||||||
|
|
||||||
|
keypad(stdscr, TRUE);
|
||||||
|
cbreak();
|
||||||
|
noecho();
|
||||||
|
dialog_clear();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_dialog_backtitle(const char *backtitle)
|
void set_dialog_backtitle(const char *backtitle)
|
||||||
@ -277,20 +293,14 @@ void set_dialog_backtitle(const char *backtitle)
|
|||||||
dlg.backtitle = backtitle;
|
dlg.backtitle = backtitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset_dialog(void)
|
|
||||||
{
|
|
||||||
initscr(); /* Init curses */
|
|
||||||
keypad(stdscr, TRUE);
|
|
||||||
cbreak();
|
|
||||||
noecho();
|
|
||||||
dialog_clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* End using dialog functions.
|
* 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();
|
endwin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,17 +8,13 @@
|
|||||||
* i18n, 2005, Arnaldo Carvalho de Melo <acme@conectiva.com.br>
|
* i18n, 2005, Arnaldo Carvalho de Melo <acme@conectiva.com.br>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <signal.h>
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <termios.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
|
||||||
@ -275,8 +271,6 @@ search_help[] = N_(
|
|||||||
"\n");
|
"\n");
|
||||||
|
|
||||||
static int indent;
|
static int indent;
|
||||||
static struct termios ios_org;
|
|
||||||
static int rows = 0, cols = 0;
|
|
||||||
static struct menu *current_menu;
|
static struct menu *current_menu;
|
||||||
static int child_count;
|
static int child_count;
|
||||||
static int single_menu_mode;
|
static int single_menu_mode;
|
||||||
@ -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_helptext(const char *title, const char *text);
|
||||||
static void show_help(struct menu *menu);
|
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)
|
static void get_prompt_str(struct gstr *r, struct property *prop)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
@ -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 main(int ac, char **av)
|
||||||
{
|
{
|
||||||
|
int saved_x, saved_y;
|
||||||
char *mode;
|
char *mode;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
@ -923,11 +878,13 @@ int main(int ac, char **av)
|
|||||||
single_menu_mode = 1;
|
single_menu_mode = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tcgetattr(1, &ios_org);
|
getyx(stdscr, saved_y, saved_x);
|
||||||
atexit(conf_cleanup);
|
if (init_dialog(NULL)) {
|
||||||
init_wsize();
|
fprintf(stderr, N_("Your display is too small to run Menuconfig!\n"));
|
||||||
reset_dialog();
|
fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n"));
|
||||||
init_dialog(NULL);
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
set_config_filename(conf_get_configname());
|
set_config_filename(conf_get_configname());
|
||||||
do {
|
do {
|
||||||
conf(&rootmenu);
|
conf(&rootmenu);
|
||||||
@ -941,7 +898,7 @@ int main(int ac, char **av)
|
|||||||
else
|
else
|
||||||
res = -1;
|
res = -1;
|
||||||
} while (res == KEY_ESC);
|
} while (res == KEY_ESC);
|
||||||
end_dialog();
|
end_dialog(saved_x, saved_y);
|
||||||
|
|
||||||
switch (res) {
|
switch (res) {
|
||||||
case 0:
|
case 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user