**** mass:werk termlib.js - JS-WebTerminal Object v1.42 ****
(c) Norbert Landsteiner 2003-2009
mass:werk - media environments
<http://www.masswerk.at>
### COMPATIBILITY WARNING ###
For the first time there is a backward compatibility issue from version 1.3 to version 1.4:
The following applies to the style vector for the `type()' method while using colors:
while with version 1.3 a color was encoded using the color code times 16 (0xf), e.g.:
myTerm.type( 'This is red.', 2*16 );
this changed with version 1.4 to the color code times 256 (0xff), e.g.:
myTerm.type( 'This is red.', 2*256 );
All other style encodings or color API remain unchanged.
Since this feature was only introduced in version 1.3 and there are no known applications
that would use a statement like the above (since you would usually use the `write()' method
for complex output), this seems to be good bargain for some codes for custom styles.
C.f.: sect 7.5 "TermGlobals.assignStyle()"
Contents:
1 About
2 Creating a new Terminal Instance
2.1 Configuration Values
3 Using the Terminal
3.1 The Default Handler
3.2 Input Modes
3.2.1 Normal Line Input (Command Line Mode)
3.2.1.2 Special Keys (ctrlHandler)
3.2.2 Raw Mode
3.2.3 Character Mode
3.3 Other Handlers
3.3.1 initHandler
3.3.2 exitHandler
3.4 Flags for Behaviour Control
4 Output Methods
4.1 Terminal.type()
4.2 Terminal.write()
4.3 Terminal.typeAt()
4.4 Terminal.setChar()
4.5 Terminal.newLine()
4.6 Terminal.clear()
4.7 Terminal.statusLine()
4.8 Terminal.printRowFromString()
4.9 Terminal.redraw()
4.10 Using Color
4.11 Text Wrap - Terminal.wrapOn(), Terminal.wrapOff()
5 Cursor Methods and Editing
5.1 Terminal.cursorOn()
5.2 Terminal.cursorOff()
5.3 Terminal.cursorSet()
5.4 Terminal.cursorLeft()
5.5 Terminal.cursorRight()
5.6 Terminal.backspace()
5.7 Terminal.fwdDelete()
5.8 Terminal.isPrintable()
6 Other Methods of the Terminal Object
6.1 Terminal.prompt()
6.2 Terminal.reset()
6.3 Terminal.open()
6.4 Terminal.close()
6.5 Terminal.focus()
6.6 Terminal.moveTo()
6.7 Terminal.resizeTo()
6.8 Terminal.getDimensions()
6.9 Terminal.rebuild()
7 Global Static Methods (TermGlobals)
7.1 TermGlobals.setFocus()
7.2 TermGlobals.keylock (Global Locking Flag)
7.3 TermGlobals Text Methods
7.3.1 TermGlobals.normalize()
7.3.2 TermGlobals.fillLeft()
7.3.3 TermGlobals.center()
7.3.4 TermGlobals.stringReplace()
7.4 TermGlobals Import Methods
7.4.1 TermGlobals.insertText()
7.4.2 TermGlobals.importEachLine()
7.4.3 TermGlobals.importMultiLine()
7.5 TermGlobals.assignStyle()
8 Localization
9 Cross Browser Functions
10 Architecture, Internals
10.1 Global Entities
10.2 I/O Architecture
10.3 Compatibility
11 History
12 Example for a Command Line Parser
13 The Socket Extension (Remote Communication)
13.1 A First Example
13.2 The send() API
13.3 Global Config Settings
13.4 The Callback (Response Handling)
13.5 Error Codes
13.6 Note on Compatibly / Browser Requirements
13.7 termlib_socket.js Version History
14 License
15 Disclaimer
16 References
1 About
The Terminal library "termlib.js" provides an object oriented constructor and control
methods for a terminal-like DHTML interface.
"termlib.js" features direct keyboard input and powerful output methods for multiple
instances of the `Terminal' object (including focus control).
The library was written with the aim of simple usage and a maximum of compatibility with
minimal foot print in the global namespace.
A simple example:
// creating a terminal and using it
var term = new Terminal( {handler: termHandler} );
term.open();
function termHandler() {
var line = this.lineBuffer;
this.newLine();
if (line == "help") {
this.write(helpPage)
}
else if (line == "exit") {
this.close();
return;
}
else if (line != "") {
this.write("You typed: "+line);
}
this.prompt();
}
var helpPage = [
"This is the monstrous help page for my groovy terminal.",
"Commands available:",
" help ... print this monstrous help page",
" exit ... leave this groovy terminal",
" ",
"Have fun!"
];
You should provide CSS font definitions for the classes ".term" (normal video) and
".termReverse" (reverse video) in a monospaced font.
A sample stylesheet "term_styles.css" comes with this library.
See the sample application "multiterm_test.html" for a demo of multiple terminals.
v.1.01: If you configure to use another font class (see 2.1 Configuration Values),
you must provide a subclass ".termReverse" for reversed video.
p.e.: .myFontClass .termReverse {
/* your definitions for reverse video here */
}
With the addition of `conf.fontClass' you can now create multiple
instances with independend appearences.
2 Creating a new Terminal Instance
Use the `new' constructor to create a new instance of the Terminal object. You will want
to supply a configuration object as an argument to the constructor. If the `new'
constructor is called without an object as its first argument, default values are used.
p.e.:
// creating a new instance of Terminal
var conf= {
x: 100,
y: 100,
cols: 80,
rows: 24
}
var term = new Term(conf);
term.open();
`Terminal.open()' initializes the terminal and makes it visible to the user.
This is handled in by separate method to allow the re-initilization of instances
previously closed.
NOTE:
The division element (or NS-layer) that holds the terminal must be present when calling
`Terminal.open()'. So you must not call this method from the header of a HTML-document at
compile time.
2.1 Configuration Values
Set any of these values in your configuration object to override:
LABEL DEFAULT VALUE COMMENT
x 100 terminal's position x in px
y 100 terminal's position y in px
divDiv 'termDiv' id of terminals CSS division
bgColor '#181818' background color (HTML hex value)
frameColor '#555555' frame color (HTML hex value)
frameWidth 1 frame border width in px
fontClass 'term' class name of CSS font definition to use
cols 80 number of cols per row
rows 24 number of rows
rowHeight 15 a row's line-height in px
blinkDelay 500 delay for cursor blinking in milliseconds
crsrBlinkMode false true for blinking cursor
crsrBlockMode true true for block-cursor else underscore
DELisBS false handle <DEL> as <BACKSPACE>
printTab true handle <TAB> as printable (prints as space)
printEuro true handle unicode 0x20AC (Euro sign) as printable
c
没有合适的资源?快使用搜索试试~ 我知道了~
JS/UIX web形式的DOS窗口
共23个文件
html:14个
txt:4个
js:4个
需积分: 42 23 下载量 130 浏览量
2009-09-24
17:36:14
上传
评论
收藏 109KB ZIP 举报
温馨提示
JS/UIX 是一个基于Web浏览器的类Unix操作系统,可以实现web形式的DOS窗口
资源推荐
资源详情
资源评论
收起资源包目录
termlib.zip (23个子文件)
termlib
parser_sample.html 8KB
samples.html 4KB
termlib.js 66KB
tests
test1.txt 34B
whats_inside.txt 183B
test2.txt 369B
sample_style_settings.html 12KB
sample_socket.html 19KB
sample_import.html 9KB
term_styles.css 178B
faq.html 18KB
sample_globbing.html 15KB
termlib_socket.js 11KB
sample_wrap.html 12KB
readme.txt 80KB
index.html 7KB
sample_color.html 22KB
termlib_parser.js 6KB
sample_chrome.html 18KB
termlib_invaders.js 19KB
multiterm_test.html 4KB
sample_invaders.html 6KB
sample_remote_terminal.html 18KB
共 23 条
- 1
资源评论
wangleileo
- 粉丝: 5
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功