topical media & game development
lib-js-terminal-sample-globbing.htm / htm
<html>
<head>
<title>termlib Globbing Sample</title>
<script language="JavaScript" type="text/javascript" src="lib-js-terminal-termlib.js"></script>
<script type="text/javascript">
<!--
// *** text import sample ***
// mass:werk, N.Landsteiner 2009
// dictionary for globbing
// Object of arrays per first letter, others in 'nonalpha'
var termGlobDict = {
'a': [
'all',
'alternate',
'any',
'anyone',
'anywhere',
'anyhow',
'are',
'arbitrage',
'arbitrary'
],
'b': [
'bar',
'bit',
'byte',
'better',
'best',
'boost',
'booster'
],
'c': [
'case',
'character',
'completion'
],
'd': [
'delete',
'dialog',
'display'
],
'e': [
'either',
'element',
'empty'
],
'f': [
'first',
'foo',
'function'
],
'g': [
'get',
'glob',
'globbing'
],
'h': [
'head',
'heat',
'help'
],
'i': [
'is',
'it',
'iteration'
],
'j': [
'joke',
'just',
'justice'
],
'k': [
'karma',
'kilo',
'kilobit'
],
'l': [
'lambda',
'like',
'limit'
],
'm': [
'meta',
'metaphysic',
'metaphor'
],
'n': [
'neither',
'never',
'number'
],
'o': [
'object',
'open',
'order'
],
'p': [
'parser',
'print',
'prompt'
],
'q': [
'quantum',
'query',
'quote'
],
'r': [
'remember',
'rest',
'roman'
],
's': [
'sane',
'some',
'sort'
],
't': [
'target',
'tell',
'tolerance'
],
'u': [
'under',
'upper',
'urgent'
],
'v': [
'vane',
'vertical',
'vital'
],
'w': [
'want',
'which',
'width'
],
'x': [
'x-ray',
'xanadu',
'xylophone'
],
'y': [
'yacht',
'yet',
'ypsilon'
],
'z': [
'zet',
'zeta',
'zoom'
],
'nonalpha': [
// non-alphanumeric go here
'100',
'1000',
'0.0',
'#!/usr/bin/perl'
]
};
// flag: sort hit list alphabetical
var termGlobSortAlphabetical = false;
var term;
function termOpen() {
if ((!term) || (term.closed)) {
term = new Terminal(
{
x: 220,
y: 70,
termDiv: 'termDiv',
bgColor: '#232e45',
greeting: '%+r **** termlib.js globbing sample **** %-r\%n\%ntype any text and hit ESC or TAB for globbing.\%ntype "exit" to quit.\%n ',
handler: termHandler,
exitHandler: termExitHandler,
ctrlHandler: termCtrlHandler,
printTab: false,
closeOnESC: false
}
);
term.open();
// dimm UI text
var mainPane = (document.getElementById)?
document.getElementById('mainPane') : document.all.mainPane;
if (mainPane) mainPane.className = 'lh15 dimmed';
}
}
function termExitHandler() {
// reset the UI
var mainPane = (document.getElementById)?
document.getElementById('mainPane') : document.all.mainPane;
if (mainPane) mainPane.className = 'lh15';
}
function termHandler() {
// default handler + exit
this.newLine();
if (this.lineBuffer.search(/^\s*exit\s*\|\!])/g, '\$1');
re = new RegExp('^'+qword, 'i');
rword = new RegExp('^'+qword+'
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.