Skip to content

Commit

Permalink
Add clipbard copy!
Browse files Browse the repository at this point in the history
  • Loading branch information
hatsu38 committed Aug 24, 2021
1 parent af0664c commit 201ad45
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions go.mod
Expand Up @@ -3,6 +3,7 @@ module github.com/hatsu38/postman-tui
go 1.16

require (
github.com/atotto/clipboard v0.1.4
github.com/gdamore/tcell/v2 v2.4.0
github.com/rivo/tview v0.0.0-20210624165335-29d673af0ce2
)
2 changes: 2 additions & 0 deletions 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/gdamore/encoding v1.0.0 h1:+7OoQ1Bc6eTm5niUzBa0Ctsh6JbMW6Ra+YNuAtDBdko=
github.com/gdamore/encoding v1.0.0/go.mod h1:alR0ol34c49FCSBLjhosxzcPHQbf2trDkoo5dl+VrEg=
github.com/gdamore/tcell/v2 v2.3.3/go.mod h1:cTTuF84Dlj/RqmaCIV5p4w8uG1zWdk0SF6oBpwHp4fU=
Expand Down
2 changes: 1 addition & 1 deletion gui/navigate.go
Expand Up @@ -16,7 +16,7 @@ func newNavigate() *navigate {
keybindings: map[string]string{
"http": " Tab: move url field, Enter: change http method",
"url": " Tab: move Response Field, Enter: http request",
"resField": " Tab: move params table, Enter: set body paramater",
"resField": " Tab: move params table, Enter: Copy response text to clipboard",
"paramsTable": " Tab: move body table, Enter: set query paramater",
"bodyTable": " Tab: move params table, Enter: set body paramater",
},
Expand Down
4 changes: 4 additions & 0 deletions gui/res_text_view.go
@@ -1,6 +1,7 @@
package gui

import (
"github.com/atotto/clipboard"
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
)
Expand Down Expand Up @@ -36,6 +37,9 @@ func newResTextView() *resTestView {
func (t *resTestView) setFunc(g *Gui) {
t.SetDoneFunc(func(key tcell.Key) {
switch key {
case tcell.KeyEnter:
txt := t.GetText(true)
clipboard.WriteAll(txt)
case tcell.KeyTab:
g.ToFocus()
}
Expand Down

0 comments on commit 201ad45

Please sign in to comment.