shithub: orca

Download patch

ref: 2c6ccbaedf7c996e73528f71feffd55e3c27a18e
parent: 751cb707f948bb7eabe8eb3eb9993aee3dfbfc86
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Tue Feb 18 10:16:52 EST 2020

plan9: add -c option to set custom cursor

--- a/orca.man
+++ b/orca.man
@@ -14,6 +14,8 @@
 ] [
 .I -r random_seed
 ] [
+.I -c cursor
+] [
 .I file
 ]
 .SH DESCRIPTION
@@ -49,6 +51,10 @@
 .TP
 .B -b
 Sets initial "beats per minute" value.
+.TP
+.B -c
+Set the cursor character.
+.PP
 .EE
 Extensive documentation and examples are available on the project's
 GitHub web page.
--- a/plan9.c
+++ b/plan9.c
@@ -68,6 +68,7 @@
 static int rulerstyle = Sfancy, dotstyle = Sfancy;
 
 static Rune *linebuf;
+static Rune cursor = '@';
 static vlong tick;
 static Point glyphsz;
 static Point cur;
@@ -80,7 +81,6 @@
 static bool altdown, pause, forward;
 static int mode = Minsert;
 static long framedev; /* frame deviation in ms */
-static Rune *linebuf;
 
 static char *dotstyles[Numstyles] = {
 	[Sfancy] = "fancy dots",
@@ -411,7 +411,7 @@
 				attr &= ~Mark_flag_group_highlight;
 
 			if (c == '.' && eqpt(Pt(x, y), cur))
-				c = '@';
+				c = cursor;
 
 			if (!grouphl && !complete && c == copyfield.buffer[off] && attr == mscr.buffer[off]) {
 				if (i > 0) {
@@ -873,6 +873,12 @@
 		}
 		srand(seed);
 		break;
+	case 'c':
+		if (chartorune(&cursor, EARGF(usage())) < 1 || cursor == Runeerror) {
+			fprint(2, "invalid cursor \"%s\"\n", EARGF(usage()));
+			threadexitsall("args");
+		}
+		break;
 	default:
 		usage();
 	}ARGEND
@@ -913,7 +919,7 @@
 			theme[n] = ~theme[n] | 0xff;
 		color[n] = allocimage(display, Rect(0, 0, 1, 1), RGBA32, 1, setalpha(theme[n] & ~0xff, theme[n] & 0xff));
 	}
-	glyphsz.x = stringwidth(font, "X");
+	glyphsz.x = stringwidth(font, "@");
 	glyphsz.y = font->height;
 
 	if (filename[0] == 0) {