moo/kernel/Console.moo

107 lines
1.1 KiB
Smalltalk
Raw Permalink Normal View History

// TODO: move Pointe to a separate file
class Point(Object)
2016-12-31 17:22:57 +00:00
{
var x, y.
2016-12-31 17:22:57 +00:00
method(#class) new
2016-12-31 17:22:57 +00:00
{
^self basicNew x: 0 y: 0.
}
method(#class) x: x y: y
2016-12-31 17:22:57 +00:00
{
^self basicNew x: x y: y.
}
method x
2016-12-31 17:22:57 +00:00
{
^self.x
}
method y
2016-12-31 17:22:57 +00:00
{
^self.y
}
method x: x
2016-12-31 17:22:57 +00:00
{
self.x := x
}
method y: y
2016-12-31 17:22:57 +00:00
{
self.y := y
}
method x: x y: y
2016-12-31 17:22:57 +00:00
{
self.x := x.
self.y := y
}
}
extend SmallInteger
2016-12-31 17:22:57 +00:00
{
method @ y
2016-12-31 17:22:57 +00:00
{
^Point x: self y: y
}
}
class Console(Object) from 'con'
2016-12-31 17:22:57 +00:00
{
method(#primitive) _open.
method(#primitive) _close.
method(#primitive) _clear.
method(#primitive) _setcursor(x, y).
method(#primitive) _write(msg).
/*
method finalize
2016-12-31 17:22:57 +00:00
{
if (still open) {
self _close.
}
2016-12-31 17:22:57 +00:00
}
*/
2016-12-31 17:22:57 +00:00
// method(#class) input
// {
// ^self new _open: filename mode: mode
// }
2016-12-31 17:22:57 +00:00
method(#class) output
2016-12-31 17:22:57 +00:00
{
| c |
c := self new.
c _open. // TODO error check - if ((e := c _open) isError) { ^e }.
2016-12-31 17:22:57 +00:00
^c
}
// method(#class) error
// {
// }
2016-12-31 17:22:57 +00:00
method close
2016-12-31 17:22:57 +00:00
{
self _close.
2016-12-31 17:22:57 +00:00
}
method write: text
2016-12-31 17:22:57 +00:00
{
^self _write(text)
2016-12-31 17:22:57 +00:00
}
method clear
2016-12-31 17:22:57 +00:00
{
^self _clear.
2016-12-31 17:22:57 +00:00
}
method setCursor: point
2016-12-31 17:22:57 +00:00
{
^self _setcursor(point x, point y)
2016-12-31 17:22:57 +00:00
}
}