check out my latest app: Online Check
and my latest blog post
ANSI escape codes for manipulating the terminal
License: MIT License
check out my latest app: Online Check
and my latest blog post
For better tree-shaking.
Snowpack is using this package to clear the terminal and it is causing my Windows 10 Git Bash terminal to spam output.
Here is the gist of the output: https://gist.github.com/stramel/66bed75cb5900c3a87ba1f5e6e942e74
Here is the usage: https://github.com/pikapkg/snowpack/blob/2e010bb862d3d8349b6254cbfc9f8d9d98bb0c6a/src/commands/paint.ts#L53
Also, related discussion on snowpack's discussion board: https://www.pika.dev/npm/snowpack/discuss/191
👋
We just had this issue reported which said \x1bc
(from clearScreen
) in xterm.js behaves differently to Terminal.app/iTerm xtermjs/xterm.js#3315. We behave as xterm/VTE does and don't think we should change so I would suggest indicating the fact in this lib that clearScreen
may actually clear everything.
Note also that RIS is also more destructive than just clearing the buffer, also resetting modes among other things.
how do i fix this error, im not sure what is causing the issue.
https://github.com/The-Code-Monkey/tcm-cli/runs/5390864828?check_suite_focus=true
cursorSavePosition
, and cursorRestorePosition
to not work at all on OSX.
The following appears to:
var ESC = '\u001b';
var STORE = ESC + '7';
var RESTORE = ESC + '8';
Source:
http://stackoverflow.com/questions/25879183/can-terminal-app-be-made-to-respect-ansi-escape-codes
I am not sure what the differences are, but it's worth exploring.
Our project Garden uses ansi-escapes
to update CLI output in–place and I just noticed that the cursor is all over the place on the macOS Terminal.app. (See also this issue from our project.)
Using this suggestion seems to fix the issue. I'll submit a PR shortly.
Any chance of supporting this? You can see the basic trick at the top of the original imgcat
bash script:
# tmux requires unrecognized OSC sequences to be wrapped with DCS tmux;
# <sequence> ST, and for all ESCs in <sequence> to be replaced with ESC ESC. It
# only accepts ESC backslash for ST.
function print_osc() {
if [[ $TERM == screen* ]] ; then
printf "\033Ptmux;\033\033]"
else
printf "\033]"
fi
}
# More of the tmux workaround described above.
function print_st() {
if [[ $TERM == screen* ]] ; then
printf "\a\033\\"
else
printf "\a"
fi
}
This would make it possible to use termimg
from within tmux, which would be cool!
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: xxx\node_modules_ansi-escapes@5.0.0@ansi-escapes\index.js
require() of ES modules is not supported.
Would you be interested in adding escapes for alternate screen functionality that's used in CLIs like vim, nano and others? It allows the CLI to be rendered in a separate ephemeral screen, which goes away as soon as CLI quits.
I can submit a PR that adds:
enterAlternateScreen
- \u001B[?1049h
exitAlternateScreen
- \u001B[?1049l
Hi Guys,
since yesterday afternoon (about 22 hours) I keep recieving the error message at 'yarn install' shown below.
verbose 11.853500195 Error: https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.2.0.tgz: Integrity check failed for "ansi-escapes" (computed integrity doesn't match our records, got "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==")
at SecurityError.ExtendableBuiltin (/opt/yarn-v1.15.2/lib/cli.js:721:66)
at SecurityError.MessageError (/opt/yarn-v1.15.2/lib/cli.js:750:123)
at new SecurityError (/opt/yarn-v1.15.2/lib/cli.js:779:113)
at Extract.<anonymous> (/opt/yarn-v1.15.2/lib/cli.js:62700:25)
at Extract.emit (events.js:201:15)
at finishMaybe (/opt/yarn-v1.15.2/lib/cli.js:73383:14)
at /opt/yarn-v1.15.2/lib/cli.js:73361:5
at Extract.module.exports.Extract._final (/opt/yarn-v1.15.2/lib/cli.js:139683:3)
at callFinal (/opt/yarn-v1.15.2/lib/cli.js:73354:10)
at processTicksAndRejections (internal/process/task_queues.js:84:9)
error https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-3.2.0.tgz: Integrity check failed for "ansi-escapes" (computed integrity doesn't match our records, got "sha512-cBhpre4ma+U0T1oM5fXg7Dy1Jw7zzwv7lt/GoCpr+hDQJoYnKVPLL4dCvSEFMmQurOQvSrwT7SL/DAlhBI97RQ==")
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
These are my steps:
$ rm -rf ./.yarn
$ apk add yarn
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.9/community/x86_64/APKINDEX.tar.gz
(1/6) Installing ca-certificates (20190108-r0)
(2/6) Installing c-ares (1.15.0-r0)
(3/6) Installing http-parser (2.8.1-r0)
(4/6) Installing libuv (1.23.2-r0)
(5/6) Installing nodejs (10.14.2-r0)
(6/6) Installing yarn (1.12.3-r0)
Executing busybox-1.29.3-r10.trigger
Executing ca-certificates-20190108-r0.trigger
OK: 36 MiB in 22 packages
$ yarn cache clean
yarn cache v1.15.2
success Cleared cache.
Done in 0.05s.
$ yarn config set cache-folder .yarn
yarn config v1.15.2
success Set "cache-folder" to ".yarn".
Done in 0.05s.
$ yarn install --verbose
yarn install v1.15.2
iTerm supports many proprietary escapes, and it might be cool to implement more of them.
There's also a bunch of "OSC" escapes which various terminals implement, though it's unclear to me if those escape codes are standardized in any way. It's seemingly non-trivial to get a list of which of these any given terminal supports...
For example, OSC 9 seems to be "Growl notification" as implemented by iTerm, hterm, and probably others--but I'm going to wager that implementing terminal sniffing is better suited to higher-level modules (e.g., term-img-cli).
If you're amenable to adding stuff, I'm curious:
Thanks!
I'm really enjoyed this package, but can you help me with something?
I'm trying to use this package with ts-node, but it rejects the "exports": "./index.js"
of the package because my compilerOptions.module
need to be a CJS.
I'm here to suggest ship ESM & CJS with the following configuration:
"type": "module",
"exports": {
"import": "./index.js",
"require": "./dist/index.cjs"
},
"scripts": {
...
"build": "tsup src/index.js",
"prepublishOnly": "npm run build"
},
"files": [
"dist",
"index.js",
"index.d.ts"
],
"devDependencies": {
...
"tsup": "^6.7.0",
}
wrap-ansi have the same issue
Is this viable ? Need help ?
I get the result from cursorGetPosition
is: ^[[12;1R. So how can to parse or convert this to x, y then I can use other API likes cursorMove
?
process.env
calls don't compile under Vite, so it's odd to see it in the compiled code:
import process from 'node:process';
const ESC = '\u001B[';
const OSC = '\u001B]';
const BEL = '\u0007';
const SEP = ';';
/* global window */
const isBrowser = typeof window !== 'undefined' && typeof window.document !== 'undefined';
const isTerminalApp = !isBrowser && process.env.TERM_PROGRAM === 'Apple_Terminal';
const isWindows = !isBrowser && process.platform === 'win32';
const cwdFunction = isBrowser ? () => {
throw new Error('`process.cwd()` only works in Node.js, not the browser.');
} : process.cwd;
const ansiEscapes = {};
// and so on...
Compiled output in browser:
const ESC = '\u001B[';
const OSC = '\u001B]';
const BEL = '\u0007';
const SEP = ';';
const isTerminalApp = process.env.TERM_PROGRAM === 'Apple_Terminal';
const ansiEscapes = {};
// and so on...
I'm guessing that the inBrowser
check on line 9 probably isn't suitable for detecting a bundler like Vite
(or perhaps I have something set up wrong...)
My project depends on [email protected]. When I tried updating to tsc 4.8, I'm now getting these errors:
node_modules/type-fest/ts41/get.d.ts:95:37 - error TS2344: Type 'BaseType' does not satisfy the constraint 'Record<string | number, any>'.
95 : Key extends keyof WithStringKeys<BaseType>
~~~~~~~~
node_modules/type-fest/ts41/get.d.ts:79:17
79 type PropertyOf<BaseType, Key extends string> =
~~~~~~~~
This type parameter might need an `extends Record<string | number, any>` constraint.
node_modules/type-fest/ts41/get.d.ts:96:19 - error TS2344: Type 'BaseType' does not satisfy the constraint 'Record<string | number, any>'.
96 ? WithStringKeys<BaseType>[Key]
~~~~~~~~
node_modules/type-fest/ts41/get.d.ts:79:17
79 type PropertyOf<BaseType, Key extends string> =
~~~~~~~~
This type parameter might need an `extends Record<string | number, any>` constraint.
Found 2 errors in the same file, starting at: node_modules/type-fest/ts41/get.d.ts:95
Would updating this package's type-fest version help? But I see that it updates the minimum TS version supported, so updating it might be a semver major change? Slightly messy.
I'd like to add some of the ConEmu-specific escape codes via a PR if it's okay with you.
documentation:
https://conemu.github.io/en/AnsiEscapeCodes.html#ConEmu_specific_OSC
For example, the equivalent to this iTerm 2 sequence:
Line 129 in 5f93eca
Would be this for ConEmu:
x.ConEmu.setCwd = (cwd = process.cwd()) => `${OSC}9;9;${cwd}${BEL}`;
per the documentation:
Sequence Description ESC ] 9 ; 9 ; “cwd” ST
Inform ConEmu about shell current working directory.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.