Repository: jesseduffield/lazygit
File: pkg/gui/types/context.go (Go)

Code before:
	// view renders differently only when the screen mode changes
	NEEDS_RERENDER_ON_WIDTH_CHANGE_WHEN_SCREEN_MODE_CHANGES
)

type IBaseContext interface {
	HasKeybindings
	ParentContexter

	GetKind() ContextKind
	GetViewName() string
	GetView() *gocui.View
	GetViewTrait() IViewTrait
	GetWindowName() string
	SetWindowName(string)
	GetKey() ContextKey
	IsFocusable() bool
	// if a context is transient, then it only appears via some keybinding on another
	// context. Until we add support for having multiple of the same context, no two
	// of the same transient context can appear at once meaning one might be 'stolen'
	// from another window.
	IsTransient() bool
	// this tells us if the view's bounds are determined by its window or if they're
	// determined independently.
	HasControlledBounds() bool

	// to what extend the view needs to be rerendered when its width changes
	NeedsRerenderOnWidthChange() NeedsRerenderOnWidthChangeLevel

	// returns the desired title for the view upon activation. If there is no desired title (returns empty string), then
	// no title will be set
	Title() string

	GetOptionsMap() map[string]string

	AddKeybindingsFn(KeybindingsFn)
	AddMouseKeybindingsFn(MouseKeybindingsFn)

	// This is a bit of a hack at the moment: we currently only set an onclick function so that
	// our list controller can come along and wrap it in a list-specific click handler.
	// We'll need to think of a better way to do this.
	AddOnClickFn(func() error)

	AddOnRenderToMainFn(func() error)
	AddOnFocusFn(func(OnFocusOpts) error)
	AddOnFocusLostFn(func(OnFocusLostOpts) error)
}

type Context interface {
	IBaseContext

	HandleFocus(opts OnFocusOpts) error

Review comment (suggestion):
```suggestion
	// to what extent the view needs to be rerendered when its width changes
```

Code after:
	// view renders differently only when the screen mode changes
	NEEDS_RERENDER_ON_WIDTH_CHANGE_WHEN_SCREEN_MODE_CHANGES
)

type IBaseContext interface {
	HasKeybindings
	ParentContexter

	GetKind() ContextKind
	GetViewName() string
	GetView() *gocui.View
	GetViewTrait() IViewTrait
	GetWindowName() string
	SetWindowName(string)
	GetKey() ContextKey
	IsFocusable() bool
	// if a context is transient, then it only appears via some keybinding on another
	// context. Until we add support for having multiple of the same context, no two
	// of the same transient context can appear at once meaning one might be 'stolen'
	// from another window.
	IsTransient() bool
	// this tells us if the view's bounds are determined by its window or if they're
	// determined independently.
	HasControlledBounds() bool

	// to what extent the view needs to be rerendered when its width changes
	NeedsRerenderOnWidthChange() NeedsRerenderOnWidthChangeLevel

	// true if the view needs to be rerendered when its height changes
	NeedsRerenderOnHeightChange() bool

	// returns the desired title for the view upon activation. If there is no desired title (returns empty string), then
	// no title will be set
	Title() string

	GetOptionsMap() map[string]string

	AddKeybindingsFn(KeybindingsFn)
	AddMouseKeybindingsFn(MouseKeybindingsFn)
	ClearAllBindingsFn()

	// This is a bit of a hack at the moment: we currently only set an onclick function so that
	// our list controller can come along and wrap it in a list-specific click handler.
	// We'll need to think of a better way to do this.
	AddOnClickFn(func() error)

	AddOnRenderToMainFn(func() error)
	AddOnFocusFn(func(OnFocusOpts) error)
	AddOnFocusLostFn(func(OnFocusLostOpts) error)
}