diff options
author | Camil Staps | 2015-08-23 17:31:44 +0200 |
---|---|---|
committer | Camil Staps | 2015-08-23 17:31:44 +0200 |
commit | f64444fb2a67ee84e973d894fbad7e2222a7767a (patch) | |
tree | bba2f2994a61830747e9619453e2c33fbbebd559 /tut6_7_1.icl | |
parent | Tut 12.1 Simple clipboard editor (diff) |
Tut 6.7 (mousespotting, keyspotting); tut 11.3.2 (stopwatch)
Diffstat (limited to 'tut6_7_1.icl')
-rw-r--r-- | tut6_7_1.icl | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/tut6_7_1.icl b/tut6_7_1.icl new file mode 100644 index 0000000..c26c244 --- /dev/null +++ b/tut6_7_1.icl @@ -0,0 +1,30 @@ +module tut6_7_1 + +// ******************************************************************************** +// Clean tutorial example program. +// +// This program monitors keyboard input that is sent to a Window. +// ******************************************************************************** + +import StdEnv, StdIO + +Start :: *World -> *World +Start world +# (wid, world) = openId world +# window = Window "Keyspotting" NilLS [ + WindowKeyboard (const True) Able (noLS1 (spotting wid)), + WindowId wid, + WindowClose (noLS closeProcess)] += startIO SDI Void (snd o openWindow Void window) [ProcessClose closeProcess] world +where + spotting :: Id x (PSt .l) -> PSt .l | toString x + spotting wid x pst = appPIO (setWindowLook wid True (False, look (toString x))) pst + + look :: String SelectState UpdateState *Picture -> *Picture + look text _ {newFrame} picture + # picture = unfill newFrame picture + # (width, picture) = getPenFontStringWidth text picture + = drawAt {x=(w-width)/2,y=h/2} text picture + where + {w,h} = rectangleSize newFrame + |