
Research
Security News
The Growing Risk of Malicious Browser Extensions
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
ansiterm
is a library for manipulating terminal input and output.
npm install ansiterm
ANSITerm
This library provides a main object for interacting with the terminal. Besides
the methods on it, instances of the object also function as an EventEmitter
to
inform the consumer when keys are pressed or the window gets resized.
ANSITerm#clear()
Clear the screen.
ANSITerm#cursor(show)
Enable or disable the cursor by passing true or false respectively.
ANSITerm#size()
Returns an object indicating the terminal size:
h
, the number of rows of the terminalw
, the number of columns of the terminalANSITerm#softReset()
Resets the terminal state.
ANSITerm#moveto(x, y)
Move the cursor to a new location.
"resize"
Indicates that the terminal has been resized. Emits the new size, as
represented by ANSITerm#size()
.
"keypress"
Emitted when a normal key has been pressed. Passes the string representation of
the character pressed (e.g., "c"
, "C"
, "!"
, etc.).
"control"
Emitted when a control character has been pressed, e.g. ^C
. An object
is passed with the event, containing the following fields:
key
, a representation of the keys pressed, e.g. ^[
for escape, ^C
for
control-C, ^H
for backspace, ^I
for tab, etc.ascii
, the ASCII name of the control character (e.g. NUL
, SOH
, etc.)"special"
Emitted for special keys on the keyboard. An string is passed with the event, indicating which key was pressed:
"home"
)"insert"
)"delete"
)"end"
)"prior"
)"next"
)"up"
, "down"
, "right"
, or "left"
)"reverse-tab"
)Additionally, an object is passed with the following fields:
alt
, indicating if alt was held while pressing the keyshift
, indicating if shift was held while pressing the keycontrol
, indicating if control was held while pressing the keymeta
, indicating if meta (super) was held while pressing the keyNote that terminals don't support the full matrix of possible combinations, and will ignore shift or control in some cases.
wcwidth(codepoint)
When given a numeric UCS codepoint, this function will return how many columns are needed to display it in the terminal. This function is compatible with wcwidth(3C) in C.
wcswidth(str)
When given a string, this function will return how many columns are needed to display it when printed to the terminal. If the string contains any nonprintable characters, then this returns -1. This function is compatible with wcswidth(3C) in C.
forEachGrapheme(str, f)
This function will call f(grapheme, width)
for each individual grapheme.
Combining characters are grouped with their preceding, printing character, and
nonprintable characters (width of -1) are emitted independently.
MIT
FAQs
Terminal Handling Utility Library
The npm package ansiterm receives a total of 1 weekly downloads. As such, ansiterm popularity was classified as not popular.
We found that ansiterm demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover how browser extensions in trusted stores are used to hijack sessions, redirect traffic, and manipulate user behavior.
Research
Security News
An in-depth analysis of credential stealers, crypto drainers, cryptojackers, and clipboard hijackers abusing open source package registries to compromise Web3 development environments.
Security News
pnpm 10.12.1 introduces a global virtual store for faster installs and new options for managing dependencies with version catalogs.