@timmy6942025/cli-timer 1.1.14 → 1.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.js +16 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timmy6942025/cli-timer",
3
- "version": "1.1.14",
3
+ "version": "1.1.15",
4
4
  "description": "Simple customizable terminal timer and stopwatch",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/index.js CHANGED
@@ -83,6 +83,14 @@ function showCursor() {
83
83
  process.stdout.write("\x1b[?25h");
84
84
  }
85
85
 
86
+ function enterAlternateScreen() {
87
+ process.stdout.write("\x1b[?1049h");
88
+ }
89
+
90
+ function exitAlternateScreen() {
91
+ process.stdout.write("\x1b[?1049l");
92
+ }
93
+
86
94
  function formatHms(totalSeconds) {
87
95
  const hours = Math.floor(totalSeconds / 3600);
88
96
  const minutes = Math.floor((totalSeconds % 3600) / 60);
@@ -958,6 +966,7 @@ function runClock({ mode, initialSeconds, config }) {
958
966
  let tick = null;
959
967
  let lastDrawState = "";
960
968
  let hasExited = false;
969
+ let didEnterAlternateScreen = false;
961
970
 
962
971
  const stdin = process.stdin;
963
972
 
@@ -1053,7 +1062,11 @@ function runClock({ mode, initialSeconds, config }) {
1053
1062
  }
1054
1063
  stdin.pause();
1055
1064
  showCursor();
1056
- clearScreen();
1065
+ if (didEnterAlternateScreen) {
1066
+ exitAlternateScreen();
1067
+ } else {
1068
+ clearScreen();
1069
+ }
1057
1070
  process.exit(code);
1058
1071
  }
1059
1072
 
@@ -1112,6 +1125,8 @@ function runClock({ mode, initialSeconds, config }) {
1112
1125
  stdin.resume();
1113
1126
  stdin.setEncoding("utf8");
1114
1127
  stdin.on("data", onKeypress);
1128
+ enterAlternateScreen();
1129
+ didEnterAlternateScreen = true;
1115
1130
  hideCursor();
1116
1131
 
1117
1132
  draw(true);