(dx)
| 1229 | // This function moves cursor dx places to the right |
| 1230 | // (-dx for left) and refreshes the line if it is needed. |
| 1231 | [kMoveCursor](dx) { |
| 1232 | if (dx === 0) { |
| 1233 | return; |
| 1234 | } |
| 1235 | const oldPos = this.getCursorPos(); |
| 1236 | this.cursor += dx; |
| 1237 | |
| 1238 | // Bounds check |
| 1239 | if (this.cursor < 0) { |
| 1240 | this.cursor = 0; |
| 1241 | } else if (this.cursor > this.line.length) { |
| 1242 | this.cursor = this.line.length; |
| 1243 | } |
| 1244 | |
| 1245 | const newPos = this.getCursorPos(); |
| 1246 | |
| 1247 | // Check if cursor stayed on the line. |
| 1248 | if (oldPos.rows === newPos.rows) { |
| 1249 | const diffWidth = newPos.cols - oldPos.cols; |
| 1250 | moveCursor(this.output, diffWidth, 0); |
| 1251 | } else { |
| 1252 | this[kRefreshLine](); |
| 1253 | } |
| 1254 | } |
| 1255 | |
| 1256 | // Handle a write from the tty |
| 1257 | [kTtyWrite](s, key) { |
nothing calls this directly
no test coverage detected