bsdinstaller / partedit emacs key patch

From: Daniel O'Connor <doconnor_at_gsoft.com.au>
Date: Wed, 30 Mar 2011 12:20:26 +1030
Hi,
I noticed that the entry widgets in the bsdinstaller label editor don't understand various "emacs keys" (eg C-a, C-d, C-e). 

Here's a patch which adds the basics.. Unfortunately dialog doesn't have a "key" for delete all, delete left or delete right so I couldn't add C-u, C-w or C-k.

Note that you can't just call dlg_parse_bindkey("* ^a BEGIN") because dialog modifies the string which crashes (seg fault).

--- partedit.c.orig	2011-03-30 01:41:20.000000000 +0000
+++ partedit.c	2011-03-30 01:47:06.000000000 +0000
_at__at_ -50,6 +50,13 _at__at_
 static void get_mount_points(struct partedit_item *items, int nitems);
 static int validate_setup(void);
 
+static char *bindings[] = {
+	"* ^a BEGIN",
+	"* ^d DELETE_RIGHT",
+	"* ^e FINAL",
+	NULL
+};
+
 int
 main(int argc, const char **argv) {
 	struct partition_metadata *md;
_at__at_ -58,12 +65,18 _at__at_
 	struct gmesh mesh;
 	int i, op, nitems, nscroll;
 	int error;
+	char tmp[80];
 
 	TAILQ_INIT(&part_metadata);
 
 	init_fstab_metadata();
 
 	init_dialog(stdin, stdout);
+	
+	for (i = 0; bindings[i] != NULL; i++) {
+		*stpncpy(tmp,  bindings[i], sizeof(tmp) - 1) = 0;
+		dlg_parse_bindkey(tmp);
+	}
 
 	if (strcmp(basename(argv[0]), "sade") != 0)
 		dialog_vars.backtitle = __DECONST(char *, "FreeBSD Installer");


--
Daniel O'Connor software and network engineer
for Genesis Software - http://www.gsoft.com.au
"The nice thing about standards is that there
are so many of them to choose from."
  -- Andrew Tanenbaum
GPG Fingerprint - 5596 B766 97C0 0E94 4347 295E E593 DC20 7B3F CE8C
Received on Tue Mar 29 2011 - 23:50:31 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:12 UTC