cookiedemo = proc () s = "COOKIE" s1 = "cookie" x_keymap$load("") root: x_window := x_display$root() bwidth: int := int$parse(xdemo_default("cookie", "BorderWidth")) except when not_found, overflow, bad_format: bwidth := 5 end back: x_pixmap := x_display$white() bdr: x_pixmap := x_display$black() plane: int := 1 backpix: int := WhitePixel textpix: int := BlackPixel if x_display$cells() > 2 then begin r, g, b: int := x_parse_color(xdemo_default("cookie", "Border")) bdr := x_pixmap$tile(x_display$alloc_color(r, g, b)) end except when not_found: end begin r, g, b: int := x_parse_color(xdemo_default("cookie", "Background")) backpix := x_display$alloc_color(r, g, b) back := x_pixmap$tile(backpix) end except when not_found: end begin r, g, b: int := x_parse_color(xdemo_default("cookie", "Foreground")) textpix := x_display$alloc_color(r, g, b) end except when not_found: end end font: x_font := x_font$create("esch80") except when error (*): font := x_font$create("oldeng") end except when error (*): font := x_font$create(xdemo_default("cookie", "BodyFont")) end fwidth, fheight: int, f, l: char, b: int, fix: bool := x_font$query(font) swid: int := x_font$width(font, s) w: x_window := x_window$create((x_display$width() - swid - 20) / 2, (x_display$height() - fheight - 20) / 2, swid + 5, fheight + 5, back, root, bwidth, bdr) w.name := "cookie" w.input := KeyPressed + KeyReleased + ExposeWindow x_window$map(w) x_window$text(w, s, font, textpix, backpix, 5, 5) i: int := 1 ev: event := x_input$empty_event() while i <= string$size(s) do x_input$deq(ev) if ev.kind = ExposeWindow then x_window$text(w, s, font, textpix, backpix, 5, 5) elseif ev.kind = KeyPressed then c: char := x_keymap$getc(ev.value, ev.mask) except when none, multi (*): continue end if c = s[i] cor c = s1[i] then i := i + 1 else i := 1 end else i := 1 end end x_window$clear(w) x_window$text(w, "YUMMY", font, textpix, backpix, 5, 5) x_flush() sleep(2) x_window$destroy(w) end cookiedemo