Repository: jesseduffield/lazygit
File: pkg/gui/controllers/confirmation_controller.go (Go)

Code before:
		},
		{
			Key:             opts.GetKey(opts.Config.Universal.Return),
			Handler:         func() error { return self.context().State.OnClose() },
			Description:     self.c.Tr.CloseCancel,
			DisplayOnScreen: true,
		},
		{
			Key: opts.GetKey(opts.Config.Universal.TogglePanel),
			Handler: func() error {
				if len(self.c.Contexts().Suggestions.State.Suggestions) > 0 {
					self.switchToSuggestions()
				}
				return nil
			},
		},
		{
			Key: opts.GetKey(opts.Config.Universal.CopyToClipboard),
			Handler: func() error {
				confirmationView := self.c.Views().Confirmation
				text := confirmationView.Buffer()
				if err := self.c.OS().CopyToClipboard(text); err != nil {
					return err
				}

				self.c.Toast(fmt.Sprintf("Window content %s", self.c.Tr.CopiedToClipboard))
				return nil
			},
			Description:     self.c.Tr.CopyToClipboardMenu,
			DisplayOnScreen: true,
		},
	}

	return bindings
}

func (self *ConfirmationController) GetMouseKeybindings(opts types.KeybindingsOpts) []*gocui.ViewMouseBinding {
	return []*gocui.ViewMouseBinding{
		{
			ViewName:    self.c.Contexts().Suggestions.GetViewName(),
			FocusedView: self.c.Contexts().Confirmation.GetViewName(),
			Key:         gocui.MouseLeft,
			Handler: func(gocui.ViewMouseBindingOpts) error {
				self.switchToSuggestions()
				// Let it fall through to the ListController's click handler so that
				// the clicked line gets selected:
				return gocui.ErrKeybindingNotHandled
			},
		},
	}
}

Review comment (suggestion):
This needs to be i18n'ed too. I added 79f1d7c187be to do this. We can't use the existing `Tr.CopiedToClipboard` text here, this is only for hashes or branch names etc., so we need to add a new text for this.

Code after:
		},
		{
			Key:             opts.GetKey(opts.Config.Universal.Return),
			Handler:         func() error { return self.context().State.OnClose() },
			Description:     self.c.Tr.CloseCancel,
			DisplayOnScreen: true,
		},
		{
			Key: opts.GetKey(opts.Config.Universal.TogglePanel),
			Handler: func() error {
				if len(self.c.Contexts().Suggestions.State.Suggestions) > 0 {
					self.switchToSuggestions()
				}
				return nil
			},
		},
		{
			Key:               opts.GetKey(opts.Config.Universal.CopyToClipboard),
			Handler:           self.handleCopyToClipboard,
			Description:       self.c.Tr.CopyToClipboardMenu,
			DisplayOnScreen:   true,
			GetDisabledReason: self.copyToClipboardEnabled,
		},
	}

	return bindings
}

func (self *ConfirmationController) GetMouseKeybindings(opts types.KeybindingsOpts) []*gocui.ViewMouseBinding {
	return []*gocui.ViewMouseBinding{
		{
			ViewName:    self.c.Contexts().Suggestions.GetViewName(),
			FocusedView: self.c.Contexts().Confirmation.GetViewName(),
			Key:         gocui.MouseLeft,
			Handler: func(gocui.ViewMouseBindingOpts) error {
				self.switchToSuggestions()
				// Let it fall through to the ListController's click handler so that
				// the clicked line gets selected:
				return gocui.ErrKeybindingNotHandled
			},
		},
	}
}

func (self *ConfirmationController) GetOnFocusLost() func(types.OnFocusLostOpts) {
	return func(types.OnFocusLostOpts) {
		self.c.Helpers().Confirmation.DeactivateConfirmationPrompt()
	}
}

func (self *ConfirmationController) Context() types.Context {