shithub: vexed

Download patch

ref: 864748af0fa9ad18dd5b94fe36962d7706763d1b
parent: cd2bda88b9173d7c238710c11f7f6ceb2abd8cfb
author: phil9 <[email protected]>
date: Fri Sep 23 09:49:40 EDT 2022

add 's' shortcut to save file (thanks grimmware)

--- a/README.md
+++ b/README.md
@@ -12,6 +12,7 @@
 `x` deletes the currently selected byte.  
 `u` undo last edit.  
 `r` redo last undo'ed edit.  
+`s` save file.  
 `l` look for a byte sequence within the file.  
 `n` go to next matching occurence of looked sequence.  
 `?` show the decode window that displays bytes as numbers of various sizes.  
--- a/vexed.c
+++ b/vexed.c
@@ -310,6 +310,17 @@
 		search(0);
 }
 
+void
+save(void)
+{
+	if(!modified)
+		return;
+	if(writefile(&buf, filename) < 0)
+		sysfatal("writefile: %r");
+	modified = 0;
+	redraw();
+}
+
 int
 selvisible(void)
 {
@@ -542,12 +553,7 @@
 	n = menuhit(3, mctl, &menu3, nil);
 	switch(n){
 	case Msave:
-		if(!modified)
-			return;
-		if(writefile(&buf, filename) < 0)
-			sysfatal("writefile: %r");
-		modified = 0;
-		redraw();
+		save();
 		break;
 	case Mquit:
 		threadexitsall(nil);
@@ -714,6 +720,10 @@
 	case 'n':
 	case 'N':
 		xnext();
+		break;
+	case 's':
+	case 'S':
+		save();
 		break;
 	case '?':
 		showdec(&buf, sel, mctl, kctl);