clears the current line the cursor is on:
-1 for left of the cursor
+1 for right of the cursor
0 for the entire line
function clearLine(stream, dir) {
  if (stream === null || stream === undefined)
    return;

  if (dir < 0) {
    // to the beginning
    stream.write(kClearToBeginning);
  } else if (dir > 0) {
    // to the end
    stream.write(kClearToEnd);
  } else {
    // entire line
    stream.write(kClearLine);
  }
}