mirror of
https://github.com/fadden/6502bench.git
synced 2024-12-28 01:29:29 +00:00
Minor changes to local variable tables
Split "edit local variable table" into "create" and "edit prior". The motivation is to allow the user to make changes to the most recently defined table without having to go search for it. Having table creation be an explicit action, rather than something that just happens if you edit a table that isn't there, feels reasonable. Show table offset in LV table edit dialog, so if you really want to go find it there's a (clumsy) way to do so. Increased the maximum width of a variable from 4 to 8. (This is entirely arbitrary.)
This commit is contained in:
parent
6bc491885a
commit
6df874c559
@ -30,7 +30,7 @@ namespace SourceGen {
|
||||
// width to use when width doesn't matter; use 1 to try to get a prefab object
|
||||
public const int NO_WIDTH = 1;
|
||||
public const int MIN_WIDTH = 1;
|
||||
public const int MAX_WIDTH = 4;
|
||||
public const int MAX_WIDTH = 8;
|
||||
|
||||
/// <summary>
|
||||
/// Data format descriptor.
|
||||
|
@ -1641,19 +1641,52 @@ namespace SourceGen {
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanCreateLocalVariableTable() {
|
||||
int selIndex = mMainWin.CodeListView_GetFirstSelectedIndex();
|
||||
// Only allow on code lines. This is somewhat arbitrary; data would work fine.
|
||||
if (CodeLineList[selIndex].LineType != LineListGen.Line.Type.Code) {
|
||||
return false;
|
||||
}
|
||||
int offset = CodeLineList[selIndex].FileOffset;
|
||||
// Don't allow creation if a table already exists.
|
||||
return !mProject.LvTables.ContainsKey(offset);
|
||||
}
|
||||
|
||||
public void CreateLocalVariableTable() {
|
||||
int selIndex = mMainWin.CodeListView_GetFirstSelectedIndex();
|
||||
int offset = CodeLineList[selIndex].FileOffset;
|
||||
Debug.Assert(!mProject.LvTables.ContainsKey(offset));
|
||||
CreateOrEditLocalVariableTable(offset);
|
||||
}
|
||||
|
||||
public bool CanEditLocalVariableTable() {
|
||||
if (SelectionAnalysis.mNumItemsSelected != 1) {
|
||||
return false;
|
||||
}
|
||||
EntityCounts counts = SelectionAnalysis.mEntityCounts;
|
||||
// Single line of code, or a local variable table.
|
||||
return SelectionAnalysis.mLineType == LineListGen.Line.Type.Code ||
|
||||
SelectionAnalysis.mLineType == LineListGen.Line.Type.LocalVariableTable;
|
||||
// Check to see if the offset of the first-defined table is less than or equal to
|
||||
// the offset of the selected line. If so, we know there's a table, though we
|
||||
// don't know which one.
|
||||
int selIndex = mMainWin.CodeListView_GetFirstSelectedIndex();
|
||||
int offset = CodeLineList[selIndex].FileOffset;
|
||||
return mProject.LvTables.Count > 0 && mProject.LvTables.Keys[0] <= offset;
|
||||
}
|
||||
|
||||
public void EditLocalVariableTable() {
|
||||
int selIndex = mMainWin.CodeListView_GetFirstSelectedIndex();
|
||||
int offset = CodeLineList[selIndex].FileOffset;
|
||||
// Find the offset of the nearest table that's earlier in the file.
|
||||
int bestOffset = -1;
|
||||
foreach (KeyValuePair<int,LocalVariableTable> kvp in mProject.LvTables) {
|
||||
if (kvp.Key > offset) {
|
||||
break; // too far
|
||||
}
|
||||
bestOffset = kvp.Key;
|
||||
}
|
||||
Debug.Assert(bestOffset >= 0);
|
||||
CreateOrEditLocalVariableTable(bestOffset);
|
||||
}
|
||||
|
||||
private void CreateOrEditLocalVariableTable(int offset) {
|
||||
// Get existing table, if any.
|
||||
mProject.LvTables.TryGetValue(offset, out LocalVariableTable oldLvt);
|
||||
|
||||
|
@ -309,15 +309,20 @@ operand references an address outside the scope of the data file. Symbols
|
||||
marked as "constant" will not, though you can still specify them manually.</p>
|
||||
|
||||
|
||||
<h2><a name="lvtable">Edit Local Variable Table</a></h2>
|
||||
<h2><a name="lvtable">Create/Edit Local Variable Table</a></h2>
|
||||
<p><a href="intro.html#local-vars">Local variables</a> are arranged in
|
||||
tables, which are created at a specific file offset. They must be
|
||||
associated with a line of code, and are usually placed at the start of
|
||||
a subroutine. The editor allows you to create, edit, delete, and
|
||||
move tables.</p>
|
||||
<p>Empty tables are allowed. These can be useful if the "clear previous"
|
||||
flag is set. If you want to delete the table, click the "Delete Table"
|
||||
button.</p>
|
||||
a subroutine.
|
||||
The "Create Local Variable Table" action creates a new table, and
|
||||
opens the editor. The "Edit Prior Local Variable Table" searches
|
||||
for the closest table that appears at or before the selected line,
|
||||
and edits that.</p>
|
||||
<p>The editor allows you to create, edit, and delete entries, as well
|
||||
as move and delete entire tables (though these last two options are not
|
||||
available when creating a new table). Empty tables are allowed. These
|
||||
can be useful if the "clear previous" flag is set. If you want to
|
||||
delete the table, click the "Delete Table" button.</p>
|
||||
<p>Use the buttons to add, edit, or remove individual variables. Each
|
||||
variable has a name, a value, a width, and an optional comment. The
|
||||
standard naming rules for symbols apply. Variables are only used for
|
||||
@ -326,8 +331,8 @@ range 0-255, with their width factored in. So the maximum address for
|
||||
a two-byte pointer is $fe.</p>
|
||||
<p>You can move a table to any offset that is the start of an instruction
|
||||
and doesn't already have a local variable table present. Click the
|
||||
"Move Table" button and enter the new offset in hex. You can also use the
|
||||
up/down arrows to move to the next valid offset.</p>
|
||||
"Move Table" button and enter the new offset in hex. You can also click
|
||||
on the up/down buttons to move to the next valid offset.</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
@ -186,8 +186,11 @@ enabled will depend on what you have selected in the main window.</p>
|
||||
Sets the name, value, and comment of the project symbol. Enabled
|
||||
when a single equate directive, generated from a project symbol, is
|
||||
selected.</li>
|
||||
<li><a href="editors.html#lvtable">Edit Local Variable Table</a>.
|
||||
Create, modify, or delete entries in a local variable table.</li>
|
||||
<li><a href="editors.html#lvtable">Create Local Variable Table</a>.
|
||||
Create a new local variable table.</li>
|
||||
<li><a href="editors.html#lvtable">Edit Prior Local Variable Table</a>.
|
||||
Modify or delete entries in the most recently defined local
|
||||
variable table.</li>
|
||||
|
||||
<li><a href="#hints">Hinting</a> (Hint As Code Entry Point, Hint As
|
||||
Data Start, Hint As Inline Data, Remove Hints). Enabled when one or more
|
||||
|
@ -63,7 +63,7 @@ limitations under the License.
|
||||
<StackPanel Name="widthEntry2" Grid.Column="1" Grid.Row="2">
|
||||
<TextBox Margin="0,1,0,0" Text="{Binding VarWidth, UpdateSourceTrigger=PropertyChanged}"
|
||||
FontFamily="{StaticResource GeneralMonoFont}"/>
|
||||
<TextBlock Name="widthNotesLabel" Text="• Decimal value, 1-4" Margin="0,4,0,16"/>
|
||||
<TextBlock Name="widthNotesLabel" Text="• Decimal value, 1-8" Margin="0,4,0,16"/>
|
||||
</StackPanel>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="3" Text="Comment:" Margin="0,0,8,0"/>
|
||||
|
@ -1167,6 +1167,8 @@ namespace SourceGen.WpfGui {
|
||||
} else {
|
||||
Debug.WriteLine("No change to def symbol, ignoring edit");
|
||||
}
|
||||
|
||||
okButton.Focus();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ limitations under the License.
|
||||
<Window.Resources>
|
||||
<system:String x:Key="str_ConfirmDelete">Are you sure you want to delete the entire table?</system:String>
|
||||
<system:String x:Key="str_ConfirmDeleteCaption">Confirm Deletion</system:String>
|
||||
<system:String x:Key="str_TableHeaderFmt">Symbols defined in table at {0}:</system:String>
|
||||
</Window.Resources>
|
||||
|
||||
<Grid Margin="8">
|
||||
@ -44,8 +45,8 @@ limitations under the License.
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2"
|
||||
Margin="0,4,0,0" Text="Symbols defined in project:"/>
|
||||
<TextBlock Grid.Column="0" Grid.Row="0" Grid.ColumnSpan="2" Margin="0,4,0,0"
|
||||
Text="{Binding TableHeaderText, FallbackValue=Symbols defined in table at +######:}"/>
|
||||
|
||||
<ListView Name="symbolsListView" Grid.Column="0" Grid.Row="1" Margin="0,4,4,0"
|
||||
Height="300"
|
||||
|
@ -79,6 +79,15 @@ namespace SourceGen.WpfGui {
|
||||
}
|
||||
private bool mIsNotNewTable;
|
||||
|
||||
/// <summary>
|
||||
/// Table header text string, formatted at load time.
|
||||
/// </summary>
|
||||
public string TableHeaderText {
|
||||
get { return mTableHeaderText; }
|
||||
set { mTableHeaderText = value; OnPropertyChanged(); }
|
||||
}
|
||||
private string mTableHeaderText;
|
||||
|
||||
/// <summary>
|
||||
/// Working set. Used internally to hold state.
|
||||
/// </summary>
|
||||
@ -136,6 +145,9 @@ namespace SourceGen.WpfGui {
|
||||
}
|
||||
|
||||
public void Window_Loaded(object sender, RoutedEventArgs e) {
|
||||
string fmt = (string)FindResource("str_TableHeaderFmt");
|
||||
TableHeaderText = string.Format(fmt, mFormatter.FormatOffset24(mOffset));
|
||||
|
||||
UpdateControls();
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,7 @@ limitations under the License.
|
||||
</RoutedUICommand.InputGestures>
|
||||
</RoutedUICommand>
|
||||
<RoutedUICommand x:Key="CloseCmd" Text="Close"/>
|
||||
<RoutedUICommand x:Key="CreateLocalVariableTableCmd" Text="Create Local Variable Table..."/>
|
||||
<RoutedUICommand x:Key="DeleteMlcCmd" Text="Delete Note/Long Comment">
|
||||
<RoutedUICommand.InputGestures>
|
||||
<KeyGesture>Del</KeyGesture>
|
||||
@ -80,7 +81,7 @@ limitations under the License.
|
||||
<KeyGesture>Ctrl+L</KeyGesture>
|
||||
</RoutedUICommand.InputGestures>
|
||||
</RoutedUICommand>
|
||||
<RoutedUICommand x:Key="EditLocalVariableTableCmd" Text="Edit Local Variable Table..."/>
|
||||
<RoutedUICommand x:Key="EditLocalVariableTableCmd" Text="Edit Prior Local Variable Table..."/>
|
||||
<RoutedUICommand x:Key="EditLongCommentCmd" Text="Edit Long Comment...">
|
||||
<RoutedUICommand.InputGestures>
|
||||
<KeyGesture>Ctrl+M</KeyGesture>
|
||||
@ -176,18 +177,20 @@ limitations under the License.
|
||||
<Window.CommandBindings>
|
||||
<CommandBinding Command="{StaticResource AboutCmd}"
|
||||
Executed="AboutCmd_Executed"/>
|
||||
<CommandBinding Command="{StaticResource EditAppSettingsCmd}"
|
||||
Executed="EditAppSettingsCmd_Executed"/>
|
||||
<CommandBinding Command="{StaticResource AssembleCmd}"
|
||||
CanExecute="IsProjectOpen" Executed="AssembleCmd_Executed"/>
|
||||
<CommandBinding Command="{StaticResource CloseCmd}"
|
||||
CanExecute="IsProjectOpen" Executed="CloseCmd_Executed"/>
|
||||
<CommandBinding Command="{StaticResource CreateLocalVariableTableCmd}"
|
||||
CanExecute="CanCreateLocalVariableTable" Executed="CreateLocalVariableTableCmd_Executed"/>
|
||||
<CommandBinding Command="{StaticResource DeleteMlcCmd}"
|
||||
CanExecute="CanDeleteMlc" Executed="DeleteMlcCmd_Executed"/>
|
||||
<CommandBinding Command="{StaticResource Debug_SourceGenerationTestsCmd}"
|
||||
Executed="Debug_SourceGenerationTestsCmd_Executed"/>
|
||||
<CommandBinding Command="{StaticResource EditAddressCmd}"
|
||||
CanExecute="CanEditAddress" Executed="EditAddressCmd_Executed"/>
|
||||
<CommandBinding Command="{StaticResource EditAppSettingsCmd}"
|
||||
Executed="EditAppSettingsCmd_Executed"/>
|
||||
<CommandBinding Command="{StaticResource EditCommentCmd}"
|
||||
CanExecute="CanEditComment" Executed="EditCommentCmd_Executed"/>
|
||||
<CommandBinding Command="{StaticResource EditHeaderCommentCmd}"
|
||||
@ -331,6 +334,7 @@ limitations under the License.
|
||||
<MenuItem Command="{StaticResource EditLongCommentCmd}"/>
|
||||
<MenuItem Command="{StaticResource EditNoteCmd}"/>
|
||||
<MenuItem Command="{StaticResource EditProjectSymbolCmd}"/>
|
||||
<MenuItem Command="{StaticResource CreateLocalVariableTableCmd}"/>
|
||||
<MenuItem Command="{StaticResource EditLocalVariableTableCmd}"/>
|
||||
<Separator/>
|
||||
<MenuItem Command="{StaticResource HintAsCodeEntryPointCmd}" InputGestureText="Ctrl+H, Ctrl+C"/>
|
||||
|
@ -935,6 +935,10 @@ namespace SourceGen.WpfGui {
|
||||
e.CanExecute = IsProjectOpen();
|
||||
}
|
||||
|
||||
private void CanCreateLocalVariableTable(object sender, CanExecuteRoutedEventArgs e) {
|
||||
e.CanExecute = IsProjectOpen() && mMainCtrl.CanCreateLocalVariableTable();
|
||||
}
|
||||
|
||||
private void CanDeleteMlc(object sender, CanExecuteRoutedEventArgs e) {
|
||||
e.CanExecute = IsProjectOpen() && mMainCtrl.CanDeleteMlc();
|
||||
}
|
||||
@ -1057,6 +1061,10 @@ namespace SourceGen.WpfGui {
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateLocalVariableTableCmd_Executed(object sender, ExecutedRoutedEventArgs e) {
|
||||
mMainCtrl.CreateLocalVariableTable();
|
||||
}
|
||||
|
||||
private void CopyCmd_Executed(object sender, ExecutedRoutedEventArgs e) {
|
||||
mMainCtrl.CopyToClipboard();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user