Commit 692d97c3 authored by nir.tzachar@gmail.com's avatar nir.tzachar@gmail.com Committed by Michal Marek

kconfig: new configuration interface (nconfig)

This patch was inspired by the kernel projects page, where an ncurses
replacement for menuconfig was mentioned (by Sam Ravnborg).

Building on menuconfig, this patch implements a more modern look
interface using ncurses and ncurses' satellite libraries (menu, panel,
form). The implementation does not depend on lxdialog, which is
currently distributed with the kernel.
Signed-off-by: default avatarNir Tzachar <nir.tzachar@gmail.com>
Signed-off-by: default avatarMichal Marek <mmarek@suse.cz>
parent c64152bf
...@@ -23,6 +23,9 @@ menuconfig: $(obj)/mconf ...@@ -23,6 +23,9 @@ menuconfig: $(obj)/mconf
config: $(obj)/conf config: $(obj)/conf
$< $(Kconfig) $< $(Kconfig)
nconfig: $(obj)/nconf
$< $(Kconfig)
oldconfig: $(obj)/conf oldconfig: $(obj)/conf
$< -o $(Kconfig) $< -o $(Kconfig)
...@@ -110,6 +113,7 @@ endif ...@@ -110,6 +113,7 @@ endif
# Help text used by make help # Help text used by make help
help: help:
@echo ' config - Update current config utilising a line-oriented program' @echo ' config - Update current config utilising a line-oriented program'
@echo ' nconfig - Update current config utilising a ncurses menu based program'
@echo ' menuconfig - Update current config utilising a menu based program' @echo ' menuconfig - Update current config utilising a menu based program'
@echo ' xconfig - Update current config utilising a QT based front-end' @echo ' xconfig - Update current config utilising a QT based front-end'
@echo ' gconfig - Update current config utilising a GTK based front-end' @echo ' gconfig - Update current config utilising a GTK based front-end'
...@@ -137,6 +141,8 @@ HOST_EXTRACFLAGS += -DLOCALE ...@@ -137,6 +141,8 @@ HOST_EXTRACFLAGS += -DLOCALE
# =========================================================================== # ===========================================================================
# 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
# nconf: Used for the nconfig target.
# Utilizes ncurses
# mconf: Used for the menuconfig target # mconf: Used for the menuconfig target
# Utilizes the lxdialog package # Utilizes the lxdialog package
# qconf: Used for the xconfig target # qconf: Used for the xconfig target
...@@ -149,11 +155,16 @@ lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o ...@@ -149,11 +155,16 @@ lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o
lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.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 $(lxdialog) mconf-objs := mconf.o zconf.tab.o $(lxdialog)
nconf-objs := nconf.o zconf.tab.o nconf.gui.o
kxgettext-objs := kxgettext.o zconf.tab.o kxgettext-objs := kxgettext.o zconf.tab.o
hostprogs-y := conf qconf gconf kxgettext hostprogs-y := conf qconf gconf kxgettext
ifeq ($(MAKECMDGOALS),nconfig)
hostprogs-y += nconf
endif
ifeq ($(MAKECMDGOALS),menuconfig) ifeq ($(MAKECMDGOALS),menuconfig)
hostprogs-y += mconf hostprogs-y += mconf
endif endif
...@@ -177,7 +188,7 @@ endif ...@@ -177,7 +188,7 @@ 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 gconf.glade.h .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c gconf.glade.h
clean-files += mconf qconf gconf clean-files += mconf qconf gconf nconf
clean-files += config.pot linux.pot clean-files += config.pot linux.pot
# Check that we have the required ncurses stuff installed for lxdialog (menuconfig) # Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
...@@ -202,6 +213,7 @@ HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0` ...@@ -202,6 +213,7 @@ HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0`
HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \ HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
-D LKC_DIRECT_LINK -D LKC_DIRECT_LINK
HOSTLOADLIBES_nconf = -lmenu -lpanel -lncurses
$(obj)/qconf.o: $(obj)/.tmp_qtcheck $(obj)/qconf.o: $(obj)/.tmp_qtcheck
ifeq ($(qconf-target),1) ifeq ($(qconf-target),1)
......
...@@ -84,7 +84,7 @@ void conf_set_all_new_symbols(enum conf_def_mode mode); ...@@ -84,7 +84,7 @@ void conf_set_all_new_symbols(enum conf_def_mode mode);
void kconfig_load(void); void kconfig_load(void);
/* menu.c */ /* menu.c */
void menu_init(void); void _menu_init(void);
void menu_warn(struct menu *menu, const char *fmt, ...); void menu_warn(struct menu *menu, const char *fmt, ...);
struct menu *menu_add_menu(void); struct menu *menu_add_menu(void);
void menu_end_menu(void); void menu_end_menu(void);
......
...@@ -17,7 +17,8 @@ P(menu_get_root_menu,struct menu *,(struct menu *menu)); ...@@ -17,7 +17,8 @@ P(menu_get_root_menu,struct menu *,(struct menu *menu));
P(menu_get_parent_menu,struct menu *,(struct menu *menu)); P(menu_get_parent_menu,struct menu *,(struct menu *menu));
P(menu_has_help,bool,(struct menu *menu)); P(menu_has_help,bool,(struct menu *menu));
P(menu_get_help,const char *,(struct menu *menu)); P(menu_get_help,const char *,(struct menu *menu));
P(get_symbol_str,void,(struct gstr *r, struct symbol *sym)); P(get_symbol_str, void, (struct gstr *r, struct symbol *sym));
P(get_relations_str, struct gstr, (struct symbol **sym_arr));
P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help)); P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help));
/* symbol.c */ /* symbol.c */
......
...@@ -282,19 +282,6 @@ static void show_textbox(const char *title, const char *text, int r, int c); ...@@ -282,19 +282,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 struct gstr get_relations_str(struct symbol **sym_arr)
{
struct symbol *sym;
struct gstr res = str_new();
int i;
for (i = 0; sym_arr && (sym = sym_arr[i]); i++)
get_symbol_str(&res, sym);
if (!i)
str_append(&res, _("No matches found.\n"));
return res;
}
static char filename[PATH_MAX+1]; static char filename[PATH_MAX+1];
static void set_config_filename(const char *config_filename) static void set_config_filename(const char *config_filename)
{ {
......
...@@ -38,7 +38,7 @@ static void prop_warn(struct property *prop, const char *fmt, ...) ...@@ -38,7 +38,7 @@ static void prop_warn(struct property *prop, const char *fmt, ...)
va_end(ap); va_end(ap);
} }
void menu_init(void) void _menu_init(void)
{ {
current_entry = current_menu = &rootmenu; current_entry = current_menu = &rootmenu;
last_entry_ptr = &rootmenu.list; last_entry_ptr = &rootmenu.list;
...@@ -515,6 +515,20 @@ void get_symbol_str(struct gstr *r, struct symbol *sym) ...@@ -515,6 +515,20 @@ void get_symbol_str(struct gstr *r, struct symbol *sym)
str_append(r, "\n\n"); str_append(r, "\n\n");
} }
struct gstr get_relations_str(struct symbol **sym_arr)
{
struct symbol *sym;
struct gstr res = str_new();
int i;
for (i = 0; sym_arr && (sym = sym_arr[i]); i++)
get_symbol_str(&res, sym);
if (!i)
str_append(&res, _("No matches found.\n"));
return res;
}
void menu_get_ext_help(struct menu *menu, struct gstr *help) void menu_get_ext_help(struct menu *menu, struct gstr *help)
{ {
struct symbol *sym = menu->sym; struct symbol *sym = menu->sym;
......
This diff is collapsed.
This diff is collapsed.
/*
* Copyright (C) 2008 Nir Tzachar <nir.tzachar@gmail.com?
* Released under the terms of the GNU GPL v2.0.
*
* Derived from menuconfig.
*
*/
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <locale.h>
#include <curses.h>
#include <menu.h>
#include <panel.h>
#include <form.h>
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
#include "ncurses.h"
#define max(a, b) ({\
typeof(a) _a = a;\
typeof(b) _b = b;\
_a > _b ? _a : _b; })
#define min(a, b) ({\
typeof(a) _a = a;\
typeof(b) _b = b;\
_a < _b ? _a : _b; })
typedef enum {
NORMAL = 1,
MAIN_HEADING,
MAIN_MENU_BOX,
MAIN_MENU_FORE,
MAIN_MENU_BACK,
MAIN_MENU_GREY,
MAIN_MENU_HEADING,
SCROLLWIN_TEXT,
SCROLLWIN_HEADING,
SCROLLWIN_BOX,
DIALOG_TEXT,
DIALOG_MENU_FORE,
DIALOG_MENU_BACK,
DIALOG_BOX,
INPUT_BOX,
INPUT_HEADING,
INPUT_TEXT,
INPUT_FIELD,
FUNCTION_TEXT,
FUNCTION_HIGHLIGHT,
ATTR_MAX
} attributes_t;
extern attributes_t attributes[];
typedef enum {
F_HELP = 1,
F_SYMBOL = 2,
F_INSTS = 3,
F_CONF = 4,
F_BACK = 5,
F_SAVE = 6,
F_LOAD = 7,
F_EXIT = 8
} function_key;
void set_colors(void);
/* this changes the windows attributes !!! */
void print_in_middle(WINDOW *win,
int starty,
int startx,
int width,
const char *string,
chtype color);
int get_line_length(const char *line);
int get_line_no(const char *text);
const char *get_line(const char *text, int line_no);
void fill_window(WINDOW *win, const char *text);
int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...);
int dialog_inputbox(WINDOW *main_window,
const char *title, const char *prompt,
const char *init, char *result, int result_len);
void refresh_all_windows(WINDOW *main_window);
void show_scroll_win(WINDOW *main_window,
const char *title,
const char *text);
...@@ -2220,7 +2220,7 @@ void conf_parse(const char *name) ...@@ -2220,7 +2220,7 @@ void conf_parse(const char *name)
zconf_initscan(name); zconf_initscan(name);
sym_init(); sym_init();
menu_init(); _menu_init();
modules_sym = sym_lookup(NULL, 0); modules_sym = sym_lookup(NULL, 0);
modules_sym->type = S_BOOLEAN; modules_sym->type = S_BOOLEAN;
modules_sym->flags |= SYMBOL_AUTO; modules_sym->flags |= SYMBOL_AUTO;
......
...@@ -475,7 +475,7 @@ void conf_parse(const char *name) ...@@ -475,7 +475,7 @@ void conf_parse(const char *name)
zconf_initscan(name); zconf_initscan(name);
sym_init(); sym_init();
menu_init(); _menu_init();
modules_sym = sym_lookup(NULL, 0); modules_sym = sym_lookup(NULL, 0);
modules_sym->type = S_BOOLEAN; modules_sym->type = S_BOOLEAN;
modules_sym->flags |= SYMBOL_AUTO; modules_sym->flags |= SYMBOL_AUTO;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment