@@ -6,7 +6,10 @@ use crate::{
66 fonts:: { ic, setup_custom_fonts} ,
77 settings:: Settings ,
88 settings_window:: SettingsWindow ,
9- stage:: Stage ,
9+ stage:: {
10+ Stage ,
11+ structs:: { Entity , Text } ,
12+ } ,
1013 themes:: apply_custom_theme,
1114} ;
1215
@@ -16,7 +19,7 @@ pub struct MyApp {
1619 show_about : bool ,
1720 settings_window : SettingsWindow ,
1821
19- test_input : String ,
22+ terminal_input : String ,
2023
2124 #[ cfg( android) ]
2225 last_ime_active : bool ,
@@ -38,7 +41,7 @@ impl MyApp {
3841 show_about : true ,
3942 settings_window : SettingsWindow :: new ( ) ,
4043
41- test_input : String :: new ( ) ,
44+ terminal_input : String :: new ( ) ,
4245
4346 #[ cfg( android) ]
4447 last_ime_active : false ,
@@ -126,6 +129,20 @@ impl eframe::App for MyApp {
126129 . show ( ctx, |ui| {
127130 ui. heading ( "Terminal" ) ;
128131 ui. separator ( ) ;
132+ ui. text_edit_multiline ( & mut self . terminal_input ) ;
133+ if ui. button ( "execute" ) . clicked ( ) {
134+ match knus:: parse :: < Vec < Text > > ( "terminal_input.kdl" , & self . terminal_input ) {
135+ Ok ( doc) => {
136+ for entity in doc {
137+ self . stage . context . add ( entity. into ( ) ) ;
138+ }
139+ }
140+ Err ( e) => {
141+ log:: error!( "{:?}" , miette:: Report :: new( e) ) ;
142+ }
143+ }
144+ self . terminal_input . clear ( ) ;
145+ }
129146 } ) ;
130147
131148 egui:: CentralPanel :: default ( ) . show ( ctx, |ui| {
@@ -141,9 +158,6 @@ impl eframe::App for MyApp {
141158 ui. label ( "这是 Project Graph 3.0 的雏形,基于 Rust 和 egui 构建,性能和内存占用将会得到显著提升" ) ;
142159 ui. label ( "目前处于早期开发阶段,功能还非常基础,但未来会逐步完善" ) ;
143160 ui. separator ( ) ;
144- ui. label ( "测试输入框" ) ;
145- ui. text_edit_multiline ( & mut self . test_input ) ;
146- ui. separator ( ) ;
147161 ui. columns ( 2 , |columns| {
148162 columns[ 0 ] . add ( egui:: Image :: new ( egui:: include_image!(
149163 "../assets/icon.png"
0 commit comments