summaryrefslogtreecommitdiff
path: root/sys/src/cmd/mothra/mothra.c
diff options
context:
space:
mode:
author23hiro <23hiro@gmail.com>2018-06-27 19:20:28 +0200
committer23hiro <23hiro@gmail.com>2018-06-27 19:20:28 +0200
commit2f1b8246e23f8d3e88885822efcf25f3b4474bff (patch)
treeb815f509ffdbd10c565a9b2edf74fc2d79dc749f /sys/src/cmd/mothra/mothra.c
parent902eceee63f5132f315db1a15ecce95af51359df (diff)
Persist 'k' command in mothra and add matching -k flag (thanks piroko)
"I sometimes find myself on either slow or data-capped network links where downloading images isn't ideal. Attached is a simple patch to mothra that changes the 'k' command to not only remove already-downloaded images from a page, but also toggle a state such that mothra won't attempt to download images on future visited sites until 'k' is toggled again. This also adds a '-k' flag to mothra which enables the flag at startup." --Jeremy O'Brien<neutral@fastmail.com> on 9fans
Diffstat (limited to 'sys/src/cmd/mothra/mothra.c')
-rw-r--r--sys/src/cmd/mothra/mothra.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/sys/src/cmd/mothra/mothra.c b/sys/src/cmd/mothra/mothra.c
index 5d7c57f40..165e65620 100644
--- a/sys/src/cmd/mothra/mothra.c
+++ b/sys/src/cmd/mothra/mothra.c
@@ -14,6 +14,7 @@
#include "rtext.h"
int debug=0;
int verbose=0; /* -v flag causes html errors to be written to file-descriptor 2 */
+int killimgs=0; /* should mothra kill images? */
int defdisplay=1; /* is the default (initial) display visible? */
int visxbar=0; /* horizontal scrollbar visible? */
int topxbar=0; /* horizontal scrollbar at top? */
@@ -306,6 +307,7 @@ void main(int argc, char *argv[]){
ARGBEGIN{
case 'd': debug=1; break;
case 'v': verbose=1; break;
+ case 'k': killimgs=1; break;
case 'm':
if(mtpt = ARGF())
break;
@@ -329,7 +331,7 @@ void main(int argc, char *argv[]){
switch(argc){
default:
Usage:
- fprint(2, "Usage: %s [-dva] [-m mtpt] [url]\n", argv0);
+ fprint(2, "Usage: %s [-dvak] [-m mtpt] [url]\n", argv0);
exits("usage");
case 0:
url=getenv("url");
@@ -687,7 +689,9 @@ void docmd(Panel *p, char *s){
mothon(current, !mothmode);
break;
case 'k':
- killpix(current);
+ killimgs = !killimgs;
+ if (killimgs)
+ killpix(current);
break;
case 'w':
case 'W':
@@ -837,7 +841,7 @@ void gettext(Www *w, int fd, int type){
break;
case 0:
if(type==HTML)
- plrdhtml(w->url->fullname, fd, w);
+ plrdhtml(w->url->fullname, fd, w, killimgs);
else
plrdplain(w->url->fullname, fd, w);
_exits(0);