Changeset 31226 in project


Ignore:
Timestamp:
08/17/14 22:25:27 (5 years ago)
Author:
svnwiki
Message:

Anonymous wiki edit for IP [88.159.209.23]:

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wiki/eggref/4/termbox

    r31225 r31226  
    3636;; Create a list of cells of every character in the string "Hello world !!!!!!"
    3737;; all with a black underlined foreground and a yellow background.
    38 (define cells (create-cells "Hello world !!!!!!" (black underline) yellow))
     38(define cells (create-cells "Hello world !!!!!!"
     39                            (style black underline) (style yellow)))
    3940
    4041(let loop ()
     
    4344  (blit 5 5 6 3 cells)
    4445
    45   ;; Present all made changes to the screen.
     46  ;; Present the just blited box to the screen
    4647  (present)
    4748
     
    5152
    5253           ;; When enter is pressed, clear the screen to a random colour.
    53            ((eq? key key-enter) (clear black (random-colour)))
     54           ((eq? key key-enter) (clear (style black)
     55                                       (style (random-colour))))
    5456
    5557           ;; When escape is pressed stop the script.
     
    5860        (lambda (w h)
    5961          ;; When screen is resized, print the screensize at the top-left corner
    60           (bprintf 0 0 black white "screen size ~a, ~a" w h)
    61           ))
     62          (bprintf 0 0
     63                   (style black underline) (style white)
     64                   "screen size ~a, ~a" w h)))
    6265
    6366  ;; Continue running the loop when enter was not pressed.
     
    7073=== Documentation
    7174
    72 ==== Syntax
    73 <syntax>(create-cell char fg bg)</syntax><br/>
    74 <syntax>(create-cell char (fg attributes ...) bg)</syntax><br/>
     75<procedure>(style colour attributes ...)</procedure><br/>
     76Creates a style, combining a ''colour'' with zero or more
     77attributes: ''underline'', ''bold'', and ''reversed''.
     78
     79<procedure>(create-cell char fg-style bg-style)</procedure><br/>
    7580Creates a cell containing a character with specific foreground and
    7681background colours/attributes. These can then be put on screen with
    7782the functions ''(put-cell!)'' or ''(blit)''.
    7883
    79 
    80 ''fg'' and ''bg'' can be a list starting with a colour
    81 plus zero or more attributes: bold, underline or reversed.
    82 
    83 
    8484Example:
     85<enscript highlight="scheme">
    8586        ; Create a letter ''H'' with black text and a white background.
    86         (create-cell #\H black white)
     87        (create-cell #\H (style black) (style white))
    8788        ; Create a letter ''H'' with black underlines text and a white background.
    88         (create-cell #\H (create-attributes (black underline) white)
     89        (create-cell #\H (style black underline) (style white))
     90</enscript>
     91
     92<procedure>(create-cells string fg-style bg-style)</procedure><br/>
     93Create a list of cells of all characters in ''string'' all sharing the
     94same foreground and background style.
    8995
    9096==== Procedures
    9197
    92 <procedure>(init)</procedure></br>
    93 <procedure>(shutdown)</procedure></br>
     98<procedure>(init)</procedure><br/>
     99<procedure>(shutdown)</procedure><br/>
    94100Initializes the termbox library. This function should be called before any
    95101other functions. After successful initialization, the library must be
    96102finalized using the ''(shutdown)'' function.
    97103
    98 <procedure>(width)</procedure></br>
    99 <procedure>(height)</procedure></br>
     104<procedure>(width)</procedure><br/>
     105<procedure>(height)</procedure><br/>
    100106Returns the size of the internal back buffer (which is the same as
    101107terminal's window size in characters). The internal buffer can be resized
     
    104110
    105111
    106 <procedure>(clear [fg bg])</procedure></br>
     112<procedure>(clear [fg bg])</procedure><br/>
    107113Clears the interbal back buffer to specific foreground and background
    108 color/attributes which default to ''color-default''
    109 
    110 <procedure>(present)</procedure></br>
     114colour which default to ''colour-default''
     115
     116<procedure>(present)</procedure><br/>
    111117Syncronizes the internal back buffer with the terminal.
    112118
    113 <procedure>(cursor-set! x y)</procedure></br>
     119<procedure>(cursor-set! x y)</procedure><br/>
    114120Sets the position of the cursor. Upper-left character is (0, 0).
    115121
    116 <procedure>(hide-cursor!)</procedure></br>
     122<procedure>(hide-cursor!)</procedure><br/>
    117123Hides the cursor. If ''(cursor-set!)'' is called after this the
    118124cursor will be visible again. Cursor is hidden by default.
    119125
    120 <procedure>(put-cell!)</procedure></br>
     126<procedure>(put-cell!)</procedure><br/>
    121127Changes cell's parameters in the internal back buffer at the specified
    122128position.
    123129
    124 <procedure>(blit x y w h cells)</procedure></br>
     130<procedure>(blit x y w h cells)</procedure><br/>
    125131Copies the buffer from 'cells' at the specified position, assuming the
    126132buffer is a two-dimensional list of size ('w' x 'h'), represented as a
    127133one-dimensional list containing lines of cells starting from the top.
    128134
    129 <procedure>(bprintf x y fg bg formatstring ... args)</procedure><br/>
     135<procedure>(bprintf x y fg-style bg-style formatstring ... args)</procedure><br/>
    130136Prints a formated string (like printf) at position (x y).
    131137Using a specific foreground and background style.
    132138
    133 <procedure>(input-mode [mode])</procedure></br>
    134 Sets the termbox input mode. Termbox has two input modes:</br>
     139<procedure>(input-mode [mode])</procedure><br/>
     140Sets the termbox input mode. Termbox has two input modes:<br/>
    135141
    136142
     
    143149Returns the current mode if node ''mode'' is given.
    144150
    145 <procedure>(output-mode [mode])</procedure></br>
     151<procedure>(output-mode [mode])</procedure><br/>
    146152Sets the termbox output mode. Termbox has three output options:
    147153
    148154
    149 * ''normal'' [1..8]:  This mode provides 8 different colors: black, red, green, yellow, blue, magenta, cyan, white.
     155* ''normal'' [1..8]:  This mode provides 8 different colours: black, red, green, yellow, blue, magenta, cyan, white.
    150156Attributes: bold, underline, reversed
    151157
    152158
    153159Example usage:
    154        (change_cell! x y #\@ (create-attribute color-black bold) red)
     160       (change_cell! x y #\@ (style black bold) red)
    155161
    156162* ''256'' [0..256]:  In this mode you can leverage the 256 terminal mode:
    157 ** 0x00 - 0x07: the 8 colors as in ''normal''
    158 ** 0x08 - 0x0f: (create-attribute colour-* bold)
    159 ** 0x10 - 0xe7: 216 different colors
     163** 0x00 - 0x07: the 8 colours as in ''normal''
     164** 0x08 - 0x0f: (style red bold)
     165** 0x10 - 0xe7: 216 different colours
    160166** 0xe8 - 0xff: 24 different shades of grey
    161167
     
    171177Returns the current mode if node ''mode'' is given.
    172178
    173 <procedure>(poll on-keypress on-resize)</procedure></br>
     179<procedure>(poll on-keypress on-resize)</procedure><br/>
    174180Waits until there is an event availiable. If there is it
    175181will call, if it is a key event, ''on-keypress'' which must
     
    253259===== Key modifiers
    254260
    255 <constant>d-alt</constant><br/>
     261<constant>mod-alt</constant><br/>
    256262
    257263===== Colours
Note: See TracChangeset for help on using the changeset viewer.