forked from denoland/deno
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tty: Deno.setRaw(rid, mode) to turn on/off raw mode (denoland#3958)
- Loading branch information
1 parent
e53064c
commit 5946808
Showing
19 changed files
with
429 additions
and
49 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,3 +72,6 @@ nix = "0.14.1" | |
|
||
[dev-dependencies] | ||
os_pipe = "0.9.1" | ||
|
||
[target.'cfg(unix)'.dev-dependencies] | ||
pty = "0.2" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { sendSync } from "./dispatch_json.ts"; | ||
|
||
/** Check if a given resource is TTY. */ | ||
export function isatty(rid: number): boolean { | ||
return sendSync("op_isatty", { rid }); | ||
} | ||
|
||
/** Set TTY to be under raw mode or not. */ | ||
export function setRaw(rid: number, mode: boolean): void { | ||
sendSync("op_set_raw", { | ||
rid, | ||
mode | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. | ||
import { test, testPerm, assert } from "./test_util.ts"; | ||
|
||
// Note tests for Deno.setRaw is in integration tests. | ||
|
||
testPerm({ read: true }, function isatty(): void { | ||
// CI not under TTY, so cannot test stdin/stdout/stderr. | ||
const f = Deno.openSync("cli/tests/hello.txt"); | ||
assert(!Deno.isatty(f.rid)); | ||
}); | ||
|
||
test(function isattyError(): void { | ||
let caught = false; | ||
try { | ||
// Absurdly large rid. | ||
Deno.isatty(0x7fffffff); | ||
} catch (e) { | ||
caught = true; | ||
assert(e instanceof Deno.errors.BadResource); | ||
} | ||
assert(caught); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.