github.com/elves/elvish@v0.15.0/pkg/cli/util.go (about)

     1  package cli
     2  
     3  // GetCodeBuffer returns the code buffer of the main code area widget of the app.
     4  func GetCodeBuffer(a App) CodeBuffer {
     5  	return a.CodeArea().CopyState().Buffer
     6  }
     7  
     8  // SetCodeBuffer sets the code buffer of the main code area widget of the app.
     9  func SetCodeBuffer(a App, buf CodeBuffer) {
    10  	a.CodeArea().MutateState(func(s *CodeAreaState) {
    11  		s.Buffer = buf
    12  	})
    13  }
    14  
    15  // Addon gets the current addon widget of the app.
    16  func Addon(a App) Widget {
    17  	return a.CopyState().Addon
    18  }
    19  
    20  // SetAddon sets the addon widget of the app.
    21  func SetAddon(a App, addon Widget) {
    22  	a.MutateState(func(s *State) { s.Addon = addon })
    23  }