mothra: add menu option to save url

This commit is contained in:
stanley lieber 2011-09-27 12:54:39 -05:00
parent 86ef52682c
commit 388e7781c2
2 changed files with 18 additions and 2 deletions

View file

@ -91,6 +91,10 @@ Copy the current URL to the snarf buffer.
.B paste .B paste
Paste the current snarf buffer at the current cursor position. Paste the current snarf buffer at the current cursor position.
.TP .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 .B save hit
Save the current URL to the hit list. Save the current URL to the hit list.
.TP .TP

View file

@ -92,6 +92,7 @@ char *buttons[]={
"alt display", "alt display",
"snarf url", "snarf url",
"paste", "paste",
"save url",
"save hit", "save hit",
"hit list", "hit list",
"exit", "exit",
@ -1048,6 +1049,7 @@ void paste(Panel *p){
} }
void hit3(int button, int item){ void hit3(int button, int item){
char name[NNAME]; char name[NNAME];
char file[128];
Panel *swap; Panel *swap;
int fd; int fd;
USED(button); USED(button);
@ -1073,6 +1075,16 @@ void hit3(int button, int item){
paste(cmd); paste(cmd);
break; break;
case 3: 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); snprint(name, sizeof(name), "%s/hit.html", home);
fd=open(name, OWRITE); fd=open(name, OWRITE);
if(fd==-1){ if(fd==-1){
@ -1089,11 +1101,11 @@ void hit3(int button, int item){
selection->fullname, selection->fullname); selection->fullname, selection->fullname);
close(fd); close(fd);
break; break;
case 4: case 5:
snprint(name, sizeof(name), "file:%s/hit.html", home); snprint(name, sizeof(name), "file:%s/hit.html", home);
geturl(name, GET, 0, 1, 0); geturl(name, GET, 0, 1, 0);
break; break;
case 5: case 6:
if(confirm(3)){ if(confirm(3)){
draw(screen, screen->r, display->white, 0, ZP); draw(screen, screen->r, display->white, 0, ZP);
exits(0); exits(0);