feat: basic nvim setup and other partially working stuff
This commit is contained in:
22
src/components/terminal/TerminalBox.tsx
Normal file
22
src/components/terminal/TerminalBox.tsx
Normal file
@@ -0,0 +1,22 @@
|
||||
import { useTerminalCanvas } from "~/context/TerminalCanvasContext";
|
||||
import { type CellStyle } from "~/utils/terminal/cell";
|
||||
import { TerminalBoxElement } from "~/utils/terminal/elements/box";
|
||||
|
||||
export const TerminalBox = (props: {
|
||||
x: number;
|
||||
y: number;
|
||||
width: number;
|
||||
height: number;
|
||||
style?: CellStyle;
|
||||
}) => {
|
||||
const canvas = useTerminalCanvas();
|
||||
|
||||
const element = new TerminalBoxElement(
|
||||
props.width,
|
||||
props.height,
|
||||
props.style ?? {},
|
||||
);
|
||||
canvas.writeElement(element, props.x, props.y);
|
||||
|
||||
return null;
|
||||
};
|
||||
21
src/components/terminal/TerminalCell.tsx
Normal file
21
src/components/terminal/TerminalCell.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import { useTerminalCanvas } from "~/context/TerminalCanvasContext";
|
||||
import { type CellStyle } from "~/utils/terminal/cell";
|
||||
|
||||
export const TerminalCell = (props: {
|
||||
x: number;
|
||||
y: number;
|
||||
children: Array<string> | string;
|
||||
style?: CellStyle;
|
||||
}) => {
|
||||
const canvas = useTerminalCanvas();
|
||||
|
||||
const text = Array.isArray(props.children)
|
||||
? props.children.join("")
|
||||
: props.children;
|
||||
canvas.apply(props.x, props.y, {
|
||||
char: text,
|
||||
...(props.style ?? {}),
|
||||
});
|
||||
|
||||
return null;
|
||||
};
|
||||
25
src/components/terminal/TerminalSubCanvas.tsx
Normal file
25
src/components/terminal/TerminalSubCanvas.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import React, { type ReactNode, useState } from "react";
|
||||
import {
|
||||
TerminalCanvasContextProvider,
|
||||
useTerminalCanvas,
|
||||
} from "~/context/TerminalCanvasContext";
|
||||
import { TerminalRenderer } from "~/utils/terminal/renderer";
|
||||
|
||||
export const TerminalSubCanvas = (props: {
|
||||
x: number;
|
||||
y: number;
|
||||
width: number;
|
||||
height: number;
|
||||
children?: Array<ReactNode> | ReactNode;
|
||||
}) => {
|
||||
const parent = useTerminalCanvas();
|
||||
const [canvas] = useState(new TerminalRenderer(props.width, props.height));
|
||||
|
||||
parent.writeElement(canvas, props.x, props.y);
|
||||
|
||||
return (
|
||||
<TerminalCanvasContextProvider value={canvas}>
|
||||
{props.children}
|
||||
</TerminalCanvasContextProvider>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user