2019-06-27 06:29:09 +00:00
|
|
|
// TODO: move Pointe to a separate file
|
2017-01-06 09:53:40 +00:00
|
|
|
class Point(Object)
|
2016-12-31 17:22:57 +00:00
|
|
|
{
|
2017-04-19 16:46:44 +00:00
|
|
|
var x, y.
|
2016-12-31 17:22:57 +00:00
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) new
|
2016-12-31 17:22:57 +00:00
|
|
|
{
|
|
|
|
^self basicNew x: 0 y: 0.
|
|
|
|
}
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) x: x y: y
|
2016-12-31 17:22:57 +00:00
|
|
|
{
|
|
|
|
^self basicNew x: x y: y.
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method x
|
2016-12-31 17:22:57 +00:00
|
|
|
{
|
|
|
|
^self.x
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method y
|
2016-12-31 17:22:57 +00:00
|
|
|
{
|
|
|
|
^self.y
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method x: x
|
2016-12-31 17:22:57 +00:00
|
|
|
{
|
|
|
|
self.x := x
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method y: y
|
2016-12-31 17:22:57 +00:00
|
|
|
{
|
|
|
|
self.y := y
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method x: x y: y
|
2016-12-31 17:22:57 +00:00
|
|
|
{
|
|
|
|
self.x := x.
|
|
|
|
self.y := y
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
extend SmallInteger
|
2016-12-31 17:22:57 +00:00
|
|
|
{
|
2017-01-06 09:53:40 +00:00
|
|
|
method @ y
|
2016-12-31 17:22:57 +00:00
|
|
|
{
|
|
|
|
^Point x: self y: y
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-12-13 16:00:48 +00:00
|
|
|
class Console(Object) from 'con'
|
2016-12-31 17:22:57 +00:00
|
|
|
{
|
2017-03-30 14:59:55 +00:00
|
|
|
method(#primitive) _open.
|
|
|
|
method(#primitive) _close.
|
|
|
|
method(#primitive) _clear.
|
|
|
|
method(#primitive) _setcursor(x, y).
|
|
|
|
method(#primitive) _write(msg).
|
|
|
|
|
2019-06-19 12:38:09 +00:00
|
|
|
/*
|
2017-01-06 09:53:40 +00:00
|
|
|
method finalize
|
2016-12-31 17:22:57 +00:00
|
|
|
{
|
2017-03-30 14:59:55 +00:00
|
|
|
if (still open) {
|
|
|
|
self _close.
|
|
|
|
}
|
2016-12-31 17:22:57 +00:00
|
|
|
}
|
2019-06-19 12:38:09 +00:00
|
|
|
*/
|
2016-12-31 17:22:57 +00:00
|
|
|
|
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
// method(#class) input
|
|
|
|
// {
|
|
|
|
// ^self new _open: filename mode: mode
|
|
|
|
// }
|
2016-12-31 17:22:57 +00:00
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method(#class) output
|
2016-12-31 17:22:57 +00:00
|
|
|
{
|
|
|
|
| c |
|
|
|
|
|
|
|
|
c := self new.
|
2019-06-27 06:29:09 +00:00
|
|
|
c _open. // TODO error check - if ((e := c _open) isError) { ^e }.
|
2016-12-31 17:22:57 +00:00
|
|
|
^c
|
|
|
|
}
|
|
|
|
|
2019-06-27 06:29:09 +00:00
|
|
|
// method(#class) error
|
|
|
|
// {
|
|
|
|
// }
|
2016-12-31 17:22:57 +00:00
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method close
|
2016-12-31 17:22:57 +00:00
|
|
|
{
|
2017-03-30 14:59:55 +00:00
|
|
|
self _close.
|
2016-12-31 17:22:57 +00:00
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method write: text
|
2016-12-31 17:22:57 +00:00
|
|
|
{
|
2017-03-30 14:59:55 +00:00
|
|
|
^self _write(text)
|
2016-12-31 17:22:57 +00:00
|
|
|
}
|
|
|
|
|
2017-01-06 09:53:40 +00:00
|
|
|
method clear
|
2016-12-31 17:22:57 +00:00
|
|
|
{
|
2017-03-30 14:59:55 +00:00
|
|
|
^self _clear.
|
2016-12-31 17:22:57 +00:00
|
|
|
}
|
|
|
|
|
2017-03-30 14:59:55 +00:00
|
|
|
method setCursor: point
|
2016-12-31 17:22:57 +00:00
|
|
|
{
|
2017-03-30 14:59:55 +00:00
|
|
|
^self _setcursor(point x, point y)
|
2016-12-31 17:22:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|