Skip to content

Conversation

@na-trium-144
Copy link
Contributor

@na-trium-144 na-trium-144 commented Aug 9, 2025

(PythonREPL単体のプレビューは https://terminal-my-code.ut-code.workers.dev/terminal/python )
ドキュメント内にも埋め込めるようになったので、↑これではなく普通にプレビューURLを開いてもok

ターミナルの見た目を調整する都合でフォントをなにか指定しないといけなかったので、 Inconsolata で統一 (DaisyUI/TailwindCSSのfont-monoもInconsolataで表示するようになる)

埋め込んだコードの内容はsection.tsxで replOutputs, fileContents, execResults として取得できる (aiのプロンプトに適宜与える用)

replCommands: ReplCommand[];

// ReplCommand, ReplOutput の定義は app/terminal/repl.tsx にある
interface ReplCommand {
  command: string;
  outputs: ReplOutput[];
}
interface ReplOutput {
  type: "stdout" | "stderr" | "error" | "return";
  message: string;
}[];

fileContents: { name: string; content: string }[];

execResults: Record<string, ReplOutput[]>;
// つまり、 execResults = {"hoge.py": [{...}], "fuga.py": [{...}], ...}; 

markdown仕様

(READMEにも書いた)

```言語名-repl
>>> コマンド
実行結果例
```

でターミナルを埋め込む。

  • ターミナル表示部は app/terminal/terminal.tsx
  • コマンド入力処理は app/terminal/repl.tsx
  • 各言語の実行環境は app/terminal/言語名/ 内に書く。
  • 実行結果はSectionContextにも送られ、section.tsxからアクセスできる
```言語名:ファイル名
ファイルの内容
```

でテキストエディターを埋め込む。

  • app/terminal/editor.tsx
  • editor.tsx内で import "ace-builds/src-min-noconflict/mode-言語名"; を追加すればその言語に対応した色付けがされる。
  • 編集した内容は app/terminal/file.tsx のFileContextで管理される。
    • 編集中のコードはFileContextに即時送られる
    • FileContextが書き換えられたら即時すべてのエディターに反映される
  • 編集したファイルの一覧はSectionContextにも送られ、section.tsxからアクセスできる
```言語名-readonly:ファイル名
ファイルの内容
```

で同様にテキストエディターを埋め込むが、編集不可になる

```言語名-exec:ファイル名
実行結果例
```

で実行ボタンを表示する

  • 実行ボタンを押した際にFileContextからファイルを読み、実行し、結果を表示する
  • app/terminal/exec.tsx に各言語ごとの実装を書く (それぞれ app/terminal/言語名/ 内に定義した関数を呼び出す)
  • 実行結果はSectionContextにも送られ、section.tsxからアクセスできる

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Aug 9, 2025

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
my-code f111788 Commit Preview URL

Branch Preview URL
Aug 18 2025, 02:24 PM

@na-trium-144 na-trium-144 marked this pull request as ready for review August 18, 2025 06:25
@na-trium-144 na-trium-144 merged commit 7f6e6e7 into main Aug 20, 2025
3 checks passed
@na-trium-144 na-trium-144 deleted the terminal branch August 23, 2025 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants