]> git.lizzy.rs Git - plan9front.git/commitdiff
acme: implement 'scratch' ctl command (thanks Drew DeVault)
authorkvik <kvik@a-b.xyz>
Sun, 31 May 2020 20:39:46 +0000 (22:39 +0200)
committerkvik <kvik@a-b.xyz>
Sun, 31 May 2020 20:39:46 +0000 (22:39 +0200)
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).

acme/bin/source/win/main.c
sys/man/4/acme
sys/src/cmd/acme/xfid.c

index b8a4aa3c49cd132ee7e562bb68b392eeae1aff08..ebdb31f5f5f465df4c47bb7ef31096c85d9b7ed5 100644 (file)
@@ -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);
index a2e68ddf1305b70172fe96f86ef7eee98cf4cbf5..c91d01e2fa8af4798dad7b620dfe9b5d66f1b181 100644 (file)
@@ -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
index 2a8e17bdb53f89207905ea8bdde91323dd4714a2..2feb438b2ac3bc8ad55c21e0a7d3b6e3bc88cc4f 100644 (file)
@@ -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;