Files
hakorune/examples/simple_notepad_win.rs
Moe Charm e7f6666917 🎨 feat: EguiBox GUI開発基盤完成 + パーサー無限ループバグ修正
## 🚀 主要機能追加
### EguiBox - GUI開発基盤
- Windows版GUIメモ帳アプリ (simple_notepad.rs, nyash_notepad_jp.rs)
- 日本語フォント対応 (NotoSansJP-VariableFont_wght.ttf)
- BMPアイコン表示システム (c_drive_icon.bmp)
- Windowsエクスプローラー風アプリ (nyash_explorer.rs)
- アイコン抽出システム (test_icon_extraction.rs)

### ビジュアルプログラミング準備
- NyashFlow プロジェクト設計完成 (NYASHFLOW_PROJECT_HANDOVER.md)
- ビジュアルノードプロトタイプ基盤
- WebAssembly対応準備

## 🔧 重大バグ修正
### パーサー無限ループ問題 (3引数メソッド呼び出し)
- 原因: メソッドパラメータ解析ループの予約語処理不備
- 修正: src/parser/mod.rs - 非IDENTIFIERトークンのエラーハンドリング追加
- 効果: "from"等の予約語で適切なエラー報告、ハング→瞬時エラー

### MapBoxハング問題調査
- MapBox+3引数メソッド呼び出し組み合わせ問題特定
- バグレポート作成 (MAPBOX_HANG_BUG_REPORT.md)
- 事前評価vs必要時評価の設計問題明確化

## 🧹 コード品質向上
- box_methods.rs を8モジュールに機能分離
- 一時デバッグコード全削除 (eprintln\!, unsafe等)
- 構文チェック通過確認済み

## 📝 ドキュメント整備
- CLAUDE.md にGUI開発セクション追加
- Gemini/ChatGPT先生相談ログ保存 (sessions/)
- 段階的デバッグ手法確立

## 🎯 次の目標
- must_advance\!マクロ実装 (無限ループ早期検出)
- コマンド引数でデバッグ制御 (--debug-fuel)
- MapBox問題の根本修正

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-10 07:54:03 +09:00

176 lines
5.9 KiB
Rust

// Nyash + egui Windows Notepad App
// Simple GUI application with text input functionality
use eframe::egui;
fn main() -> eframe::Result {
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default()
.with_inner_size([640.0, 480.0])
.with_title("Nyash Notepad"),
..Default::default()
};
eframe::run_native(
"Nyash Notepad",
options,
Box::new(|cc| {
// Configure fonts for Windows
setup_custom_fonts(&cc.egui_ctx);
Ok(Box::new(NyashNotepad::default()))
}),
)
}
fn setup_custom_fonts(ctx: &egui::Context) {
// Start with the default fonts
let mut fonts = egui::FontDefinitions::default();
// Use default system fonts for better Windows compatibility
fonts.font_data.insert(
"system".to_owned(),
std::sync::Arc::new(egui::FontData::from_static(include_bytes!(
"C:/Windows/Fonts/arial.ttf"
))),
);
// Configure font families
fonts
.families
.entry(egui::FontFamily::Proportional)
.or_default()
.push("system".to_owned());
fonts
.families
.entry(egui::FontFamily::Monospace)
.or_default()
.push("system".to_owned());
// Tell egui to use these fonts
ctx.set_fonts(fonts);
}
#[derive(Default)]
struct NyashNotepad {
text: String,
status: String,
}
impl NyashNotepad {
fn new() -> Self {
Self {
text: String::new(),
status: "Ready".to_string(),
}
}
}
impl eframe::App for NyashNotepad {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
// Menu bar
egui::TopBottomPanel::top("menu_bar").show(ctx, |ui| {
egui::menu::bar(ui, |ui| {
ui.menu_button("File", |ui| {
if ui.button("New").clicked() {
self.text.clear();
self.status = "New file created".to_string();
}
if ui.button("Clear").clicked() {
self.text.clear();
self.status = "Text cleared".to_string();
}
ui.separator();
if ui.button("Exit").clicked() {
ctx.send_viewport_cmd(egui::ViewportCommand::Close);
}
});
ui.menu_button("Edit", |ui| {
if ui.button("Select All").clicked() {
self.status = "Select All (not implemented)".to_string();
}
});
ui.menu_button("Help", |ui| {
if ui.button("About Nyash").clicked() {
self.status = "Nyash - Everything is Box!".to_string();
}
});
});
});
// Status bar
egui::TopBottomPanel::bottom("status_bar").show(ctx, |ui| {
ui.horizontal(|ui| {
ui.label(&self.status);
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
ui.label(format!("Characters: {}", self.text.chars().count()));
});
});
});
// Main text editor
egui::CentralPanel::default().show(ctx, |ui| {
// Toolbar with ASCII-only labels
ui.horizontal(|ui| {
if ui.button("[Clear]").clicked() {
self.text.clear();
self.status = "Text cleared".to_string();
}
ui.separator();
if ui.button("[Copy]").clicked() {
ui.output_mut(|o| o.copied_text = self.text.clone());
self.status = "Text copied to clipboard".to_string();
}
if ui.button("[Cut]").clicked() {
ui.output_mut(|o| o.copied_text = self.text.clone());
self.text.clear();
self.status = "Text cut to clipboard".to_string();
}
if ui.button("[Paste]").clicked() {
self.status = "Paste (simplified version)".to_string();
}
});
ui.separator();
// Text editor body
egui::ScrollArea::vertical().show(ui, |ui| {
ui.add(
egui::TextEdit::multiline(&mut self.text)
.font(egui::TextStyle::Monospace)
.desired_width(f32::INFINITY)
.desired_rows(20)
.hint_text("Type your text here... nya!")
);
});
// Sample buttons
ui.separator();
ui.horizontal(|ui| {
if ui.button("Insert Nyash Sample").clicked() {
self.text.push_str("\n// Nyash - Everything is Box!\n");
self.text.push_str("box HelloWorld {\n");
self.text.push_str(" init { message }\n");
self.text.push_str(" \n");
self.text.push_str(" HelloWorld() {\n");
self.text.push_str(" me.message = \"Hello, Nyash World! nya!\"\n");
self.text.push_str(" }\n");
self.text.push_str("}\n");
self.status = "Nyash sample code inserted".to_string();
}
if ui.button("Insert Timestamp").clicked() {
let now = chrono::Local::now();
self.text.push_str(&format!("\n{}\n", now.format("%Y-%m-%d %H:%M:%S")));
self.status = "Timestamp inserted".to_string();
}
});
});
}
}