MCPcopy Create free account
hub / github.com/nodejs/node / moveCursor

Method moveCursor

lib/internal/readline/promises.js:61–83  ·  view source on GitHub ↗

* Moves the cursor relative to its current location. * @param {integer} dx * @param {integer} dy * @returns {Readline} this

(dx, dy)

Source from the content-addressed store, hash-verified

59 * @returns {Readline} this
60 */
61 moveCursor(dx, dy) {
62 if (dx || dy) {
63 validateInteger(dx, 'dx');
64 validateInteger(dy, 'dy');
65
66 let data = '';
67
68 if (dx < 0) {
69 data += CSI`${-dx}D`;
70 } else if (dx > 0) {
71 data += CSI`${dx}C`;
72 }
73
74 if (dy < 0) {
75 data += CSI`${-dy}A`;
76 } else if (dy > 0) {
77 data += CSI`${dy}B`;
78 }
79 if (this.#autoCommit) process.nextTick(() => this.#stream.write(data));
80 else ArrayPrototypePush(this.#todo, data);
81 }
82 return this;
83 }
84
85 /**
86 * Clears the current line the cursor is on.

Callers 4

tty.jsFile · 0.80

Calls 2

CSIFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected