ref: 388e7781c24cbdb2299607d47472f7741cc5f80f
parent: 86ef52682cc59db2543e31036e5f80f0ea58d785
author: stanley lieber <[email protected]>
date: Tue Sep 27 08:54:39 EDT 2011
mothra: add menu option to save url
--- a/sys/man/1/mothra
+++ b/sys/man/1/mothra
@@ -91,6 +91,10 @@
.B paste
Paste the current snarf buffer at the current cursor position.
.TP
+.B save url
+Save the currently selected URL as a file. Directory indexes are saved in a file named
+.I index.
+.TP
.B save hit
Save the current URL to the hit list.
.TP
--- a/sys/src/cmd/mothra/mothra.c
+++ b/sys/src/cmd/mothra/mothra.c
@@ -92,6 +92,7 @@
"alt display",
"snarf url",
"paste",
+ "save url",
"save hit",
"hit list",
"exit",
@@ -1048,6 +1049,7 @@
}
void hit3(int button, int item){
char name[NNAME];
+ char file[128];
Panel *swap;
int fd;
USED(button);
@@ -1073,6 +1075,16 @@
paste(cmd);
break;
case 3:
+ if(strrchr(selection->reltext, '/')){
+ snprint(file, sizeof(file), "%s", strrchr(selection->reltext, '/')+1);
+ if(file[0]==0)
+ strcpy(file, "index");
+ } else
+ snprint(file, sizeof(file), "%s", selection->reltext);
+ save(selection, file);
+ message("saved %s", file);
+ break;
+ case 4:
snprint(name, sizeof(name), "%s/hit.html", home);
fd=open(name, OWRITE);
if(fd==-1){
@@ -1089,11 +1101,11 @@
selection->fullname, selection->fullname);
close(fd);
break;
- case 4:
+ case 5:
snprint(name, sizeof(name), "file:%s/hit.html", home);
geturl(name, GET, 0, 1, 0);
break;
- case 5:
+ case 6:
if(confirm(3)){
draw(screen, screen->r, display->white, 0, ZP);
exits(0);