Skip to content

Commit 21357e8

Browse files
committed
Convert line ending.
1 parent ce8410a commit 21357e8

File tree

3 files changed

+15
-7
lines changed

3 files changed

+15
-7
lines changed

client/client.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,16 @@ import (
1515
)
1616

1717
type client struct {
18-
host string
19-
port int
18+
host string
19+
port int
20+
lineEnding string
2021
}
2122

2223
func New(c *lemon.CLI) *client {
2324
return &client{
24-
host: c.Host,
25-
port: c.Port,
25+
host: c.Host,
26+
port: c.Port,
27+
lineEnding: c.LineEnding,
2628
}
2729
}
2830

@@ -95,7 +97,7 @@ func (c *client) Paste() (string, error) {
9597
return "", err
9698
}
9799

98-
return resp, nil
100+
return lemon.ConvertLineEnding(resp, c.lineEnding), nil
99101
}
100102

101103
func (c *client) Copy(text string) error {

server/clipboard.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package server
22

3-
import "github.com/atotto/clipboard"
3+
import (
4+
"github.com/atotto/clipboard"
5+
"github.com/pocke/lemonade/lemon"
6+
)
47

58
type Clipboard struct{}
69

710
func (_ *Clipboard) Copy(text string, _ *struct{}) error {
811
<-connCh
9-
return clipboard.WriteAll(text)
12+
return clipboard.WriteAll(lemon.ConvertLineEnding(text, lineEndingOpt))
1013
}
1114

1215
func (_ *Clipboard) Paste(_ struct{}, resp *string) error {

server/server.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,12 @@ import (
1212

1313
var connCh = make(chan net.Conn, 1)
1414

15+
var lineEndingOpt string
16+
1517
func Serve(c *lemon.CLI) error {
1618
port := c.Port
1719
allowIP := c.Allow
20+
lineEndingOpt = c.LineEnding
1821
ra, err := iprange.New(allowIP)
1922
if err != nil {
2023
return err

0 commit comments

Comments
 (0)