func (w *ItemWidget) Layout(g *gocui.Gui) error {
	w.g = g
	v, err := g.SetView("itemWidget", w.x, w.y, w.x+w.w, w.y+w.h)
	if err != nil && err != gocui.ErrUnknownView {
		return err
	}
	v.Editable = true
	v.Wrap = true

	w.view = v
	v.Clear()

	if w.content == "" {
		return nil
	}

	if w.hideGuids {
		w.content = stripSecretVals(w.content)
	}

	var obj map[string]interface{}
	err = json.Unmarshal([]byte(w.content), &obj)
	if err != nil {
		eventing.SendStatusEvent(eventing.StatusEvent{
			InProgress: false,
			Failure:    true,
			Message:    "Failed to display as JSON: " + err.Error(),
			Timeout:    time.Duration(time.Second * 4),
		})
		fmt.Fprint(v, w.content)
		return nil
	}

	f := colorjson.NewFormatter()
	f.Indent = 2
	s, err := f.Marshal(obj)
	if err != nil {
		fmt.Fprint(v, w.content)
	} else {
		fmt.Fprint(v, string(s))
	}

	return nil
}
// Layout draws the widget in the gocui view
Layout draws the widget in the gocui view
// Layout draws the widget in the gocui view
func (w *ItemWidget) Layout(g *gocui.Gui) error {
	w.g = g
	v, err := g.SetView("itemWidget", w.x, w.y, w.x+w.w, w.y+w.h)
	if err != nil && err != gocui.ErrUnknownView {
		return err
	}
	v.Editable = true
	v.Wrap = true
	w.view = v
	v.Clear()
	if w.content == "" {
		return nil
	}
	if w.hideGuids {
		w.content = stripSecretVals(w.content)
	}
	var obj map[string]interface{}
	err = json.Unmarshal([]byte(w.content), &obj)
	if err != nil {
		eventing.SendStatusEvent(eventing.StatusEvent{
			InProgress: false,
			Failure:    true,
			Message:    "Failed to display as JSON: " + err.Error(),
			Timeout:    time.Duration(time.Second * 4),
		})
		fmt.Fprint(v, w.content)
		return nil
	}
	f := colorjson.NewFormatter()
	f.Indent = 2
	s, err := f.Marshal(obj)
	if err != nil {
		fmt.Fprint(v, w.content)
	} else {
		fmt.Fprint(v, string(s))
	}
	return nil
}
func ( w * ItemWidget ) Layout ( g * gocui . Gui ) error { w . g = g v , err := g . SetView ( " " , w . x , w . y , w . x + w . w , w . y + w . h ) if err != nil && err != gocui . ErrUnknownView { return err } v . Editable = true v . Wrap = true w . view = v v . Clear ( ) if w . content == " " { return nil } if w . hideGuids { w . content = stripSecretVals ( w . content ) } var obj map [ string ] interface { } err = json . Unmarshal ( [ ] byte ( w . content ) , & obj ) if err != nil { eventing . SendStatusEvent ( eventing . StatusEvent { InProgress : false , Failure : true , Message : " " + err . Error ( ) , Timeout : time . Duration ( time . Second * 4 ) , } ) fmt . Fprint ( v , w . content ) return nil } f := colorjson . NewFormatter ( ) f . Indent = 2 s , err := f . Marshal ( obj ) if err != nil { fmt . Fprint ( v , w . content ) } else { fmt . Fprint ( v , string ( s ) ) } return nil }
Layout draws the widget in the gocui view
Layout draws the widget in the gocui view