shithub: nime

Download patch

ref: c69fcca52c8c2895ad213337eace16668036e28a
parent: ccb335c11e91fbfff113668ec030b9d3a02869e3
author: Ethan Long <ethandavidlong@gmail.com>
date: Mon Jun 28 08:14:43 EDT 2021

Updated and corrected mkfiles, started some documentation for to-kana.

--- a/doc/mkfile
+++ b/doc/mkfile
@@ -3,8 +3,8 @@
 
 all:
 	for(i in $DOCS) @{
-		mk $i
+		window -m mk $i
 	}
 
 %.pdf: %.ms
-	pic $stem.ms | troff -ms | dpost | ps2pdf - - > $stem.pdf
+	pic $stem.ms | tbl | troff -ms -mnihongo | dpost | ps2pdf - - > $stem.pdf
binary files a/doc/proposal.pdf b/doc/proposal.pdf differ
--- /dev/null
+++ b/doc/to-kana.ms
@@ -1,0 +1,73 @@
+.AU
+Ethan Long
+.TL
+.CW to-kana ,
+a program for converting romaji to kana.
+
+.AB
+.CW to-kana
+converts a incoming stream of romaji to either hiragana or katakana either from a file,
+or from standard input, and outputs to a file or standard output.
+.CW to-kana
+aims to be as modular as possible,
+it should be usable for any project that requires a stream of romaji to be converted.
+.AE
+
+.SH
+Purpose in
+.CW nIME
+.PP
+.CW nIME
+uses
+.CW to-kana
+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 nIME ,
+without it no kana conversion could take place.
+
+.SH
+Usage
+.PP
+.CW to-kana
+takes in a very rigid but simple form of romaji,
+every character except the basic vowels takes two letters to type.
+The style is most similar to the ``modern'' IME,
+rather than
+.CW ktrans '
+SKK format.
+Some examples of common usage:
+
+.ce 4
+\f(CWwatashi\fR → \f(Jpわたし\fR
+\f(CWkorega!epikku!desu\fR → \f(Jpこれがエピックです\fR
+\f(CWnannde\fR → \f(Jpなんで\fR
+\f(CWdonnna\fR → \f(Jpどんな\fR
+
+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
+c|c
+c|c
+c|c.
+\f(Jp日本語\fR	\f(Jpロマ字\fR
+\f(Jpあ\fR	a
+\f(Jpか\fR	ka
+\f(Jpきゃ\fR	kya
+\f(Jpっか\fR	kka
+\f(Jpっきゃ\fR	kkya
+\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.
+
binary files /dev/null b/doc/to-kana.pdf differ
--- a/src/mkfile
+++ b/src/mkfile
@@ -2,10 +2,17 @@
 
 TARGETS = to-kana test
 
+all:
+	for(i in $TARGETS) @{
+		mk $i
+	}
+
 %: %.$O
 	$LD $LDFLAGS -o $target $prereq
-%.$0: %.c
+
+%.$O: %.c
 	$CC $CFLAGS $stem.c
 
+
 clean:
-	rm *.$O
+	rm *.$O $TARGETS
--- a/src/to-kana.c
+++ b/src/to-kana.c
@@ -140,6 +140,10 @@
 	
 	/* さ family */
 	case 's':
+		if(buf[index + 1] == 'h'){
+			end[0] = buf[index + 2];
+			end[1] = 0;
+		}
 		kanafill((Rune)((int)(L'さ') + katakana), end, 0, str + index);
 		break;
 	case 'z':
@@ -235,13 +239,13 @@
 	case L'ヤ':
 		switch(in[0]){
 		case 'a':
-			out[0] = L'や';
+			out[0] = base;
 			break;
 		case 'u':
-			out[0] = L'ゆ';
+			out[0] = (Rune)((int)base + 2);
 			break;
 		case 'o':
-			out[0] = L'よ';
+			out[0] = (Rune)((int)base + 4);
 			break;
 		default:
 			break;
@@ -248,6 +252,26 @@
 		}
 		break;
 
+	case L'わ':
+	case L'ワ':
+		switch(in[0]){
+		case 'a':
+			out[0] = base;
+			break;
+		case 'i':
+			out[0] = (Rune)((int)base + 1);
+			break;
+		case 'e':
+			out[0] = (Rune)((int)base + 2);
+			break;
+		case 'o':
+			out[0] = (Rune)((int)base + 3);
+			break;
+		default:
+			break;
+		}
+		break;
+
 	case L'ん':
 	case L'ン':
 		out[0] = L'ん';
@@ -299,8 +323,6 @@
 	case L'マ':
 	case L'な':
 	case L'ナ':
-	case L'わ':
-	case L'ワ':
 		switch(in[0]){
 		case 'a':
 			out[0] = base;