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).
This commit is contained in:
parent
5cd7f7b0ec
commit
8918bd5981
3 changed files with 8 additions and 0 deletions
|
@ -64,6 +64,7 @@ threadmain(int argc, char *argv[])
|
||||||
wintagwrite(win, "Send Noscroll", 5+8);
|
wintagwrite(win, "Send Noscroll", 5+8);
|
||||||
|
|
||||||
ctlprint(win->ctl, "scroll");
|
ctlprint(win->ctl, "scroll");
|
||||||
|
ctlprint(win->ctl, "scratch");
|
||||||
|
|
||||||
snprint(buf, sizeof(buf), "/proc/%d/notepg", getpid());
|
snprint(buf, sizeof(buf), "/proc/%d/notepg", getpid());
|
||||||
notepg = open(buf, OWRITE);
|
notepg = open(buf, OWRITE);
|
||||||
|
|
|
@ -280,6 +280,9 @@ Equivalent to the
|
||||||
.B Put
|
.B Put
|
||||||
interactive command with no arguments; accepts no arguments.
|
interactive command with no arguments; accepts no arguments.
|
||||||
.TP
|
.TP
|
||||||
|
.B scratch
|
||||||
|
Turn off tracking the `dirty' status, the window stays clean.
|
||||||
|
.TP
|
||||||
.B scroll
|
.B scroll
|
||||||
Cancel a
|
Cancel a
|
||||||
.B noscroll
|
.B noscroll
|
||||||
|
|
|
@ -759,6 +759,10 @@ out:
|
||||||
if(strncmp(p, "scroll", 6) == 0){ /* turn on automatic scrolling (writes to body only) */
|
if(strncmp(p, "scroll", 6) == 0){ /* turn on automatic scrolling (writes to body only) */
|
||||||
w->noscroll = FALSE;
|
w->noscroll = FALSE;
|
||||||
m = 6;
|
m = 6;
|
||||||
|
}else
|
||||||
|
if(strncmp(p, "scratch", 7) == 0){ /* mark as a scratch file */
|
||||||
|
w->isscratch = TRUE;
|
||||||
|
m = 7;
|
||||||
}else{
|
}else{
|
||||||
err = Ebadctl;
|
err = Ebadctl;
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue