@@ -73,6 +73,7 @@ public class MainWindow : SystemWindow
7373 private FlowLayoutWidget objectEditorList ;
7474 private FlowLayoutWidget textSide ;
7575 private TextEditWidget hello ;
76+ private ListBox errorListBox ;
7677 private Union rootUnion = new Union ( "root" ) ;
7778 dynamic classRef ;
7879
@@ -110,7 +111,15 @@ public MainWindow(bool renderRayTrace) : base(800, 600)
110111 } ;
111112
112113 var code = new StringBuilder ( ) ;
113- code . AppendLine ( "Draw(new Box(8, 20, 10));" ) ;
114+ code . AppendLine ( "var holesize =4;" ) ;
115+ code . AppendLine ( "// draw a box" ) ;
116+ code . AppendLine ( "var box = new Box(20, 20, 20);" ) ;
117+ code . AppendLine ( "var rotated = new Rotate(box, x: MathHelper.DegreesToRadians(45));" ) ;
118+ code . AppendLine ( "var cylinder = new Cylinder(50,20,60);" ) ;
119+ code . AppendLine ( "// draw the rotated box on top of the original" ) ;
120+ code . AppendLine ( "var translated = new Translate(new Box(40, 10, 10), 0, holesize, holesize);" ) ;
121+ code . AppendLine ( "Draw(box + rotated - translated + cylinder);" ) ;
122+
114123
115124 hello = new TextEditWidget ( code . ToString ( ) . Replace ( '\r ' , '\n ' ) )
116125 {
@@ -125,23 +134,34 @@ public MainWindow(bool renderRayTrace) : base(800, 600)
125134
126135 {
127136 // panel 2 stuff
128- FlowLayoutWidget renderSide = new FlowLayoutWidget ( FlowDirection . TopToBottom )
137+ Splitter rightSplitter = new Splitter ( )
129138 {
130139 HAnchor = HAnchor . Stretch ,
131140 VAnchor = VAnchor . Stretch ,
141+ Orientation = Orientation . Horizontal ,
142+ SplitterDistance = 150 ,
132143 } ;
144+ verticalSplitter . Panel2 . AddChild ( rightSplitter ) ;
133145
134146 var world = new WorldView ( 800 , 600 ) ;
135147 world . TranslationMatrix = Matrix4X4 . CreateTranslation ( 0 , 0 , - 50 ) ;
136- trackBallWidget = new TrackballTumbleView ( world , renderSide )
148+ trackBallWidget = new TrackballTumbleView ( world , rightSplitter . Panel1 )
137149 {
138150 HAnchor = HAnchor . Stretch ,
139151 VAnchor = VAnchor . Stretch ,
140152 DrawContent = glLightedView_DrawGlContent ,
141153 TransformState = MatterHackers . VectorMath . TrackBall . TrackBallTransformType . Rotation ,
142154 } ;
143- renderSide . AddChild ( trackBallWidget ) ;
144- verticalSplitter . Panel2 . AddChild ( renderSide ) ;
155+ rightSplitter . Panel1 . AddChild ( trackBallWidget ) ;
156+
157+ errorListBox = new ListBox ( )
158+ {
159+ HAnchor = HAnchor . Stretch ,
160+ VAnchor = VAnchor . Stretch ,
161+ BackgroundColor = Color . White ,
162+ } ;
163+ errorListBox . SelectedValueChanged += ErrorListBox_SelectedValueChanged ;
164+ rightSplitter . Panel2 . AddChild ( errorListBox ) ;
145165 }
146166
147167 BackgroundColor = Color . White ;
@@ -151,27 +171,42 @@ public MainWindow(bool renderRayTrace) : base(800, 600)
151171
152172 private void Hello_TextChanged ( object sender , EventArgs e )
153173 {
174+ hello . ErrorLineIndices . Clear ( ) ;
154175 Compile ( ) ;
155176 }
156177
178+ private void ErrorListBox_SelectedValueChanged ( object sender , EventArgs e )
179+ {
180+ if ( errorListBox . SelectedItem is ListBoxTextItem item )
181+ {
182+ if ( int . TryParse ( item . ItemValue , out int line ) )
183+ {
184+ hello . JumpToLine ( line ) ;
185+ }
186+ }
187+ }
188+
157189 private void Compile ( )
158190 {
159191 var compilerService = new CompilerService ( ) ;
160- List < string > errors ;
192+ List < Diagnostic > errors ;
161193
162194 // The service expects just the content inside Render(), which comes from hello.Text
163195 classRef = compilerService . Compile ( hello . Text , out errors ) ;
164196
197+ errorListBox . Clear ( ) ;
198+
165199 if ( errors . Count > 0 )
166200 {
167- StringBuilder sberror = new StringBuilder ( ) ;
168201 foreach ( var error in errors )
169202 {
170- sberror . AppendLine ( error ) ;
203+ var lineSpan = error . Location . GetLineSpan ( ) ;
204+ int line = lineSpan . StartLinePosition . Line - 17 ; // offset from preamble
205+ string message = $ "{ line + 1 } : { error . GetMessage ( ) } ";
206+ errorListBox . AddChild ( new ListBoxTextItem ( message , line . ToString ( ) ) ) ;
207+ hello . ErrorLineIndices . Add ( line ) ;
171208 }
172- // TODO: Display errors to user (e.g., txtErrors.Text = sberror.ToString())
173- // For now, logging as before might be done by caller or added here if needed,
174- // but simpler to just return.
209+ hello . Invalidate ( ) ;
175210 return ;
176211 }
177212 trackBallWidget . Invalidate ( ) ;
0 commit comments