diff --git a/go.mod b/go.mod index 6ae54c4..152ff23 100644 --- a/go.mod +++ b/go.mod @@ -14,6 +14,8 @@ require ( github.com/spf13/cobra v1.6.1 ) +require github.com/atotto/clipboard v0.1.4 // indirect + require ( github.com/aws/aws-sdk-go-v2/credentials v1.13.8 // indirect github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.12.21 // indirect diff --git a/go.sum b/go.sum index 50a82bd..f78bc63 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= +github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/aws/aws-sdk-go v1.44.177 h1:ckMJhU5Gj+4Rta+bJIUiUd7jvHom84aim3zkGPblq0s= github.com/aws/aws-sdk-go v1.44.177/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v1.17.3 h1:shN7NlnVzvDUgPQ+1rLMSxY8OWRNDRYtiqe0p/PgrhY= diff --git a/internal/view/app.go b/internal/view/app.go index c067dda..b91c335 100644 --- a/internal/view/app.go +++ b/internal/view/app.go @@ -8,6 +8,7 @@ import ( "strings" "time" + "github.com/atotto/clipboard" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/s3" @@ -617,6 +618,7 @@ func (a *App) DisplayS3Json(sess *session.Session, bucketName string) { a.Main.AddAndSwitchToPage("s3Json", flex, true) flex.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { if event.Key() == tcell.KeyESC { + tvForS3Json.SetTextColor(tcell.ColorWhite) a.Main.SwitchToPage("main") a.Application.SetFocus(a.Views()["content"].(*tview.Flex).ItemAt(0)) } @@ -625,6 +627,15 @@ func (a *App) DisplayS3Json(sess *session.Session, bucketName string) { } return event }) + tvForS3Json.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey { + if event.Rune() == 67 { + tvForS3Json.SetTextColor(tcell.ColorYellowGreen) + text := tvForS3Json.GetText(true) + clipboard.WriteAll(text) + } + return event + }) + } func (a *App) DisplayS3Objects(s3DataTable *tview.Table, flex *tview.Flex, folderName string, fileArrayInfo []string, sess session.Session, bucketName string) {