Compare commits

...

18 Commits
v0.33 ... v0.34

Author SHA1 Message Date
Ram Bhosale
7be25a105d allow skipping confirmation prompt after opening subprocess 2022-03-17 17:52:31 +11:00
Jesse Duffield
28c9d85141 fix tests 2022-03-16 20:52:49 +11:00
tiwood
f0d0d45ba7 refactor: 💡 Use new approach introduced via #1637
fix: 🐛 The root URI for Azure DevOps repositories contains _git

refactor so that we don't have conditional logic based on service definition

no need for this commend anymore

add comment

Fixed RegEx for HTTP remote git URL

Added Tests

pretty sure we can do this safely
2022-03-16 20:52:49 +11:00
Moritz Haase
08ee3309cb docs: Let 'Tag' badge in README.md link to Github 'Releases' page
Clicking the badge that shows the current tag (i.e. release) will now direct you
to the 'Releases' page.
2022-03-16 20:44:49 +11:00
Moritz Haase
7544d853fc docs: Remove 'GolangCI' badge from README.md
The service has apparently closed down some time ago.

See: https://medium.com/golangci/golangci-com-is-closing-d1fc1bd30e0e
2022-03-16 20:44:49 +11:00
Francisco Miamoto
ca8180e1b7 Use editFileAtLine method for line by line panel 2022-03-16 20:43:53 +11:00
Jesse Duffield
f53b10072d open code in existing window 2022-03-16 19:55:58 +11:00
Jesse Duffield
11acac0091 more explicit 2022-03-16 19:55:58 +11:00
Luka Markušić
866f4b9f0e Support line offset for most common editors by default 2022-03-16 19:55:58 +11:00
Jesse Duffield
f56988039a ignore current user language when generating cheatsheets 2022-03-16 19:46:11 +11:00
Akash Soedamah
7e6b43d13b Just spotted some small typos in NL translation
I'm learning the LazyGit keybindings right now
2022-03-16 19:46:11 +11:00
Daniel Kiss
f5a5b7f966 Add unstagedChangesColor config option 2022-03-16 19:21:39 +11:00
Moritz Haase
91dab7fef9 docs: Update 'VS Code launch configuration' in contribution guide
To simplify debugging via VS Code, add '--debug' argument to example launch
configuration. Also, reword the hint regarding the 'console' key slightly. It
has apparently been available for a long time in stable releases and is also
listed in the documentation. It is however, still marked as an experimental
feature, even in the current release v1.65.2.

See: https://code.visualstudio.com/updates/v1_5#_launch-debug-target-in-integrated-terminal
See: https://code.visualstudio.com/Docs/editor/debugging#_launchjson-attributes
2022-03-15 19:42:52 +11:00
Moritz Haase
75e654634f docs: Update link to GoDoc in README.md to use HTTPS instead of HTTP 2022-03-15 19:42:23 +11:00
Moritz Haase
c9f1a40ffa docs: Minor formatting fixes for README.md
Running 'mdformat' on README.md adds and removes a few line breaks to improve
readability. Also, '$' doesn't need to be escaped.
2022-03-15 19:42:23 +11:00
Moritz Haase
eb182abf48 docs: Fix typos in README.md 2022-03-15 19:42:23 +11:00
MATSUDA Takashi
2c7c99522b chore: go mod vendor 2022-03-15 13:31:11 +11:00
MATSUDA Takashi
a9fa3b2af1 chore: go get github.com/gdamore/tcell/v2@2a1a1b58 2022-03-15 13:31:11 +11:00
35 changed files with 440 additions and 282 deletions

View File

@@ -64,7 +64,7 @@ If you find that the existing logs are too noisy, you can set the log level with
If you keep having to do some setup steps to reproduce an issue, read the Testing section below to see how to create an integration test by recording a lazygit session. It's pretty easy!
If you want to trigger a debug session from VSCode, you can use the following snippet. Note that the 'console' key is not, at the time of writing, in a stable release.
If you want to trigger a debug session from VSCode, you can use the following snippet. Note that the `console` key is, at the time of writing, still an experimental feature.
```jsonc
// .vscode/launch.json
@@ -77,6 +77,9 @@ If you want to trigger a debug session from VSCode, you can use the following sn
"request": "launch",
"mode": "auto",
"program": "main.go",
"args": [
"--debug"
],
"console": "externalTerminal" // <-- you need this to actually see the lazygit UI in a window while debugging
}
]

View File

@@ -2,10 +2,7 @@
<img src="https://i.imgur.com/oYB7Cj8.png">
</p>
![CI](https://github.com/jesseduffield/lazygit/workflows/Continuous%20Integration/badge.svg) [![Go Report Card](https://goreportcard.com/badge/github.com/jesseduffield/lazygit)](https://goreportcard.com/report/github.com/jesseduffield/lazygit) [![GolangCI](https://golangci.com/badges/github.com/jesseduffield/lazygit.svg)](https://golangci.com) [![GoDoc](https://godoc.org/github.com/jesseduffield/lazygit?status.svg)](http://godoc.org/github.com/jesseduffield/lazygit) [![GitHub tag](https://img.shields.io/github/tag/jesseduffield/lazygit.svg)]() [![TODOs](https://badgen.net/https/api.tickgit.com/badgen/github.com/jesseduffield/lazygit)](https://www.tickgit.com/browse?repo=github.com/jesseduffield/lazygit)
![CI](https://github.com/jesseduffield/lazygit/workflows/Continuous%20Integration/badge.svg) [![Go Report Card](https://goreportcard.com/badge/github.com/jesseduffield/lazygit)](https://goreportcard.com/report/github.com/jesseduffield/lazygit) [![GoDoc](https://godoc.org/github.com/jesseduffield/lazygit?status.svg)](https://godoc.org/github.com/jesseduffield/lazygit) [![GitHub tag](https://img.shields.io/github/tag/jesseduffield/lazygit.svg)](https://github.com/jesseduffield/lazygit/releases) [![TODOs](https://badgen.net/https/api.tickgit.com/badgen/github.com/jesseduffield/lazygit)](https://www.tickgit.com/browse?repo=github.com/jesseduffield/lazygit)
A simple terminal UI for git commands, written in Go with the [gocui](https://github.com/jroimartin/gocui "gocui") library.
@@ -157,7 +154,6 @@ sudo emerge dev-vcs/lazygit
pkg install lazygit
```
### Conda
Released versions are available for different platforms, see <https://anaconda.org/conda-forge/lazygit>
@@ -174,9 +170,9 @@ go install github.com/jesseduffield/lazygit@latest
Please note:
If you get an error claiming that lazygit cannot be found or is not defined, you
may need to add `~/go/bin` to your \$PATH (MacOS/Linux), or `%HOME%\go\bin`
(Windows). Not to be mistaked for `C:\Go\bin` (which is for Go's own binaries,
not apps like Lazygit).
may need to add `~/go/bin` to your $PATH (MacOS/Linux), or `%HOME%\go\bin`
(Windows). Not to be mistaken for `C:\Go\bin` (which is for Go's own binaries,
not apps like lazygit).
### Chocolatey (Windows)
@@ -232,7 +228,7 @@ lg()
}
```
Then `source ~/.zshrc` and from now on when you call `lg` and exit you'll switch directories to whatever you were in inside lazyigt. To override this behaviour you can exit using `shift+Q` rather than just `q`.
Then `source ~/.zshrc` and from now on when you call `lg` and exit you'll switch directories to whatever you were in inside lazygit. To override this behaviour you can exit using `shift+Q` rather than just `q`.
### Undo/Redo
@@ -258,7 +254,6 @@ See the [docs](docs/Custom_Command_Keybindings.md)
- [Rebase Magic Video Tutorial](https://youtu.be/4XaToVut_hs)
- [Twitch Stream](https://www.twitch.tv/jesseduffield)
## Cool features
- Adding files easily
@@ -284,6 +279,7 @@ For contributor discussion about things not better discussed here in the repo, j
[![Slack](../assets/slack_rgb.png)](https://join.slack.com/t/lazygit/shared_invite/zt-5bo2clzo-hB8ZTVN5dWUCqj5QFiQVLA)
### Debugging Locally
Run `lazygit --debug` in one terminal tab and `lazygit --logs` in another to view the program and its log output side by side
## Donate
@@ -293,6 +289,7 @@ If you would like to support the development of lazygit, consider [sponsoring me
## FAQ
### I'm struggling to see the selected line
see [here](https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md#struggling-to-see-selected-line)
## Social

View File

@@ -40,6 +40,8 @@ gui:
- blue
cherryPickedCommitFgColor:
- cyan
unstagedChangesColor:
- red
commitLength:
show: true
mouseEvents: true
@@ -93,6 +95,7 @@ confirmOnQuit: false
quitOnTopLevelReturn: false
disableStartupPopups: false
notARepository: 'prompt' # one of: 'prompt' | 'create' | 'skip'
promptToReturnFromSubprocess: true # display confirmation when subprocess terminates
keybinding:
universal:
quit: 'q'

View File

@@ -18,7 +18,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
<kbd>ctrl+z</kbd>: redo (via reflog) (experimenteel)
<kbd>+</kbd>: volgende scherm modus (normaal/half/groot)
<kbd>_</kbd>: vorige scherm modus
<kbd>:</kbd>: voor aangepaste commando uit
<kbd>:</kbd>: voer aangepaste commando uit
<kbd>ctrl+s</kbd>: bekijk scoping opties
<kbd>W</kbd>: open diff menu
<kbd>ctrl+e</kbd>: open diff menu
@@ -63,7 +63,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
## Branches Paneel (Remote Branches (in Remotes tabblad))
<pre>
<kbd>esc</kbd>: Ga terug naar remotes lijst
<kbd>esc</kbd>: ga terug naar remotes lijst
<kbd>g</kbd>: bekijk reset opties
<kbd>enter</kbd>: bekijk commits
<kbd>space</kbd>: uitchecken
@@ -179,7 +179,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
## Bestanden Paneel (Bestanden)
<pre>
<kbd>c</kbd>: Commit veranderingen
<kbd>c</kbd>: commit veranderingen
<kbd>w</kbd>: commit veranderingen zonder pre-commit hook
<kbd>A</kbd>: wijzig laatste commit
<kbd>C</kbd>: commit veranderingen met de git editor
@@ -276,7 +276,7 @@ _This file is auto-generated. To update, make the changes in the pkg/i18n direct
<kbd>a</kbd>: toggle selecteer hunk
<kbd>H</kbd>: scroll left
<kbd>L</kbd>: scroll right
<kbd>c</kbd>: Commit veranderingen
<kbd>c</kbd>: commit veranderingen
<kbd>w</kbd>: commit veranderingen zonder pre-commit hook
<kbd>C</kbd>: commit veranderingen met de git editor
</pre>

4
go.mod
View File

@@ -11,10 +11,10 @@ require (
github.com/creack/pty v1.1.11
github.com/fatih/color v1.9.0 // indirect
github.com/fsnotify/fsnotify v1.4.7
github.com/gdamore/tcell/v2 v2.4.1-0.20210926162909-66f061b1fc9b // indirect
github.com/gdamore/tcell/v2 v2.4.1-0.20220313203054-2a1a1b586447 // indirect
github.com/go-errors/errors v1.4.1
github.com/go-logfmt/logfmt v0.5.0 // indirect
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 // indirect
github.com/golang/protobuf v1.3.2 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/gookit/color v1.4.2

3
go.sum
View File

@@ -37,6 +37,8 @@ github.com/gdamore/tcell/v2 v2.4.0 h1:W6dxJEmaxYvhICFoTY3WrLLEXsQ11SaFnKGVEXW57K
github.com/gdamore/tcell/v2 v2.4.0/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
github.com/gdamore/tcell/v2 v2.4.1-0.20210926162909-66f061b1fc9b h1:eoaSI4eEwM5eTx/HvmRSwmicxuMhL73AyoEfM1oCJLc=
github.com/gdamore/tcell/v2 v2.4.1-0.20210926162909-66f061b1fc9b/go.mod h1:ZPwXnysybtQqdqKcWMWXux9aGdtMHe+kr+cwEZEe+A4=
github.com/gdamore/tcell/v2 v2.4.1-0.20220313203054-2a1a1b586447 h1:4idf9699cuWAc7ZIB+2RzuDWU30oRkB0X/FZTUlWOVY=
github.com/gdamore/tcell/v2 v2.4.1-0.20220313203054-2a1a1b586447/go.mod h1:I8YJFI9gzgl4dHi9UlRDZosCW+jYkDA37AXmXvL51w4=
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
github.com/go-errors/errors v1.0.2/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs=
@@ -184,6 +186,7 @@ golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211113001501-0c823b97ae02/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM=
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=

View File

@@ -35,13 +35,11 @@ func GetDir() string {
}
func generateAtDir(cheatsheetDir string) {
os.Setenv("LANG", "en")
translationSetsByLang := i18n.GetTranslationSets()
mConfig := config.NewDummyAppConfig()
for lang := range translationSetsByLang {
os.Setenv("LC_ALL", lang)
mConfig.GetUserConfig().Gui.Language = lang
mApp, _ := app.NewApp(mConfig, "")
path := cheatsheetDir + "/Keybindings_" + lang + ".md"
file, err := os.Create(path)

View File

@@ -5,6 +5,7 @@ import (
"strconv"
"github.com/go-errors/errors"
"github.com/jesseduffield/lazygit/pkg/config"
"github.com/jesseduffield/lazygit/pkg/utils"
)
@@ -58,5 +59,15 @@ func (self *FileCommands) GetEditCmdStr(filename string, lineNumber int) (string
}
editCmdTemplate := self.UserConfig.OS.EditCommandTemplate
if editCmdTemplate == config.DefaultEditCommandTemplate {
switch editor {
case "emacs", "nano", "vi", "vim":
editCmdTemplate = "{{editor}} +{{line}} {{filename}}"
case "subl":
editCmdTemplate = "{{editor}} {{filename}}:{{line}}"
case "code":
editCmdTemplate = "{{editor}} -r --goto {{filename}}:{{line}}"
}
}
return utils.ResolvePlaceholderString(editCmdTemplate, templateValues), nil
}

View File

@@ -47,7 +47,7 @@ func TestEditFileCmdStr(t *testing.T) {
gitConfigMockResponses: nil,
test: func(cmdStr string, err error) {
assert.NoError(t, err)
assert.Equal(t, `nano "test"`, cmdStr)
assert.Equal(t, `nano +1 "test"`, cmdStr)
},
},
{
@@ -61,7 +61,7 @@ func TestEditFileCmdStr(t *testing.T) {
gitConfigMockResponses: map[string]string{"core.editor": "nano"},
test: func(cmdStr string, err error) {
assert.NoError(t, err)
assert.Equal(t, `nano "test"`, cmdStr)
assert.Equal(t, `nano +1 "test"`, cmdStr)
},
},
{
@@ -79,6 +79,7 @@ func TestEditFileCmdStr(t *testing.T) {
gitConfigMockResponses: nil,
test: func(cmdStr string, err error) {
assert.NoError(t, err)
assert.Equal(t, `nano +1 "test"`, cmdStr)
},
},
{
@@ -96,7 +97,7 @@ func TestEditFileCmdStr(t *testing.T) {
gitConfigMockResponses: nil,
test: func(cmdStr string, err error) {
assert.NoError(t, err)
assert.Equal(t, `emacs "test"`, cmdStr)
assert.Equal(t, `emacs +1 "test"`, cmdStr)
},
},
{
@@ -111,7 +112,7 @@ func TestEditFileCmdStr(t *testing.T) {
gitConfigMockResponses: nil,
test: func(cmdStr string, err error) {
assert.NoError(t, err)
assert.Equal(t, `vi "test"`, cmdStr)
assert.Equal(t, `vi +1 "test"`, cmdStr)
},
},
{
@@ -126,7 +127,7 @@ func TestEditFileCmdStr(t *testing.T) {
gitConfigMockResponses: nil,
test: func(cmdStr string, err error) {
assert.NoError(t, err)
assert.Equal(t, `vi "file/with space"`, cmdStr)
assert.Equal(t, `vi +1 "file/with space"`, cmdStr)
},
},
{

View File

@@ -6,6 +6,7 @@ var defaultUrlRegexStrings = []string{
`^(?:https?|ssh)://.*/(?P<owner>.*)/(?P<repo>.*?)(?:\.git)?$`,
`^git@.*:(?P<owner>.*)/(?P<repo>.*?)(?:\.git)?$`,
}
var defaultRepoURLTemplate = "https://{{.webDomain}}/{{.owner}}/{{.repo}}"
// we've got less type safety using go templates but this lends itself better to
// users adding custom service definitions in their config
@@ -15,6 +16,7 @@ var githubServiceDef = ServiceDefinition{
pullRequestURLIntoTargetBranch: "/compare/{{.To}}...{{.From}}?expand=1",
commitURL: "/commit/{{.CommitSha}}",
regexStrings: defaultUrlRegexStrings,
repoURLTemplate: defaultRepoURLTemplate,
}
var bitbucketServiceDef = ServiceDefinition{
@@ -23,6 +25,7 @@ var bitbucketServiceDef = ServiceDefinition{
pullRequestURLIntoTargetBranch: "/pull-requests/new?source={{.From}}&dest={{.To}}&t=1",
commitURL: "/commits/{{.CommitSha}}",
regexStrings: defaultUrlRegexStrings,
repoURLTemplate: defaultRepoURLTemplate,
}
var gitLabServiceDef = ServiceDefinition{
@@ -31,9 +34,27 @@ var gitLabServiceDef = ServiceDefinition{
pullRequestURLIntoTargetBranch: "/merge_requests/new?merge_request[source_branch]={{.From}}&merge_request[target_branch]={{.To}}",
commitURL: "/commit/{{.CommitSha}}",
regexStrings: defaultUrlRegexStrings,
repoURLTemplate: defaultRepoURLTemplate,
}
var serviceDefinitions = []ServiceDefinition{githubServiceDef, bitbucketServiceDef, gitLabServiceDef}
var azdoServiceDef = ServiceDefinition{
provider: "azuredevops",
pullRequestURLIntoDefaultBranch: "/pullrequestcreate?sourceRef={{.From}}",
pullRequestURLIntoTargetBranch: "/pullrequestcreate?sourceRef={{.From}}&targetRef={{.To}}",
commitURL: "/commit/{{.CommitSha}}",
regexStrings: []string{
`^git@ssh.dev.azure.com.*/(?P<org>.*)/(?P<project>.*)/(?P<repo>.*?)(?:\.git)?$`,
`^https://.*@dev.azure.com/(?P<org>.*?)/(?P<project>.*?)/_git/(?P<repo>.*?)(?:\.git)?$`,
},
repoURLTemplate: "https://{{.webDomain}}/{{.org}}/{{.project}}/_git/{{.repo}}",
}
var serviceDefinitions = []ServiceDefinition{
githubServiceDef,
bitbucketServiceDef,
gitLabServiceDef,
azdoServiceDef,
}
var defaultServiceDomains = []ServiceDomain{
{
@@ -51,4 +72,9 @@ var defaultServiceDomains = []ServiceDomain{
gitDomain: "gitlab.com",
webDomain: "gitlab.com",
},
{
serviceDefinition: azdoServiceDef,
gitDomain: "dev.azure.com",
webDomain: "dev.azure.com",
},
}

View File

@@ -1,7 +1,6 @@
package hosting_service
import (
"fmt"
"net/url"
"regexp"
"strings"
@@ -66,13 +65,13 @@ func (self *HostingServiceMgr) getService() (*Service, error) {
return nil, err
}
root, err := serviceDomain.getRootFromRemoteURL(self.remoteURL)
repoURL, err := serviceDomain.serviceDefinition.getRepoURLFromRemoteURL(self.remoteURL, serviceDomain.webDomain)
if err != nil {
return nil, err
}
return &Service{
root: root,
repoURL: repoURL,
ServiceDefinition: serviceDomain.serviceDefinition,
}, nil
}
@@ -139,47 +138,32 @@ type ServiceDomain struct {
serviceDefinition ServiceDefinition
}
func (self ServiceDomain) getRootFromRemoteURL(repoURL string) (string, error) {
// we may want to make this more specific to the service in future e.g. if
// some new service comes along which has a different root url structure.
repoInfo, err := self.serviceDefinition.getRepoInfoFromURL(repoURL)
if err != nil {
return "", err
}
return fmt.Sprintf("https://%s/%s/%s", self.webDomain, repoInfo.Owner, repoInfo.Repository), nil
}
// RepoInformation holds some basic information about the repo
type RepoInformation struct {
Owner string
Repository string
}
type ServiceDefinition struct {
provider string
pullRequestURLIntoDefaultBranch string
pullRequestURLIntoTargetBranch string
commitURL string
regexStrings []string
// can expect 'webdomain' to be passed in. Otherwise, you get to pick what we match in the regex
repoURLTemplate string
}
func (self ServiceDefinition) getRepoInfoFromURL(url string) (*RepoInformation, error) {
func (self ServiceDefinition) getRepoURLFromRemoteURL(url string, webDomain string) (string, error) {
for _, regexStr := range self.regexStrings {
re := regexp.MustCompile(regexStr)
matches := utils.FindNamedMatches(re, url)
if matches != nil {
return &RepoInformation{
Owner: matches["owner"],
Repository: matches["repo"],
}, nil
input := utils.FindNamedMatches(re, url)
if input != nil {
input["webDomain"] = webDomain
return utils.ResolvePlaceholderString(self.repoURLTemplate, input), nil
}
}
return nil, errors.New("Failed to parse repo information from url")
return "", errors.New("Failed to parse repo information from url")
}
type Service struct {
root string
repoURL string
ServiceDefinition
}
@@ -196,5 +180,5 @@ func (self *Service) getCommitURL(commitSha string) string {
}
func (self *Service) resolveUrl(templateString string, args map[string]string) string {
return self.root + utils.ResolvePlaceholderString(templateString, args)
return self.repoURL + utils.ResolvePlaceholderString(templateString, args)
}

View File

@@ -8,63 +8,6 @@ import (
"github.com/stretchr/testify/assert"
)
func TestGetRepoInfoFromURL(t *testing.T) {
type scenario struct {
serviceDefinition ServiceDefinition
testName string
repoURL string
test func(*RepoInformation)
}
scenarios := []scenario{
{
githubServiceDef,
"Returns repository information for git remote url",
"git@github.com:petersmith/super_calculator",
func(repoInfo *RepoInformation) {
assert.EqualValues(t, repoInfo.Owner, "petersmith")
assert.EqualValues(t, repoInfo.Repository, "super_calculator")
},
},
{
githubServiceDef,
"Returns repository information for git remote url, trimming trailing '.git'",
"git@github.com:petersmith/super_calculator.git",
func(repoInfo *RepoInformation) {
assert.EqualValues(t, repoInfo.Owner, "petersmith")
assert.EqualValues(t, repoInfo.Repository, "super_calculator")
},
},
{
githubServiceDef,
"Returns repository information for ssh remote url",
"ssh://git@github.com/petersmith/super_calculator",
func(repoInfo *RepoInformation) {
assert.EqualValues(t, repoInfo.Owner, "petersmith")
assert.EqualValues(t, repoInfo.Repository, "super_calculator")
},
},
{
githubServiceDef,
"Returns repository information for http remote url",
"https://my_username@bitbucket.org/johndoe/social_network.git",
func(repoInfo *RepoInformation) {
assert.EqualValues(t, repoInfo.Owner, "johndoe")
assert.EqualValues(t, repoInfo.Repository, "social_network")
},
},
}
for _, s := range scenarios {
s := s
t.Run(s.testName, func(t *testing.T) {
result, err := s.serviceDefinition.getRepoInfoFromURL(s.repoURL)
assert.NoError(t, err)
s.test(result)
})
}
}
func TestGetPullRequestURL(t *testing.T) {
type scenario struct {
testName string
@@ -172,6 +115,44 @@ func TestGetPullRequestURL(t *testing.T) {
assert.Equal(t, "https://gitlab.com/peter/public/calculator/merge_requests/new?merge_request[source_branch]=feature%2Fcommit-ui&merge_request[target_branch]=epic%2Fui", url)
},
},
{
testName: "Opens a link to new pull request on Azure DevOps (SSH)",
from: "feature/new",
remoteUrl: "git@ssh.dev.azure.com:v3/myorg/myproject/myrepo",
test: func(url string, err error) {
assert.NoError(t, err)
assert.Equal(t, "https://dev.azure.com/myorg/myproject/_git/myrepo/pullrequestcreate?sourceRef=feature%2Fnew", url)
},
},
{
testName: "Opens a link to new pull request on Azure DevOps (SSH) with specifc target",
from: "feature/new",
to: "dev",
remoteUrl: "git@ssh.dev.azure.com:v3/myorg/myproject/myrepo",
test: func(url string, err error) {
assert.NoError(t, err)
assert.Equal(t, "https://dev.azure.com/myorg/myproject/_git/myrepo/pullrequestcreate?sourceRef=feature%2Fnew&targetRef=dev", url)
},
},
{
testName: "Opens a link to new pull request on Azure DevOps (HTTP)",
from: "feature/new",
remoteUrl: "https://myorg@dev.azure.com/myorg/myproject/_git/myrepo",
test: func(url string, err error) {
assert.NoError(t, err)
assert.Equal(t, "https://dev.azure.com/myorg/myproject/_git/myrepo/pullrequestcreate?sourceRef=feature%2Fnew", url)
},
},
{
testName: "Opens a link to new pull request on Azure DevOps (HTTP) with specifc target",
from: "feature/new",
to: "dev",
remoteUrl: "https://myorg@dev.azure.com/myorg/myproject/_git/myrepo",
test: func(url string, err error) {
assert.NoError(t, err)
assert.Equal(t, "https://dev.azure.com/myorg/myproject/_git/myrepo/pullrequestcreate?sourceRef=feature%2Fnew&targetRef=dev", url)
},
},
{
testName: "Throws an error if git service is unsupported",
from: "feature/divide-operation",
@@ -218,7 +199,7 @@ func TestGetPullRequestURL(t *testing.T) {
assert.NoError(t, err)
assert.Equal(t, "https://bitbucket.org/johndoe/social_network/pull-requests/new?source=feature%2Fprofile-page&t=1", url)
},
expectedLoggedErrors: []string{"Unknown git service type: 'noservice'. Expected one of github, bitbucket, gitlab"},
expectedLoggedErrors: []string{"Unknown git service type: 'noservice'. Expected one of github, bitbucket, gitlab, azuredevops"},
},
{
testName: "Escapes reserved URL characters in from branch name",

View File

@@ -3,11 +3,13 @@
package config
const DefaultEditCommandTemplate = `{{editor}} {{filename}}`
// GetPlatformDefaultConfig gets the defaults for the platform
func GetPlatformDefaultConfig() OSConfig {
return OSConfig{
EditCommand: ``,
EditCommandTemplate: `{{editor}} {{filename}}`,
EditCommandTemplate: DefaultEditCommandTemplate,
OpenCommand: "open {{filename}}",
OpenLinkCommand: "open {{link}}",
}

View File

@@ -1,10 +1,12 @@
package config
const DefaultEditCommandTemplate = `{{editor}} {{filename}}`
// GetPlatformDefaultConfig gets the defaults for the platform
func GetPlatformDefaultConfig() OSConfig {
return OSConfig{
EditCommand: ``,
EditCommandTemplate: `{{editor}} {{filename}}`,
EditCommandTemplate: DefaultEditCommandTemplate,
OpenCommand: `xdg-open {{filename}} >/dev/null`,
OpenLinkCommand: `xdg-open {{link}} >/dev/null`,
}

View File

@@ -1,10 +1,12 @@
package config
const DefaultEditCommandTemplate = `{{editor}} {{filename}}`
// GetPlatformDefaultConfig gets the defaults for the platform
func GetPlatformDefaultConfig() OSConfig {
return OSConfig{
EditCommand: ``,
EditCommandTemplate: `{{editor}} {{filename}}`,
EditCommandTemplate: DefaultEditCommandTemplate,
OpenCommand: `start "" {{filename}}`,
OpenLinkCommand: `start "" {{link}}`,
}

View File

@@ -11,11 +11,12 @@ type UserConfig struct {
QuitOnTopLevelReturn bool `yaml:"quitOnTopLevelReturn"`
Keybinding KeybindingConfig `yaml:"keybinding"`
// OS determines what defaults are set for opening files and links
OS OSConfig `yaml:"os,omitempty"`
DisableStartupPopups bool `yaml:"disableStartupPopups"`
CustomCommands []CustomCommand `yaml:"customCommands"`
Services map[string]string `yaml:"services"`
NotARepository string `yaml:"notARepository"`
OS OSConfig `yaml:"os,omitempty"`
DisableStartupPopups bool `yaml:"disableStartupPopups"`
CustomCommands []CustomCommand `yaml:"customCommands"`
Services map[string]string `yaml:"services"`
NotARepository string `yaml:"notARepository"`
PromptToReturnFromSubprocess bool `yaml:"promptToReturnFromSubprocess"`
}
type RefresherConfig struct {
@@ -54,6 +55,7 @@ type ThemeConfig struct {
SelectedRangeBgColor []string `yaml:"selectedRangeBgColor"`
CherryPickedCommitBgColor []string `yaml:"cherryPickedCommitBgColor"`
CherryPickedCommitFgColor []string `yaml:"cherryPickedCommitFgColor"`
UnstagedChangesColor []string `yaml:"unstagedChangesColor"`
}
type CommitLengthConfig struct {
@@ -342,6 +344,7 @@ func GetDefaultConfig() *UserConfig {
SelectedRangeBgColor: []string{"blue"},
CherryPickedCommitBgColor: []string{"blue"},
CherryPickedCommitFgColor: []string{"cyan"},
UnstagedChangesColor: []string{"red"},
},
CommitLength: CommitLengthConfig{Show: true},
SkipNoStagedFilesWarning: false,
@@ -533,10 +536,11 @@ func GetDefaultConfig() *UserConfig {
BulkMenu: "b",
},
},
OS: GetPlatformDefaultConfig(),
DisableStartupPopups: false,
CustomCommands: []CustomCommand(nil),
Services: map[string]string(nil),
NotARepository: "prompt",
OS: GetPlatformDefaultConfig(),
DisableStartupPopups: false,
CustomCommands: []CustomCommand(nil),
Services: map[string]string(nil),
NotARepository: "prompt",
PromptToReturnFromSubprocess: true,
}
}

View File

@@ -675,8 +675,10 @@ func (gui *Gui) runSubprocess(cmdObj oscommands.ICmdObj) error { //nolint:unpara
subprocess.Stderr = ioutil.Discard
subprocess.Stdin = nil
fmt.Fprintf(os.Stdout, "\n%s\n", style.FgGreen.Sprint(gui.Tr.PressEnterToReturn))
fmt.Scanln() // wait for enter press
if gui.Config.GetUserConfig().PromptToReturnFromSubprocess {
fmt.Fprintf(os.Stdout, "\n%s", style.FgGreen.Sprint(gui.Tr.PressEnterToReturn))
fmt.Scanln() // wait for enter press
}
return err
}

View File

@@ -1,8 +1,6 @@
package gui
import (
"fmt"
"github.com/go-errors/errors"
"github.com/jesseduffield/lazygit/pkg/commands/patch"
"github.com/jesseduffield/lazygit/pkg/gui/lbl"
@@ -217,8 +215,7 @@ func (gui *Gui) handleOpenFileAtLine() error {
// need to look at current index, then work out what my hunk's header information is, and see how far my line is away from the hunk header
lineNumber := state.CurrentLineNumber()
filenameWithLineNum := fmt.Sprintf("%s:%d", filename, lineNumber)
if err := gui.OSCommand.OpenFile(filenameWithLineNum); err != nil {
if err := gui.editFileAtLine(filename, lineNumber); err != nil {
return err
}

View File

@@ -129,7 +129,7 @@ func getFileLine(hasUnstagedChanges bool, hasStagedChanges bool, name string, di
} else if file == nil && hasStagedChanges && hasUnstagedChanges {
restColor = partiallyModifiedColor
} else if hasUnstagedChanges {
restColor = style.FgRed
restColor = theme.UnstagedChangesColor
}
output := ""
@@ -138,13 +138,13 @@ func getFileLine(hasUnstagedChanges bool, hasStagedChanges bool, name string, di
firstChar := file.ShortStatus[0:1]
firstCharCl := style.FgGreen
if firstChar == "?" {
firstCharCl = style.FgRed
firstCharCl = theme.UnstagedChangesColor
} else if firstChar == " " {
firstCharCl = restColor
}
secondChar := file.ShortStatus[1:2]
secondCharCl := style.FgRed
secondCharCl := theme.UnstagedChangesColor
if secondChar == " " {
secondCharCl = restColor
}
@@ -193,7 +193,7 @@ func getColorForChangeStatus(changeStatus string) style.TextStyle {
case "M", "R":
return style.FgYellow
case "D":
return style.FgRed
return theme.UnstagedChangesColor
case "C":
return style.FgCyan
case "T":

View File

@@ -18,7 +18,7 @@ func dutchTranslationSet() TranslationSet {
CredentialsPassword: "Wachtwoord",
CredentialsPassphrase: "Voer een wachtwoordzin in voor de SSH-sleutel",
PassUnameWrong: "Wachtwoord en/of gebruikersnaam verkeerd",
CommitChanges: "Commit veranderingen",
CommitChanges: "commit veranderingen",
AmendLastCommit: "wijzig laatste commit",
SureToAmend: "Weet je zeker dat je de laatste commit wilt wijzigen? U kunt het commit-bericht wijzigen vanuit het commits-paneel.",
NoCommitToAmend: "Er is geen commits om te wijzigen.",
@@ -241,7 +241,7 @@ func dutchTranslationSet() TranslationSet {
SureSquashAboveCommits: `Weet je zeker dat je alles wil squash/fixup! voor de bovenstaand commits {{.commit}}?`,
CreateFixupCommit: `Creëer fixup commit`,
SureCreateFixupCommit: `Weet je zeker dat je een fixup wil maken! commit voor commit {{.commit}}?`,
LcExecuteCustomCommand: "voor aangepaste commando uit",
LcExecuteCustomCommand: "voer aangepaste commando uit",
CustomCommand: "Aangepaste commando:",
LcCommitChangesWithoutHook: "commit veranderingen zonder pre-commit hook",
SkipHookPrefixNotConfigured: "Je hebt nog niet een commit bericht voorvoegsel ingesteld voor het overslaan van hooks. Set `git.skipHookPrefix = 'WIP'` in je config",
@@ -263,7 +263,7 @@ func dutchTranslationSet() TranslationSet {
LcEnterFile: "enter bestand om geselecteerde regels toe te voegen aan de patch",
ExitLineByLineMode: `sluit lijn-bij-lijn modus`,
EnterUpstream: `Enter upstream als '<remote> <branchnaam>'`,
ReturnToRemotesList: `Ga terug naar remotes lijst`,
ReturnToRemotesList: `ga terug naar remotes lijst`,
LcAddNewRemote: `voeg een nieuwe remote toe`,
LcNewRemoteName: `Nieuwe remote name:`,
LcNewRemoteUrl: `Nieuwe remote url:`,

View File

@@ -39,6 +39,8 @@ var (
OptionsFgColor = style.New()
DiffTerminalColor = style.FgMagenta
UnstagedChangesColor = style.New()
)
// UpdateTheme updates all theme variables
@@ -52,6 +54,9 @@ func UpdateTheme(themeConfig config.ThemeConfig) {
cherryPickedCommitFgTextStyle := GetTextStyle(themeConfig.CherryPickedCommitFgColor, false)
CherryPickedCommitTextStyle = cherryPickedCommitBgTextStyle.MergeStyle(cherryPickedCommitFgTextStyle)
unstagedChangesTextStyle := GetTextStyle(themeConfig.UnstagedChangesColor, false)
UnstagedChangesColor = unstagedChangesTextStyle
GocuiSelectedLineBgColor = GetGocuiStyle(themeConfig.SelectedLineBgColor)
OptionsColor = GetGocuiStyle(themeConfig.OptionsTextColor)
OptionsFgColor = GetTextStyle(themeConfig.OptionsTextColor, false)

View File

@@ -1,6 +1,8 @@
# ![Tcell](logos/tcell.png)
Please see [here](UKRAINE.md) for an important message for the people of Russia.
_Tcell_ is a _Go_ package that provides a cell based view for text terminals, like _XTerm_.
It was inspired by _termbox_, but includes many additional improvements.
@@ -17,6 +19,7 @@ Version 1.x remains available using the import `github.com/gdamore/tcell`.
## Tutorial
A brief, and still somewhat rough, [tutorial](TUTORIAL.md) is available.
## Examples
* [proxima5](https://github.com/gdamore/proxima5) - space shooter ([video](https://youtu.be/jNxKTCmY_bQ))
@@ -45,6 +48,7 @@ A brief, and still somewhat rough, [tutorial](TUTORIAL.md) is available.
* [gorss](https://github.com/lallassu/gorss) - RSS/Atom feed reader
* [memoryalike](https://github.com/Bios-Marcel/memoryalike) - memorization game
* [lf](https://github.com/gokcehan/lf) - file manager
* [goful](https://github.com/anmitsu/goful) - CUI file manager
* [gokeybr](https://github.com/bunyk/gokeybr) - deliberately practice your typing
* [gonano](https://github.com/jbaramidze/gonano) - editor, mimics _nano_
* [uchess](https://github.com/tmountain/uchess) - UCI chess client
@@ -53,9 +57,10 @@ A brief, and still somewhat rough, [tutorial](TUTORIAL.md) is available.
* [tmux-wormhole](https://github.com/gcla/tmux-wormhole) - _tmux_ plugin to transfer files
* [gruid-tcell](https://github.com/anaseto/gruid-tcell) - driver for the grid based UI and game framework
* [aretext](https://github.com/aretext/aretext) - minimalist text editor with _vim_ key bindings
* [sync](https://github.com/kyprifog/sync) - github repo synchronization tool
* [sync](https://github.com/kyprifog/sync) - GitHub repo synchronization tool
* [statusbar](https://github.com/kyprifog/statusbar) - statusbar motivation tool for tracking periodic tasks/goals
* [todo](https://github.com/kyprifog/todo) - simple todo app
* [gosnakego](https://github.com/liweiyi88/gosnakego) - a snake game
## Pure Go Terminfo Database

77
vendor/github.com/gdamore/tcell/v2/UKRAINE.md generated vendored Normal file
View File

@@ -0,0 +1,77 @@
# Ukraine, Russia, and a World Tragedy
## A message to those inside Russia
### Written March 4, 2022.
It is with a very heavy heart that I write this. I am normally opposed to the use of open source
projects to communicate political positions or advocate for things outside the immediate relevancy
to that project.
However, the events occurring in Ukraine, and specifically the unprecedented invasion of Ukraine by
Russian forces operating under orders from Russian President Vladimir Putin compel me to speak out.
Those who know me, know that I have family, friends, and colleagues in Russia, and Ukraine both. My closest friends
have historically been Russian friends my wife's hometown of Chelyabinsk. I myself have in the past
frequently traveled to Russia, and indeed operated a software development firm with offices in St. Petersburg.
I had a special kinship with Russia and its people.
I say "had", because I fear that the actions of Putin, and the massive disinformation campaign that his regime
has waged inside Russia, mean that it's likely that I won't see those friends again. At present, I'm not sure
my wife will see her own mother again. We no longer feel it's safe for either of us to return Russia given
actions taken by the regime to crack down on those who express disagreement.
Russian citizens are being led to believe it is acting purely defensively, and that only legitimate military
targets are being targeted, and that all the information we have received in the West are fakes.
I am confident that nothing could be further from the truth.
This has caused many in Russia, including people whom I respect and believe to be smarter than this, to
stand by Putin, and endorse his actions. The claim is that the entirety of NATO is operating at the behest
of the USA, and that the entirety of Europe was poised to attack Russia. While this is clearly absurd to those
of us with any understanding of western politics, Russian citizens are being fed this lie, and believing it.
If you're reading this from inside Russia -- YOU are the person that I hope this message reaches. Your
government is LYING to you. Of course, all governments lie all the time. But consider this. Almost the
entire world has condemned the invasion of Ukraine as criminal, and has applied sanctions. Even countries
which have poor relations with the US sanctioning Russia, as well as nations which historically have remained
neutral. (Famously neutral -- even during World War II, Switzerland has acted to apply sanctions in
concert with the rest of the world.)
Ask yourself, why does Putin fear a free press so much, if what he says is true? Why the crack-downs on
children expressing only a desire for peace with Ukraine? Why would the entire world unified against him,
if Putin was in the right? Why would the only countries that stood with Russia against
the UN resolution to condemn these acts as crimes be Belarus, North Korea, and Syria? Even countries normally
allied to Russia could not bring themselves to do more than abstain from the vote to condemn it.
To be clear, I do not claim that the actions taken by the West or by the Ukrainian government were completely
blameless. On the contrary, I understand that Western media is biased, and the truth is rarely exactly
as reported. I believe that there is a kernel of truth in the claims of fascists and ultra-nationalist
militias operating in Ukraine and specifically Donbas. However, I am also equally certain that Putin's
response is out of proportion, and that concerns about such militias are principally just a pretext to justify
an invasion.
Europe is at war, unlike we've seen in my lifetime. The world is more divided, and closer to nuclear holocaust
than it has been since the Cold War. And that is 100% the fault of Putin.
While Putin remains in power, there cannot really be any way for Russian international relations to return
to normal. Putin has set your country on a path to return to the Cold War, likely because he fancies himself
to be a new Stalin. However, unlike the Soviet Union, the Russian economy does not have the wherewithal to
stand on its own, and the invasion of Ukraine has fully ensured that Russia will not find any friends anywhere
else in Europe, and probably few places in Asia.
The *only* paths forward for Russia are either a Russia without Putin (and those who would support his agenda),
or a complete breakdown of Russian prosperity, likely followed by the increasing international conflict that will
be the natural escalation from a country that is isolated and impoverished. Those of us observing from the West are
gravely concerned, because we cannot see any end to this madness that does not result in nuclear conflict,
unless from within.
In the meantime, the worst prices will be paid for by innocents in Ukraine, and by young Russian mean
forced to carry out the orders of Putin's corrupt regime.
And *that* is why I write this -- to appeal to those within Russia to open your eyes, and think with
your minds. It is right and proper to be proud of your country and its rich heritage. But it is also
right and proper to look for ways to save it from the ruinous path that its current leadership has set it upon,
and to recognize when that leadership is no longer acting in interest of the country or its people.
- Garrett D'Amore, March 4, 2022

View File

@@ -46,11 +46,12 @@ type cScreen struct {
w int
h int
oscreen consoleInfo
ocursor cursorInfo
oimode uint32
oomode uint32
cells CellBuffer
oscreen consoleInfo
ocursor cursorInfo
cursorStyle CursorStyle
oimode uint32
oomode uint32
cells CellBuffer
finiOnce sync.Once
@@ -138,20 +139,37 @@ const (
const (
// VT100/XTerm escapes understood by the console
vtShowCursor = "\x1b[?25h"
vtHideCursor = "\x1b[?25l"
vtCursorPos = "\x1b[%d;%dH" // Note that it is Y then X
vtSgr0 = "\x1b[0m"
vtBold = "\x1b[1m"
vtUnderline = "\x1b[4m"
vtBlink = "\x1b[5m" // Not sure this is processed
vtReverse = "\x1b[7m"
vtSetFg = "\x1b[38;5;%dm"
vtSetBg = "\x1b[48;5;%dm"
vtSetFgRGB = "\x1b[38;2;%d;%d;%dm" // RGB
vtSetBgRGB = "\x1b[48;2;%d;%d;%dm" // RGB
vtShowCursor = "\x1b[?25h"
vtHideCursor = "\x1b[?25l"
vtCursorPos = "\x1b[%d;%dH" // Note that it is Y then X
vtSgr0 = "\x1b[0m"
vtBold = "\x1b[1m"
vtUnderline = "\x1b[4m"
vtBlink = "\x1b[5m" // Not sure this is processed
vtReverse = "\x1b[7m"
vtSetFg = "\x1b[38;5;%dm"
vtSetBg = "\x1b[48;5;%dm"
vtSetFgRGB = "\x1b[38;2;%d;%d;%dm" // RGB
vtSetBgRGB = "\x1b[48;2;%d;%d;%dm" // RGB
vtCursorDefault = "\x1b[0 q"
vtCursorBlinkingBlock = "\x1b[1 q"
vtCursorSteadyBlock = "\x1b[2 q"
vtCursorBlinkingUnderline = "\x1b[3 q"
vtCursorSteadyUnderline = "\x1b[4 q"
vtCursorBlinkingBar = "\x1b[5 q"
vtCursorSteadyBar = "\x1b[6 q"
)
var vtCursorStyles = map[CursorStyle]string{
CursorStyleDefault: vtCursorDefault,
CursorStyleBlinkingBlock: vtCursorBlinkingBlock,
CursorStyleSteadyBlock: vtCursorSteadyBlock,
CursorStyleBlinkingUnderline: vtCursorBlinkingUnderline,
CursorStyleSteadyUnderline: vtCursorSteadyUnderline,
CursorStyleBlinkingBar: vtCursorBlinkingBar,
CursorStyleSteadyBar: vtCursorSteadyBar,
}
// NewConsoleScreen returns a Screen for the Windows console associated
// with the current process. The Screen makes use of the Windows Console
// API to display content and read events.
@@ -280,6 +298,9 @@ func (s *cScreen) disengage() {
s.wg.Wait()
if s.vten {
s.emitVtString(vtCursorStyles[CursorStyleDefault])
}
s.setInMode(s.oimode)
s.setOutMode(s.oomode)
s.setBufferSize(int(s.oscreen.size.x), int(s.oscreen.size.y))
@@ -406,6 +427,7 @@ func (s *cScreen) emitVtString(vs string) {
func (s *cScreen) showCursor() {
if s.vten {
s.emitVtString(vtShowCursor)
s.emitVtString(vtCursorStyles[s.cursorStyle])
} else {
s.setCursorInfo(&cursorInfo{size: 100, visible: 1})
}
@@ -429,6 +451,17 @@ func (s *cScreen) ShowCursor(x, y int) {
s.Unlock()
}
func (s *cScreen) SetCursorStyle(cs CursorStyle) {
s.Lock()
if !s.fini {
if _, ok := vtCursorStyles[cs]; ok {
s.cursorStyle = cs
s.doCursor()
}
}
s.Unlock()
}
func (s *cScreen) doCursor() {
x, y := s.curx, s.cury

View File

@@ -6,7 +6,7 @@ require (
github.com/gdamore/encoding v1.0.0
github.com/lucasb-eyer/go-colorful v1.2.0
github.com/mattn/go-runewidth v0.0.13
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68
golang.org/x/sys v0.0.0-20211113001501-0c823b97ae02
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf
golang.org/x/text v0.3.7
)

View File

@@ -6,8 +6,9 @@ github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68 h1:nxC68pudNYkKU6jWhgrqdreuFiOQWj1Fs7T3VrH4Pjw=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20211113001501-0c823b97ae02 h1:7NCfEGl0sfUojmX78nK9pBJuUlSZWEJA/TwASvfiPLo=
golang.org/x/sys v0.0.0-20211113001501-0c823b97ae02/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf h1:MZ2shdL+ZM/XzY3ZGOnh4Nlpnxz5GSOhOmtHo3iPU6M=
golang.org/x/term v0.0.0-20201210144234-2321bbc49cbf/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

View File

@@ -71,9 +71,14 @@ type Screen interface {
ShowCursor(x int, y int)
// HideCursor is used to hide the cursor. Its an alias for
// ShowCursor(-1, -1).
// ShowCursor(-1, -1).sim
HideCursor()
// SetCursorStyle is used to set the cursor style. If the style
// is not supported (or cursor styles are not supported at all),
// then this will have no effect.
SetCursorStyle(CursorStyle)
// Size returns the screen size as width, height. This changes in
// response to a call to Clear or Flush.
Size() (width, height int)
@@ -258,3 +263,17 @@ const (
MouseDragEvents = MouseFlags(2) // Click-drag events (includes button events)
MouseMotionEvents = MouseFlags(4) // All mouse events (includes click and drag events)
)
// CursorStyle represents a given cursor style, which can include the shape and
// whether the cursor blinks or is solid. Support for changing these is not universal.
type CursorStyle int
const (
CursorStyleDefault = CursorStyle(iota) // The default
CursorStyleBlinkingBlock
CursorStyleSteadyBlock
CursorStyleBlinkingUnderline
CursorStyleSteadyUnderline
CursorStyleBlinkingBar
CursorStyleSteadyBar
)

View File

@@ -281,6 +281,8 @@ func (s *simscreen) hideCursor() {
s.cursorvis = false
}
func (s *simscreen) SetCursorStyle(CursorStyle) {}
func (s *simscreen) Show() {
s.Lock()
s.resize()

View File

@@ -9,6 +9,7 @@ func init() {
// foot terminal emulator
terminfo.AddTerminfo(&terminfo.Terminfo{
Name: "foot",
Aliases: []string{"foot-extra"},
Columns: 80,
Lines: 24,
Colors: 256,

View File

@@ -167,59 +167,66 @@ type Terminfo struct {
// Terminal support for these are going to vary amongst XTerm
// emulations, so don't depend too much on them in your application.
StrikeThrough string // smxx
SetFgBg string // setfgbg
SetFgBgRGB string // setfgbgrgb
SetFgRGB string // setfrgb
SetBgRGB string // setbrgb
KeyShfUp string // shift-up
KeyShfDown string // shift-down
KeyShfPgUp string // shift-kpp
KeyShfPgDn string // shift-knp
KeyCtrlUp string // ctrl-up
KeyCtrlDown string // ctrl-left
KeyCtrlRight string // ctrl-right
KeyCtrlLeft string // ctrl-left
KeyMetaUp string // meta-up
KeyMetaDown string // meta-left
KeyMetaRight string // meta-right
KeyMetaLeft string // meta-left
KeyAltUp string // alt-up
KeyAltDown string // alt-left
KeyAltRight string // alt-right
KeyAltLeft string // alt-left
KeyCtrlHome string
KeyCtrlEnd string
KeyMetaHome string
KeyMetaEnd string
KeyAltHome string
KeyAltEnd string
KeyAltShfUp string
KeyAltShfDown string
KeyAltShfLeft string
KeyAltShfRight string
KeyMetaShfUp string
KeyMetaShfDown string
KeyMetaShfLeft string
KeyMetaShfRight string
KeyCtrlShfUp string
KeyCtrlShfDown string
KeyCtrlShfLeft string
KeyCtrlShfRight string
KeyCtrlShfHome string
KeyCtrlShfEnd string
KeyAltShfHome string
KeyAltShfEnd string
KeyMetaShfHome string
KeyMetaShfEnd string
EnablePaste string // bracketed paste mode
DisablePaste string
PasteStart string
PasteEnd string
Modifiers int
InsertChar string // string to insert a character (ich1)
AutoMargin bool // true if writing to last cell in line advances
TrueColor bool // true if the terminal supports direct color
StrikeThrough string // smxx
SetFgBg string // setfgbg
SetFgBgRGB string // setfgbgrgb
SetFgRGB string // setfrgb
SetBgRGB string // setbrgb
KeyShfUp string // shift-up
KeyShfDown string // shift-down
KeyShfPgUp string // shift-kpp
KeyShfPgDn string // shift-knp
KeyCtrlUp string // ctrl-up
KeyCtrlDown string // ctrl-left
KeyCtrlRight string // ctrl-right
KeyCtrlLeft string // ctrl-left
KeyMetaUp string // meta-up
KeyMetaDown string // meta-left
KeyMetaRight string // meta-right
KeyMetaLeft string // meta-left
KeyAltUp string // alt-up
KeyAltDown string // alt-left
KeyAltRight string // alt-right
KeyAltLeft string // alt-left
KeyCtrlHome string
KeyCtrlEnd string
KeyMetaHome string
KeyMetaEnd string
KeyAltHome string
KeyAltEnd string
KeyAltShfUp string
KeyAltShfDown string
KeyAltShfLeft string
KeyAltShfRight string
KeyMetaShfUp string
KeyMetaShfDown string
KeyMetaShfLeft string
KeyMetaShfRight string
KeyCtrlShfUp string
KeyCtrlShfDown string
KeyCtrlShfLeft string
KeyCtrlShfRight string
KeyCtrlShfHome string
KeyCtrlShfEnd string
KeyAltShfHome string
KeyAltShfEnd string
KeyMetaShfHome string
KeyMetaShfEnd string
EnablePaste string // bracketed paste mode
DisablePaste string
PasteStart string
PasteEnd string
Modifiers int
InsertChar string // string to insert a character (ich1)
AutoMargin bool // true if writing to last cell in line advances
TrueColor bool // true if the terminal supports direct color
CursorDefault string
CursorBlinkingBlock string
CursorSteadyBlock string
CursorBlinkingUnderline string
CursorSteadyUnderline string
CursorBlinkingBar string
CursorSteadyBar string
}
const (

View File

@@ -148,6 +148,8 @@ type tScreen struct {
finiOnce sync.Once
enablePaste string
disablePaste string
cursorStyles map[CursorStyle]string
cursorStyle CursorStyle
saved *term.State
stopQ chan struct{}
running bool
@@ -332,6 +334,34 @@ func (t *tScreen) prepareBracketedPaste() {
}
}
func (t *tScreen) prepareCursorStyles() {
// Another workaround for lack of reporting in terminfo.
// We assume if the terminal has a mouse entry, that it
// offers bracketed paste. But we allow specific overrides
// via our terminal database.
if t.ti.CursorDefault != "" {
t.cursorStyles = map[CursorStyle]string{
CursorStyleDefault: t.ti.CursorDefault,
CursorStyleBlinkingBlock: t.ti.CursorBlinkingBlock,
CursorStyleSteadyBlock: t.ti.CursorSteadyBlock,
CursorStyleBlinkingUnderline: t.ti.CursorBlinkingUnderline,
CursorStyleSteadyUnderline: t.ti.CursorSteadyUnderline,
CursorStyleBlinkingBar: t.ti.CursorBlinkingBar,
CursorStyleSteadyBar: t.ti.CursorSteadyBar,
}
} else if t.ti.Mouse != "" {
t.cursorStyles = map[CursorStyle]string{
CursorStyleDefault: "\x1b[0 q",
CursorStyleBlinkingBlock: "\x1b[1 q",
CursorStyleSteadyBlock: "\x1b[2 q",
CursorStyleBlinkingUnderline: "\x1b[3 q",
CursorStyleSteadyUnderline: "\x1b[4 q",
CursorStyleBlinkingBar: "\x1b[5 q",
CursorStyleSteadyBar: "\x1b[6 q",
}
}
}
func (t *tScreen) prepareKey(key Key, val string) {
t.prepareKeyMod(key, ModNone, val)
}
@@ -471,6 +501,7 @@ func (t *tScreen) prepareKeys() {
t.prepareKey(keyPasteEnd, ti.PasteEnd)
t.prepareXtermModifiers()
t.prepareBracketedPaste()
t.prepareCursorStyles()
outer:
// Add key mappings for control keys.
@@ -517,6 +548,18 @@ func (t *tScreen) SetStyle(style Style) {
func (t *tScreen) Clear() {
t.Fill(' ', t.style)
t.Lock()
t.clear = true
w, h := t.cells.Size()
// because we are going to clear (see t.clear) in the next cycle,
// let's also unmark the dirty bit so that we don't waste cycles
// drawing things that are already dealt with via the clear escape sequence.
for row := 0; row < h; row++ {
for col := 0; col < w; col++ {
t.cells.SetDirty(col, row, false)
}
}
t.Unlock()
}
func (t *tScreen) Fill(r rune, style Style) {
@@ -754,6 +797,12 @@ func (t *tScreen) ShowCursor(x, y int) {
t.Unlock()
}
func (t *tScreen) SetCursorStyle(cs CursorStyle) {
t.Lock()
t.cursorStyle = cs
t.Unlock()
}
func (t *tScreen) HideCursor() {
t.ShowCursor(-1, -1)
}
@@ -768,6 +817,11 @@ func (t *tScreen) showCursor() {
}
t.TPuts(t.ti.TGoto(x, y))
t.TPuts(t.ti.ShowCursor)
if t.cursorStyles != nil {
if esc, ok := t.cursorStyles[t.cursorStyle]; ok {
t.TPuts(esc)
}
}
t.cx = x
t.cy = y
}
@@ -894,8 +948,9 @@ func (t *tScreen) enableMouse(f MouseFlags) {
if f&MouseMotionEvents != 0 {
t.TPuts("\x1b[?1003h")
}
t.TPuts("\x1b[?1006h")
if f&(MouseButtonEvents|MouseDragEvents|MouseMotionEvents) != 0 {
t.TPuts("\x1b[?1006h")
}
}
}
@@ -1737,6 +1792,9 @@ func (t *tScreen) disengage() {
ti := t.ti
t.cells.Resize(0, 0)
t.TPuts(ti.ShowCursor)
if t.cursorStyles != nil && t.cursorStyle != CursorStyleDefault {
t.TPuts(t.cursorStyles[t.cursorStyle])
}
t.TPuts(ti.ResetFgBg)
t.TPuts(ti.AttrOff)
t.TPuts(ti.Clear)

View File

@@ -72,7 +72,6 @@ func (tty *devTty) Start() error {
if tty.f, err = os.OpenFile(tty.dev, os.O_RDWR, 0); err != nil {
return err
}
tty.fd = int(tty.f.Fd())
if !term.IsTerminal(tty.fd) {
return errors.New("device is not a terminal")

View File

@@ -1,20 +0,0 @@
Copyright (c) 2012 Caleb Doxsey
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@@ -1,44 +0,0 @@
package stack
type (
Stack struct {
top *node
length int
}
node struct {
value interface{}
prev *node
}
)
// Create a new stack
func New() *Stack {
return &Stack{nil,0}
}
// Return the number of items in the stack
func (this *Stack) Len() int {
return this.length
}
// View the top item on the stack
func (this *Stack) Peek() interface{} {
if this.length == 0 {
return nil
}
return this.top.value
}
// Pop the top item of the stack and return it
func (this *Stack) Pop() interface{} {
if this.length == 0 {
return nil
}
n := this.top
this.top = n.prev
this.length--
return n.value
}
// Push a value onto the top of the stack
func (this *Stack) Push(value interface{}) {
n := &node{value,this.top}
this.top = n
this.length++
}

3
vendor/modules.txt vendored
View File

@@ -33,7 +33,7 @@ github.com/fatih/color
github.com/fsnotify/fsnotify
# github.com/gdamore/encoding v1.0.0
github.com/gdamore/encoding
# github.com/gdamore/tcell/v2 v2.4.1-0.20210926162909-66f061b1fc9b
# github.com/gdamore/tcell/v2 v2.4.1-0.20220313203054-2a1a1b586447
## explicit
github.com/gdamore/tcell/v2
github.com/gdamore/tcell/v2/terminfo
@@ -102,7 +102,6 @@ github.com/gobwas/glob/util/runes
github.com/gobwas/glob/util/strings
# github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3
## explicit
github.com/golang-collections/collections/stack
# github.com/golang/protobuf v1.3.2
## explicit
# github.com/google/go-cmp v0.5.6