Skip to content

Commit

Permalink
add: lua history
Browse files Browse the repository at this point in the history
  • Loading branch information
ankushKun committed Aug 4, 2024
1 parent 68eb994 commit b973264
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useGlobalState } from "@/hooks";
import { MsgHistory } from "@/hooks/useGlobalState";
import Ansi from "ansi-to-react";
import { ExternalLink } from "lucide-react";
import Link from "next/link";
import { useEffect } from "react";
Expand Down Expand Up @@ -28,7 +29,10 @@ export default function History() {
</div>
<div className="text-xs">{msg.id}</div>
</div>
<pre className="text-xs max-h-[200px] overflow-scroll">{msg.code}</pre>
<div className="flex flex-col gap-2">
<pre className="text-xs max-h-[200px] overflow-scroll">&gt; {msg.code}</pre>
<pre className="text-xs max-h-[200px] overflow-scroll text-green-400"><Ansi>{typeof msg.output == "object" ? (msg.output as any).output : msg.output}</Ansi></pre>
</div>
</div>
)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ const CodeCell = ({
{ name: "File-Type", value: "Notebook" }
]);
console.log(result);
globalState.appendHistory(project.name, { id: (result as any).id!, code: cell.code, timestamp: Date.now() })
globalState.appendHistory(project.name, { id: (result as any).id!, code: cell.code, timestamp: Date.now(), output: result.Output.data });

// const fileContent = {...manager.getProject(project.name).getFile(file.name).content};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export default function AOTerminal({ commandOutputs, setCommandOutputs }: {
const result = await runLua(text, project.process, [
{ name: "File-Type", value: "Terminal" }
]);
globalState.appendHistory(project.name, { id: (result as any).id!, code: text, timestamp: Date.now(), output: result.Output.data });
if (result.Error) {
console.log(result.Error);

Expand Down
1 change: 1 addition & 0 deletions next_app/src/components/views/components/editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ function Editor() {
{ name: "File-Type", value: "Normal" }
]);
console.log(result);
globalState.appendHistory(project.name, { id: (result as any).id!, code: code, timestamp: Date.now(), output: result.Output.data });
if (result.Error) {
console.log(result.Error);
globalState.setLastOutput("\x1b[1;31m" + result.Error as string);
Expand Down
1 change: 1 addition & 0 deletions next_app/src/hooks/useGlobalState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface MsgHistory {
code: string;
id: string;
timestamp: number;
output: string;
}

interface State {
Expand Down

0 comments on commit b973264

Please sign in to comment.