ref: 60929ada1a066c49396d48bf45cf347a50f8e363
parent: 4b38242b2325a46a1ac4aa067bc82221742cdb26
author: Ethan Long <[email protected]>
date: Fri Jul 16 07:21:16 EDT 2021
Added supporting documentation for the halfway deadline/evaluation.
--- /dev/null
+++ b/doc/halfdline.ms
@@ -1,0 +1,100 @@
+.so ./macros
+.AU
+Ethan Long
+.TL
+Information for the halfway deadline (16/07/2021)
+
+.AB
+As of the halfway GSoC deadline,
+no parts of nIME are complete,
+but concrete development paths have been established.
+More work will need to be done to flesh out the concepts,
+but the backend design is mostly there.
+.AE
+
+.HC
+How to use the current project (16/07/2021)
+.PP
+As of 16/07/2021, the programs in
+.CW nIME
+are not fully developed.
+As such,
+only barebones demonstrations are currently in the project.
+
+To build the current programs,
+simply run
+.CW "mk all"
+in the
+.CW src
+directory.
+
+For a quick demonstration of all the modules being used together,
+run any of the following:
+
+.P1
+echo -n 'korega!tesuto!desuyo' | to-kana.out -s | optshow.out -s
+echo -n 'konnnichihasekai' | to-kana.out -s | optshow.out -s
+echo -n '\f(Jpこれがテストだよ。パソコンで日本語を使います。\f(CW' | optshow.out -s
+.P2
+
+In the final build,
+a full filesystem will be used to express all the intermediate steps,
+no
+.CW stdin ,
+.CW stdout
+or piping will be necessary.
+
+.HC
+Using
+.CT to-kana
+.PP
+To use
+.CW to-kana ,
+run the following:
+
+.P1
+echo -n 'korega!tesuto!desuyo' | to-kana.out -s
+echo -n 'konnnichihasekai' | to-kana.out -s
+.P2
+
+For more information,
+see
+.CW to-kana.pdf
+in the docs.
+
+.HC
+Using
+.CT optshow
+.PP
+To use
+.CW optshow ,
+run the following:
+
+.P1
+echo -n '\f(Jpこれがテストですよ\f(CW' | optshow.out -s
+echo -n '\f(Jp今日は、世界\f(CW' | optshow.out -s
+.P2
+
+.CW optshow
+should take control of the window,
+and display the input
+.CW Rune s
+in a box at either the top or bottom of the screen.
+
+For more information,
+see
+.CW optshow.pdf
+in the docs.
+
+.HC
+Final Note
+.PP
+As a final note,
+I will admit that this project is much farther behind schedule than expected.
+I did not expect it to be this difficult to get the time to program,
+but unforseen circumstances in life have caused it to be behind schedule.
+
+At the current time,
+I have full confidence that I will be able to complete
+.CW nIME
+before the final deadline.
binary files /dev/null b/doc/halfdline.pdf differ
--- /dev/null
+++ b/doc/halfdlinescript
@@ -1,0 +1,3 @@
+#!/bin/rc
+
+echo -n 'korega!tesuto!desuyo' | to-kana.out -s | optshow.out -s
--- /dev/null
+++ b/doc/macros
@@ -1,0 +1,88 @@
+.\" Macroset by Ethan Long, a compilation of small macros from various sources
+.\" Requires the s macroset (-ms).
+
+.\" To source this in a document, use the following command
+.\" .so /usr/USERNAME/refs/macros
+
+.\" FOR NEATREFER ONLY:
+.\" Macro for superscript, allows for references to be superscript in text.
+.\" neatrefer will look at the argument and replace it with a citation number
+.\" corresponding to the reference list.
+.de RE
+\*([.\\$1\*(.]
+..
+
+.\" Macro for inserting PostScript images, unfortunately non-postscript is not
+.\" supported, so things need to be converted first. (Takes up a fair bit of
+.\" space.
+.de FG \" Usage: .FG <basename>
+.ie h .html - <img src="\\$1.\\$2" />
+.el .BP \\$1.ps
+.br
+..
+
+.\" Macro for bullet points in a bullet point list
+.de BU
+.IP "•" 3
+..
+
+\" Macro for numbered point in a list
+.de NU
+.IP "\\$1." 3
+..
+
+\" Macro for numbering figures, will optionally take in an input describing the
+\" figure.
+\" Syntax:
+\" .FI "string describing figure"
+.nr fi 1
+.de FI
+.ps 8
+.if '\\$1'' \{
+.ce
+Figure \\n(fi
+.nr fi +1 \}
+.if !'\\$1'' \{
+.ce
+Figure \\n(fi: \\$1
+.nr fi +1 \}
+.ps
+..
+
+\" Macro for custom heading with cumulative numbering
+.nr se 0
+.de HC
+.nr se +1
+.SH
+.ps +4
+.ft NB
+\\n(se.
+.nr su 1
+..
+
+\" Macro for heading monospace fonts
+.de CT
+.nr PQ \\n(.f
+.if t .if \\n(.$>0 \%\&\\$3\f(CB\\$1
+.ft
+..
+
+\" Macro for custom subheading with cumulative numbering
+.de SC
+.SH
+.ps +2
+.ft BI
+\\n(se.\\n(su.
+.nr su +1
+..
+
+\" Macro for subheading monospace fonts,
+\" partly stolen from ms source ;)
+.de CI
+.nr PQ \\n(.f
+.if t .if \\n(.$>0 \%\&\\$3\f(CX\\$1
+.ft
+..
+
+\" Fix the boarders on default ms documents:
+.po +1.7
--- a/doc/mkfile
+++ b/doc/mkfile
@@ -1,5 +1,8 @@
DOCS=\
- proposal.pdf
+ proposal.pdf \
+ to-kana.pdf \
+ optshow.pdf \
+ halfdline.pdf
all:
for(i in $DOCS) @{
@@ -7,4 +10,7 @@
}
%.pdf: %.ms
+ bind /lib/font/bit/dejavusans/unicode.18.font /lib/font/bit/pelm/unicode.9x24.font
pic $stem.ms | tbl | troff -ms -mnihongo | dpost | ps2pdf - - > $stem.pdf
+clean:
+ rm *.pdf
--- /dev/null
+++ b/doc/optshow.ms
@@ -1,0 +1,109 @@
+.so ./macros
+.AU
+Ethan Long
+.TL
+.CT optshow,
+a program for showing possible convertion options from an IME.
+
+.AB
+.CW optshow
+is a program designed to interact with an underlying text based IME,
+optshow flicks through the possible convertion options and outputs the options as a GUI menu.
+.CW optshow
+should work with any IME with similar interaction to
+.CW ktrans ,
+I.E. the IME requires a key to be hit to cycle through possible convertions.
+.AE
+
+.HC
+Purpose in
+.CT nIME
+.PP
+.CW nIME
+will use
+.CW optshow
+for its intended purpose,
+to show the potential kanji convertions available for output.
+
+.HC
+Usage
+.PP
+.CW optshow
+in its final incantation will cycle through conversions with a given IME,
+and output a menu with a list of options to select.
+
+As of the time of writing,
+.CW optshow
+is simply a proof of concept and so it simply shows whatever is input into it if the
+.CW -s
+flag is given.
+
+.CW optshow
+should position itself near the cursor or in a convenient position to read while typing,
+fonts should be able to be as big as desired.
+
+.HC
+Function documentation
+.PP
+.CW optshow
+is a threaded program,
+and so the functions mostly run concurrently sending messages through channels.
+
+.SC
+The
+.CI clockproc
+function
+.PP
+The
+.CW clockproc
+function is made to be run as a separate process.
+It runs as a clock,
+sending a pulse over the provided channel every second.
+The channel should be an integer,
+clockproc will set the channel to 1 every pulse.
+If clockproc has send a 0,
+then something has broken with the sending of a pulse and the process will crash.
+
+This can be useful for any routine checks,
+like refreshing the position (although this should also be triggered by any movement anyway),
+or for syncing up channel communication.
+The final version of
+.CW optshow
+likely won't use this process.
+
+.SC
+The
+.CI optdraw
+function
+.PP
+.CW optdraw will take in a array of Rune strings,
+and display them as a menu for the user to interact with either through the keyboard or mouse.
+The final incantation of
+.CW optdraw
+will output an integer corresponding to the selected option.
+
+.SC
+The
+.CI readinproc
+function
+.PP
+The
+.CW readinproc
+function is designed to be ran as a process.
+.CW readinproc
+should return a string of Runes as input to the
+.CW INPUT
+member of the interaction alts,
+which can then be sent to optdraw to be evaluated.
+
+.SC
+The
+.CI relocate
+function
+.PP
+When run,
+the
+.CW relocate
+function should relocate the menu to where it needs to be,
+a place near the typing that is convenient to read for the user typing.
+The current method of imlementation is through wctl.
binary files /dev/null b/doc/optshow.pdf differ
binary files a/doc/proposal.pdf b/doc/proposal.pdf differ
--- a/doc/to-kana.ms
+++ b/doc/to-kana.ms
@@ -1,7 +1,8 @@
+.so ./macros
.AU
Ethan Long
.TL
-.CW to-kana ,
+.CT to-kana,
a program for converting romaji to kana.
.AB
@@ -13,9 +14,9 @@
it should be usable for any project that requires a stream of romaji to be converted.
.AE
-.SH
+.HC
Purpose in
-.CW nIME
+.CT nIME
.PP
.CW nIME
uses
@@ -23,11 +24,12 @@
to convert the stream of keyboard inputs into basic kana for
.CW to-kanji
to then convert to kanji.
-.CW to-kana plays a very pivotal role in
+.CW to-kana
+plays a very pivotal role in
.CW nIME ,
without it no kana conversion could take place.
-.SH
+.HC
Usage
.PP
.CW to-kana
@@ -45,11 +47,18 @@
\f(CWnannde\fR → \f(Jpなんで\fR
\f(CWdonnna\fR → \f(Jpどんな\fR
+In the raw stream,
+.CW ! ' `
+is used as a placeholder for the katakana trigger character,
+.CW nIME 's
+GUI will trigger said placeholder when conversion is requested.
+
As one can see from this usage,
the common letters all take two keystrokes to type.
.TS
c|c
+= =
c|c
c|c
c|c
@@ -57,6 +66,7 @@
c|c
c|c.
\f(Jp日本語\fR \f(Jpロマ字\fR
+
\f(Jpあ\fR a
\f(Jpか\fR ka
\f(Jpきゃ\fR kya
@@ -65,18 +75,107 @@
\f(Jpん\fR nn
.TE
-In the raw stream,
-.CW !
-is used as a placeholder for the katakana trigger character,
-.CW nIME 's
-GUI will trigger said placeholder when conversion is requested.
-.SH
-Technical documentation
+.HC
+Function documentation
.PP
All the functions in
.CW to-kana
-serve the purposes of the
+serve the purposes of generating kana from a stream.
+.SC
+The
+.CI eval
+function
+.PP
+The
.CW eval
+function takes in a file pointer and converts the contents assuming that they are in the previously described romaji form.
+The function should run with buffered IO (as of writing buffered IO has not been implemented yet),
+waiting on any new input from a file,
+and outputting to a separate file.
+The final filesystem layout is TBD.
+
+.SC
+The
+.CI strappend
+function
+.PP
+The
+.CW strappend
+function takes in a pointer to a string,
+along with a character to append,
+it then appends the character in the first null address of the string.
+
+Additionally,
+since its purpose is in the context of Japanese input,
+it returns an integer value representing whether or not the string now represents a full Japanese character in Romaji,
+if it does it returns 1.
+
+.SC
+The
+.CI kanalook
+function
+.PP
+The
+.CW kanalook
+function takes in a pointer to a complete Romaji buffer representing a single syllable,
+and converts the output to a string of
+.CW Rune s.
+It does this with the help of the
+.CW kanafill
function.
-The eval function takes in a file pointer and converts the contents assuming that they are in the previously described romaji form.
+
+.SC
+The
+.CI kanafill
+function
+.PP
+The
+.CW kanafill
+function is designed to output a string of runes representing a single syllable in kana.
+It takes in a
+.CW Rune
+representing the base 'a' family of the kana
+(like \f(Jpあ\fR, \f(Jpか\fR, \f(Jpら\fR, etc.),
+and then uses the
+.CW in
+string of characters representing the ending of the kana,
+along with an integer representing the presence of dakuten to determine which kana / kana combination to output.
+
+Here is an example table of output from the
+.CW kanafill
+function:
+
+.TS
+ - - - -
+|c|c|c|c|
+ = = = =
+|c|c|c|c|
+|c|c|c|c|
+|c|c|c|c|
+|c|c|c|c|
+|c|c|c|c|
+|c|c|c|c|
+|c|c|c|c|
+ - - - -.
+
+T{
+.CW "Rune base"
+T} T{
+.CW "char* in"
+T} T{
+.CW "int dakuten"
+T} T{
+.CW "Rune* out"
+T}
+
+\f(Jpか\fR a 0 \f(Jpか\fR
+\f(Jpか\fR e 0 \f(Jpけ\fR
+\f(Jpか\fR i 1 \f(Jpぎ\fR
+\f(Jpは\fR i 2 \f(Jpぴ\fR
+\f(Jpは\fR ya 0 \f(Jpひゃ\fR
+\f(Jpは\fR yu 2 \f(Jpぴゅ\fR
+\f(Jpハ\fR u 0 \f(Jpフ\fR
+
+.TE
+
binary files a/doc/to-kana.pdf b/doc/to-kana.pdf differ
--- a/src/mkfile
+++ b/src/mkfile
@@ -1,6 +1,9 @@
</$objtype/mkfile
-TARGETS = to-kana.out test.out optshow.out
+TARGETS =\
+ to-kana.out \
+ test.out \
+ optshow.out
all:
for(i in $TARGETS) @{
--- a/src/optshow.c
+++ b/src/optshow.c
@@ -18,6 +18,12 @@
#include <frame.h>
#include <bio.h>
+void clockproc(void*);
+void optdraw(Image*, Image*, Point, Rune*);
+void readinproc(void*);
+void relocate(Rune*);
+void usage(void);
+
enum
{
STACK = 2048,
@@ -27,83 +33,8 @@
int top = 0;
Biobuf bin, bout;
-void
-clockproc(void *arg)
-{
- int o;
- Channel *c;
-
- c = arg;
-
- o = 1;
-
- while(o){
- if(!(send(c, &o))){
- o = 0;
- sysfatal("%s: Clock broke can't fix\n%r", argv0);
- }
- sleep(1000);
- }
-}
void
-relocate(Rune *buf)
-{
- Point min, max;
- int wp, wid, ht, strlen;
-
- wid = 0;
-
- for(strlen=0; buf[strlen] != 0; strlen++)
- if((wid = strlen * (font->width + 4)) < 100)
- wid = 100;
-
- ht = font->height * 2;
-
- if((wp = open("/dev/wctl", ORDWR)) < 0)
- sysfatal("%s: Couldn't open wctl\n %r", argv0);
-
- if(top){
- min = Pt(0,0);
- max = Pt(wid, ht);
- }else{
- min = Pt(0, display->image->r.max.y - ht);
- max = Pt(wid, display->image->r.max.y);
- }
-
- fprint(wp, "resize -r %d %d %d %d", min.x, min.y, max.x, max.y);
- close(wp);
-}
-
-void
-readinproc(void *arg)
-{
- Rune input[64];
- Rune r;
- Channel *mc;
-
- mc = arg;
-
- for(int i=0; (r=Bgetrune(&bin)) != Beof; i++){
- input[i] = r;
- input[i+1] = 0;
- }
-
-
- while(recv(timer, nil)){
- send(mc, nil);
- send(mc, input);
- }
-}
-
-void
-optdraw(Image *bg, Image *text, Point textpos, Rune *opt)
-{
- draw(screen, screen->r, bg, nil, ZP);
- runestring(screen, textpos, text, ZP, font, opt);
-}
-
-void
usage(void)
{
fprint(2, "usage: %s [-s]\n", argv0);
@@ -153,7 +84,6 @@
buf = L"No input recieved";
optdraw(bg, text, textpos, buf);
- flushimage(display, Refnone);
if((mctl = initmouse(nil, screen)) == nil)
sysfatal("%s: %r", argv0);
@@ -180,7 +110,6 @@
case CLOCK:
relocate(buf);
optdraw(bg, text, textpos, buf);
- flushimage(display, Refnone);
break;
case INPUT:
relocate(buf);
@@ -189,7 +118,6 @@
}
buf = input;
optdraw(bg, text, textpos, buf);
- flushimage(display, Refnone);
break;
case MOUSE:
relocate(buf);
@@ -200,10 +128,86 @@
freeimage(text);
text = allocimage(display, Rect(0,0,screen->r.max.x,font->height), RGB24, 0, textco);
optdraw(bg, text, textpos, buf);
- flushimage(display, Refnone);
break;
case NONE:
break;
}
}
+}
+
+void
+clockproc(void *arg)
+{
+ int o;
+ Channel *c;
+
+ c = arg;
+
+ o = 1;
+
+ while(o){
+ if(!(send(c, &o))){
+ o = 0;
+ sysfatal("%s: Clock broke can't fix\n%r", argv0);
+ }
+ sleep(1000);
+ }
+}
+
+void
+optdraw(Image *bg, Image *text, Point textpos, Rune *opt)
+{
+ draw(screen, screen->r, bg, nil, ZP);
+ runestring(screen, textpos, text, ZP, font, opt);
+ flushimage(display, Refnone);
+}
+
+void
+readinproc(void *arg)
+{
+ Rune input[64];
+ Rune r;
+ Channel *mc;
+
+ mc = arg;
+
+ for(int i=0; (r=Bgetrune(&bin)) != Beof; i++){
+ input[i] = r;
+ input[i+1] = 0;
+ }
+
+
+ while(recv(timer, nil)){
+ send(mc, nil);
+ send(mc, input);
+ }
+}
+
+void
+relocate(Rune *buf)
+{
+ Point min, max;
+ int wp, wid, ht, strlen;
+
+ wid = 0;
+
+ for(strlen=0; buf[strlen] != 0; strlen++)
+ if((wid = strlen * (font->width + 4)) < 100)
+ wid = 100;
+
+ ht = font->height * 2;
+
+ if((wp = open("/dev/wctl", ORDWR)) < 0)
+ sysfatal("%s: Couldn't open wctl\n %r", argv0);
+
+ if(top){
+ min = Pt(0,0);
+ max = Pt(wid, ht);
+ }else{
+ min = Pt(0, display->image->r.max.y - ht);
+ max = Pt(wid, display->image->r.max.y);
+ }
+
+ fprint(wp, "resize -r %d %d %d %d", min.x, min.y, max.x, max.y);
+ close(wp);
}