Open galaktor opened 10 years ago
I was just thinking, a "fluent" package with a more functional API using higher order functions and linked via stateful args/return value struct could work. Result might look something like:
kb := gostwriter.New("myKeyboard")
f := fluent.Wrap(kb) // get the fluent wrapper
f.Press(fluent.Keys().Shift()).Then.Punch(fluent.Keys.A().B().C()).Then().Release(fluent.Keys.Shift())
and so on. Maybe some namespace/package trickery can get rid of boilerplate (or shorten) the "fluent" part, which obviously doesn't feel that fluent...
For ASCII alpha-numeric characters and very common keys such as Enter, shift, ctrl, arrows... create an abstraction on the keyboard the exposes those with utmost simplicity, i.e.
type LazyKey interface { Press() error Release() error Punch() error }
type LazyKeyboard interface { A() LazyKey B() LazyKey // ... etc Enter() LazyKey }
// usage func main() { // wrap keyboard in lazy wrapper kb := gostwriter.LazyKeyboard(gostwriter.New("foo"))
}