diff mbox

[remarks,2/4] menuconfig: allow editing of remarks for config symbols

Message ID 4ae8cdd5.0d1abc0a.0bd6.3d1f@mx.google.com (mailing list archive)
State New, archived
Headers show

Commit Message

Bernhard Kaindl Oct. 28, 2009, 10:53 p.m. UTC
None
diff mbox

Patch

diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c
index fa9d633..6b6bc48 100644
--- a/scripts/kconfig/lxdialog/menubox.c
+++ b/scripts/kconfig/lxdialog/menubox.c
@@ -383,6 +383,7 @@  do_resize:
 		case 'n':
 		case 'm':
 		case '/':
+		case '<':
 			/* save scroll info */
 			*s_scroll = scroll;
 			delwin(menu);
@@ -402,6 +403,8 @@  do_resize:
 				return 6;
 			case '/':
 				return 7;
+			case '<':
+				return 8;
 			}
 			return 0;
 		case 'h':
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index d829535..50a9b10 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -276,6 +276,7 @@  static int single_menu_mode;
 static void conf(struct menu *menu);
 static void conf_choice(struct menu *menu);
 static void conf_string(struct menu *menu);
+static void conf_remark(struct menu *menu);
 static void conf_load(void);
 static void conf_save(void);
 static void show_textbox(const char *title, const char *text, int r, int c);
@@ -619,6 +620,9 @@  static void conf(struct menu *menu)
 		case 7:
 			search_conf();
 			break;
+		case 8:
+			conf_remark(submenu);
+			break;
 		}
 	}
 }
@@ -743,6 +747,53 @@  static void conf_string(struct menu *menu)
 	}
 }
 
+/**
+ * Based on conf_string(), this edits the remark for a config symbol
+ */
+static void conf_remark(struct menu *menu)
+{
+	const char *prompt = menu_get_prompt(menu);
+
+	if (!prompt || !menu->sym) {
+		show_textbox(NULL,
+			N_("Editing comments for menus without a config symbol\n"
+				"is currently not supported."), 6, 63);
+		return;
+	}
+
+	while (1) {
+		int res;
+		dialog_clear();
+		res = dialog_inputbox(prompt ? _(prompt) : _("Main Menu"),
+				      _("Edit the remark below"), 10, 75,
+				      menu->sym->remark);
+		switch (res) {
+		case 0:
+			if (!dialog_input_result[0] && !menu->sym->remark)
+				return;
+			if (menu->sym->remark) {
+				if (!strcmp(menu->sym->remark, dialog_input_result))
+					return;
+				free(menu->sym->remark);
+			}
+			if (dialog_input_result[0]) {
+				menu->sym->remark = strdup(dialog_input_result);
+			} else {
+				menu->sym->remark = NULL;
+			}
+			/* Write new .config{,-remarks} on exit: */
+			sym_add_change_count(1);
+			sym_clear_all_valid();
+			return;
+		case 1:
+			show_help(menu);
+			break;
+		case KEY_ESC:
+			return;
+		}
+	}
+}
+
 static void conf_load(void)
 {