Commit b4a9071a authored by Linus Torvalds's avatar Linus Torvalds

Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild

* git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild:
  kbuild: trivial documentation fixes
  kconfig: fix saving alternate kconfig file in parent dir
  kbuild: make modpost processing configurable
  kconfig/menuconfig: do not let ncurses clutter screen on exit
  kconfig/lxdialog: clear long menu lines
  kbuild: do not build mconf & lxdialog unless needed
  kconfig/lxdialog: fix make mrproper
  kconfig/lxdialog: support resize
  kconfig/lxdialog: let <ESC><ESC> behave as expected
  kconfig/menuconfig: lxdialog is now built-in
  kconfig/lxdialog: add a new theme bluetitle which is now default
  kconfig/lxdialog: add support for color themes and add blackbg theme
  kconfig/lxdialog: refactor color support
parents 8b2a1fd1 99c8b947
...@@ -43,7 +43,7 @@ are not planned to be included in the kernel tree. ...@@ -43,7 +43,7 @@ are not planned to be included in the kernel tree.
What is covered within this file is mainly information to authors What is covered within this file is mainly information to authors
of modules. The author of an external module should supply of modules. The author of an external module should supply
a makefile that hides most of the complexity, so one only has to type a makefile that hides most of the complexity, so one only has to type
'make' to build the module. A complete example will be present in 'make' to build the module. A complete example will be presented in
chapter 4, "Creating a kbuild file for an external module". chapter 4, "Creating a kbuild file for an external module".
...@@ -61,6 +61,7 @@ when building an external module. ...@@ -61,6 +61,7 @@ when building an external module.
make -C <path-to-kernel> M=`pwd` make -C <path-to-kernel> M=`pwd`
For the running kernel use: For the running kernel use:
make -C /lib/modules/`uname -r`/build M=`pwd` make -C /lib/modules/`uname -r`/build M=`pwd`
For the above command to succeed, the kernel must have been For the above command to succeed, the kernel must have been
...@@ -130,10 +131,10 @@ when building an external module. ...@@ -130,10 +131,10 @@ when building an external module.
To make sure the kernel contains the information required to To make sure the kernel contains the information required to
build external modules the target 'modules_prepare' must be used. build external modules the target 'modules_prepare' must be used.
'module_prepare' exists solely as a simple way to prepare 'modules_prepare' exists solely as a simple way to prepare
a kernel source tree for building external modules. a kernel source tree for building external modules.
Note: modules_prepare will not build Module.symvers even if Note: modules_prepare will not build Module.symvers even if
CONFIG_MODULEVERSIONING is set. Therefore a full kernel build CONFIG_MODVERSIONS is set. Therefore a full kernel build
needs to be executed to make module versioning work. needs to be executed to make module versioning work.
--- 2.5 Building separate files for a module --- 2.5 Building separate files for a module
...@@ -450,7 +451,7 @@ kernel refuses to load the module. ...@@ -450,7 +451,7 @@ kernel refuses to load the module.
Module.symvers contains a list of all exported symbols from a kernel build. Module.symvers contains a list of all exported symbols from a kernel build.
--- 7.1 Symbols fron the kernel (vmlinux + modules) --- 7.1 Symbols from the kernel (vmlinux + modules)
During a kernel build, a file named Module.symvers will be generated. During a kernel build, a file named Module.symvers will be generated.
Module.symvers contains all exported symbols from the kernel and Module.symvers contains all exported symbols from the kernel and
......
...@@ -32,6 +32,10 @@ ...@@ -32,6 +32,10 @@
# Step 4 is solely used to allow module versioning in external modules, # Step 4 is solely used to allow module versioning in external modules,
# where the CRC of each module is retrieved from the Module.symers file. # where the CRC of each module is retrieved from the Module.symers file.
# KBUILD_MODPOST_WARN can be set to avoid error out in case of undefined
# symbols in the final module linking stage
# KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
# This is solely usefull to speed up test compiles
PHONY := _modpost PHONY := _modpost
_modpost: __modpost _modpost: __modpost
...@@ -46,7 +50,8 @@ modulesymfile := $(KBUILD_EXTMOD)/Module.symvers ...@@ -46,7 +50,8 @@ modulesymfile := $(KBUILD_EXTMOD)/Module.symvers
__modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod))) __modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod)))
modules := $(patsubst %.o,%.ko, $(wildcard $(__modules:.ko=.o))) modules := $(patsubst %.o,%.ko, $(wildcard $(__modules:.ko=.o)))
_modpost: $(modules) # Stop after building .o files if NOFINAL is set. Makes compile tests quicker
_modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules))
# Step 2), invoke modpost # Step 2), invoke modpost
...@@ -58,7 +63,7 @@ quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules ...@@ -58,7 +63,7 @@ quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules
$(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \
$(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \ $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \
$(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
$(if $(KBUILD_EXTMOD),-w) \ $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) \
$(wildcard vmlinux) $(filter-out FORCE,$^) $(wildcard vmlinux) $(filter-out FORCE,$^)
PHONY += __modpost PHONY += __modpost
...@@ -92,7 +97,7 @@ targets += $(modules:.ko=.mod.o) ...@@ -92,7 +97,7 @@ targets += $(modules:.ko=.mod.o)
# Step 6), final link of the modules # Step 6), final link of the modules
quiet_cmd_ld_ko_o = LD [M] [email protected] quiet_cmd_ld_ko_o = LD [M] [email protected]
cmd_ld_ko_o = $(LD) $(LDFLAGS) $(LDFLAGS_MODULE) -o [email protected] \ cmd_ld_ko_o = $(LD) $(LDFLAGS) $(LDFLAGS_MODULE) -o [email protected] \
$(filter-out FORCE,$^) $(filter-out FORCE,$^)
$(modules): %.ko :%.o %.mod.o FORCE $(modules): %.ko :%.o %.mod.o FORCE
......
...@@ -11,7 +11,6 @@ gconfig: $(obj)/gconf ...@@ -11,7 +11,6 @@ gconfig: $(obj)/gconf
$< arch/$(ARCH)/Kconfig $< arch/$(ARCH)/Kconfig
menuconfig: $(obj)/mconf menuconfig: $(obj)/mconf
$(Q)$(MAKE) $(build)=scripts/kconfig/lxdialog
$< arch/$(ARCH)/Kconfig $< arch/$(ARCH)/Kconfig
config: $(obj)/conf config: $(obj)/conf
...@@ -81,6 +80,23 @@ help: ...@@ -81,6 +80,23 @@ help:
@echo ' allyesconfig - New config where all options are accepted with yes' @echo ' allyesconfig - New config where all options are accepted with yes'
@echo ' allnoconfig - New config where all options are answered with no' @echo ' allnoconfig - New config where all options are answered with no'
# lxdialog stuff
check-lxdialog := $(srctree)/$(src)/lxdialog/check-lxdialog.sh
# Use reursively expanded variables so we do not call gcc unless
# we really need to do so. (Do not call gcc as part of make mrproper)
HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags)
HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
HOST_EXTRACFLAGS += -DLOCALE
PHONY += $(obj)/dochecklxdialog
$(obj)/dochecklxdialog:
$(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES)
always := dochecklxdialog
# =========================================================================== # ===========================================================================
# Shared Makefile for the various kconfig executables: # Shared Makefile for the various kconfig executables:
# conf: Used for defconfig, oldconfig and related targets # conf: Used for defconfig, oldconfig and related targets
...@@ -92,11 +108,19 @@ help: ...@@ -92,11 +108,19 @@ help:
# Based on GTK which needs to be installed to compile it # Based on GTK which needs to be installed to compile it
# object files used by all kconfig flavours # object files used by all kconfig flavours
hostprogs-y := conf mconf qconf gconf kxgettext lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o
lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
conf-objs := conf.o zconf.tab.o conf-objs := conf.o zconf.tab.o
mconf-objs := mconf.o zconf.tab.o mconf-objs := mconf.o zconf.tab.o $(lxdialog)
kxgettext-objs := kxgettext.o zconf.tab.o kxgettext-objs := kxgettext.o zconf.tab.o
hostprogs-y := conf qconf gconf kxgettext
ifeq ($(MAKECMDGOALS),menuconfig)
hostprogs-y += mconf
endif
ifeq ($(MAKECMDGOALS),xconfig) ifeq ($(MAKECMDGOALS),xconfig)
qconf-target := 1 qconf-target := 1
endif endif
...@@ -116,7 +140,6 @@ endif ...@@ -116,7 +140,6 @@ endif
clean-files := lkc_defs.h qconf.moc .tmp_qtcheck \ clean-files := lkc_defs.h qconf.moc .tmp_qtcheck \
.tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c
subdir- += lxdialog
# Needed for systems without gettext # Needed for systems without gettext
KBUILD_HAVE_NLS := $(shell \ KBUILD_HAVE_NLS := $(shell \
......
...@@ -517,7 +517,7 @@ int conf_write(const char *name) ...@@ -517,7 +517,7 @@ int conf_write(const char *name)
fclose(out); fclose(out);
if (*tmpname) { if (*tmpname) {
strcat(dirname, name ? name : conf_get_configname()); strcat(dirname, basename);
strcat(dirname, ".old"); strcat(dirname, ".old");
rename(newname, dirname); rename(newname, dirname);
if (rename(tmpname, newname)) if (rename(tmpname, newname))
......
# Makefile to build lxdialog package
#
check-lxdialog := $(srctree)/$(src)/check-lxdialog.sh
# Use reursively expanded variables so we do not call gcc unless
# we really need to do so. (Do not call gcc as part of make mrproper)
HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags)
HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
HOST_EXTRACFLAGS += -DLOCALE
PHONY += dochecklxdialog
$(obj)/dochecklxdialog:
$(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES)
hostprogs-y := lxdialog
always := $(hostprogs-y) dochecklxdialog
lxdialog-objs := checklist.o menubox.o textbox.o yesno.o inputbox.o \
util.o lxdialog.o msgbox.o
This diff is collapsed.
/*
* colors.h -- color attribute definitions
*
* AUTHOR: Savio Lam ([email protected])
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/*
* Default color definitions
*
* *_FG = foreground
* *_BG = background
* *_HL = highlight?
*/
#define SCREEN_FG COLOR_CYAN
#define SCREEN_BG COLOR_BLUE
#define SCREEN_HL TRUE
#define SHADOW_FG COLOR_BLACK
#define SHADOW_BG COLOR_BLACK
#define SHADOW_HL TRUE
#define DIALOG_FG COLOR_BLACK
#define DIALOG_BG COLOR_WHITE
#define DIALOG_HL FALSE
#define TITLE_FG COLOR_YELLOW
#define TITLE_BG COLOR_WHITE
#define TITLE_HL TRUE
#define BORDER_FG COLOR_WHITE
#define BORDER_BG COLOR_WHITE
#define BORDER_HL TRUE
#define BUTTON_ACTIVE_FG COLOR_WHITE
#define BUTTON_ACTIVE_BG COLOR_BLUE
#define BUTTON_ACTIVE_HL TRUE
#define BUTTON_INACTIVE_FG COLOR_BLACK
#define BUTTON_INACTIVE_BG COLOR_WHITE
#define BUTTON_INACTIVE_HL FALSE
#define BUTTON_KEY_ACTIVE_FG COLOR_WHITE
#define BUTTON_KEY_ACTIVE_BG COLOR_BLUE
#define BUTTON_KEY_ACTIVE_HL TRUE
#define BUTTON_KEY_INACTIVE_FG COLOR_RED
#define BUTTON_KEY_INACTIVE_BG COLOR_WHITE
#define BUTTON_KEY_INACTIVE_HL FALSE
#define BUTTON_LABEL_ACTIVE_FG COLOR_YELLOW
#define BUTTON_LABEL_ACTIVE_BG COLOR_BLUE
#define BUTTON_LABEL_ACTIVE_HL TRUE
#define BUTTON_LABEL_INACTIVE_FG COLOR_BLACK
#define BUTTON_LABEL_INACTIVE_BG COLOR_WHITE
#define BUTTON_LABEL_INACTIVE_HL TRUE
#define INPUTBOX_FG COLOR_BLACK
#define INPUTBOX_BG COLOR_WHITE
#define INPUTBOX_HL FALSE
#define INPUTBOX_BORDER_FG COLOR_BLACK
#define INPUTBOX_BORDER_BG COLOR_WHITE
#define INPUTBOX_BORDER_HL FALSE
#define SEARCHBOX_FG COLOR_BLACK
#define SEARCHBOX_BG COLOR_WHITE
#define SEARCHBOX_HL FALSE
#define SEARCHBOX_TITLE_FG COLOR_YELLOW
#define SEARCHBOX_TITLE_BG COLOR_WHITE
#define SEARCHBOX_TITLE_HL TRUE
#define SEARCHBOX_BORDER_FG COLOR_WHITE
#define SEARCHBOX_BORDER_BG COLOR_WHITE
#define SEARCHBOX_BORDER_HL TRUE
#define POSITION_INDICATOR_FG COLOR_YELLOW
#define POSITION_INDICATOR_BG COLOR_WHITE
#define POSITION_INDICATOR_HL TRUE
#define MENUBOX_FG COLOR_BLACK
#define MENUBOX_BG COLOR_WHITE
#define MENUBOX_HL FALSE
#define MENUBOX_BORDER_FG COLOR_WHITE
#define MENUBOX_BORDER_BG COLOR_WHITE
#define MENUBOX_BORDER_HL TRUE
#define ITEM_FG COLOR_BLACK
#define ITEM_BG COLOR_WHITE
#define ITEM_HL FALSE
#define ITEM_SELECTED_FG COLOR_WHITE
#define ITEM_SELECTED_BG COLOR_BLUE
#define ITEM_SELECTED_HL TRUE
#define TAG_FG COLOR_YELLOW
#define TAG_BG COLOR_WHITE
#define TAG_HL TRUE
#define TAG_SELECTED_FG COLOR_YELLOW
#define TAG_SELECTED_BG COLOR_BLUE
#define TAG_SELECTED_HL TRUE
#define TAG_KEY_FG COLOR_YELLOW
#define TAG_KEY_BG COLOR_WHITE
#define TAG_KEY_HL TRUE
#define TAG_KEY_SELECTED_FG COLOR_YELLOW
#define TAG_KEY_SELECTED_BG COLOR_BLUE
#define TAG_KEY_SELECTED_HL TRUE
#define CHECK_FG COLOR_BLACK
#define CHECK_BG COLOR_WHITE
#define CHECK_HL FALSE
#define CHECK_SELECTED_FG COLOR_WHITE
#define CHECK_SELECTED_BG COLOR_BLUE
#define CHECK_SELECTED_HL TRUE
#define UARROW_FG COLOR_GREEN
#define UARROW_BG COLOR_WHITE
#define UARROW_HL TRUE
#define DARROW_FG COLOR_GREEN
#define DARROW_BG COLOR_WHITE
#define DARROW_HL TRUE
/* End of default color definitions */
#define C_ATTR(x,y) ((x ? A_BOLD : 0) | COLOR_PAIR((y)))
#define COLOR_NAME_LEN 10
#define COLOR_COUNT 8
/*
* Global variables
*/
extern int color_table[][3];
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
#define TR(params) _tracef params #define TR(params) _tracef params
#define ESC 27 #define KEY_ESC 27
#define TAB 9 #define TAB 9
#define MAX_LEN 2048 #define MAX_LEN 2048
#define BUF_SIZE (10*1024) #define BUF_SIZE (10*1024)
...@@ -86,63 +86,111 @@ ...@@ -86,63 +86,111 @@
#define ACS_DARROW 'v' #define ACS_DARROW 'v'
#endif #endif
/* error return codes */
#define ERRDISPLAYTOOSMALL (KEY_MAX + 1)
/* /*
* Attribute names * Color definitions
*/ */
#define screen_attr attributes[0] struct dialog_color {
#define shadow_attr attributes[1] chtype atr; /* Color attribute */
#define dialog_attr attributes[2] int fg; /* foreground */
#define title_attr attributes[3] int bg; /* background */
#define border_attr attributes[4] int hl; /* highlight this item */
#define button_active_attr attributes[5] };
#define button_inactive_attr attributes[6]
#define button_key_active_attr attributes[7] struct dialog_info {
#define button_key_inactive_attr attributes[8] const char *backtitle;
#define button_label_active_attr attributes[9] struct dialog_color screen;
#define button_label_inactive_attr attributes[10] struct dialog_color shadow;
#define inputbox_attr attributes[11] struct dialog_color dialog;
#define inputbox_border_attr attributes[12] struct dialog_color title;
#define searchbox_attr attributes[13] struct dialog_color border;
#define searchbox_title_attr attributes[14] struct dialog_color button_active;
#define searchbox_border_attr attributes[15] struct dialog_color button_inactive;
#define position_indicator_attr attributes[16] struct dialog_color button_key_active;
#define menubox_attr attributes[17] struct dialog_color button_key_inactive;
#define menubox_border_attr attributes[18] struct dialog_color button_label_active;
#define item_attr attributes[19] struct dialog_color button_label_inactive;
#define item_selected_attr attributes[20] struct dialog_color inputbox;
#define tag_attr attributes[21] struct dialog_color inputbox_border;
#define tag_selected_attr attributes[22] struct dialog_color searchbox;
#define tag_key_attr attributes[23] struct dialog_color searchbox_title;
#define tag_key_selected_attr attributes[24] struct dialog_color searchbox_border;
#define check_attr attributes[25] struct dialog_color position_indicator;
#define check_selected_attr attributes[26] struct dialog_color menubox;
#define uarrow_attr attributes[27] struct dialog_color menubox_border;
#define darrow_attr attributes[28] struct dialog_color item;
struct dialog_color item_selected;
/* number of attributes */ struct dialog_color tag;
#define ATTRIBUTE_COUNT 29 struct dialog_color tag_selected;
struct dialog_color tag_key;
struct dialog_color tag_key_selected;
struct dialog_color check;
struct dialog_color check_selected;
struct dialog_color uarrow;
struct dialog_color darrow;
};
/* /*
* Global variables * Global variables
*/ */
extern bool use_colors; extern struct dialog_info dlg;
extern bool use_shadow; extern char dialog_input_result[];
extern chtype attributes[];
extern const char *backtitle;
/* /*
* Function prototypes * Function prototypes
*/ */
extern void create_rc(const char *filename);
extern int parse_rc(void);
void init_dialog(void); /* item list as used by checklist and menubox */
void item_reset(void);
void item_make(const char *fmt, ...);
void item_add_str(const char *fmt, ...);
void item_set_tag(char tag);
void item_set_data(void *p);
void item_set_selected(int val);
int item_activate_selected(void);
void *item_data(void);
char item_tag(void);
/* item list manipulation for lxdialog use */
#define MAXITEMSTR 200
struct dialog_item {
char str[MAXITEMSTR]; /* promtp displayed */
char tag;
void *data; /* pointer to menu item - used by menubox+checklist */
int selected; /* Set to 1 by dialog_*() function if selected. */
};
/* list of lialog_items */
struct dialog_list {
struct dialog_item node;
struct dialog_list *next;
};
extern struct dialog_list *item_cur;
extern struct dialog_list item_nil;
extern struct dialog_list *item_head;
int item_count(void);
void item_set(int n);
int item_n(void);
const char *item_str(void);
int item_is_selected(void);
int item_is_tag(char tag);
#define item_foreach() \
for (item_cur = item_head ? item_head: item_cur; \
item_cur && (item_cur != &item_nil); item_cur = item_cur->next)
/* generic key handlers */
int on_key_esc(WINDOW *win);
int on_key_resize(void);
void init_dialog(const char *backtitle);
void reset_dialog(void);
void end_dialog(void); 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 color_setup(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);
void print_button(WINDOW * win, const char *label, int y, int x, int selected); void print_button(WINDOW * win, const char *label, int y, int x, int selected);
void print_title(WINDOW *dialog, const char *title, int width); void print_title(WINDOW *dialog, const char *title, int width);
...@@ -155,12 +203,10 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width); ...@@ -155,12 +203,10 @@ int dialog_yesno(const char *title, const char *prompt, int height, int width);
int dialog_msgbox(const char *title, const char *prompt, int height, int dialog_msgbox(const char *title, const char *prompt, int height,
int width, int pause); int width, int pause);
int dialog_textbox(const char *title, const char *file, int height, int width); int dialog_textbox(const char *title, const char *file, int height, int width);
int dialog_menu(const char *title, const char *prompt, int height, int width, int dialog_menu(const char *title, const char *prompt,
int menu_height, const char *choice, int item_no, const void *selected, int *s_scroll);
const char *const *items);
int dialog_checklist(const char *title, const char *prompt, int height, int dialog_checklist(const char *title, const char *prompt, int height,
int width, int list_height, int item_no, int width, int list_height);
const char *const *items);
extern char dialog_input_result[]; extern char dialog_input_result[];
int dialog_inputbox(const char *title, const char *prompt, int height, int dialog_inputbox(const char *title, const char *prompt, int height,
int width, const char *init); int width, const char *init);
......
...@@ -49,6 +49,17 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width ...@@ -49,6 +49,17 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
char *instr = dialog_input_result; char *instr = dialog_input_result;
WINDOW *dialog; WINDOW *dialog;
if (!init)
instr[0] = '\0';
else
strcpy(instr, init);
do_resize:
if (getmaxy(stdscr) <= (height - 2))
return -ERRDISPLAYTOOSMALL;
if (getmaxx(stdscr) <= (width - 2))
return -ERRDISPLAYTOOSMALL;
/* center dialog box on screen */ /* center dialog box on screen */
x = (COLS - width) / 2; x = (COLS - width) / 2;
y = (LINES - height) / 2; y = (LINES - height) / 2;
...@@ -58,17 +69,18 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width ...@@ -58,17 +69,18 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
dialog = newwin(height, width, y, x); dialog = newwin(height, width, y, x);
keypad(dialog, TRUE); keypad(dialog, TRUE);
draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr); draw_box(dialog, 0, 0, height, width,
wattrset(dialog, border_attr); dlg.dialog.atr, dlg.border.atr);
wattrset(dialog, dlg.border.atr);
mvwaddch(dialog, height - 3, 0, ACS_LTEE); mvwaddch(dialog, height - 3, 0, ACS_LTEE);
for (i = 0; i < width - 2; i++) for (i = 0; i < width - 2; i++)
waddch(dialog, ACS_HLINE); waddch(dialog, ACS_HLINE);
wattrset(dialog, dialog_attr); wattrset(dialog, dlg.dialog.atr);
waddch(dialog, ACS_RTEE); waddch(dialog, ACS_RTEE);
print_title(dialog, title, width); print_title(dialog, title, width);
wattrset(dialog, dialog_attr); wattrset(dialog, dlg.dialog.atr);
print_autowrap(dialog, prompt, width - 2, 1, 3); print_autowrap(dialog, prompt, width - 2, 1, 3);
/* Draw the input field box */ /* Draw the input field box */
...@@ -76,18 +88,14 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width ...@@ -76,18 +88,14 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
getyx(dialog, y, x); getyx(dialog, y, x);
box_y = y + 2; box_y = y + 2;
box_x = (width - box_width) / 2; box_x = (width - box_width) / 2;
draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2, border_attr, dialog_attr); draw_box(dialog, y + 1, box_x - 1, 3, box_width + 2,
dlg.border.atr, dlg.dialog.atr);
print_buttons(dialog, height, width, 0); print_buttons(dialog, height, width, 0);
/* Set up the initial value */ /* Set up the initial value */
wmove(dialog, box_y, box_x); wmove(dialog, box_y, box_x);
wattrset(dialog, inputbox_attr); wattrset(dialog, dlg.inputbox.atr);
if (!init)
instr[0] = '\0';
else
strcpy(instr, init);
input_x = strlen(instr); input_x = strlen(instr);
...@@ -104,7 +112,7 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width ...@@ -104,7 +112,7 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
wrefresh(dialog); wrefresh(dialog);
while (key != ESC) { while (key != KEY_ESC) {
key = wgetch(dialog); key = wgetch(dialog);
if (button == -1) { /* Input box selected */ if (button == -1) { /* Input box selected */
...@@ -120,7 +128,7 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width ...@@ -120,7 +128,7 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
case KEY_BACKSPACE: case KEY_BACKSPACE:
case 127: case 127:
if (input_x || scroll) { if (input_x || scroll) {
wattrset(dialog, inputbox_attr); wattrset(dialog, dlg.inputbox.atr);
if (!input_x) { if (!input_x) {
scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1); scroll = scroll < box_width - 1 ? 0 : scroll - (box_width - 1);
wmove(dialog, box_y, box_x); wmove(dialog, box_y, box_x);
...@@ -140,7 +148,7 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width ...@@ -140,7 +148,7 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
default: default:
if (key < 0x100 && isprint(key)) { if (key < 0x100 && isprint(key)) {
if (scroll + input_x < MAX_LEN) { if (scroll + input_x < MAX_LEN) {
wattrset(dialog, inputbox_attr); wattrset(dialog, dlg.inputbox.atr);
instr[scroll + input_x] = key; instr[scroll + input_x] = key;
instr[scroll + input_x + 1] = '\0'; instr[scroll + input_x + 1] = '\0';
if (input_x == box_width - 1) { if (input_x == box_width - 1) {
...@@ -213,12 +221,18 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width ...@@ -213,12 +221,18 @@ int dialog_inputbox(const char *title, const char *prompt, int height, int width
return (button == -1 ? 0 : button); return (button == -1 ? 0 : button);
case 'X': case 'X':
case 'x': case 'x':
key = ESC; key = KEY_ESC;
case ESC: break;
case KEY_ESC:
key = on_key_esc(dialog);
break; break;
case KEY_RESIZE:
delwin(dialog);
on_key_resize();
goto do_resize;
} }
} }
delwin(dialog); delwin(dialog);
return -1; /* ESC pressed */ return KEY_ESC; /* ESC pressed */
}