shithub: nime

Download patch

ref: 74df3901c04f70c1ba89e71b78dee9dc2882e116
parent: bac60f84fa0916fdeb2a0165cd1738404e825438
author: Ethan Long <ethandavidlong@gmail.com>
date: Tue Aug 3 09:17:32 EDT 2021

Started progress on intercepting program

--- /dev/null
+++ b/src/fserv.c
@@ -1,0 +1,15 @@
+/*
+ *******************************************************************************
+ * Author: Ethan Long
+ * Licence: Public Domain
+ * Email: ethandavidlong@gmail.com, u7281759@anu.edu.au
+ * Description: fserv will take an IME's output and present it to opshow to
+ *              show the available conversion options to the user.
+ */
+
+#include <u.h>
+#include <libc.h>
+#include <thread.h>
+#include <bio.h>
+
+
--- a/src/mkfile
+++ b/src/mkfile
@@ -3,7 +3,8 @@
 TARGETS =\
 	to-kana.out \
 	test.out \
-	optshow.out
+	optshow.out \
+	fserv.out
 
 all:
 	for(i in $TARGETS) @{
--- a/src/optshow.c
+++ b/src/optshow.c
@@ -55,6 +55,7 @@
 	bgco = 0xFFFFFFFF;
 	textco = 0x000000FF;
 	
+	char *f;
 	ARGBEGIN{
 	case 's':
 		Binit(&bin, 0, OREAD);
@@ -61,10 +62,10 @@
 		Binit(&bout, 1, OWRITE);
 		break;
 	case 'f':
-		if (open(argv[1], OREAD) == -1){
-			sysfatal("File \"%s\" does not exist", argv[1]);
-		}
-		bin = *Bopen(argv[1], OREAD);
+		f = ARGF();
+		if (open(f, OREAD) == -1)
+			sysfatal("File \"%s\" does not exist", f);
+		bin = *Bopen(f, OREAD);
 		//Binit(&bin, 0, OREAD);
 		Binit(&bout, 1, OWRITE);
 		break;
@@ -78,7 +79,7 @@
 	bg = allocimage(display, Rect(0,0,1,1), RGB24, 1, bgco);
 	text = allocimage(display, Rect(0,0,screen->r.max.x,font->height), RGB24, 0, textco);
 	if(bg == nil || text == nil)
-		sysfatal("%s: We need more memory\n%r", argv0);
+		sysfatal("We need more memory\n%r");
 	
 	textpos.x = screen->r.min.x;
 	textpos.y = screen->r.min.y;