9front - general discussion about 9front
 help / color / mirror / Atom feed
From: qwx@sciops.net
To: 9front@9front.org
Subject: Re: [9front] [PATCH] better rio exit menu entry check
Date: Thu, 04 Aug 2022 22:18:35 +0200	[thread overview]
Message-ID: <CCE6BE59DC10790A75C28B4049316F6C@wopr.sciops.net> (raw)
In-Reply-To: <9009aa07-2c7a-9dee-7b3c-63bb01af31f9@posixcafe.org>

On Thu Aug  4 16:36:38 +0200 2022, moody@mail.posixcafe.org wrote:
> Checking for if the binary name contains .out always seemed a bit
> like a hack. What I seem to want most of the time is for the
> Exit option to show up on subrios, but not my "main" rio.
> This patch does this by checking for an existing
> rio mounted on /mnt/wsys.

I've been using subrios heavily for years now, and I find that an
Exit entry is massively useful for me, but with a safeguard:  a
second click for confirmation like in mothra.  Thanks to this, I
have never had an accidental discharge despite being a total klutz.
Personally I'd prefer the Exit to be present regardless of context,
but this is a nice idea.

Cheers,
qwx


diff -r c055db14ff2b sys/src/cmd/rio/dat.h
--- a/sys/src/cmd/rio/dat.h	Sun Dec 06 14:50:50 2020 +0100
+++ b/sys/src/cmd/rio/dat.h	Sun Dec 06 15:36:58 2020 +0100
@@ -308,6 +308,7 @@
 Display	*display;
 Image	*view;
 Screen	*wscreen;
+Cursor	confirmcursor;
 Cursor	boxcursor;
 Cursor	crosscursor;
 Cursor	sightcursor;
diff -r c055db14ff2b sys/src/cmd/rio/data.c
--- a/sys/src/cmd/rio/data.c	Sun Dec 06 14:50:50 2020 +0100
+++ b/sys/src/cmd/rio/data.c	Sun Dec 06 15:36:58 2020 +0100
@@ -10,6 +10,19 @@
 #include "dat.h"
 #include "fns.h"
 
+Cursor confirmcursor={
+	0, 0,
+	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+	0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
+
+	0x00, 0x0E, 0x07, 0x1F, 0x03, 0x17, 0x73, 0x6F,
+	0xFB, 0xCE, 0xDB, 0x8C, 0xDB, 0xC0, 0xFB, 0x6C,
+	0x77, 0xFC, 0x00, 0x00, 0x00, 0x01, 0x00, 0x03,
+	0x94, 0xA6, 0x63, 0x3C, 0x63, 0x18, 0x94, 0x90,
+};
+
 Cursor crosscursor = {
 	{-7, -7},
 	{0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0, 0x03, 0xC0,
diff -r c055db14ff2b sys/src/cmd/rio/rio.c
--- a/sys/src/cmd/rio/rio.c	Sun Dec 06 14:50:50 2020 +0100
+++ b/sys/src/cmd/rio/rio.c	Sun Dec 06 15:36:58 2020 +0100
@@ -26,6 +26,7 @@
 void		hide(void);
 void		unhide(int);
 void		newtile(int);
+void		confirmexit(void);
 Image*	sweep(void);
 Image*	bandsize(Window*);
 Image*	drag(Window*);
@@ -124,10 +125,6 @@
 	Image *i;
 	Rectangle r;
 
-	if(strstr(argv[0], ".out") == nil){
-		menu3str[Exit] = nil;
-		Hidden--;
-	}
 	initstr = nil;
 	kbdin = nil;
 	maxtab = 0;
@@ -731,11 +728,8 @@
 		hide();
 		break;
 	case Exit:
-		if(Hidden > Exit){
-			send(exitchan, nil);
-			break;
-		}
-		/* else fall through */
+		confirmexit();
+		break;
 	default:
 		unhide(i);
 		break;
@@ -1006,6 +1000,26 @@
 }
 
 void
+confirmexit(void)
+{
+	menuing = TRUE;
+	riosetcursor(&confirmcursor);
+	while(mouse->buttons == 0)
+		readmouse(mousectl);
+	if(mouse->buttons != 4)
+		goto nope;
+	while(mouse->buttons){
+		if(mouse->buttons != 4)
+			goto nope;
+		readmouse(mousectl);
+	}
+	send(exitchan, nil);
+nope:
+	riosetcursor(nil);
+	menuing = FALSE;
+}
+
+void
 resize(void)
 {
 	Window *w;


  parent reply	other threads:[~2022-08-04 20:20 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-04 14:36 Jacob Moody
2022-08-04 14:56 ` sirjofri
2022-08-04 16:45 ` B. Atticus Grobe
2022-08-04 19:19   ` umbraticus
2022-08-04 20:18 ` qwx [this message]
2022-08-04 22:08   ` umbraticus
2022-08-05  4:55     ` qwx

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CCE6BE59DC10790A75C28B4049316F6C@wopr.sciops.net \
    --to=qwx@sciops.net \
    --cc=9front@9front.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).