summaryrefslogtreecommitdiff
path: root/src/ui/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/utils.ts')
-rw-r--r--src/ui/utils.ts20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/ui/utils.ts b/src/ui/utils.ts
new file mode 100644
index 0000000..32de02e
--- /dev/null
+++ b/src/ui/utils.ts
@@ -0,0 +1,20 @@
+import process from "node:process";
+import { GAME_SIZE } from "../state";
+
+export const TERM_SIZE = {
+ rows: GAME_SIZE.rows + 2,
+ cols: (GAME_SIZE.cols * 2 + 2) * 2,
+};
+
+export const getCurrentTerminalSize = (): { rows: number; cols: number } => {
+ const { rows, columns } = process.stdout;
+ return { rows, cols: columns };
+};
+
+export const clearTerminal = () => {
+ process.stdout.write("\x1Bc");
+};
+
+export const prepareTerminal = () => {
+ clearTerminal();
+};