1
0
mirror of https://github.com/fadden/6502bench.git synced 2024-11-29 10:50:28 +00:00

Implement Edit Project Symbol

This commit is contained in:
Andy McFadden 2019-07-14 13:18:10 -07:00
parent f8b1fa3d66
commit 2dd21d433d
3 changed files with 48 additions and 5 deletions

View File

@ -1333,11 +1333,9 @@ namespace SourceGenWPF {
case LineListGen.Line.Type.EquDirective:
// Currently only does something for project symbols; platform symbols
// do nothing.
#if false
if (editProjectSymbolToolStripMenuItem.Enabled) {
EditProjectSymbol_Click(sender, e);
if (CanEditProjectSymbol()) {
EditProjectSymbol();
}
#endif
break;
case LineListGen.Line.Type.OrgDirective:
if (CanEditAddress()) {
@ -1774,6 +1772,40 @@ namespace SourceGenWPF {
}
}
public bool CanEditProjectSymbol() {
if (SelectionAnalysis.mNumItemsSelected != 1) {
return false;
}
if (SelectionAnalysis.mLineType != LineListGen.Line.Type.EquDirective) {
return false;
}
int selIndex = mMainWin.CodeListView_GetFirstSelectedIndex();
int symIndex = LineListGen.DefSymIndexFromOffset(CodeLineList[selIndex].FileOffset);
DefSymbol defSym = mProject.ActiveDefSymbolList[symIndex];
return (defSym.SymbolSource == Symbol.Source.Project);
}
public void EditProjectSymbol() {
int selIndex = mMainWin.CodeListView_GetFirstSelectedIndex();
int symIndex = LineListGen.DefSymIndexFromOffset(CodeLineList[selIndex].FileOffset);
DefSymbol origDefSym = mProject.ActiveDefSymbolList[symIndex];
Debug.Assert(origDefSym.SymbolSource == Symbol.Source.Project);
EditDefSymbol dlg = new EditDefSymbol(mMainWin, mOutputFormatter,
mProject.ProjectProps.ProjectSyms);
dlg.DefSym = origDefSym;
if (dlg.ShowDialog() == true) {
ProjectProperties newProps = new ProjectProperties(mProject.ProjectProps);
newProps.ProjectSyms.Remove(origDefSym.Label);
newProps.ProjectSyms[dlg.DefSym.Label] = dlg.DefSym;
UndoableChange uc = UndoableChange.CreateProjectPropertiesChange(
mProject.ProjectProps, newProps);
ChangeSet cs = new ChangeSet(uc);
ApplyUndoableChanges(cs);
}
}
public bool CanEditStatusFlags() {
if (SelectionAnalysis.mNumItemsSelected != 1) {
return false;

View File

@ -84,6 +84,7 @@ limitations under the License.
<KeyGesture>Ctrl+N</KeyGesture>
</RoutedUICommand.InputGestures>
</RoutedUICommand>
<RoutedUICommand x:Key="EditProjectSymbolCmd" Text="Edit Project Symbol..."/>
<RoutedUICommand x:Key="EditStatusFlagsCmd" Text="Override Status Flags..."/>
<RoutedUICommand x:Key="ExitCmd" Text="Exit"/>
<RoutedUICommand x:Key="FindNextCmd" Text="Find Next">
@ -172,6 +173,8 @@ limitations under the License.
CanExecute="CanEditNote" Executed="EditNoteCmd_Executed"/>
<CommandBinding Command="{StaticResource EditOperandCmd}"
CanExecute="CanEditOperand" Executed="EditOperandCmd_Executed"/>
<CommandBinding Command="{StaticResource EditProjectSymbolCmd}"
CanExecute="CanEditProjectSymbol" Executed="EditProjectSymbolCmd_Executed"/>
<CommandBinding Command="{StaticResource EditStatusFlagsCmd}"
CanExecute="CanEditStatusFlags" Executed="EditStatusFlagsCmd_Executed"/>
<CommandBinding Command="{StaticResource ExitCmd}"
@ -270,7 +273,7 @@ limitations under the License.
<MenuItem Command="{StaticResource EditCommentCmd}" InputGestureText="Ctrl+;"/>
<MenuItem Command="{StaticResource EditLongCommentCmd}"/>
<MenuItem Command="{StaticResource EditNoteCmd}"/>
<MenuItem Header="Edit Project Symbol..."/>
<MenuItem Command="{StaticResource EditProjectSymbolCmd}"/>
<Separator/>
<MenuItem Command="{StaticResource HintAsCodeEntryPointCmd}" InputGestureText="Ctrl+H, Ctrl+C"/>
<MenuItem Command="{StaticResource HintAsDataStartCmd}" InputGestureText="Ctrl+H, Ctrl+D"/>

View File

@ -769,6 +769,10 @@ namespace SourceGenWPF.WpfGui {
e.CanExecute = IsProjectOpen() && mMainCtrl.CanEditOperand();
}
private void CanEditProjectSymbol(object sender, CanExecuteRoutedEventArgs e) {
e.CanExecute = IsProjectOpen() && mMainCtrl.CanEditProjectSymbol();
}
private void CanEditStatusFlags(object sender, CanExecuteRoutedEventArgs e) {
e.CanExecute = IsProjectOpen() && mMainCtrl.CanEditStatusFlags();
}
@ -888,6 +892,10 @@ namespace SourceGenWPF.WpfGui {
mMainCtrl.EditOperand();
}
private void EditProjectSymbolCmd_Executed(object sender, ExecutedRoutedEventArgs e) {
mMainCtrl.EditProjectSymbol();
}
private void EditStatusFlagsCmd_Executed(object sender, ExecutedRoutedEventArgs e) {
mMainCtrl.EditStatusFlags();
}