summaryrefslogtreecommitdiff
path: root/runtime/js/40_tty.js
blob: 598d3323764c71207349f28da3fe7f7977363286 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.

((window) => {
  const core = window.Deno.core;

  function consoleSize(rid) {
    return core.jsonOpSync("op_console_size", { rid });
  }

  function isatty(rid) {
    return core.jsonOpSync("op_isatty", { rid });
  }

  const DEFAULT_SET_RAW_OPTIONS = {
    cbreak: false,
  };

  function setRaw(rid, mode, options = {}) {
    const rOptions = { ...DEFAULT_SET_RAW_OPTIONS, ...options };
    core.jsonOpSync("op_set_raw", { rid, mode, options: rOptions });
  }

  window.__bootstrap.tty = {
    consoleSize,
    isatty,
    setRaw,
  };
})(this);