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

Function moveCursor

lib/internal/readline/callbacks.js:61–86  ·  view source on GitHub ↗

* moves the cursor relative to its current location

(stream, dx, dy, callback)

Source from the content-addressed store, hash-verified

59 */
60
61function moveCursor(stream, dx, dy, callback) {
62 if (callback !== undefined) {
63 validateFunction(callback, 'callback');
64 }
65
66 if (stream == null || !(dx || dy)) {
67 if (typeof callback === 'function') process.nextTick(callback, null);
68 return true;
69 }
70
71 let data = '';
72
73 if (dx < 0) {
74 data += CSI`${-dx}D`;
75 } else if (dx > 0) {
76 data += CSI`${dx}C`;
77 }
78
79 if (dy < 0) {
80 data += CSI`${-dy}A`;
81 } else if (dy > 0) {
82 data += CSI`${dy}B`;
83 }
84
85 return stream.write(data, callback);
86}
87
88/**
89 * clears the current line the cursor is on:

Callers 8

[kRefreshLine]Method · 0.85
[kAddNewLineOnTTY]Method · 0.85
[kMoveCursor]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…