2022-01-07 22:09:52 -05:00
|
|
|
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
2021-02-04 17:18:32 -05:00
|
|
|
"use strict";
|
2020-07-19 13:49:44 -04:00
|
|
|
|
|
|
|
((window) => {
|
2022-09-23 00:05:45 -04:00
|
|
|
const {
|
|
|
|
Uint32Array,
|
|
|
|
Uint8Array,
|
|
|
|
} = window.__bootstrap.primordials;
|
2020-09-16 16:22:43 -04:00
|
|
|
const core = window.Deno.core;
|
2022-08-11 09:56:56 -04:00
|
|
|
const ops = core.ops;
|
2020-07-19 13:49:44 -04:00
|
|
|
|
2022-09-23 00:05:45 -04:00
|
|
|
const size = new Uint32Array(2);
|
2020-07-19 13:49:44 -04:00
|
|
|
function consoleSize(rid) {
|
2022-09-23 00:05:45 -04:00
|
|
|
ops.op_console_size(rid, size);
|
|
|
|
return { columns: size[0], rows: size[1] };
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
2022-09-23 00:05:45 -04:00
|
|
|
const isattyBuffer = new Uint8Array(1);
|
2020-07-19 13:49:44 -04:00
|
|
|
function isatty(rid) {
|
2022-09-23 00:05:45 -04:00
|
|
|
ops.op_isatty(rid, isattyBuffer);
|
|
|
|
return !!isattyBuffer[0];
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
2022-09-23 00:05:45 -04:00
|
|
|
const DEFAULT_CBREAK = false;
|
2020-11-30 11:08:03 -05:00
|
|
|
function setRaw(rid, mode, options = {}) {
|
2022-09-23 00:05:45 -04:00
|
|
|
ops.op_set_raw(rid, mode, options.cbreak || DEFAULT_CBREAK);
|
2020-07-19 13:49:44 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
window.__bootstrap.tty = {
|
|
|
|
consoleSize,
|
|
|
|
isatty,
|
|
|
|
setRaw,
|
|
|
|
};
|
|
|
|
})(this);
|