summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkvik <kvik@a-b.xyz>2020-05-31 22:39:46 +0200
committerkvik <kvik@a-b.xyz>2020-05-31 22:39:46 +0200
commit8918bd598190b8c467746524f1886cc40be0b617 (patch)
tree816d5d531138eb95f1d59d490b979181b6549960
parent5cd7f7b0ec0df483bb5fd768ed59829e44849ed3 (diff)
downloadplan9front-8918bd598190b8c467746524f1886cc40be0b617.tar.xz
acme: implement 'scratch' ctl command (thanks Drew DeVault)
The new command marks the target window as a scratch window -- a window whose state cannot be "dirtied" by changes made to its body, therefore avoiding warnings about unsaved changes when deleting the window or exiting acme. Existing examples of scratch windows are error, directory, and guide windows, whose scratchness is set internally. With the new command users and programs alike can create their own scratch windows. This is put to use in acme's own win(1).
-rw-r--r--acme/bin/source/win/main.c1
-rw-r--r--sys/man/4/acme3
-rw-r--r--sys/src/cmd/acme/xfid.c4
3 files changed, 8 insertions, 0 deletions
diff --git a/acme/bin/source/win/main.c b/acme/bin/source/win/main.c
index b8a4aa3c4..ebdb31f5f 100644
--- a/acme/bin/source/win/main.c
+++ b/acme/bin/source/win/main.c
@@ -64,6 +64,7 @@ threadmain(int argc, char *argv[])
wintagwrite(win, "Send Noscroll", 5+8);
ctlprint(win->ctl, "scroll");
+ ctlprint(win->ctl, "scratch");
snprint(buf, sizeof(buf), "/proc/%d/notepg", getpid());
notepg = open(buf, OWRITE);
diff --git a/sys/man/4/acme b/sys/man/4/acme
index a2e68ddf1..c91d01e2f 100644
--- a/sys/man/4/acme
+++ b/sys/man/4/acme
@@ -280,6 +280,9 @@ Equivalent to the
.B Put
interactive command with no arguments; accepts no arguments.
.TP
+.B scratch
+Turn off tracking the `dirty' status, the window stays clean.
+.TP
.B scroll
Cancel a
.B noscroll
diff --git a/sys/src/cmd/acme/xfid.c b/sys/src/cmd/acme/xfid.c
index 2a8e17bdb..2feb438b2 100644
--- a/sys/src/cmd/acme/xfid.c
+++ b/sys/src/cmd/acme/xfid.c
@@ -759,6 +759,10 @@ out:
if(strncmp(p, "scroll", 6) == 0){ /* turn on automatic scrolling (writes to body only) */
w->noscroll = FALSE;
m = 6;
+ }else
+ if(strncmp(p, "scratch", 7) == 0){ /* mark as a scratch file */
+ w->isscratch = TRUE;
+ m = 7;
}else{
err = Ebadctl;
break;