Changeset 37842 in project


Ignore:
Timestamp:
08/05/19 12:14:22 (4 months ago)
Author:
Mario Domenech Goulart
Message:

eggref/5/xlib: fix imports in the example & format it with the <enscript> tag

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/5/xlib

    r37841 r37842  
    26762676The canonical "Hello World" program:
    26772677
    2678   ;;; Shows a window and terminates after a button-press
    2679   ;   (or after the second exposure event)
    2680  
    2681   (require-extension xlib)
    2682  
    2683   (let ((display (xopendisplay #f)))
    2684    (assert display)
    2685    (let* ((screen (xdefaultscreen display))
    2686         (root (xrootwindow display screen))
    2687         (window (xcreatesimplewindow
    2688                  display root 100 200 300 50 0
    2689                  (xblackpixel display screen)
    2690                  (xwhitepixel display screen))))
    2691     (assert window)
    2692     (let ((font (xloadfont display "10x20")))
    2693       (assert font)
    2694       (let ((gc (xcreategc display window 0 #f))
    2695           (event (make-xevent)))
    2696         (xsetforeground display gc (xblackpixel display screen))
    2697         (xsetbackground display gc (xwhitepixel display screen))
    2698         (xsetfunction display gc GXCOPY)
    2699         (xsetfont display gc font)
    2700         (xselectinput display window (bitwise-ior EXPOSUREMASK BUTTONPRESSMASK))
    2701         (xmapwindow display window)
    2702         (xnextevent display event)
    2703         (xdrawstring display window gc 100 30 "Hello World!" 12)
    2704         (xflush display)
    2705         (xnextevent display event)))))
     2678<enscript highlight=scheme>
     2679;;; Shows a window and terminates after a button-press
     2680;;; (or after the second exposure event)
     2681
     2682(import xlib (chicken bitwise))
     2683
     2684(let ((display (xopendisplay #f)))
     2685 (assert display)
     2686 (let* ((screen (xdefaultscreen display))
     2687        (root (xrootwindow display screen))
     2688        (window (xcreatesimplewindow
     2689                 display root 100 200 300 50 0
     2690                 (xblackpixel display screen)
     2691                 (xwhitepixel display screen))))
     2692  (assert window)
     2693  (let ((font (xloadfont display "10x20")))
     2694    (assert font)
     2695    (let ((gc (xcreategc display window 0 #f))
     2696          (event (make-xevent)))
     2697      (xsetforeground display gc (xblackpixel display screen))
     2698      (xsetbackground display gc (xwhitepixel display screen))
     2699      (xsetfunction display gc GXCOPY)
     2700      (xsetfont display gc font)
     2701      (xselectinput display window (bitwise-ior EXPOSUREMASK BUTTONPRESSMASK))
     2702      (xmapwindow display window)
     2703      (xnextevent display event)
     2704      (xdrawstring display window gc 100 30 "Hello World!" 12)
     2705      (xflush display)
     2706      (xnextevent display event)))))
     2707</enscript>
     2708
    27062709
    27072710=== Changelog
Note: See TracChangeset for help on using the changeset viewer.