1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-25 15:29:32 -05:00
denoland-deno/runtime/js/40_tty.js

29 lines
603 B
JavaScript
Raw Normal View History

// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
"use strict";
((window) => {
2022-09-23 00:05:45 -04:00
const {
Uint32Array,
Uint8Array,
} = window.__bootstrap.primordials;
const core = window.Deno.core;
const ops = core.ops;
2022-09-23 00:05:45 -04:00
const size = new Uint32Array(2);
function consoleSize() {
ops.op_console_size(size);
2022-09-23 00:05:45 -04:00
return { columns: size[0], rows: size[1] };
}
2022-09-23 00:05:45 -04:00
const isattyBuffer = new Uint8Array(1);
function isatty(rid) {
2022-09-23 00:05:45 -04:00
ops.op_isatty(rid, isattyBuffer);
return !!isattyBuffer[0];
}
window.__bootstrap.tty = {
consoleSize,
isatty,
};
})(this);