Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
== Outdated egg! This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for [[/eggref/5/mojo|the CHICKEN 5 version of this egg]], if it exists. If it does not exist, there may be equivalent functionality provided by another egg; have a look at the [[https://wiki.call-cc.org/chicken-projects/egg-index-5.html|egg index]]. Otherwise, please consider porting this egg to the current version of CHICKEN. [[tags: egg]] == mojo [[toc:]] === Description Mojo is a high-level API for the infamous ncurses library. It's fairly incomplete but does a few useful things already so that it may be interesting to others. As a real world example see the Chicken implementation of the board game [[https://github.com/DerGuteMoritz/kalaha/|kalaha]] which is based on Mojo. === Author [[/users/moritz-heidkamp|Moritz Heidkamp]] === Requirements Mojo is built with the [[/egg/coops|coops]] object system. Additionally it (obviously) requires ncurses to be available on your system and the [[/egg/ncurses|ncurses egg]] as well as [[/egg/miscmacros|miscmacros]]. === Documentation Mojo basically provides a window layout API (window as in ncurses {{WINDOW}}), i.e. it allows specifying dimensions and relations of windows in relative and absolute terms. Everything else (like displaying text, coloring etc.) has to be done through the low-level [[/egg/ncurses|ncurses]] API at the time being. ==== General <procedure>(initialize #!key terminal)</procedure> Initializes {{terminal}} for ncurses operation. By default this is the terminal connected to {{(current-output-port)}}. Usually this procedure has to be called once before the program's main loop. <procedure>(redraw)</procedure> Draws all Mojo windows. This should usually be called at the beginning of the program's main loop. <parameter>width</parameter> The current terminal width. <parameter>height</parameter> The current terminal height. <procedure>(get-char)</procedure> Reads a character using ncurses' {{getch}} and implicitly handles {{KEY_RESIZE}}. ==== Windows Windows in Mojo are represented as [[/egg/coops|coops]] objects. <class><win></class> This is the class that represents a Mojo window. It has the following public slots: ; left : the distance from the left ; right : the distance from the right ; top : the distance from the top ; bottom : the distance from the bottom ; pointer : the ncurses window pointer <procedure>(win-left win)</procedure> <procedure>(win-right win)</procedure> <procedure>(win-top win)</procedure> <procedure>(win-bottom win)</procedure> <procedure>(win-pointer win)</procedure> Accessors for the respective {{<win>}} slots. <procedure>(make-win #!key width height left right top bottom left-of right-of below above box background)</procedure> Convenience constructor function so you don't have to {{(use coops)}} in your program to create window objects. {{box}} is a boolean indicating whether to draw a border box around the window. The default is {{#t}}. {{background}} is a boolean indicating whether to fill the window's background with the foreground color. It does not work very well. The default is {{#f}}. All other arguments are used for specifying dimension, position and relation of the window. In the simplest case, a {{width}} and a {{height}} is given as well as absolute {{top}}/{{bottom}} and {{left}}/{{right}} positions: <enscript highlight="scheme"> (make-win width: 10 height: 5 left: 2 top: 2) </enscript> However, almost all combinations are possible, e.g. one could leave out the {{width}} and only specify the positions from the {{left}} and {{right}} borders of the terminal. This will result in a variable width window that is resized when the terminal is resized, maintaining its distance from the left and right borders: <enscript highlight="scheme"> (make-win height: 5 top: 2 left: 2 right: 2) </enscript> The {{left-of}}, {{right-of}}, {{above}} and {{below}} arguments can take other windows as values. All positions and distances are then relative to the outer borders of that window. For example: <enscript highlight="scheme"> (define foo (make-win width: 2 height: 1 left: 2 top: 2)) (define bar (make-win right-of: foo width: 2 height: 1 left 1)) </enscript> This will draw {{bar}} on the right of {{foo}} with 1 unit distance between them. Since no vertical positioning of {{bar}} is given its upper border will align with that of {{foo}}. ==== Constants <constant>key-up</constant> <constant>key-down</constant> <constant>key-left</constant> <constant>key-right</constant> Character values of arrow keys as returned by {{get-char}}. === License Copyright (c) 2010-2012, Moritz Heidkamp All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you add 13 to 13?