make sure file contents are in CRLF

This commit is contained in:
bluepilledgreat 2024-10-24 18:06:57 +01:00
parent 14ee7015e6
commit 4d9c647edb

View File

@ -133,10 +133,13 @@ namespace Bloxstrap.UI.Elements.Editor
{
CustomBootstrapperSchema.ParseSchema();
string themeContents = File.ReadAllText(Path.Combine(Paths.CustomThemes, name, "Theme.xml"));
themeContents = ToCRLF(themeContents); // make sure the theme is in CRLF. a function expects CRLF.
var viewModel = new BootstrapperEditorWindowViewModel();
viewModel.Name = name;
viewModel.Title = $"Editing \"{name}\"";
viewModel.Code = File.ReadAllText(Path.Combine(Paths.CustomThemes, name, "Theme.xml"));
viewModel.Code = themeContents;
DataContext = viewModel;
InitializeComponent();
@ -145,6 +148,11 @@ namespace Bloxstrap.UI.Elements.Editor
UIXML.TextArea.TextEntered += OnTextAreaTextEntered;
}
private static string ToCRLF(string text)
{
return text.Replace("\r\n", "\n").Replace("\r", "\n").Replace("\n", "\r\n");
}
private void OnCodeChanged(object sender, EventArgs e)
{
BootstrapperEditorWindowViewModel viewModel = (BootstrapperEditorWindowViewModel)DataContext;