Skip to content

Commit

Permalink
fix: Get naming straight
Browse files Browse the repository at this point in the history
  • Loading branch information
ja-he committed Jul 1, 2024
1 parent 444a328 commit 79ce7aa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
26 changes: 13 additions & 13 deletions internal/control/edit/editors/composite_editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,10 @@ func ConstructEditor(id string, obj any, extraSpec map[string]any, parentEditor
parts := strings.Split(tag, ",")

// build the edit spec
subeditorID := parts[0]
editspec := dpedit{
ID: subeditorID,
ID: parts[0],
}
log.Trace().Interface("dpedit", editspec).Msgf("have editspec")
if len(parts) == 2 {
switch parts[1] {
case "ignore":
Expand All @@ -148,14 +148,14 @@ func ConstructEditor(id string, obj any, extraSpec map[string]any, parentEditor
if !editspec.Ignore {
// set the active field to the first field
if constructedCompositeEditor.activeFieldID == "___unassigned" {
constructedCompositeEditor.activeFieldID = subeditorID
constructedCompositeEditor.activeFieldID = editspec.ID
}
constructedCompositeEditor.fieldOrder = append(constructedCompositeEditor.fieldOrder, subeditorID)
constructedCompositeEditor.fieldOrder = append(constructedCompositeEditor.fieldOrder, editspec.ID)

switch field.Type.Kind() {
case reflect.String:
f := structValue.Field(i)
constructedCompositeEditor.fields[subeditorID] = &StringEditor{
constructedCompositeEditor.fields[editspec.ID] = &StringEditor{
Name: editspec.ID,
Content: f.String(),
CursorPos: 0,
Expand All @@ -165,7 +165,7 @@ func ConstructEditor(id string, obj any, extraSpec map[string]any, parentEditor
case edit.EditorInactive, edit.EditorSelected:
return edit.EditorInactive
case edit.EditorChildActive, edit.EditorFocussed:
if constructedCompositeEditor.activeFieldID == subeditorID {
if constructedCompositeEditor.activeFieldID == editspec.ID {
if constructedCompositeEditor.inField {
return edit.EditorFocussed
}
Expand All @@ -178,7 +178,7 @@ func ConstructEditor(id string, obj any, extraSpec map[string]any, parentEditor
}
},
QuitCallback: func() {
if constructedCompositeEditor.activeFieldID == subeditorID {
if constructedCompositeEditor.activeFieldID == editspec.ID {
constructedCompositeEditor.inField = false
}
},
Expand All @@ -198,21 +198,21 @@ func ConstructEditor(id string, obj any, extraSpec map[string]any, parentEditor
} else {
fAsPtr = f.Addr().Interface()
}
log.Debug().Msgf("constructing subeditor for field '%s' of type '%s'", field.Name, field.Type.String())
sube, err := ConstructEditor(field.Name, fAsPtr, nil, constructedCompositeEditor)
log.Debug().Msgf("constructing subeditor for field '%s' (tagged '%s') of type '%s'", field.Name, editspec.ID, field.Type.String())
sube, err := ConstructEditor(editspec.ID, fAsPtr, nil, constructedCompositeEditor)
if err != nil {
return nil, fmt.Errorf("unable to construct subeditor for field '%s' of type '%s' (%s)", field.Name, field.Type.String(), err.Error())
return nil, fmt.Errorf("unable to construct subeditor for field '%s' (tagged '%s') of type '%s' (%s)", field.Name, editspec.ID, field.Type.String(), err.Error())
}
sube.AddQuitCallback(func() { constructedCompositeEditor.inField = false })
log.Debug().Msgf("successfully constructed subeditor for field '%s' of type '%s'", field.Name, field.Type.String())
constructedCompositeEditor.fields[subeditorID] = sube
log.Debug().Msgf("successfully constructed subeditor for field '%s' (tagged '%s') of type '%s'", field.Name, editspec.ID, field.Type.String())
constructedCompositeEditor.fields[editspec.ID] = sube
}

case reflect.Ptr:
// TODO
log.Warn().Msgf("ignoring PTR '%s' tagged '%s' (ignore:%t) of type '%s'", field.Name, editspec.ID, editspec.Ignore, field.Type.String())
default:
return nil, fmt.Errorf("unable to edit non-ignored field '%s' of type '%s'", field.Name, field.Type.Kind())
return nil, fmt.Errorf("unable to edit non-ignored field '%s' (tagged '%s') of type '%s'", field.Name, editspec.ID, field.Type.Kind())
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion internal/ui/panes/composite_editor_ui_pane.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (p *CompositeEditorPane) Draw() {
p.Renderer.DrawText(x, y, 1, 1, style.Bolded(), ">")
}

p.Renderer.DrawText(x, y, w, 1, style.Italicized(), string(status))
// p.Renderer.DrawText(x, y, w, 1, style.Italicized(), string(status))

// draw all subpanes
for _, subpane := range p.subpanes {
Expand Down

0 comments on commit 79ce7aa

Please sign in to comment.