1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-12-05 19:50:33 +00:00
6502bench/SourceGen/WpfGui/GenerateLabels.xaml.cs
Andy McFadden 4322a0c231 Add option to put labels on separate lines
We currently have two options for assembly code output, selected by
a checkbox in the application settings: always put labels on the same
lines as the instruction or data operand, or split the labels onto
their own line if they were wider than the label text field.

This change adds a third option, which puts labels on their own line
whenever possible.  Assemblers don't generally allow this for variable
assignment pseudo-ops like "foo = $1000", but it's accepted for most
other situations.  This is a cosmetic change to the output, and will
not affect the generated code.

The old true/false app setting will be disregarded.  "Split if too
long" will be used by default.

Added test 20280-label-placement to exercise the "split whenever
allowed" behavior.

The "export" function has a similar option that has not been updated
(for no particular reason other than laziness).

Also, simplified the app settings GetEnum / SetEnum calls, which
can infer the enumerated type from the arguments.  This should not
impact behavior.
2024-04-21 16:26:42 -07:00

72 lines
2.5 KiB
C#

/*
* Copyright 2019 faddenSoft
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Runtime.CompilerServices;
using System.Windows;
using System.Windows.Controls;
namespace SourceGen.WpfGui {
/// <summary>
/// Select parameters for label file generation.
/// </summary>
public partial class GenerateLabels : Window, INotifyPropertyChanged {
// INotifyPropertyChanged implementation
public event PropertyChangedEventHandler PropertyChanged;
private void OnPropertyChanged([CallerMemberName] string propertyName = "") {
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public bool IncludeAutoLabels {
get { return mIncludeAutoLabels; }
set { mIncludeAutoLabels = value; OnPropertyChanged(); }
}
private bool mIncludeAutoLabels;
public LabelFileGenerator.LabelFmt Format { get; private set; }
public bool Format_VICE {
get { return Format == LabelFileGenerator.LabelFmt.VICE;}
set { Format = LabelFileGenerator.LabelFmt.VICE; UpdateFormats(); }
}
private void UpdateFormats() {
OnPropertyChanged(nameof(Format_VICE));
}
public GenerateLabels(Window owner) {
InitializeComponent();
Owner = owner;
DataContext = this;
Format = AppSettings.Global.GetEnum(AppSettings.LABGEN_FORMAT,
LabelFileGenerator.LabelFmt.VICE);
UpdateFormats();
mIncludeAutoLabels = AppSettings.Global.GetBool(AppSettings.LABGEN_INCLUDE_AUTO, false);
}
private void OkButton_Click(object sender, RoutedEventArgs e) {
// Save settings.
AppSettings.Global.SetEnum(AppSettings.LABGEN_FORMAT, Format);
AppSettings.Global.SetBool(AppSettings.LABGEN_INCLUDE_AUTO, mIncludeAutoLabels);
DialogResult = true;
}
}
}