Skip to content

Commit

Permalink
Merge branch 'master' into features/graphics_rework
Browse files Browse the repository at this point in the history
  • Loading branch information
gusmanb authored Jan 7, 2024
2 parents 2935832 + 036fb8f commit edeb452
Show file tree
Hide file tree
Showing 15 changed files with 239 additions and 22 deletions.
75 changes: 73 additions & 2 deletions ZXBStudio/BuildSystem/ZXCodeFile.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using Avalonia.Svg.Skia;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
Expand Down Expand Up @@ -116,7 +117,14 @@ public void CreateBuildFile(IEnumerable<ZXCodeFile> AllFiles)
string line = lines[lineNum];
string trim = line.Trim().ToLower();

if (trim.StartsWith("#line") || string.IsNullOrWhiteSpace(trim))
if (string.IsNullOrWhiteSpace(trim))
{
sbSource.AppendLine(line);
sb.AppendLine(line);
continue;
}

if (trim.StartsWith("#line"))
continue;

if (regInclude.IsMatch(line))
Expand Down Expand Up @@ -156,8 +164,48 @@ public void CreateBuildFile(IEnumerable<ZXCodeFile> AllFiles)

BuildContent = sb.ToString();

bool doTrim = true;

while (doTrim)
{
BuildContent.TrimEnd();

if (BuildContent.EndsWith("\r") || BuildContent.EndsWith("\n"))
{

if (BuildContent.EndsWith("\r\n"))
BuildContent = BuildContent.Substring(0, BuildContent.Length - 2);
else
BuildContent = BuildContent.Substring(0, BuildContent.Length - 1);

}
else
doTrim = false;
}

File.WriteAllText(Path.Combine(Directory, TempFileName), BuildContent);

Content = sbSource.ToString();

doTrim = true;

while (doTrim)
{

Content.TrimEnd();

if (Content.EndsWith("\r") || Content.EndsWith("\n"))
{

if (Content.EndsWith("\r\n"))
Content = Content.Substring(0, Content.Length - 2);
else
Content = Content.Substring(0, Content.Length - 1);

}
else
doTrim = false;
}
}
else
{
Expand All @@ -171,7 +219,10 @@ public void CreateBuildFile(IEnumerable<ZXCodeFile> AllFiles)
string trim = line.Trim().ToLower();

if (string.IsNullOrWhiteSpace(trim))
{
sb.AppendLine(line);
continue;
}

if (!inAsm)
inAsm = line.Trim().ToLower().StartsWith("asm");
Expand Down Expand Up @@ -209,6 +260,26 @@ public void CreateBuildFile(IEnumerable<ZXCodeFile> AllFiles)

BuildContent = sb.ToString();

bool dotrim = true;

while (dotrim)
{

BuildContent.TrimEnd();

if (BuildContent.EndsWith("\r") || BuildContent.EndsWith("\n"))
{

if (BuildContent.EndsWith("\r\n"))
BuildContent = BuildContent.Substring(0, BuildContent.Length - 2);
else
BuildContent = BuildContent.Substring(0, BuildContent.Length - 1);

}
else
dotrim = false;
}

File.WriteAllText(Path.Combine(Directory, TempFileName), sb.ToString());
}
}
Expand Down
8 changes: 4 additions & 4 deletions ZXBStudio/BuildSystem/ZXProjectBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class ZXProjectBuilder

if (ZXProjectManager.Current == null)
{
OutputLogWritter.WriteLine("No open projcet, aborting...");
OutputLogWritter.WriteLine("No open project, aborting...");
return null;
}

Expand Down Expand Up @@ -262,7 +262,7 @@ private static bool BuildNexFile(byte[] binary, ZXBuildSettings settings, ZXProj
{
if (ZXProjectManager.Current == null)
{
OutputLogWritter.WriteLine("No open projcet, aborting...");
OutputLogWritter.WriteLine("No open project, aborting...");
return null;
}

Expand Down Expand Up @@ -454,14 +454,14 @@ public static bool Export(ZXExportOptions Export, TextWriter OutputLogWritter)
{
if (ZXProjectManager.Current == null)
{
OutputLogWritter.WriteLine("No open projcet, aborting...");
OutputLogWritter.WriteLine("No open project, aborting...");
return false;
}

var project = ZXProjectManager.Current;

Cleanup(project.ProjectPath);
ZXBuildSettings? settings = null;
ZXBuildSettings? settings;
string? mainFile = null;

if (string.IsNullOrWhiteSpace(ZXOptions.Current.ZxbcPath) || string.IsNullOrWhiteSpace(ZXOptions.Current.ZxbasmPath))
Expand Down
1 change: 1 addition & 0 deletions ZXBStudio/Classes/ZXOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,6 @@ public static void SaveCurrentSettings()
public string LastProjectPath { get; set; }
public ZXBuildSettings? DefaultBuildSettings { get; set; }
public string? NextEmulatorPath { get; set; }
public bool DisableAuto { get; set; }
}
}
2 changes: 1 addition & 1 deletion ZXBStudio/Controls/ZXOutputLog.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
</UserControl.ContextMenu>
<Grid RowDefinitions="auto,*">
<Grid ColumnDefinitions="1*" DataContext=".ZXMemoryView">
<StackPanel Grid.Row="0" Spacing="2" Orientation="Horizontal" Margin="2,4" HorizontalAlignment="Left">
<StackPanel Grid.Row="0" Spacing="2" Orientation="Horizontal" Margin="2" HorizontalAlignment="Left">
<Button Width="30" Foreground="Black" Classes="toolbar" Name="btnClearOutputWindow" ToolTip.Tip="Clear output window"><svg:Svg Path="/Svg/eraser-solid.svg"></svg:Svg></Button>
<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>
</StackPanel>
Expand Down
56 changes: 56 additions & 0 deletions ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="ZXBasicStudio.DebuggingTools.Flags.Controls.ZXFlagsView">
<UserControl.Styles>
</UserControl.Styles>
<Grid Grid.Row="1" RowDefinitions="50" VerticalAlignment="Stretch">
<Panel Background="#FF606060">
<Grid ColumnDefinitions="*,*,*,*,*,*,*,*" RowDefinitions="25,25" Name="gridFlags">
<TextBlock Grid.Row="0" Grid.Column="0" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="S - Sign flag: Set if the 2-complement value is negative (copy of MSB)">S</TextBlock>
<TextBlock Grid.Row="0" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="Z - Zero flag: Set if the value is zero">Z</TextBlock>
<TextBlock Grid.Row="0" Grid.Column="2" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="F5 - undocumented: Copy of bit 5">-</TextBlock>
<TextBlock Grid.Row="0" Grid.Column="3" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="H - Half Carry: Carry from bit 3 to bit 4">H</TextBlock>
<TextBlock Grid.Row="0" Grid.Column="4" HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="F3 - undocumented: Copy of bit 3">-</TextBlock>
<TextBlock Grid.Row="0" Grid.Column="5"
HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="P/V - Parity or Overflow: Parity set if even number of bits set. Overflow set if the 2-complement result does not fit in the register">
V
</TextBlock>
<TextBlock Grid.Row="0" Grid.Column="6"
HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="N - Subtract: Set if the last operation was a subtraction">
N
</TextBlock>
<TextBlock Grid.Row="0" Grid.Column="7"
HorizontalAlignment="Center" VerticalAlignment="Center" ToolTip.Tip="C - Carry: Set if the result did not fit in the register">
C
</TextBlock>
<Border Grid.Column="0" Grid.Row="1" BorderBrush="Black" BorderThickness="0,1,0,0">
<TextBlock Name="Bit7" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<Border Grid.Column="1" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0">
<TextBlock Name="Bit6" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<Border Grid.Column="2" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0">
<TextBlock Name="Bit5" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<Border Grid.Column="3" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0">
<TextBlock Name="Bit4" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<Border Grid.Column="4" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0">
<TextBlock Name="Bit3" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<Border Grid.Column="5" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0">
<TextBlock Name="Bit2" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<Border Grid.Column="6" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0">
<TextBlock Name="Bit1" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
<Border Grid.Column="7" Grid.Row="1" BorderBrush="Black" BorderThickness="1,1,0,0">
<TextBlock Name="Bit0" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</Border>
</Grid>
</Panel>
</Grid>
</UserControl>
52 changes: 52 additions & 0 deletions ZXBStudio/DebuggingTools/Flags/Controls/ZXFlagsView.axaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System;
using System.Linq;
using Avalonia.Controls;

namespace ZXBasicStudio.DebuggingTools.Flags.Controls
{
public partial class ZXFlagsView : UserControl
{

public ZXFlagsView()
{
InitializeComponent();
}

public void Update(byte value)
{
var bits = GetBinaryFromByte(value);
Bit7.Text = bits[7].ToString();
Bit6.Text = bits[6].ToString();
Bit5.Text = bits[5].ToString();
Bit4.Text = bits[4].ToString();
Bit3.Text = bits[3].ToString();
Bit2.Text = bits[2].ToString();
Bit1.Text = bits[1].ToString();
Bit0.Text = bits[0].ToString();
}

private static int[] GetBinaryFromByte(byte value)
{
string s = Convert.ToString(value, 2);
int[] bits = s.PadLeft(8, '0')
.Select(c => int.Parse(c.ToString()))
.ToArray();

Array.Reverse(bits);
return bits;
}

public void Clear()
{
Bit7.Text = "-";
Bit6.Text = "-";
Bit5.Text = "-";
Bit4.Text = "-";
Bit3.Text = "-";
Bit2.Text = "-";
Bit1.Text = "-";
Bit0.Text = "-";

}
}
}
10 changes: 8 additions & 2 deletions ZXBStudio/Dialogs/ZXOptionsDialog.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,14 @@
<TextBox Classes="dialog" Grid.Row="8" Grid.Column="2" Name="txtNextEmulator" IsReadOnly="True"></TextBox>
<Button Classes="dialog" Grid.Row="8" Grid.Column="3" VerticalAlignment="Center" Name="btnSelectNextEmulator">...</Button>

<Button Classes="dialog" Grid.Row="9" Grid.Column="2" Padding="6" VerticalAlignment="Center" Name="btnKeybMap">Keyboard mappings</Button>
<Button Classes="dialog" Grid.Row="10" Grid.Column="2" Padding="6" VerticalAlignment="Center" Name="btnDefaultBuildConfig">Default build options</Button>
<TextBlock Classes="dialog" Grid.Row="9" Grid.Column="1" VerticalAlignment="Center">Disable autocomplete:</TextBlock>
<CheckBox Classes="dialog" Name="ckDisableAuto" Grid.Column="2" Grid.Row="9"></CheckBox>

<StackPanel Spacing="10" Margin="0,0,0,0" Grid.Row="10" Grid.ColumnSpan="5" Grid.RowSpan="1" Orientation="Horizontal" HorizontalAlignment="Center">
<Button Classes="dialog" Margin="0" Padding="6" VerticalAlignment="Center" Name="btnDefaultBuildConfig">Default build options</Button>
<Button Classes="dialog" Margin="0" Padding="6" VerticalAlignment="Center" Name="btnKeybMap">Keyboard mappings</Button>
</StackPanel>

<StackPanel Margin="0,0,0,10" Grid.Row="11" Grid.ColumnSpan="4" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Classes="dialog" VerticalAlignment="Bottom" Padding="7" Name="btnCancel">Cancel</Button>
<Button Classes="dialog" VerticalAlignment="Bottom" Padding="7" Name="btnAccept">Accept</Button>
Expand Down
11 changes: 5 additions & 6 deletions ZXBStudio/Dialogs/ZXOptionsDialog.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ public ZXOptionsDialog()
btnSelectZxbasm.Click += BtnSelectZxbasm_Click;
btnDefaultBuildConfig.Click += BtnDefaultBuildConfig_Click;
btnSelectNextEmulator.Click += BtnSelectNextEmulator_Click;

txtZxbasm.Text = ZXOptions.Current.ZxbasmPath;
txtZxbc.Text = ZXOptions.Current.ZxbcPath;
nudFontSize.Value = (decimal)ZXOptions.Current.EditorFontSize;
Expand All @@ -29,9 +28,10 @@ public ZXOptionsDialog()
ckBorderless.IsChecked = ZXOptions.Current.Borderless;
ckAntiAlias.IsChecked = ZXOptions.Current.AntiAlias;
txtNextEmulator.Text = ZXOptions.Current.NextEmulatorPath;
ckDisableAuto.IsChecked = ZXOptions.Current.DisableAuto;

btnKeybMap.Click += BtnKeybMap_Click;
}
}

private void BtnKeybMap_Click(object? sender, Avalonia.Interactivity.RoutedEventArgs e)
{
Expand Down Expand Up @@ -61,8 +61,7 @@ private async void BtnSelectZxbasm_Click(object? sender, Avalonia.Interactivity.
Title = "Select ZXBASM path...",
FileTypeFilter = new[]
{
new FilePickerFileType("ZXBASM executable") { Patterns = new[] { "zxbasm.exe" } },
new FilePickerFileType("All files") { Patterns = new[] { "*", "*.*" } }
new FilePickerFileType("ZXBASM executable") { Patterns = new[] { "*" } }
}
});

Expand All @@ -78,8 +77,7 @@ private async void BtnSelectZxbc_Click(object? sender, Avalonia.Interactivity.Ro
Title = "Select ZXBC path...",
FileTypeFilter = new[]
{
new FilePickerFileType("ZXBC executable") { Patterns = new[] { "zxbc.exe" } },
new FilePickerFileType("All files") { Patterns = new[] { "*", "*.*" } }
new FilePickerFileType("ZXBC executable") { Patterns = new[] { "*" } }
}
});

Expand Down Expand Up @@ -137,6 +135,7 @@ private async void BtnAccept_Click(object? sender, Avalonia.Interactivity.Routed
ZXOptions.Current.Borderless = ckBorderless.IsChecked ?? false;
ZXOptions.Current.AntiAlias = ckAntiAlias.IsChecked ?? false;
ZXOptions.Current.NextEmulatorPath = txtNextEmulator.Text;
ZXOptions.Current.DisableAuto = ckDisableAuto.IsChecked ?? false;

if (bsett != null)
ZXOptions.Current.DefaultBuildSettings = bsett;
Expand Down
1 change: 0 additions & 1 deletion ZXBStudio/DocumentEditors/ZXGraphics/SpriteEditor.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
Focusable="True"
Background="#ff202020"
x:Class="ZXBasicStudio.DocumentEditors.ZXGraphics.SpriteEditor">

<Grid Name="grdMain" RowDefinitions="*,Auto">
<Grid Name="grdEditor" Grid.RowSpan="2" ColumnDefinitions="180,4,*,4,200" Margin="0,8,0,0">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using ZXBasicStudio.Classes;
using ZXBasicStudio.DocumentEditors.ZXTextEditor.Classes.Folding;
using ZXBasicStudio.DocumentEditors.ZXTextEditor.Classes.LanguageDefinitions;
using ZXBasicStudio.IntegratedDocumentTypes.CodeDocuments.Basic;
Expand Down Expand Up @@ -472,6 +473,12 @@ public ZXBasicEditor(string DocumentPath) : base(DocumentPath, ZXBasicDocument.I

var context = GetContext(Document, line.Offset + Column);

if (!ByRequest)
{
if(ZXOptions.Current.DisableAuto)
return null;
}

if (ByRequest)
{

Expand Down
2 changes: 1 addition & 1 deletion ZXBStudio/Emulator/Controls/ZXEmulator.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
x:Class="ZXBasicStudio.Emulator.Controls.ZXEmulator" Focusable="True">
<Grid ColumnDefinitions="*,16,0" Background="#FF202020" Name="grdEmulator">
<zxc:ZXScreen Name="emuScr"></zxc:ZXScreen>
<Button Grid.Column="1" Name="btnKeyb">&lt;</Button>
<Button Grid.Column="1" Name="btnKeyb" Focusable="False">&lt;</Button>
<Border Grid.Column="2" Background="#000000" IsVisible="False" Name="brdKeyb">
<zxc:ZXKeyboardView Margin="0" Name="emuKeyb"></zxc:ZXKeyboardView>
</Border>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ namespace ZXBasicStudio.IntegratedDocumentTypes.CodeDocuments.Text
{
public class ZXTextDocument : IZXDocumentType
{
static readonly string[] _docExtensions = { ".txt", ".md" };
static readonly string[] _docExtensions = { ".txt", ".md", ".rm", ".sh", ".map", ".bat" };
static readonly string _docName = "Text document";
static readonly string _docDesc = "Plain text document.";
static readonly string _docCat = "General";
Expand Down
Loading

0 comments on commit edeb452

Please sign in to comment.