shithub: drawterm-fdroid

Download patch

ref: b2527a724b7a3fc8bd1c4bc9ba6a7bc6032bc47d
parent: 8d1d00cf25eb46f29948bc021f153e4cc4c5c598
author: Eli Cohen <echoline@gmail.com>
date: Wed Feb 2 11:39:26 EST 2022

window titlebar in /dev/label (x11 at least)

--- a/gui-android/cpp/android.c
+++ b/gui-android/cpp/android.c
@@ -228,3 +228,15 @@
 	cpubody();
 }
 
+int
+titleread(char *buf, int n)
+{
+	return 0;
+}
+
+int
+titlewrite(char *buf, int n)
+{
+	return n;
+}
+
--- a/gui-cocoa/screen.m
+++ b/gui-cocoa/screen.m
@@ -206,6 +206,17 @@
 	});
 }
 
+int
+titleread(char *buf, int n)
+{
+	return 0;
+}
+
+int
+titlewrite(char *buf, int n)
+{
+	return n;
+}
 
 @implementation AppDelegate
 
--- a/gui-fbdev/fbdev.c
+++ b/gui-fbdev/fbdev.c
@@ -666,8 +666,15 @@
 	qunlock(&drawlock);
 }
 
-void
-titlewrite(char* buf)
+int
+titleread(char *buf, int n)
 {
+	return 0;
+}
+
+int
+titlewrite(char* buf, int n)
+{
+	return n;
 }
 
--- a/gui-osx/screen.c
+++ b/gui-osx/screen.c
@@ -753,3 +753,16 @@
 {
 	cpubody();
 }
+
+int
+titleread(char *buf, int n)
+{
+	return 0;
+}
+
+int
+titlewrite(char *buf, int n)
+{
+	return n;
+}
+
--- a/gui-win32/screen.c
+++ b/gui-win32/screen.c
@@ -687,3 +687,16 @@
 {
 	cpubody();
 }
+
+int
+titleread(char *buf, int n)
+{
+	return 0;
+}
+
+int
+titlewrite(char *buf, int n)
+{
+	return n;
+}
+
--- a/gui-x11/x11.c
+++ b/gui-x11/x11.c
@@ -1266,3 +1266,24 @@
 {
 	cpubody();
 }
+
+int
+titleread(char *buf, int n)
+{
+	char *title;
+	XFetchName(xdisplay, xdrawable, &title);
+	memcpy(buf, title, n);
+	XFree(title);
+	return n;
+}
+
+int
+titlewrite(char *buf, int n)
+{
+	char *title = malloc((n+1) * sizeof(char));
+	memcpy(title, buf, n);
+	title[n] = '\0';
+	XStoreName(xdisplay, xdrawable, title);
+	free(title);
+	return n;
+}
--- a/kern/devcons.c
+++ b/kern/devcons.c
@@ -346,6 +346,7 @@
 	Qsysstat,
 	Qtime,
 	Qzero,
+	Qlabel,
 };
 
 enum
@@ -373,6 +374,7 @@
 	"sysstat",	{Qsysstat},	0,		0666,
 	"time",		{Qtime},	NUMSIZE+3*VLNUMSIZE,	0664,
 	"zero",		{Qzero},	0,		0444,
+	"label",	{Qlabel},	0, 		0666,
 };
 
 Dirtab *snarftab = &consdir[Qsnarf];
@@ -652,6 +654,12 @@
 		memset(buf, 0, n);
 		return n;
 
+	case Qlabel:
+		if (n > sizeof tmp)
+			n = sizeof tmp;
+		n = titleread(tmp, n);
+		return readstr((ulong)offset, buf, n, tmp);
+
 	case Qosversion:
 		snprint(tmp, sizeof tmp, "2000");
 		n = readstr((ulong)offset, buf, n, tmp);
@@ -784,6 +792,10 @@
 		if(buf[n-1] == '\n')
 			buf[n-1] = 0;
 		kstrdup(&sysname, buf);
+		break;
+
+	case Qlabel:
+		titlewrite(a, n);
 		break;
 
 	default:
--- a/kern/fns.h
+++ b/kern/fns.h
@@ -227,3 +227,5 @@
 void	screeninit(void);
 extern	void	terminit(void);
 extern	void	setterm(int);
+int		titleread(char*, int);
+int		titlewrite(char*, int);