diff options
Diffstat (limited to 'runtime/js')
-rw-r--r-- | runtime/js/40_tty.js | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/runtime/js/40_tty.js b/runtime/js/40_tty.js index 9cf351cc0..f43859ed7 100644 --- a/runtime/js/40_tty.js +++ b/runtime/js/40_tty.js @@ -2,24 +2,28 @@ "use strict"; ((window) => { + const { + Uint32Array, + Uint8Array, + } = window.__bootstrap.primordials; const core = window.Deno.core; const ops = core.ops; + const size = new Uint32Array(2); function consoleSize(rid) { - return ops.op_console_size(rid); + ops.op_console_size(rid, size); + return { columns: size[0], rows: size[1] }; } + const isattyBuffer = new Uint8Array(1); function isatty(rid) { - return ops.op_isatty(rid); + ops.op_isatty(rid, isattyBuffer); + return !!isattyBuffer[0]; } - const DEFAULT_SET_RAW_OPTIONS = { - cbreak: false, - }; - + const DEFAULT_CBREAK = false; function setRaw(rid, mode, options = {}) { - const rOptions = { ...DEFAULT_SET_RAW_OPTIONS, ...options }; - ops.op_set_raw({ rid, mode, options: rOptions }); + ops.op_set_raw(rid, mode, options.cbreak || DEFAULT_CBREAK); } window.__bootstrap.tty = { |