added rankings but ugly and tired
This commit is contained in:
22
source/hooks/useTerminalSize.js
Normal file
22
source/hooks/useTerminalSize.js
Normal file
@@ -0,0 +1,22 @@
|
||||
// hooks/useTerminalSize.js
|
||||
|
||||
import { useState, useEffect } from 'react';
|
||||
import { useStdout } from 'ink';
|
||||
|
||||
export function useTerminalSize() {
|
||||
const { stdout } = useStdout();
|
||||
const [size, setSize] = useState({ width: stdout.columns, height: stdout.rows });
|
||||
|
||||
useEffect(() => {
|
||||
if (!stdout) return;
|
||||
function onResize() {
|
||||
setSize({ width: stdout.columns, height: stdout.rows });
|
||||
}
|
||||
stdout.on('resize', onResize);
|
||||
return () => {
|
||||
stdout.off('resize', onResize);
|
||||
};
|
||||
}, [stdout]);
|
||||
|
||||
return size;
|
||||
}
|
||||
Reference in New Issue
Block a user