InteractiveEngine

io.github.nicheapplab.tcodeengine.InteractiveEngine
abstract class InteractiveEngine extends Strokes

Abstract class of InteractiveEngine, which generates Japanese characters step by step, interacting the user with its method calls.

It has two subclasses:

Both of them uses Layout type for its self annotation. Currently QwertyLayout and DvorakLayout are supported.

Prefix key strokes should be included in the input key strokes. In the following example, "fj" indicates entering Mixed Conversion mode (as "△", internally). In this mode, user can feed kanji and hiragana mixed input and generates conversion candidates through convert() function.

scala> import io.github.nicheapplab.tcodeengine._
scala> val ie = new ArchivedInteractiveEngine with QwertyLayout
scala> "fjyijstt".foreach(ie.put(_))
scala> ie.inflexRight()
scala> ie.convert()
scala> ie.selectCandidate(0)
scala> ie.commit()
val res0: String = "記者"

To use kanji composition, type the prefix "jf" to enter Composition mode (as "▲", internally). Composition mode can be nested as well as inside of Mixed Conversion mode. In the following example, after typing "fjjfpw.v", its internal buffer will be "△▲木目". By calling InteractiveEngine.convert(), "相" will be generated and "▲" will be consumed. The internal buffer will be "△相". Then typing ".d" ("つ") and "dt"("ぐ") will make the internal buffer to "△相つぐ". InteractiveEngine.inflexLeft() makes it to "△相つ|ぐ", which indicates "ぐ " is the inflex for the conversion. InteractiveEngine.convert() generates InteractiveEngine.candidates buffer. Then the user can choose the desired candidate with its index of the buffer, such as ie.selectCandidates(3). This will clear the candidates buffer and put the converted text "相次ぐ" into outputBuffer. To extract text from outputBuffer, call InteractiveEngine.commit().

scala> "fjjfpw.v".foreach(ie.put(_))
scala> ie.convert()
scala> ".ddt".foreach(ie.put(_))
scala> ie.inflexLeft()
scala> ie.convert()
scala> ie.selectCandidates(0)
scala> "fjjeux".foreach(ie.put(_))
scala> ie.inflexRight()
scala> ie.convert()
scala> ie.selectCandidate(3)
scala> "kgjwjc".foreach(ie.put(_))
scala> ie.commit()
val res0: String = "相次ぐ火事により"

Attributes

Graph
Supertypes
trait Strokes
class Object
trait Matchable
class Any
Known subtypes
Self type

Members list

Value members

Concrete methods

def backspace(): Boolean
def buffer: ListBuffer[Char]
def candidates: ListBuffer[String]
def commit(): String
def convert(): ListBuffer[_ >: Char & String <: Char | String]
def inflexLeft(): Unit
def inflexRight(): Unit
def lastChar: Option[Int]
def lastCharAsKey: Option[Char]
def outputBuffer: ListBuffer[Char]
def put(c: Char): Unit
def reset(): Unit
def selectCandidate(n: Int): Boolean

Inherited and Abstract methods

def getChar(first: Int, second: Int): Char

Attributes

Inherited from:
Strokes

Abstract fields