A DomTerm instance encapsulates the state of a terminal emulator / console.
Functions and properties not documented here should be considered internal and (more) likely to change.
Create a new DomTerm instance. The parameter
name
is a string. If you have multiple DomTerm instances, it is a good idea for the names to unique, but currently nothing depends on that.
Function: initializeTerminal
(element
)
Initialize the DomTerm, and associate it with the give
element
(which should be a<div>
element that hasclass="domterm"
). This creates the sub-structure of child elements ofelement
.
Interpret and insert the characters of
str
. It may have ANSI/xterm escape sequences. This method is called by the DomTerm client code.
This method is called by the DomTerm client code to notify DomTerm that the client has terminated. The backend repeatedly calls
insertString
and then finally callseofSeen
to signal end-of-file.This function may be overridden. The default action is to call the
close
function of the current window.
Function: processInputCharacters
(str
)
Send
str
to the client, wherestr
consists of typed characters and other events. This is a callback function that must be set by the client. This is called by the DomTerm code interminal.js
.
Function: reportEvent
(name
, data
)
Called by DomTerm to notify the client that some (non-character) event happened. The default action calls
processInputCharacter
with a special sequence starting with"\x92"
followed by thename
, space, thedata
and a newline.
Function: setWindowSize
(numRows
, numColumns
, availHeight
, availWidth
)
Called by DomTerm when the window changes size, or the (font) style changes so the number of rows or columns has changed. Is used to notify the client. The default behavior is to call
reportEvent
with a"WS"
event type.
Handles a
paste
operation. May be called by client code. May also be overridden if needed; the default usesexecCommand
, which triggers apaste
event. It is called by DomTerm if the user types Ctrl-Shift-V.
Called by the
paste
event handler. Actually handle a paste event.
Handles a
copy
operation. May be called by client code. May also be overridden if needed; the default usesexecCommand
. It is called by DomTerm if the user types Ctrl-Shift-C.
Set the input editing mode. The value 99 (
'c'
) sets character mode (each keystroke is sent to the client); the value 108 ('l')
sets line mode (local line editing with a complete line sent on enter); the value 97 ('a'
) sets automatic mode (switch between line and character modes depending on client pty state); the value 112 ('p'
) sets pipe mode (like line mode but with local echoing).
Function: doLineEdit
(key
, str
)
Handle keyboard event when doing input line editing ourselves, rather than depending on the default action. This is used if the
useDoLineEdit
property is set. It is also used for the first character in automatic input editing mode. (In that case we can’t use the browser default action, since we first have to check the input mode of the client.)
Called when ctrl-G (the
bell
character) is seen. The default action is to do nothing.
Function: handleLink
(event
, href
)
Called on a click event on a
<a>
link element. The default action is to callpreventDefault
on theevent
, and then callreportEvent
with an"ALINK"
type event. (We can’t let the browser do its default action since that would replace the current DomTerm page.)
Function: setWindowTitle
(title
, option
)
Set the title of the containing window. Called by DomTerm when it sees certain
xterm
-style escape sequences. CallsupdateWindowTitle(formatWindowTitle())
.
Function: formatWindowTitle
()
Returns a suitable string for a window title, based on various properies.
Function: updateWindowTitle
(title
)
Actualy set the window title - which is usually the result of
formatWindowTitle()
.
Function: elementInfo
(tag
, parents
)
Overridable function called by the HTML sanitizer.
Function: allowAttribute
(name
, value
elementInfo
, parents
)
Overridable function called by the HTML sanitizer.