summaryrefslogtreecommitdiff
path: root/cli/js
diff options
context:
space:
mode:
Diffstat (limited to 'cli/js')
-rw-r--r--cli/js/deno_unstable.ts2
-rw-r--r--cli/js/lib.deno.unstable.d.ts15
-rw-r--r--cli/js/ops/tty.ts4
3 files changed, 20 insertions, 1 deletions
diff --git a/cli/js/deno_unstable.ts b/cli/js/deno_unstable.ts
index 7d75c1c6a..f92d767b3 100644
--- a/cli/js/deno_unstable.ts
+++ b/cli/js/deno_unstable.ts
@@ -12,7 +12,7 @@ export { openPlugin } from "./ops/plugins.ts";
export { transpileOnly, compile, bundle } from "./compiler_api.ts";
export { applySourceMap, formatDiagnostics } from "./ops/errors.ts";
export { signal, signals, Signal, SignalStream } from "./signals.ts";
-export { setRaw } from "./ops/tty.ts";
+export { setRaw, consoleSize } from "./ops/tty.ts";
export { utimeSync, utime } from "./ops/fs/utime.ts";
export { ftruncateSync, ftruncate } from "./ops/fs/truncate.ts";
export { shutdown, ShutdownMode } from "./net.ts";
diff --git a/cli/js/lib.deno.unstable.d.ts b/cli/js/lib.deno.unstable.d.ts
index f237cd4be..a6547ebca 100644
--- a/cli/js/lib.deno.unstable.d.ts
+++ b/cli/js/lib.deno.unstable.d.ts
@@ -43,6 +43,21 @@ declare namespace Deno {
* Requires `allow-read` and `allow-write` permissions. */
export function link(oldpath: string, newpath: string): Promise<void>;
+ /** **UNSTABLE**: New API, yet to be vetted.
+ *
+ * Gets the size of the console as columns/rows.
+ *
+ * ```ts
+ * const { columns, rows } = await Deno.consoleSize(Deno.stdout.rid);
+ * ```
+ */
+ export function consoleSize(
+ rid: number
+ ): {
+ columns: number;
+ rows: number;
+ };
+
export type SymlinkOptions = {
type: "file" | "dir";
};
diff --git a/cli/js/ops/tty.ts b/cli/js/ops/tty.ts
index 8899ca5b8..f9da7bd0d 100644
--- a/cli/js/ops/tty.ts
+++ b/cli/js/ops/tty.ts
@@ -2,6 +2,10 @@
import { sendSync } from "./dispatch_json.ts";
+export function consoleSize(rid: number): [number, number] {
+ return sendSync("op_console_size", { rid });
+}
+
export function isatty(rid: number): boolean {
return sendSync("op_isatty", { rid });
}