You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Temporarily hands the terminal over to a child process (such as `$EDITOR`, `less`, or `fzf`), then restores Ink's terminal state and forces a full redraw.
1962
+
1963
+
While suspended, Ink stops writing output, stops consuming input, and restores the terminal modes the child expects (raw mode off, cursor visible, bracketed paste off, alternate screen exited, kitty keyboard protocol off). When the suspension ends, Ink reapplies its own terminal state and repaints from scratch.
1964
+
1965
+
##### callback
1966
+
1967
+
Type: `Function`
1968
+
1969
+
When a callback is provided, Ink suspends, runs the callback, and restores the terminal once it settles, even if the callback throws.
1970
+
1971
+
```js
1972
+
import {useApp} from'ink';
1973
+
1974
+
const {suspendTerminal} =useApp();
1975
+
1976
+
awaitsuspendTerminal(async () => {
1977
+
awaitrunEditor();
1978
+
});
1979
+
```
1980
+
1981
+
When called without a callback, it returns a suspension you resume yourself. `resume()` is async because restoring the terminal may need to wait for ordered writes and a full redraw.
1982
+
1983
+
```js
1984
+
constsuspension=awaitsuspendTerminal();
1985
+
1986
+
try {
1987
+
awaitrunEditor();
1988
+
} finally {
1989
+
awaitsuspension.resume();
1990
+
}
1991
+
```
1992
+
1993
+
The suspension is also a disposable, so it can be resumed automatically with `await using`:
1994
+
1995
+
```js
1996
+
await using suspension =awaitsuspendTerminal();
1997
+
awaitrunEditor();
1998
+
```
1999
+
2000
+
Suspending while a suspension is already active throws. This is supported only in interactive TTY mode; in non-interactive output the callback still runs but Ink performs no terminal handoff.
2001
+
1953
2002
### useStdin()
1954
2003
1955
2004
A React hook that returns the stdin stream and stdin-related utilities.
0 commit comments