0.1.1 • Published 7 years ago

tercon v0.1.1

Weekly downloads
1
License
Unlicense
Repository
-
Last release
7 years ago
This program is used as a library for full-screen terminal controls. The
export is the Screen function which can be called as a constructor. (Note:
Currently it does not do much and there may be some bugs; it may be fixed
later on. Also it is not currently compatible with Windows for local
terminals; you may be able to use it with remote terminals but this
function is currently untested.)

The constructor takes two arguments: Screen(output,input) if you omit both
then it applies to the stdin/stdout connected terminal, and it will also
call stty and will automatically restore the terminal when the program is
terminated (it will handle the process exit event). If you omit the input
but do specify output, then it is both same one (for example, if it is a
socket, so that you can make a telnet service).

All strings must be using the UTCE character set; it will automatically
convert into the relevant ISO 2022 encoding. (Currently, only ASCII and
VT100 character graphics are supported.)

Static properties:

.colorMap = An array of colour codes; converts PC colour codes into ANSI
colour codes.

.strwidth(x) = Tell you the width of string x.

Instance/prototype properties:

.bell() = Ring the terminal bell.

.cls([full]) = Clear the screen. If there is a window, only wildow will be
clear unless you specify true as its argument in which case you can clear
everything.

.color(x) = Set the colour. The format is the same as PC colours (with
blinking instead of high intensity background), and bit8 means underline.
Also programs the background colour to clear the screen.

.delayRefresh() = Delays a refresh of the current terminal parameters.

.height = Height of the screen. (Do not change this value unless the
height of the screen is actually changed using another mechanism.)

.locate([y],[x],[cursor]) = Set the cursor position (1-based). You can
also set whether or not the cursor is visible (true to make visible,
false to make not visibiel; null or undefined means no change).

.nextLine() = Emit a line break. It will scroll the screen if necessary.

.onInput(key) = Called when the user pushes a key (except escape). You
can override this to respond to keys. The parameter given will be the
ANSI code of the key pushed.

.onResize(w,h) = Called when the terminal is resized. You can override
this to specify what to do in such case.

.print(x) = Print text. Can include line breaks.

.printRaw(x) = Print a raw UTCE string without updating the internal
knowledge of the cursor position; can't include control characters. You
can override this if you want to control the translation from UTCE into
the terminal's codes.

.refresh([x]) = Refresh current terminal parameters immediately. You can
optionally specify a ANSI string for additional parameters.

.scroll(amount) = Scroll the screen (or the current window). Positive
numbers move existing text up and leave blank space at the bottom;
negative numbers move existing text down and leave space at the top.

.view(top,left,height,width) = Set the window (coordinates are 1-based).
If you omit all parameters then it applies to full screen.

.width = Width of the screen. (Do not change this value unless the width
of the screen is actually changed using another mechanism.)