1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-06-25 05:29:31 +00:00

Implement simple DEBUG menu items

Refresh, comment ruler toggle, keep-alive toggle.
This commit is contained in:
Andy McFadden 2019-07-15 15:32:27 -07:00
parent 8a483f06c2
commit ef4fe35813
4 changed files with 84 additions and 16 deletions

View File

@ -63,6 +63,10 @@ namespace SourceGenWPF.AsmGen {
/// <summary>
/// Queries the versions from all known assemblers, replacing any previously held data.
///
/// WARNING: this will execute all configured assemblers, and may cause a noticeable
/// pause while running. Should only be a fraction of a second on a modern system,
/// but it's something to bear in mind.
/// </summary>
public static void QueryVersions() {
IEnumerator<AssemblerInfo> iter = AssemblerInfo.GetInfoEnumerator();

View File

@ -471,14 +471,9 @@ namespace SourceGenWPF {
// Unpack the recent-project list.
UnpackRecentProjectList();
#if false
// Enable the DEBUG menu if configured.
bool showDebugMenu = AppSettings.Global.GetBool(AppSettings.DEBUG_MENU_ENABLED, false);
if (dEBUGToolStripMenuItem.Visible != showDebugMenu) {
dEBUGToolStripMenuItem.Visible = showDebugMenu;
mainMenuStrip.Refresh();
}
#endif
mMainWin.ShowDebugMenu =
AppSettings.Global.GetBool(AppSettings.DEBUG_MENU_ENABLED, false);
// Finally, update the display list generator with all the fancy settings.
if (CodeLineList != null) {
@ -2989,6 +2984,30 @@ namespace SourceGenWPF {
#endif
}
public void Debug_Refresh() {
Debug.WriteLine("Reanalyzing...");
// Call through ApplyChanges so we update the timer task output.
UndoableChange uc =
UndoableChange.CreateDummyChange(UndoableChange.ReanalysisScope.CodeAndData);
ApplyChanges(new ChangeSet(uc), false);
#if false
UpdateMenuItemsAndTitle(); // in case something changed
#endif
}
public void Debug_ToggleCommentRulers() {
MultiLineComment.DebugShowRuler = !MultiLineComment.DebugShowRuler;
// Don't need to repeat the analysis, but we do want to save/restore the
// selection and top position when the comment fields change size.
UndoableChange uc =
UndoableChange.CreateDummyChange(UndoableChange.ReanalysisScope.DataOnly);
ApplyChanges(new ChangeSet(uc), false);
}
public void Debug_ToggleKeepAliveHack() {
ScriptManager.UseKeepAliveHack = !ScriptManager.UseKeepAliveHack;
}
#endregion References panel
#region Notes panel

View File

@ -39,6 +39,8 @@ limitations under the License.
<ResourceDictionary Source="../Res/CommandIcons.xaml"/>
</ResourceDictionary.MergedDictionaries>
<BooleanToVisibilityConverter x:Key="BoolToVis"/>
<!-- don't center the ListView(GridView) column headers
https://stackoverflow.com/q/44119146/294248
(style without ID applies to all instances of that type)
@ -157,6 +159,9 @@ limitations under the License.
</RoutedUICommand.InputGestures>
</RoutedUICommand>
<RoutedUICommand x:Key="Debug_ToggleCommentRulersCmd" Text="Show Comment Rulers"/>
<RoutedUICommand x:Key="Debug_ToggleKeepAliveHackCmd" Text="Use Keep-Alive Hack"/>
<CollectionViewSource x:Key="SymbolTableSource" Source="{Binding SymbolsList}"
Filter="SymbolsList_Filter"/>
</ResourceDictionary>
@ -250,6 +255,13 @@ limitations under the License.
CanExecute="CanToggleSingleByteFormat" Executed="ToggleSingleByteFormatCmd_Executed"/>
<CommandBinding Command="{StaticResource UndoCmd}"
CanExecute="CanUndo" Executed="UndoCmd_Executed"/>
<CommandBinding Command="Refresh"
CanExecute="IsProjectOpen" Executed="Debug_RefreshCmd_Executed"/>
<CommandBinding Command="{StaticResource Debug_ToggleCommentRulersCmd}"
Executed="Debug_ToggleCommentRulersCmd_Executed"/>
<CommandBinding Command="{StaticResource Debug_ToggleKeepAliveHackCmd}"
Executed="Debug_ToggleKeepAliveHackCmd_Executed"/>
</Window.CommandBindings>
<DockPanel>
@ -320,15 +332,18 @@ limitations under the License.
<MenuItem Command="Help"/>
<MenuItem Command="{StaticResource AboutCmd}"/>
</MenuItem>
<MenuItem Header="_DEBUG" Name="DebugMenu">
<MenuItem Header="_DEBUG" Name="DebugMenu" SubmenuOpened="DebugMenu_SubmenuOpened"
Visibility="{Binding ShowDebugMenu, Converter={StaticResource BoolToVis}}">
<MenuItem Command="Refresh" Header="Re-analyze"/>
<MenuItem Header="Show Undo/Redo History"/>
<MenuItem Header="Show Analyzer Output"/>
<MenuItem Header="Show Analysis Timers"/>
<MenuItem Header="Extension Script Info..."/>
<Separator/>
<MenuItem Header="Toggle Comment Rulers"/>
<MenuItem Header="Use Keep-Alive Hack"/>
<MenuItem Name="debugCommentRulersMenuItem"
Command="{StaticResource Debug_ToggleCommentRulersCmd}" IsCheckable="True"/>
<MenuItem Name="debugKeepAliveHackMenuItem"
Command="{StaticResource Debug_ToggleKeepAliveHackCmd}" IsCheckable="True"/>
<Separator/>
<MenuItem Command="{StaticResource DebugSourceGenerationTestsCmd}"/>
</MenuItem>

View File

@ -69,6 +69,18 @@ namespace SourceGenWPF.WpfGui {
}
private double mLongCommentWidth;
/// <summary>
/// Set to true if the DEBUG menu should be visible on the main menu strip.
/// </summary>
public bool ShowDebugMenu {
get { return mShowDebugMenu; }
set {
mShowDebugMenu = value;
OnPropertyChanged();
}
}
bool mShowDebugMenu;
/// <summary>
/// Reference to controller object.
/// </summary>
@ -669,17 +681,19 @@ namespace SourceGenWPF.WpfGui {
/// when the ItemContainerGenerator's StatusChanged event fires.
/// </summary>
/// <remarks>
/// Steps to cause problem:
/// Sample steps to reproduce problem:
/// 1. select note
/// 2. delete note
/// 3. select nearby line
/// 4. edit > undo
/// 5. hit the down-arrow key
///
/// Without this event handler, the list jumps to line zero. The original article
/// was dealing with a different problem, where you'd have to hit the down-arrow twice
/// to make it move, because the focus was on the control rather than the item. The
/// same fix seems to apply for this issue as well.
/// Without this event handler, the list jumps to line zero. Apparently the keyboard
/// navigation is not based on which element(s) are selected.
///
/// The original article was dealing with a different problem, where you'd have to hit
/// the down-arrow twice to make it move the first time, because the focus was on the
/// control rather than an item. The same fix seems to apply for this issue as well.
///
/// From http://cytivrat.blogspot.com/2011/05/selecting-first-item-in-wpf-listview.html
/// </remarks>
@ -698,7 +712,7 @@ namespace SourceGenWPF.WpfGui {
}
}
public int CodeListView_GetTopIndex() {
public int CodeListView_GetTopIndex() {
return codeListView.GetTopItemIndex();
}
@ -1099,6 +1113,18 @@ namespace SourceGenWPF.WpfGui {
mMainCtrl.UndoChanges();
}
private void Debug_RefreshCmd_Executed(object sender, ExecutedRoutedEventArgs e) {
mMainCtrl.Debug_Refresh();
}
private void Debug_ToggleCommentRulersCmd_Executed(object sender, ExecutedRoutedEventArgs e) {
mMainCtrl.Debug_ToggleCommentRulers();
}
private void Debug_ToggleKeepAliveHackCmd_Executed(object sender, ExecutedRoutedEventArgs e) {
mMainCtrl.Debug_ToggleKeepAliveHack();
}
#endregion Command handlers
#region Misc
@ -1182,6 +1208,10 @@ namespace SourceGenWPF.WpfGui {
private void ToolsMenu_SubmenuOpened(object sender, RoutedEventArgs e) {
toggleAsciiChartMenuItem.IsChecked = mMainCtrl.IsAsciiChartOpen;
}
private void DebugMenu_SubmenuOpened(object sender, RoutedEventArgs e) {
debugCommentRulersMenuItem.IsChecked = MultiLineComment.DebugShowRuler;
debugKeepAliveHackMenuItem.IsChecked = Sandbox.ScriptManager.UseKeepAliveHack;
}
#endregion Misc