MCPcopy Index your code
hub / github.com/nodejs/node / cursorTo

Function cursorTo

lib/internal/readline/callbacks.js:33–55  ·  view source on GitHub ↗

* moves the cursor to the x and y coordinate on the given stream

(stream, x, y, callback)

Source from the content-addressed store, hash-verified

31 */
32
33function cursorTo(stream, x, y, callback) {
34 if (callback !== undefined) {
35 validateFunction(callback, 'callback');
36 }
37
38 if (typeof y === 'function') {
39 callback = y;
40 y = undefined;
41 }
42
43 if (NumberIsNaN(x)) throw new ERR_INVALID_ARG_VALUE('x', x);
44 if (NumberIsNaN(y)) throw new ERR_INVALID_ARG_VALUE('y', y);
45
46 if (stream == null || (typeof x !== 'number' && typeof y !== 'number')) {
47 if (typeof callback === 'function') process.nextTick(callback, null);
48 return true;
49 }
50
51 if (typeof x !== 'number') throw new ERR_INVALID_CURSOR_POS();
52
53 const data = typeof y !== 'number' ? CSI`${x + 1}G` : CSI`${y + 1};${x + 1}H`;
54 return stream.write(data, callback);
55}
56
57/**
58 * moves the cursor relative to its current location

Callers 8

clearFunction · 0.85
[kRefreshLine]Method · 0.85
[kTtyWrite]Method · 0.85
clearPreviewFunction · 0.85
showCompletionPreviewFunction · 0.85
inputPreviewCallbackFunction · 0.85
printFunction · 0.85
resetFunction · 0.85

Calls 2

CSIFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…