* Moves the cursor relative to its current location. * @param {integer} dx * @param {integer} dy * @returns {Readline} this
(dx, dy)
| 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. |
no test coverage detected