summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2021-04-17 20:53:36 +1000
committerJesse Duffield <jessedduffield@gmail.com>2021-04-17 21:15:54 +1000
commitb28b2d05bd26519d61730c6ced0ba61916aeb456 (patch)
tree19636c2ccbb9f29649737d306049b4a1c8a3a5c9
parent9e5f031553dcef0a73afd86cedfa9b7adf68e460 (diff)
force cursor to be at end of line when opening confirmation panel
-rw-r--r--go.mod4
-rw-r--r--go.sum6
-rw-r--r--pkg/gui/confirmation_panel.go19
-rw-r--r--pkg/gui/discard_changes_menu_panel.go1
-rw-r--r--pkg/gui/files_panel.go7
-rw-r--r--vendor/github.com/jesseduffield/gocui/edit.go18
-rw-r--r--vendor/golang.org/x/sys/unix/syscall_linux.go39
-rw-r--r--vendor/golang.org/x/sys/unix/ztypes_linux.go15
-rw-r--r--vendor/modules.txt4
9 files changed, 88 insertions, 25 deletions
diff --git a/go.mod b/go.mod
index 5da6012a8..38917a64b 100644
--- a/go.mod
+++ b/go.mod
@@ -20,7 +20,7 @@ require (
github.com/imdario/mergo v0.3.11
github.com/integrii/flaggy v1.4.0
github.com/jesseduffield/go-git/v5 v5.1.2-0.20201006095850-341962be15a4
- github.com/jesseduffield/gocui v0.3.1-0.20210412130453-de7bb5079f9f
+ github.com/jesseduffield/gocui v0.3.1-0.20210417110745-37f79434200d
github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe // indirect
github.com/jesseduffield/yaml v2.1.0+incompatible
github.com/kardianos/osext v0.0.0-20190222173326-2bc1f35cddc0
@@ -39,7 +39,7 @@ require (
github.com/stretchr/testify v1.4.0
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0 // indirect
golang.org/x/net v0.0.0-20201002202402-0a1ea396d57c // indirect
- golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 // indirect
+ golang.org/x/sys v0.0.0-20210415045647-66c3f260301c // indirect
golang.org/x/term v0.0.0-20210406210042-72f3dc4e9b72 // indirect
golang.org/x/text v0.3.6 // indirect
)
diff --git a/go.sum b/go.sum
index 573569b93..015361c28 100644
--- a/go.sum
+++ b/go.sum
@@ -116,6 +116,10 @@ github.com/jesseduffield/gocui v0.3.1-0.20210412113212-ee65bd542c08 h1:d003y2GBy
github.com/jesseduffield/gocui v0.3.1-0.20210412113212-ee65bd542c08/go.mod h1:QWq79xplEoyhQO+dgpk3sojjTVRKjQklyTlzm5nC5Kg=
github.com/jesseduffield/gocui v0.3.1-0.20210412130453-de7bb5079f9f h1:JPpHlvSrKNxro+K9rM3nEHCdZ16qD0hnEedHPF07OtA=
github.com/jesseduffield/gocui v0.3.1-0.20210412130453-de7bb5079f9f/go.mod h1:QWq79xplEoyhQO+dgpk3sojjTVRKjQklyTlzm5nC5Kg=
+github.com/jesseduffield/gocui v0.3.1-0.20210417105214-bdf37de5c917 h1:H4THGOdAJf61wByuq8EHF/NAgtqrTxpSIPsrCXU9HAY=
+github.com/jesseduffield/gocui v0.3.1-0.20210417105214-bdf37de5c917/go.mod h1:QWq79xplEoyhQO+dgpk3sojjTVRKjQklyTlzm5nC5Kg=
+github.com/jesseduffield/gocui v0.3.1-0.20210417110745-37f79434200d h1:2BPcc19W0j576hvhxtKma4jcD/+qAYvw1ln2HcIEZGU=
+github.com/jesseduffield/gocui v0.3.1-0.20210417110745-37f79434200d/go.mod h1:QWq79xplEoyhQO+dgpk3sojjTVRKjQklyTlzm5nC5Kg=
github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe h1:qsVhCf2RFyyKIUe/+gJblbCpXMUki9rZrHuEctg6M/E=
github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe/go.mod h1:anMibpZtqNxjDbxrcDEAwSdaJ37vyUeM1f/M4uekib4=
github.com/jesseduffield/yaml v2.1.0+incompatible h1:HWQJ1gIv2zHKbDYNp0Jwjlj24K8aqpFHnMCynY1EpmE=
@@ -236,6 +240,8 @@ golang.org/x/sys v0.0.0-20210402192133-700132347e07 h1:4k6HsQjxj6hVMsI2Vf0yKlzt5
golang.org/x/sys v0.0.0-20210402192133-700132347e07/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57 h1:F5Gozwx4I1xtr/sr/8CFbb57iKi3297KFs0QDbGN60A=
golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
+golang.org/x/sys v0.0.0-20210415045647-66c3f260301c h1:6L+uOeS3OQt/f4eFHXZcTxeZrGCuz+CLElgEBjbcTA4=
+golang.org/x/sys v0.0.0-20210415045647-66c3f260301c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
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/term v0.0.0-20210317153231-de623e64d2a6 h1:EC6+IGYTjPpRfv9a2b/6Puw0W+hLtAhkV1tPsXhutqs=
diff --git a/pkg/gui/confirmation_panel.go b/pkg/gui/confirmation_panel.go
index a3cec023f..f04cd43b3 100644
--- a/pkg/gui/confirmation_panel.go
+++ b/pkg/gui/confirmation_panel.go
@@ -8,7 +8,6 @@ package gui
import (
"strings"
- "time"
"github.com/fatih/color"
"github.com/jesseduffield/gocui"
@@ -216,19 +215,17 @@ func (gui *Gui) createPopupPanel(opts createPopupPanelOpts) error {
}
gui.Views.Confirmation.Editable = opts.editable
gui.Views.Confirmation.Editor = gocui.EditorFunc(gui.defaultEditor)
+
if opts.editable {
- go utils.Safe(func() {
- // TODO: remove this wait (right now if you remove it the EditGotoToEndOfLine method doesn't seem to work)
- time.Sleep(time.Millisecond)
- gui.g.Update(func(g *gocui.Gui) error {
- gui.Views.Confirmation.EditGotoToEndOfLine()
- return nil
- })
- })
+ if err := gui.Views.Confirmation.SetEditorContent(opts.prompt); err != nil {
+ return err
+ }
+ } else {
+ if err := gui.renderStringSync(gui.Views.Confirmation, opts.prompt); err != nil {
+ return err
+ }
}
- gui.renderString(gui.Views.Confirmation, opts.prompt)
-
return gui.setKeyBindings(opts)
})
return nil
diff --git a/pkg/gui/discard_changes_menu_panel.go b/pkg/gui/discard_changes_menu_panel.go
index 0b1059516..bf20b5b8c 100644
--- a/pkg/gui/discard_changes_menu_panel.go
+++ b/pkg/gui/discard_changes_menu_panel.go
@@ -52,7 +52,6 @@ func (gui *Gui) handleCreateDiscardMenu() error {
{
displayString: gui.Tr.LcDiscardAllChanges,
onPress: func() error {
- gui.Log.Warn("HA?")
if err := gui.GitCommand.WithSpan(gui.Tr.Spans.DiscardAllChangesInFile).DiscardAllFileChanges(file); err != nil {
return gui.surfaceError(err)
}
diff --git a/pkg/gui/files_panel.go b/pkg/gui/files_panel.go
index 34b9e37d2..f2bb6d43d 100644
--- a/pkg/gui/files_panel.go
+++ b/pkg/gui/files_panel.go
@@ -342,13 +342,12 @@ func (gui *Gui) handleIgnoreFile() error {
}
func (gui *Gui) handleWIPCommitPress() error {
- skipHookPreifx := gui.Config.GetUserConfig().Git.SkipHookPrefix
- if skipHookPreifx == "" {
+ skipHookPrefix := gui.Config.GetUserConfig().Git.SkipHookPrefix
+ if skipHookPrefix == "" {
return gui.createErrorPanel(gui.Tr.SkipHookPrefixNotConfigured)
}
- _ = gui.renderStringSync(gui.Views.CommitMessage, skipHookPreifx)
- if err := gui.Views.CommitMessage.SetCursor(len(skipHookPreifx), 0); err != nil {
+ if err := gui.Views.CommitMessage.SetEditorContent(skipHookPrefix); err != nil {
return err
}
diff --git a/vendor/github.com/jesseduffield/gocui/edit.go b/vendor/github.com/jesseduffield/gocui/edit.go
index ee6d7f604..a169e563b 100644
--- a/vendor/github.com/jesseduffield/gocui/edit.go
+++ b/vendor/github.com/jesseduffield/gocui/edit.go
@@ -86,6 +86,24 @@ func (v *View) EditWrite(ch rune) {
v.moveCursor(w, 0, true)
}
+func (v *View) EditWriteString(str string) {
+ for _, ch := range str {
+ v.EditWrite(ch)
+ }
+}
+
+func (v *View) SetEditorContent(content string) error {
+ v.Clear()
+ if err := v.SetOrigin(0, 0); err != nil {
+ return err
+ }
+ if err := v.SetCursor(0, 0); err != nil {
+ return err
+ }
+ v.EditWriteString(content)
+ return nil
+}
+
// EditDeleteToStartOfLine is the equivalent of pressing ctrl+U in your terminal, it deletes to the start of the line. Or if you are already at the start of the line, it deletes the newline character
func (v *View) EditDeleteToStartOfLine() {
x, _ := v.Cursor()
diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go
index 44ea96e39..c61c963b7 100644
--- a/vendor/golang.org/x/sys/unix/syscall_linux.go
+++ b/vendor/golang.org/x/sys/unix/syscall_linux.go
@@ -106,6 +106,31 @@ func IoctlGetRTCTime(fd int) (*RTCTime, error) {
return &value, err
}
+type ifreqEthtool struct {
+ name [IFNAMSIZ]byte
+ data unsafe.Pointer
+}
+
+// IoctlGetEthtoolDrvinfo fetches ethtool driver information for the network
+// device specified by ifname.
+func IoctlGetEthtoolDrvinfo(fd int, ifname string) (*EthtoolDrvinfo, error) {
+ // Leave room for terminating NULL byte.
+ if len(ifname) >= IFNAMSIZ {
+ return nil, EINVAL
+ }
+
+ value := EthtoolDrvinfo{
+ Cmd: ETHTOOL_GDRVINFO,
+ }
+ ifreq := ifreqEthtool{
+ data: unsafe.Pointer(&value),
+ }
+ copy(ifreq.name[:], ifname)
+ err := ioctl(fd, SIOCETHTOOL, uintptr(unsafe.Pointer(&ifreq)))
+ runtime.KeepAlive(ifreq)
+ return &value, err
+}
+
// IoctlGetWatchdogInfo fetches information about a watchdog device from the
// Linux watchdog API. For more information, see:
// https://www.kernel.org/doc/html/latest/watchdog/watchdog-api.html.
@@ -857,16 +882,19 @@ type SockaddrVM struct {
// CID and Port specify a context ID and port address for a VM socket.
// Guests have a unique CID, and hosts may have a well-known CID of:
// - VMADDR_CID_HYPERVISOR: refers to the hypervisor process.
+ // - VMADDR_CID_LOCAL: refers to local communication (loopback).
// - VMADDR_CID_HOST: refers to other processes on the host.
- CID uint32
- Port uint32
- raw RawSockaddrVM
+ CID uint32
+ Port uint32
+ Flags uint8
+ raw RawSockaddrVM
}
func (sa *SockaddrVM) sockaddr() (unsafe.Pointer, _Socklen, error) {
sa.raw.Family = AF_VSOCK
sa.raw.Port = sa.Port
sa.raw.Cid = sa.CID
+ sa.raw.Flags = sa.Flags
return unsafe.Pointer(&sa.raw), SizeofSockaddrVM, nil
}
@@ -1171,8 +1199,9 @@ func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
case AF_VSOCK:
pp := (*RawSockaddrVM)(unsafe.Pointer(rsa))
sa := &SockaddrVM{
- CID: pp.Cid,
- Port: pp.Port,
+ CID: pp.Cid,
+ Port: pp.Port,
+ Flags: pp.Flags,
}
return sa, nil
case AF_BLUETOOTH:
diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux.go b/vendor/golang.org/x/sys/unix/ztypes_linux.go
index c769e73cd..3bfc6f732 100644
--- a/vendor/golang.org/x/sys/unix/ztypes_linux.go
+++ b/vendor/golang.org/x/sys/unix/ztypes_linux.go
@@ -3698,6 +3698,21 @@ const (
ETHTOOL_A_TUNNEL_INFO_MAX = 0x2
)
+type EthtoolDrvinfo struct {
+ Cmd uint32
+ Driver [32]byte
+ Version [32]byte
+ Fw_version [32]byte
+ Bus_info [32]byte
+ Erom_version [32]byte
+ Reserved2 [12]byte
+ N_priv_flags uint32
+ N_stats uint32
+ Testinfo_len uint32
+ Eedump_len uint32
+ Regdump_len uint32
+}
+
type (
HIDRawReportDescriptor struct {
Size uint32
diff --git a/vendor/modules.txt b/vendor/modules.txt
index 68c377230..4cc7a5734 100644
--- a/vendor/modules.txt
+++ b/vendor/modules.txt
@@ -149,7 +149,7 @@ github.com/jesseduffield/go-git/v5/utils/merkletrie/filesystem
github.com/jesseduffield/go-git/v5/utils/merkletrie/index
github.com/jesseduffield/go-git/v5/utils/merkletrie/internal/frame
github.com/jesseduffield/go-git/v5/utils/merkletrie/noder
-# github.com/jesseduffield/gocui v0.3.1-0.20210412130453-de7bb5079f9f
+# github.com/jesseduffield/gocui v0.3.1-0.20210417110745-37f79434200d
## explicit
github.com/jesseduffield/gocui
# github.com/jesseduffield/termbox-go v0.0.0-20200823212418-a2289ed6aafe
@@ -235,7 +235,7 @@ golang.org/x/crypto/ssh/knownhosts
golang.org/x/net/context
golang.org/x/net/internal/socks
golang.org/x/net/proxy
-# golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57
+# golang.org/x/sys v0.0.0-20210415045647-66c3f260301c
## explicit
golang.org/x/sys/cpu
golang.org/x/sys/internal/unsafeheader