export class Cursor {
  private static visible = true;

  static show() {
    this.visible = true;
    Deno.stdout.writeSync(new TextEncoder().encode("\x1b[?25h"));
  }

  static hide() {
    this.visible = false;
    Deno.stdout.writeSync(new TextEncoder().encode("\x1b[?25l"));
  }

  static restoreVisibility() {
    if (this.visible) {
      this.show();
    } else {
      this.hide();
    }
  }

  static savePosition() {
    Deno.stdout.writeSync(new TextEncoder().encode("\x1b7"));
  }

  static restorePosition() {
    Deno.stdout.writeSync(new TextEncoder().encode("\x1b8"));
  }
}
