1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-07-30 03:23:08 +03:00

Bump gocui

In Gui.onWorker we only make the minimum possible change to get things to
compile after the API-breaking change of the gocui update; we'll make this
cleaner later in this branch.
This commit is contained in:
Stefan Haller
2024-04-18 10:05:52 +02:00
parent 8a77e51576
commit 9f8ae76189
19 changed files with 392 additions and 95 deletions

73
vendor/github.com/gdamore/encoding/CODE_OF_CONDUCT.md generated vendored Normal file
View File

@ -0,0 +1,73 @@
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as
contributors and maintainers pledge to making participation in our project and
our community a harassment-free experience for everyone, regardless of age, body
size, disability, ethnicity, gender identity and expression, level of experience,
nationality, personal appearance, race, religion, or sexual identity and
orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment
include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or
advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic
address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable
behavior and are expected to take appropriate and fair corrective action in
response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or
reject comments, commits, code, wiki edits, issues, and other contributions
that are not aligned to this Code of Conduct, or to ban temporarily or
permanently any contributor for other behaviors that they deem inappropriate,
threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces
when an individual is representing the project or its community. Examples of
representing a project or community include using an official project e-mail
address, posting via an official social media account, or acting as an appointed
representative at an online or offline event. Representation of a project may be
further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported by contacting the project team at garrett@damore.org. All
complaints will be reviewed and investigated and will result in a response that
is deemed necessary and appropriate to the circumstances. The project team is
obligated to maintain confidentiality with regard to the reporter of an incident.
Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good
faith may face temporary or permanent repercussions as determined by other
members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
[homepage]: https://www.contributor-covenant.org

View File

@ -1,10 +1,11 @@
## encoding
[![Linux Status](https://img.shields.io/travis/gdamore/encoding.svg?label=linux)](https://travis-ci.org/gdamore/encoding)
[![Windows Status](https://img.shields.io/appveyor/ci/gdamore/encoding.svg?label=windows)](https://ci.appveyor.com/project/gdamore/encoding)
[![Apache License](https://img.shields.io/badge/license-APACHE2-blue.svg)](https://github.com/gdamore/encoding/blob/master/LICENSE)
[![Linux](https://img.shields.io/github/actions/workflow/status/gdamore/encoding/linux.yml?branch=main&logoColor=grey&logo=linux&label=)](https://github.com/gdamore/encoding/actions/workflows/linux.yml)
[![Windows](https://img.shields.io/github/actions/workflow/status/gdamore/encoding/windows.yml?branch=main&logoColor=grey&logo=windows&label=)](https://github.com/gdamore/encoding/actions/workflows/windows.yml)
[![Apache License](https://img.shields.io/github/license/gdamore/encoding.svg?logoColor=silver&logo=opensourceinitiative&color=blue&label=)](https://github.com/gdamore/encoding/blob/master/LICENSE)
[![Coverage](https://img.shields.io/codecov/c/github/gdamore/encoding?logoColor=grey&logo=codecov&label=)](https://codecov.io/gh/gdamore/encoding)
[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)](https://godoc.org/github.com/gdamore/encoding)
[![Go Report Card](http://goreportcard.com/badge/gdamore/encoding)](http://goreportcard.com/report/gdamore/encoding)
Package encoding provides a number of encodings that are missing from the
standard Go [encoding]("https://godoc.org/golang.org/x/text/encoding") package.

12
vendor/github.com/gdamore/encoding/SECURITY.md generated vendored Normal file
View File

@ -0,0 +1,12 @@
# Security Policy
We take security very seriously in mangos, since you may be using it in
Internet-facing applications.
## Reporting a Vulnerability
To report a vulnerability, please contact us on our discord.
You may also send an email to garrett@damore.org, or info@staysail.tech.
We will keep the reporter updated on any status updates on a regular basis,
and will respond within two business days for any reported security issue.

View File

@ -1,4 +1,4 @@
// Copyright 2015 Garrett D'Amore
// Copyright 2024 Garrett D'Amore
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use file except in compliance with the License.
@ -52,7 +52,6 @@ const (
// direction takes about 100 nsec/op. (The larger cost for conversion
// from UTF-8 is most likely due to the need to convert the UTF-8 byte stream
// to a rune before conversion.
//
type Charmap struct {
transform.NopResetter
bytes map[rune]byte
@ -177,7 +176,7 @@ func (d *cmapEncoder) Transform(dst, src []byte, atEOF bool) (int, int, error) {
if r == utf8.RuneError && sz == 1 {
// If its inconclusive due to insufficient data in
// in the source, report it
if !atEOF && !utf8.FullRune(src[nsrc:]) {
if atEOF && !utf8.FullRune(src[nsrc:]) {
e = transform.ErrShortSrc
break
}

View File

@ -322,27 +322,6 @@ func (ei *escapeInterpreter) csiColor(param []string) (color Attribute, skip int
}
}
// splitFgBg splits foreground and background color according to ANSI sequence.
//
// num (number of segments in ansi) is used to determine if it's 256 mode or rgb mode (3 - 256-color, 5 - rgb-color)
func splitFgBg(params []string, num int) [][]string {
var out [][]string
var current []string
for _, p := range params {
if len(current) == num && (p == "48" || p == "38") {
out = append(out, current)
current = []string{}
}
current = append(current, p)
}
if len(current) > 0 {
out = append(out, current)
}
return out
}
func getFontEffect(f int) Attribute {
switch fontEffect(f) {
case bold:

View File

@ -172,6 +172,8 @@ type Gui struct {
NextSearchMatchKey interface{}
PrevSearchMatchKey interface{}
ErrorHandler func(error) error
screen tcell.Screen
suspendedMutex sync.Mutex
suspended bool
@ -661,7 +663,7 @@ func (g *Gui) updateAsyncAux(f func(*Gui) error, task Task) {
// consider itself 'busy` as it runs the code. Don't use for long-running
// background goroutines where you wouldn't want lazygit to be considered busy
// (i.e. when you wouldn't want a loader to be shown to the user)
func (g *Gui) OnWorker(f func(Task)) {
func (g *Gui) OnWorker(f func(Task) error) {
task := g.NewTask()
go func() {
g.onWorkerAux(f, task)
@ -669,7 +671,7 @@ func (g *Gui) OnWorker(f func(Task)) {
}()
}
func (g *Gui) onWorkerAux(f func(Task), task Task) {
func (g *Gui) onWorkerAux(f func(Task) error, task Task) {
panicking := true
defer func() {
if panicking && Screen != nil {
@ -677,9 +679,15 @@ func (g *Gui) onWorkerAux(f func(Task), task Task) {
}
}()
f(task)
err := f(task)
panicking = false
if err != nil {
g.Update(func(g *Gui) error {
return err
})
}
}
// A Manager is in charge of GUI's layout and can be used to build widgets.
@ -745,19 +753,27 @@ func (g *Gui) MainLoop() error {
}
}
func (g *Gui) handleError(err error) error {
if err != nil && !IsQuit(err) && g.ErrorHandler != nil {
return g.ErrorHandler(err)
}
return err
}
func (g *Gui) processEvent() error {
select {
case ev := <-g.gEvents:
task := g.NewTask()
defer func() { task.Done() }()
if err := g.handleEvent(&ev); err != nil {
if err := g.handleError(g.handleEvent(&ev)); err != nil {
return err
}
case ev := <-g.userEvents:
defer func() { ev.task.Done() }()
if err := ev.f(g); err != nil {
if err := g.handleError(ev.f(g)); err != nil {
return err
}
}
@ -777,11 +793,11 @@ func (g *Gui) processRemainingEvents() error {
for {
select {
case ev := <-g.gEvents:
if err := g.handleEvent(&ev); err != nil {
if err := g.handleError(g.handleEvent(&ev)); err != nil {
return err
}
case ev := <-g.userEvents:
err := ev.f(g)
err := g.handleError(ev.f(g))
ev.task.Done()
if err != nil {
return err
@ -815,17 +831,6 @@ func (g *Gui) onResize() {
// g.screen.Sync()
}
func (g *Gui) clear(fg, bg Attribute) (int, int) {
st := getTcellStyle(oldStyle{fg: fg, bg: bg, outputMode: g.outputMode})
w, h := Screen.Size()
for row := 0; row < h; row++ {
for col := 0; col < w; col++ {
Screen.SetContent(col, row, ' ', nil, st)
}
}
return w, h
}
// drawFrameEdges draws the horizontal and vertical edges of a view.
func (g *Gui) drawFrameEdges(v *View, fgColor, bgColor Attribute) error {
runeH, runeV := '─', '│'
@ -1397,7 +1402,7 @@ func (g *Gui) execKeybindings(v *View, ev *GocuiEvent) (matched bool, err error)
var matchingParentViewKb *keybinding
// if we're searching, and we've hit n/N/Esc, we ignore the default keybinding
if v != nil && v.IsSearching() && Modifier(ev.Mod) == ModNone {
if v != nil && v.IsSearching() && ev.Mod == ModNone {
if eventMatchesKey(ev, g.NextSearchMatchKey) {
return true, v.gotoNextMatch()
} else if eventMatchesKey(ev, g.PrevSearchMatchKey) {
@ -1417,7 +1422,7 @@ func (g *Gui) execKeybindings(v *View, ev *GocuiEvent) (matched bool, err error)
if kb.handler == nil {
continue
}
if !kb.matchKeypress(Key(ev.Key), ev.Ch, Modifier(ev.Mod)) {
if !kb.matchKeypress(ev.Key, ev.Ch, ev.Mod) {
continue
}
if g.matchView(v, kb) {
@ -1435,7 +1440,7 @@ func (g *Gui) execKeybindings(v *View, ev *GocuiEvent) (matched bool, err error)
}
if g.currentView != nil && g.currentView.Editable && g.currentView.Editor != nil {
matched := g.currentView.Editor.Edit(g.currentView, Key(ev.Key), ev.Ch, Modifier(ev.Mod))
matched := g.currentView.Editor.Edit(g.currentView, ev.Key, ev.Ch, ev.Mod)
if matched {
return true, nil
}
@ -1550,7 +1555,7 @@ func (g *Gui) matchView(v *View, kb *keybinding) bool {
if v == nil {
return false
}
if v.Editable == true && kb.ch != 0 {
if v.Editable && kb.ch != 0 {
return false
}
if kb.viewName != v.name {

View File

@ -46,16 +46,14 @@ func (g *Gui) getTermWindowSize() (int, int, error) {
return termw, termh, nil
}
select {
case signal := <-signalCh:
switch signal {
// when the terminal window size is changed
case syscall.SIGWINCH:
continue
// ctrl + c to cancel
case syscall.SIGINT:
return 0, 0, errors.New("stop to get term window size")
}
signal := <-signalCh
switch signal {
// when the terminal window size is changed
case syscall.SIGWINCH:
continue
// ctrl + c to cancel
case syscall.SIGINT:
return 0, 0, errors.New("stop to get term window size")
}
}
}

View File

@ -13,10 +13,12 @@ import (
"unsafe"
)
type wchar uint16
type short int16
type dword uint32
type word uint16
type (
wchar uint16
short int16
dword uint32
word uint16
)
type coord struct {
x short

View File

@ -105,7 +105,7 @@ func newKeybinding(viewname string, key Key, ch rune, mod Modifier, handler func
func eventMatchesKey(ev *GocuiEvent, key interface{}) bool {
// assuming ModNone for now
if Modifier(ev.Mod) != ModNone {
if ev.Mod != ModNone {
return false
}
@ -114,7 +114,7 @@ func eventMatchesKey(ev *GocuiEvent, key interface{}) bool {
return false
}
return k == Key(ev.Key) && ch == ev.Ch
return k == ev.Key && ch == ev.Ch
}
// matchKeypress returns if the keybinding matches the keypress.

View File

@ -767,7 +767,7 @@ func (v *View) writeString(s string) {
// parseInput parses char by char the input written to the View. It returns nil
// while processing ESC sequences. Otherwise, it returns a cell slice that
// contains the processed data.
func (v *View) parseInput(ch rune, x int, y int) (bool, []cell) {
func (v *View) parseInput(ch rune, x int, _ int) (bool, []cell) {
cells := []cell{}
moveCursor := true
@ -1283,7 +1283,7 @@ func (v *View) Word(x, y int) (string, error) {
} else {
nr = nr + x
}
return string(str[nl:nr]), nil
return str[nl:nr], nil
}
// indexFunc allows to split lines by words taking into account spaces