+
-
diff --git a/src/components/Nvim/NvimEditor.tsx b/src/components/Nvim/NvimEditor.tsx
new file mode 100644
index 0000000..1acec90
--- /dev/null
+++ b/src/components/Nvim/NvimEditor.tsx
@@ -0,0 +1,16 @@
+import { useTerminal } from "~/context/TerminalContext";
+import { TerminalRenderer } from "~/utils/terminal/renderer";
+
+export const NvimEditor = (props: { content: string | null }) => {
+ const { cols: width, rows: height } = useTerminal();
+
+ const canvas = new TerminalRenderer(width * 0.8, height - 2);
+
+ if (props.content) {
+ props.content.split("\n").forEach((line, y) => {
+ canvas.write(0, y, line);
+ });
+ }
+
+ return canvas.render();
+};
diff --git a/src/components/Nvim/NvimTree.tsx b/src/components/Nvim/NvimTree.tsx
index 7e1b91e..ce7b0f6 100644
--- a/src/components/Nvim/NvimTree.tsx
+++ b/src/components/Nvim/NvimTree.tsx
@@ -1,4 +1,5 @@
import { useState, useEffect } from "react";
+import { useNavigate } from "react-router-dom";
import { useTerminal } from "~/context/TerminalContext";
import {
DEFAULT_FILE_STYLE,
@@ -23,6 +24,7 @@ const PATH_UNFOLDED: Cell = {
export const NvimTree = (props: { files: Array
}) => {
const [selected, setSelected] = useState(0);
const [files, setFiles] = useState(props.files);
+ const navigate = useNavigate();
const { cols: width, rows: height } = useTerminal();
const canvas = new TerminalRenderer(width * 0.2, height - 2, {
@@ -108,6 +110,9 @@ export const NvimTree = (props: { files: Array }) => {
if (current.type === "directory") {
current.folded = !current.folded;
setFiles([...files]);
+ } else {
+ //document.location.href = `?view=${current.path}`
+ navigate(`?view=${current.path}`);
}
break;
}
diff --git a/src/utils/filesystem.ts b/src/utils/filesystem.ts
index 818b724..368d657 100644
--- a/src/utils/filesystem.ts
+++ b/src/utils/filesystem.ts
@@ -25,6 +25,7 @@ export const FILE_STYLES: Record = {
export type File = {
name: string;
+ path: string;
} & (
| {
type: "file";
@@ -54,17 +55,20 @@ export const buildFileTree = (manifest: Manifest): Array => {
project.files.forEach(file => {
files.push({
name: file,
+ path: file,
type: "file",
});
});
} else {
files.push({
name: project.name,
+ path: project.name,
type: "directory",
folded: true,
children: sortFiles(
project.files.map(file => ({
name: file,
+ path: `${project.name}/${file}`,
type: "file",
})),
),