Skip to content

Commit 63060b8

Browse files
authored
v1.6.0-beta4
ZX Basic Studio v1.6.0-beta4 - Build Options (Project -> Configure project) - Removed "Strict Bool" options that was deprecated on v1.18.0 of the compiler - "Strict" and “Header less” options were not being applied when compiling. - Added 4 advanced actions: - Enable pre-build: Launch a program or bash (.bat / .sh) before compiling - Custom compiler parameters: Allows the compilation parameters to be set manually - Enable post-build: Launch a program or bash (.bat / .sh) before compiling - Launch external emulator: Launches its own program or bash (.bat / .sh) after post-build instead of the embedded emulator - Output log window: Ahora se puede seleccionar y copiar texto. Includes: - The help menu has been redesigned ##17 [Bug]: Breakpoints in included files are ignored ##6 [Bug]: Project Explorer bar doesn't show new files created
2 parents b148679 + 8a22d06 commit 63060b8

File tree

10 files changed

+636
-164
lines changed

10 files changed

+636
-164
lines changed

ZXBStudio/App.axaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,21 @@
180180
<Setter Property="Height" Value="32"></Setter>
181181
<Setter Property="MaxWidth" Value="140"></Setter>
182182
</Style>
183+
<Style Selector="TextBox.dialogfw">
184+
<Setter Property="Margin" Value="5"></Setter>
185+
<Setter Property="CornerRadius" Value="5"></Setter>
186+
<Setter Property="Height" Value="32"></Setter>
187+
</Style>
188+
<Style Selector="TextBox.dialogfwh">
189+
<Setter Property="Margin" Value="5"></Setter>
190+
<Setter Property="CornerRadius" Value="5"></Setter>
191+
</Style>
183192
<Style Selector="Button.dialog">
184193
<Setter Property="Margin" Value="5"></Setter>
185194
<Setter Property="CornerRadius" Value="5"></Setter>
186195
</Style>
187196
<Style Selector="ComboBox.dialog">
188-
<Setter Property="Margin" Value="0"></Setter>
197+
<Setter Property="Margin" Value="5"></Setter>
189198
<Setter Property="CornerRadius" Value="5"></Setter>
190199
<Setter Property="Height" Value="32"></Setter>
191200
<Setter Property="Padding" Value="5"></Setter>

ZXBStudio/BuildSystem/ZXProjectBuilder.cs

Lines changed: 134 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
using System.Runtime.CompilerServices;
99
using System.Text;
1010
using System.Text.RegularExpressions;
11+
using System.Threading;
1112
using System.Threading.Tasks;
1213
using ZXBasicStudio.Classes;
14+
using ZXBasicStudio.Controls;
1315
using ZXBasicStudio.Dialogs;
1416
using ZXBasicStudio.DocumentModel.Classes;
1517
using ZXBasicStudio.IntegratedDocumentTypes.CodeDocuments.Basic;
@@ -51,6 +53,22 @@ public class ZXProjectBuilder
5153
settings = project.GetProjectSettings();
5254
mainFile = project.GetMainFile();
5355

56+
// Prebuild
57+
if (settings.PreBuild)
58+
{
59+
OutputLogWritter.WriteLine($"PreBuild: {settings.PreBuildValue}");
60+
if (!ExecuteFile(settings.PreBuildValue, new string[]
61+
{
62+
project.ProjectPath,
63+
Path.GetFileName(mainFile)
64+
},
65+
project.ProjectPath,
66+
OutputLogWritter))
67+
{
68+
return null;
69+
}
70+
}
71+
5472
if (mainFile == null)
5573
{
5674
OutputLogWritter.WriteLine("Cannot find main file, check that it exists and if there are more than one that is specified in the build settings.");
@@ -60,14 +78,19 @@ public class ZXProjectBuilder
6078
if (!PreBuild(false, project.ProjectPath, OutputLogWritter))
6179
return null;
6280

63-
var args = settings.GetSettings();
64-
81+
Process? proc = null;
6582
var startTime = DateTime.Now;
6683
OutputLogWritter.WriteLine("Project path: " + project.ProjectPath);
6784
OutputLogWritter.WriteLine("Building program " + mainFile);
6885
OutputLogWritter.WriteLine("Building starts at " + startTime);
69-
70-
var proc = Process.Start(new ProcessStartInfo(Path.GetFullPath(ZXOptions.Current.ZxbcPath), $"\"{mainFile}\" " + args) { WorkingDirectory = project.ProjectPath, RedirectStandardError = true, CreateNoWindow = true });
86+
var args = settings.GetSettings();
87+
if (settings.CustomCompiler)
88+
{
89+
OutputLogWritter.WriteLine("Custom compiler settings");
90+
args = settings.CustomCompilerValue;
91+
}
92+
OutputLogWritter.WriteLine($"zxbc \"{mainFile}\" {args}");
93+
proc = Process.Start(new ProcessStartInfo(Path.GetFullPath(ZXOptions.Current.ZxbcPath), $"\"{mainFile}\" " + args) { WorkingDirectory = project.ProjectPath, RedirectStandardError = true, CreateNoWindow = true });
7194

7295
string logOutput;
7396

@@ -84,6 +107,22 @@ public class ZXProjectBuilder
84107

85108
string binFile = Path.Combine(project.ProjectPath, Path.GetFileNameWithoutExtension(mainFile) + ".bin");
86109

110+
// Postbuild
111+
if (settings.PostBuild)
112+
{
113+
OutputLogWritter.WriteLine($"PostBuild: {settings.PostBuildValue}");
114+
if (!ExecuteFile(settings.PostBuildValue, new string[]
115+
{
116+
project.ProjectPath,
117+
Path.GetFileName(binFile)
118+
},
119+
project.ProjectPath,
120+
OutputLogWritter))
121+
{
122+
return null;
123+
}
124+
}
125+
87126
byte[] binary = File.ReadAllBytes(binFile);
88127

89128
Cleanup(project.ProjectPath, binFile);
@@ -309,6 +348,22 @@ private static void CheckNextCreator()
309348
settings = project.GetProjectSettings();
310349
mainFile = project.GetMainFile();
311350

351+
// Prebuild
352+
if (settings.PreBuild)
353+
{
354+
OutputLogWritter.WriteLine($"PreBuild: {settings.PreBuildValue}");
355+
if (!ExecuteFile(settings.PreBuildValue, new string[]
356+
{
357+
project.ProjectPath,
358+
Path.GetFileName(mainFile)
359+
},
360+
project.ProjectPath,
361+
OutputLogWritter))
362+
{
363+
return null;
364+
}
365+
}
366+
312367
if (mainFile == null)
313368
{
314369
OutputLogWritter.WriteLine("Cannot find main file, check that it exists and if there are more than one that is specified in the build settings.");
@@ -329,6 +384,11 @@ private static void CheckNextCreator()
329384
string logOutput;
330385

331386
var args = settings.GetDebugSettings();
387+
if (settings.CustomCompiler)
388+
{
389+
OutputLogWritter.WriteLine("Custom compiler settings");
390+
args = settings.CustomCompilerValue;
391+
}
332392

333393
OutputLogWritter.WriteLine("Building map files...");
334394

@@ -339,7 +399,6 @@ private static void CheckNextCreator()
339399

340400
OutputLogWritter.WriteLine("Building program map...");
341401

342-
// TODO: DUEFECTU 2023.05.17: Bug for long path
343402
var codeFile = files.FirstOrDefault(f => f.AbsolutePath == Path.GetFullPath(mainFile));
344403
if (codeFile == null)
345404
{
@@ -349,10 +408,10 @@ private static void CheckNextCreator()
349408
}
350409

351410
cmd = $"\"{Path.Combine(codeFile.Directory, codeFile.TempFileName)}\" -M MEMORY_MAP " + args;
352-
OutputLogWritter.WriteLine("zxbc "+cmd);
411+
OutputLogWritter.WriteLine("zxbc " + cmd);
353412
var proc = Process.Start(
354413
new ProcessStartInfo(
355-
Path.GetFullPath(ZXOptions.Current.ZxbcPath),cmd)
414+
Path.GetFullPath(ZXOptions.Current.ZxbcPath), cmd)
356415
{ WorkingDirectory = project.ProjectPath, RedirectStandardError = true, CreateNoWindow = true });
357416

358417
OutputProcessLog(OutputLogWritter, proc, out logOutput);
@@ -692,5 +751,73 @@ private static bool PostBuild(bool debug, string path, ZXProgram CompiledProgram
692751

693752
return true;
694753
}
754+
755+
756+
public static bool ExecuteFile(string preBuildValue, string[] parameters, string workingPath, TextWriter outLog)
757+
{
758+
try
759+
{
760+
var proc = Process.Start(
761+
new ProcessStartInfo(
762+
preBuildValue,
763+
parameters)
764+
{
765+
WorkingDirectory = workingPath,
766+
RedirectStandardError = true,
767+
RedirectStandardOutput = true,
768+
CreateNoWindow = true
769+
});
770+
771+
string logOutput = "";
772+
ProcessRedirect(proc, outLog);
773+
774+
var ecode = proc.ExitCode;
775+
776+
if (ecode != 0)
777+
{
778+
Cleanup(workingPath);
779+
outLog.WriteLine("Error building program, aborting...");
780+
return false;
781+
}
782+
return true;
783+
}
784+
catch (Exception ex)
785+
{
786+
outLog.WriteLine("ERROR executing file: " + ex.Message);
787+
return false;
788+
}
789+
}
790+
791+
792+
private static void ProcessRedirect(Process proc, TextWriter outLog)
793+
{
794+
try
795+
{
796+
while (!proc.HasExited)
797+
{
798+
if (!proc.StandardOutput.EndOfStream)
799+
{
800+
string? line = proc.StandardOutput.ReadLine();
801+
outLog.WriteLine(line);
802+
}
803+
if (!proc.StandardError.EndOfStream)
804+
{
805+
string? line = proc.StandardError.ReadLine();
806+
outLog.WriteLine(line);
807+
}
808+
}
809+
while (!proc.StandardOutput.EndOfStream)
810+
{
811+
string? line = proc.StandardOutput.ReadLine();
812+
outLog.WriteLine(line);
813+
}
814+
while (!proc.StandardError.EndOfStream)
815+
{
816+
string? line = proc.StandardError.ReadLine();
817+
outLog.WriteLine(line);
818+
}
819+
}
820+
catch { }
821+
}
695822
}
696823
}

ZXBStudio/Classes/ZXBuildSettings.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,17 @@ public class ZXBuildSettings
2424
public bool Strict { get; set; }
2525
public bool Headerless { get; set; }
2626
public bool NextMode { get; set; }
27+
28+
public bool PreBuild { get; set; }
29+
public string PreBuildValue { get; set; }
30+
public bool CustomCompiler { get; set; }
31+
public string CustomCompilerValue { get; set; }
32+
public bool PostBuild { get; set; }
33+
public string PostBuildValue { get; set; }
34+
public bool ExternalEmulator { get; set; }
35+
public string ExternalEmuladorValue { get; set; }
36+
37+
2738
public string GetSettings()
2839
{
2940
List<string> settings = new List<string>();
@@ -69,6 +80,11 @@ public string GetSettings()
6980
if (Strict)
7081
settings.Add("--strict");
7182

83+
if (Headerless)
84+
{
85+
settings.Add("--headerless");
86+
}
87+
7288
if (NextMode)
7389
{
7490
settings.Add("--zxnext");

ZXBStudio/Classes/ZXLogTextWriter.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@ namespace ZXBasicStudio.Classes
1414
{
1515
public class ZXLogTextWriter : TextWriter
1616
{
17-
TextBlock target;
17+
//TextBlock target;
18+
TextBox target;
1819
ScrollViewer scroll;
1920

20-
public ZXLogTextWriter(TextBlock Target, ScrollViewer Scroller)
21+
//public ZXLogTextWriter(TextBlock Target, ScrollViewer Scroller)
22+
public ZXLogTextWriter(TextBox Target, ScrollViewer Scroller)
2123
{
2224
this.target = Target;
2325
this.scroll = Scroller;

ZXBStudio/Controls/ZXOutputLog.axaml

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,31 @@
55
xmlns:svg="using:Avalonia.Svg.Skia"
66
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
77
x:Class="ZXBasicStudio.Controls.ZXOutputLog">
8-
<UserControl.ContextMenu>
9-
<ContextMenu Placement="Pointer">
10-
<MenuItem Header="Clear output window" Name="mnuClearOutputWindow" />
11-
<MenuItem Header="Copy to clipboard" Name="mnuCopyToClipboard" />
12-
</ContextMenu>
13-
</UserControl.ContextMenu>
14-
<Grid RowDefinitions="auto,*">
15-
<Grid ColumnDefinitions="1*" DataContext=".ZXMemoryView">
16-
<StackPanel Grid.Row="0" Spacing="2" Orientation="Horizontal" Margin="2" HorizontalAlignment="Left">
17-
<Button Width="30" Foreground="Black" Classes="toolbar" Name="btnClearOutputWindow" ToolTip.Tip="Clear output window"><svg:Svg Path="/Svg/eraser-solid.svg"></svg:Svg></Button>
18-
<Button Width="30" Foreground="Black" Classes="toolbar" Name="btnCopyToClipboard" ToolTip.Tip="Copy output log to clipboard"><svg:Svg Path="/Svg/copy-solid.svg"></svg:Svg></Button>
19-
</StackPanel>
20-
</Grid>
21-
<Grid Grid.Row="1">
22-
<ScrollViewer HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#FF202020" Name="scrOutput"
23-
VerticalScrollBarVisibility="Auto">
24-
<TextBlock TextWrapping="Wrap" Foreground="White" Name="tbOutput" Padding="10"></TextBlock>
25-
</ScrollViewer>
26-
</Grid>
8+
<UserControl.ContextMenu>
9+
<ContextMenu Placement="Pointer">
10+
<MenuItem Header="Clear output window" Name="mnuClearOutputWindow" />
11+
<MenuItem Header="Copy to clipboard" Name="mnuCopyToClipboard" />
12+
</ContextMenu>
13+
</UserControl.ContextMenu>
14+
<Grid RowDefinitions="auto,*">
15+
<Grid ColumnDefinitions="1*" DataContext=".ZXMemoryView">
16+
<StackPanel Grid.Row="0" Spacing="2" Orientation="Horizontal" Margin="2" HorizontalAlignment="Left">
17+
<Button Width="30" Foreground="Black" Classes="toolbar" Name="btnClearOutputWindow" ToolTip.Tip="Clear output window">
18+
<svg:Svg Path="/Svg/eraser-solid.svg"></svg:Svg>
19+
</Button>
20+
<Button Width="30" Foreground="Black" Classes="toolbar" Name="btnCopyToClipboard" ToolTip.Tip="Copy output log to clipboard">
21+
<svg:Svg Path="/Svg/copy-solid.svg"></svg:Svg>
22+
</Button>
23+
</StackPanel>
2724
</Grid>
25+
<Grid Grid.Row="1">
26+
<ScrollViewer HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="#FF202020" Name="scrOutput"
27+
VerticalScrollBarVisibility="Auto">
28+
<!--
29+
<TextBlock TextWrapping="Wrap" Foreground="White" Name="tbOutput" Padding="10" IsVisible="False"/>
30+
-->
31+
<TextBox TextWrapping="Wrap" AcceptsReturn="True" Foreground="White" Name="tbOutput" Padding="10" IsReadOnly="True"/>
32+
</ScrollViewer>
33+
</Grid>
34+
</Grid>
2835
</UserControl>

ZXBStudio/Dialogs/ZXAboutDialog.axaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ public ZXAboutDialog()
1212
{
1313
InitializeComponent();
1414

15-
txtBuild.Text = "1.6.0-beta3";
16-
txtDate.Text = "2025-05-13";
15+
txtBuild.Text = "1.6.0-beta4";
16+
txtDate.Text = "2025-05-21";
1717

1818
btnClose.Click += BtnClose_Click;
1919

0 commit comments

Comments
 (0)