mirror of
https://github.com/fadden/6502bench.git
synced 2025-01-02 18:30:41 +00:00
Add message list, part 2 (of 2)
Implemented show/hide mechanic, using a button on the right side of the status bar to show status and to trigger un-hide. Also, show I/O direction in project symbols editor list.
This commit is contained in:
parent
81dbab04ba
commit
a4f1de1238
@ -42,6 +42,7 @@ namespace SourceGen {
|
||||
public const string MAIN_RIGHT_PANEL_WIDTH = "main-right-panel-width";
|
||||
public const string MAIN_REFERENCES_HEIGHT = "main-references-height";
|
||||
public const string MAIN_SYMBOLS_HEIGHT = "main-symbols-height";
|
||||
public const string MAIN_HIDE_MESSAGE_WINDOW = "main-hide-message-window";
|
||||
|
||||
// New project dialog.
|
||||
public const string NEWP_SELECTED_SYSTEM = "newp-selected-system";
|
||||
|
@ -933,7 +933,7 @@ namespace SourceGen {
|
||||
mReanalysisTimer.EndTask("Call DisasmProject.Analyze()");
|
||||
|
||||
mReanalysisTimer.StartTask("Update message list");
|
||||
UpdateMessageList();
|
||||
mMainWin.UpdateMessageList(mProject.Messages, mOutputFormatter);
|
||||
mReanalysisTimer.EndTask("Update message list");
|
||||
}
|
||||
|
||||
@ -942,14 +942,6 @@ namespace SourceGen {
|
||||
mReanalysisTimer.EndTask("Generate DisplayList");
|
||||
}
|
||||
|
||||
private void UpdateMessageList() {
|
||||
List<MainWindow.MessageListItem> items = new List<MainWindow.MessageListItem>();
|
||||
foreach (MessageList.MessageEntry entry in mProject.Messages) {
|
||||
items.Add(MessageList.FormatMessage(entry, mOutputFormatter));
|
||||
}
|
||||
mMainWin.UpdateMessageList(items);
|
||||
}
|
||||
|
||||
#endregion Project management
|
||||
|
||||
#region Main window UI event handlers
|
||||
|
@ -88,7 +88,8 @@ namespace SourceGen {
|
||||
|
||||
/// <summary>
|
||||
/// List of messages. This is not kept in sorted order, because the DataGrid used to
|
||||
/// display it will do the sorting for us.
|
||||
/// display it will do the sorting for us. Call the Sort() function to establish an
|
||||
/// initial sort.
|
||||
/// </summary>
|
||||
private List<MessageEntry> mList;
|
||||
|
||||
@ -123,6 +124,18 @@ namespace SourceGen {
|
||||
mList.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sorts the list, by severity then offset.
|
||||
/// </summary>
|
||||
public void Sort() {
|
||||
mList.Sort(delegate (MessageEntry a, MessageEntry b) {
|
||||
if (a.Severity != b.Severity) {
|
||||
return (int)b.Severity - (int)a.Severity;
|
||||
}
|
||||
return a.Offset - b.Offset;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Formats a message for display.
|
||||
/// </summary>
|
||||
@ -168,7 +181,8 @@ namespace SourceGen {
|
||||
break;
|
||||
}
|
||||
|
||||
return new MainWindow.MessageListItem(severity, offset, problem, context, resolution);
|
||||
return new MainWindow.MessageListItem(severity, entry.Offset, offset, problem,
|
||||
context, resolution);
|
||||
}
|
||||
|
||||
public void DebugDump() {
|
||||
|
@ -56,6 +56,7 @@ and 65816 code. The official web site is
|
||||
<li><a href="mainwin.html#notes">Notes Window</a></li>
|
||||
<li><a href="mainwin.html#symbols">Symbols Window</a></li>
|
||||
<li><a href="mainwin.html#info">Info Window</a></li>
|
||||
<li><a href="mainwin.html#messages">Messages Window</a></li>
|
||||
<li><a href="mainwin.html#navigation">Navigation</a></li>
|
||||
<li><a href="mainwin.html#hints">Adding and Removing Hints</a></li>
|
||||
<li><a href="mainwin.html#address-table">Format Address Table</a></li>
|
||||
|
@ -321,6 +321,37 @@ brief description of what the instruction does. The latter can be
|
||||
especially handy for undocumented instructions.</p>
|
||||
|
||||
|
||||
<h3><a name="messages">Messages Window</a></h3>
|
||||
|
||||
<p>Sometimes a change will invalidate an earlier change. For example,
|
||||
suppose you hint an area as data, and format it as a string.
|
||||
Later on you hint it as code. You now have a block of code with a
|
||||
string format record sitting in the middle of it. SourceGen tries very
|
||||
hard not to throw away anything you've done, but it will ignore anything
|
||||
invalid.</p>
|
||||
<p>If a problem like this is encountered, an entry is added to a list
|
||||
of messages displayed at the bottom of the window. Each entry identifies
|
||||
the nature of the problem, the severity of the problem, the offset where
|
||||
it occurred, and what was done to resolve it. The problem categories
|
||||
include:</p>
|
||||
<ul>
|
||||
<li>Hidden label: a label placed on code or data is now stuck in the
|
||||
middle of a multi-byte instruction or data item.</li>
|
||||
<li>Unresolved weak ref: a reference to a non-existent symbol was found.</li>
|
||||
<li>Invalid offset or length: the offset or length in a format object
|
||||
had an invalid value.</li>
|
||||
<li>Invalid descriptor: the format is inappropriate, e.g. formatting
|
||||
an instruction as a string.</li>
|
||||
</ul>
|
||||
<p>The "context" column will provide additional detail about the problem.
|
||||
In most cases, the offending item will be ignored.</p>
|
||||
<p>Double-clicking on an entry will jump to that offset.</p>
|
||||
<p>The message list will not appear if there are no messages. You can
|
||||
hide the list by clicking on the "Hide" button to the left of the messages.
|
||||
Un-hide the list by clicking on the "N messages" button at the bottom-right
|
||||
corner of the application window.</p>
|
||||
|
||||
|
||||
<h3><a name="navigation">Navigation</a></h3>
|
||||
|
||||
<p>The simplest way to move through the code list is with the scroll wheel
|
||||
|
@ -466,6 +466,12 @@ namespace SourceGen.WpfGui {
|
||||
typeStr = Res.Strings.ABBREV_CONSTANT;
|
||||
} else {
|
||||
typeStr = Res.Strings.ABBREV_ADDRESS;
|
||||
|
||||
if (defSym.Direction == DefSymbol.DirectionFlags.Read) {
|
||||
typeStr += "<";
|
||||
} else if (defSym.Direction == DefSymbol.DirectionFlags.Write) {
|
||||
typeStr += ">";
|
||||
}
|
||||
}
|
||||
|
||||
FormattedSymbol fsym = new FormattedSymbol(
|
||||
|
@ -42,6 +42,12 @@ limitations under the License.
|
||||
|
||||
<BooleanToVisibilityConverter x:Key="BoolToVis"/>
|
||||
|
||||
<!-- strings for message button -->
|
||||
<system:String x:Key="str_MessageSingularFmt">{0} message</system:String>
|
||||
<system:String x:Key="str_MessageSingularWarningFmt">{0} message ({1} warning/error)</system:String>
|
||||
<system:String x:Key="str_MessagePluralFmt">{0} messages</system:String>
|
||||
<system:String x:Key="str_MessagePluralWarningFmt">{0} messages ({1} warning/error)</system:String>
|
||||
|
||||
<!-- don't center the ListView(GridView) column headers
|
||||
https://stackoverflow.com/q/44119146/294248
|
||||
(style without ID applies to all instances of that type)
|
||||
@ -423,7 +429,15 @@ limitations under the License.
|
||||
</ToolBarTray>
|
||||
|
||||
<StatusBar Name="mainStatusBar" DockPanel.Dock="Bottom">
|
||||
<TextBlock Text="{Binding StatusBarText, FallbackValue=Ready}"/>
|
||||
<DockPanel LastChildFill="False"
|
||||
Width="{Binding ActualWidth, RelativeSource={RelativeSource FindAncestor,
|
||||
AncestorType={x:Type StatusBar}}}">
|
||||
<TextBlock DockPanel.Dock="Left" Text="{Binding StatusBarText, FallbackValue=Ready}"/>
|
||||
<Button DockPanel.Dock="Right" Margin="4,0,6,0" Padding="4,0,4,0"
|
||||
Content="{Binding MessageStatusText, FallbackValue=3 messages (1 warning/error)}"
|
||||
Visibility="{Binding Path=CodeListVisibility}"
|
||||
Click="MessageStatusButton_Click"/>
|
||||
</DockPanel>
|
||||
</StatusBar>
|
||||
|
||||
<!-- Main part of the window. Three side-by-side panels, only the middle of which changes
|
||||
@ -617,7 +631,8 @@ limitations under the License.
|
||||
|
||||
<DockPanel Grid.Row="1" Visibility="{Binding MessageListVisibility}">
|
||||
<Button DockPanel.Dock="Left" Content="Hide" Width="50" Margin="4,0,4,0"
|
||||
VerticalAlignment="Bottom">
|
||||
VerticalAlignment="Bottom"
|
||||
Click="HideMessageList_Click">
|
||||
<Button.LayoutTransform>
|
||||
<RotateTransform Angle="270"/>
|
||||
</Button.LayoutTransform>
|
||||
@ -635,7 +650,8 @@ limitations under the License.
|
||||
HeadersVisibility="Column"
|
||||
CanUserReorderColumns="False"
|
||||
SelectionMode="Single"
|
||||
VerticalScrollBarVisibility="Visible">
|
||||
VerticalScrollBarVisibility="Visible"
|
||||
MouseDoubleClick="MessageGrid_MouseDoubleClick">
|
||||
<!-- should probably add ellipsis: https://stackoverflow.com/a/12880111/294248 -->
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Severity" Width="64" Binding="{Binding Severity}"/>
|
||||
|
@ -1704,9 +1704,12 @@ namespace SourceGen.WpfGui {
|
||||
public string Context { get; private set; }
|
||||
public string Resolution { get; private set; }
|
||||
|
||||
public MessageListItem(string severity, string offset, string type, string context,
|
||||
string resolution) {
|
||||
public int OffsetValue { get; private set; }
|
||||
|
||||
public MessageListItem(string severity, int offsetValue, string offset, string type,
|
||||
string context, string resolution) {
|
||||
Severity = severity;
|
||||
OffsetValue = offsetValue;
|
||||
Offset = offset;
|
||||
Type = type;
|
||||
Context = context;
|
||||
@ -1714,28 +1717,93 @@ namespace SourceGen.WpfGui {
|
||||
}
|
||||
}
|
||||
|
||||
public Visibility MessageListVisibility {
|
||||
get {
|
||||
bool visible = !HideMessageList && FormattedMessages.Count > 0;
|
||||
return visible ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
private bool HideMessageList {
|
||||
get { return AppSettings.Global.GetBool(AppSettings.MAIN_HIDE_MESSAGE_WINDOW, false); }
|
||||
set {
|
||||
AppSettings.Global.SetBool(AppSettings.MAIN_HIDE_MESSAGE_WINDOW, value);
|
||||
OnPropertyChanged("MessageListVisibility");
|
||||
}
|
||||
}
|
||||
|
||||
private string mMessageStatusText;
|
||||
public string MessageStatusText {
|
||||
get { return mMessageStatusText; }
|
||||
set { mMessageStatusText = value; OnPropertyChanged(); }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ItemsSource for DataGrid.
|
||||
/// </summary>
|
||||
public ObservableCollection<MessageListItem> FormattedMessages { get; private set; } =
|
||||
new ObservableCollection<MessageListItem>();
|
||||
|
||||
public void UpdateMessageList(List<MessageListItem> list) {
|
||||
private void MessageStatusButton_Click(object sender, RoutedEventArgs e) {
|
||||
HideMessageList = false;
|
||||
}
|
||||
|
||||
private void HideMessageList_Click(object sender, RoutedEventArgs e) {
|
||||
HideMessageList = true;
|
||||
}
|
||||
|
||||
private void MessageGrid_MouseDoubleClick(object sender, MouseButtonEventArgs e) {
|
||||
if (!messageGrid.GetClickRowColItem(e, out int unusedRow, out int unusedCol,
|
||||
out object item)) {
|
||||
// Header or empty area; ignore.
|
||||
return;
|
||||
}
|
||||
MessageListItem mli = (MessageListItem)item;
|
||||
|
||||
// Jump to the offset, then shift the focus back to the code list.
|
||||
mMainCtrl.GoToLocation(new NavStack.Location(mli.OffsetValue, 0, false),
|
||||
MainController.GoToMode.JumpToCodeData, true);
|
||||
codeListView.Focus();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Regenerates the contents of the message list.
|
||||
/// </summary>
|
||||
/// <param name="list">Message list.</param>
|
||||
/// <param name="formatter">Format object.</param>
|
||||
public void UpdateMessageList(MessageList list, Asm65.Formatter formatter) {
|
||||
FormattedMessages.Clear();
|
||||
foreach (MessageListItem item in list) {
|
||||
FormattedMessages.Add(item);
|
||||
list.Sort();
|
||||
|
||||
int warnErrCount = 0;
|
||||
foreach (MessageList.MessageEntry entry in list) {
|
||||
FormattedMessages.Add(MessageList.FormatMessage(entry, formatter));
|
||||
if (entry.Severity != MessageList.MessageEntry.SeverityLevel.Info) {
|
||||
warnErrCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (warnErrCount == 0) {
|
||||
if (FormattedMessages.Count == 1) {
|
||||
string fmt = (string)FindResource("str_MessageSingularFmt");
|
||||
MessageStatusText = string.Format(fmt, FormattedMessages.Count);
|
||||
} else {
|
||||
string fmt = (string)FindResource("str_MessagePluralFmt");
|
||||
MessageStatusText = string.Format(fmt, FormattedMessages.Count);
|
||||
}
|
||||
} else {
|
||||
if (FormattedMessages.Count == 1) {
|
||||
string fmt = (string)FindResource("str_MessageSingularWarningFmt");
|
||||
MessageStatusText = string.Format(fmt, FormattedMessages.Count, warnErrCount);
|
||||
} else {
|
||||
string fmt = (string)FindResource("str_MessagePluralWarningFmt");
|
||||
MessageStatusText = string.Format(fmt, FormattedMessages.Count, warnErrCount);
|
||||
}
|
||||
}
|
||||
|
||||
OnPropertyChanged("MessageListVisibility");
|
||||
}
|
||||
|
||||
public Visibility MessageListVisibility {
|
||||
get {
|
||||
bool visible = FormattedMessages.Count > 0;
|
||||
return visible ? Visibility.Visible : Visibility.Collapsed;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Message list panel
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user