mirror of
https://github.com/fadden/6502bench.git
synced 2024-11-29 10:50:28 +00:00
Set initial focus to appropriate field for project properties
If you double-click a project symbol declaration, the symbol editor opens. I found that I was double-clicking on the comment field and typing with the expectation that the comment would be updated, but it was actually setting the initial focus to the label field. With this change the symbol editor will focus the label, value, or comment field based on which column was double-clicked. The behavior for Actions > Edit Project Symbol and other paths to the symbol editor are unchanged. Also, disabled a wayward assert.
This commit is contained in:
parent
40b21e2ddb
commit
3820bfee8b
@ -722,6 +722,13 @@ namespace SourceGen.AsmGen {
|
||||
if (!mHighAsciiMacroOutput) {
|
||||
mHighAsciiMacroOutput = true;
|
||||
// Output a macro for high-ASCII strings.
|
||||
//
|
||||
// TODO(maybe): the preferred way to do this is apparently
|
||||
// ".macpack apple2" to load some standard macros, then e.g.
|
||||
// scrcode "My high-ASCII string". The macro takes 9 arguments and
|
||||
// recognizes characters and numbers, so it should be possible to
|
||||
// mix strings, string delimiters, and control chars so long as the
|
||||
// argument count is not exceeded.
|
||||
OutputLine(".macro", "HiAscii", "Arg", string.Empty);
|
||||
OutputLine(string.Empty, ".repeat", ".strlen(Arg), I", string.Empty);
|
||||
OutputLine(string.Empty, ".byte", ".strat(Arg, I) | $80", string.Empty);
|
||||
|
@ -1541,7 +1541,10 @@ namespace SourceGen {
|
||||
sym.SymbolSource == Symbol.Source.Platform) {
|
||||
DefSymbol defSym = sym as DefSymbol;
|
||||
int adj = 0;
|
||||
Debug.Assert(operandOffset < 0); // outside file scope
|
||||
// NOTE: operandOffset may be valid, since you are allowed to
|
||||
// define project symbols for addresses inside the file. I
|
||||
// don't think we need to fiddle with that though.
|
||||
//Debug.Assert(operandOffset < 0);
|
||||
if (sym.SymbolType != Symbol.Type.Constant &&
|
||||
attr.OperandAddress >= 0) {
|
||||
// It's an address operand, so we can compute the offset.
|
||||
|
@ -1495,7 +1495,7 @@ namespace SourceGen {
|
||||
// Currently only does something for project symbols; platform symbols
|
||||
// do nothing.
|
||||
if (CanEditProjectSymbol()) {
|
||||
EditProjectSymbol();
|
||||
EditProjectSymbol((CodeListColumn)col);
|
||||
}
|
||||
break;
|
||||
case LineListGen.Line.Type.OrgDirective:
|
||||
@ -2203,7 +2203,7 @@ namespace SourceGen {
|
||||
return (defSym.SymbolSource == Symbol.Source.Project);
|
||||
}
|
||||
|
||||
public void EditProjectSymbol() {
|
||||
public void EditProjectSymbol(CodeListColumn col) {
|
||||
int selIndex = mMainWin.CodeListView_GetFirstSelectedIndex();
|
||||
int symIndex = LineListGen.DefSymIndexFromOffset(CodeLineList[selIndex].FileOffset);
|
||||
DefSymbol origDefSym = mProject.ActiveDefSymbolList[symIndex];
|
||||
@ -2211,6 +2211,20 @@ namespace SourceGen {
|
||||
|
||||
EditDefSymbol dlg = new EditDefSymbol(mMainWin, mFormatter,
|
||||
mProject.ProjectProps.ProjectSyms, origDefSym, null);
|
||||
|
||||
switch (col) {
|
||||
case CodeListColumn.Operand:
|
||||
dlg.InitialFocusField = EditDefSymbol.InputField.Value;
|
||||
break;
|
||||
case CodeListColumn.Comment:
|
||||
dlg.InitialFocusField = EditDefSymbol.InputField.Comment;
|
||||
break;
|
||||
case CodeListColumn.Label:
|
||||
default:
|
||||
dlg.InitialFocusField = EditDefSymbol.InputField.Label;
|
||||
break;
|
||||
}
|
||||
|
||||
if (dlg.ShowDialog() == true) {
|
||||
ProjectProperties newProps = new ProjectProperties(mProject.ProjectProps);
|
||||
newProps.ProjectSyms.Remove(origDefSym.Label);
|
||||
|
@ -72,7 +72,7 @@ limitations under the License.
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="2" Text="Value:"/>
|
||||
<StackPanel Grid.Column="1" Grid.Row="2" VerticalAlignment="Top" Margin="0,0,0,16">
|
||||
<TextBox Margin="0,1,0,0" Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}"
|
||||
<TextBox Name="valueTextBox" Margin="0,1,0,0" Text="{Binding Value, UpdateSourceTrigger=PropertyChanged}"
|
||||
FontFamily="{StaticResource GeneralMonoFont}"
|
||||
IsReadOnly="{Binding ReadOnlyValueAndType}"/>
|
||||
<TextBlock Name="varValueRangeLabel" Text="• Value between 0-255, including width" Margin="0,4,0,0"
|
||||
@ -97,7 +97,7 @@ limitations under the License.
|
||||
|
||||
<TextBlock Grid.Column="0" Grid.Row="4" Text="Comment:" Margin="0,0,8,0"/>
|
||||
<StackPanel Grid.Column="1" Grid.Row="4" Margin="0,0,0,16">
|
||||
<TextBox Margin="0,1,0,0" Text="{Binding Comment, UpdateSourceTrigger=PropertyChanged}"
|
||||
<TextBox Name="commentTextBox" Margin="0,1,0,0" Text="{Binding Comment, UpdateSourceTrigger=PropertyChanged}"
|
||||
FontFamily="{StaticResource GeneralMonoFont}" ScrollViewer.CanContentScroll="True"/>
|
||||
<TextBlock Text="• Optional" Margin="0,4,0,0"/>
|
||||
</StackPanel>
|
||||
|
@ -34,6 +34,14 @@ namespace SourceGen.WpfGui {
|
||||
/// </summary>
|
||||
public DefSymbol NewSym { get; private set; }
|
||||
|
||||
public enum InputField {
|
||||
Unknown = 0, Label, Value, Comment
|
||||
}
|
||||
/// <summary>
|
||||
/// Determines which field gets focus initially.
|
||||
/// </summary>
|
||||
public InputField InitialFocusField { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Set to true when all fields are valid. Controls whether the OK button is enabled.
|
||||
/// </summary>
|
||||
@ -234,8 +242,21 @@ namespace SourceGen.WpfGui {
|
||||
}
|
||||
|
||||
private void Window_ContentRendered(object sender, EventArgs e) {
|
||||
labelTextBox.SelectAll();
|
||||
labelTextBox.Focus();
|
||||
TextBox field;
|
||||
switch (InitialFocusField) {
|
||||
case InputField.Value:
|
||||
field = valueTextBox;
|
||||
break;
|
||||
case InputField.Comment:
|
||||
field = commentTextBox;
|
||||
break;
|
||||
case InputField.Label:
|
||||
default:
|
||||
field = labelTextBox;
|
||||
break;
|
||||
}
|
||||
field.SelectAll();
|
||||
field.Focus();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1192,7 +1192,7 @@ namespace SourceGen.WpfGui {
|
||||
}
|
||||
|
||||
private void EditProjectSymbolCmd_Executed(object sender, ExecutedRoutedEventArgs e) {
|
||||
mMainCtrl.EditProjectSymbol();
|
||||
mMainCtrl.EditProjectSymbol(MainController.CodeListColumn.Label);
|
||||
}
|
||||
|
||||
private void EditStatusFlagsCmd_Executed(object sender, ExecutedRoutedEventArgs e) {
|
||||
|
Loading…
Reference in New Issue
Block a user