readline.moveCursor()
moves the cursor relative to its current position.
readline.moveCursor(stream, dx, dy[, callback])
stream
<stream.Readable>
: The stream to read from.dx
<number>
: Relative distance from the current position in the direction of .dy
<number>
: Relative distance from the current position in the direction of .callback
<function>
: The function that is invoked after the operation completes.readline.moveCursor()
returns a boolean
; it returns false
if the stream expects the calling code to wait for the drain
event to be emitted. Otherwise, readline.moveCursor()
returns true
.
In the code below, we create an instance of the interface. We associate it with the standard input for the Readable
stream and the standard output for the Writeable
stream.
The readline.moveCursor()
method is used to move the cursor to the desired location. After this, we can print the location coordinates on the screen.
const readline = require('readline');const rl = readline.createInterface({input: process.stdin,output: process.stdout});readline.moveCursor(process.stdout, 5, 5);console.log("dx = 5, dy = 5");rl.close();
Free Resources