Skip to content

Commit 9735f61

Browse files
authored
Merge pull request #492 from noborus/renameFunc
Improved and changed the copy/paste function name
2 parents 754b1fb + d4815a2 commit 9735f61

File tree

4 files changed

+19
-19
lines changed

4 files changed

+19
-19
lines changed

oviewer/event.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ func (root *Root) eventLoop(ctx context.Context, quitChan chan<- struct{}) {
4545
case *eventCloseDocument:
4646
root.closeDocument()
4747
case *eventCopySelect:
48-
root.putClipboard(ctx)
48+
root.copyToClipboard(ctx)
4949
case *eventPaste:
50-
root.getClipboard(ctx)
50+
root.pasteFromClipboard(ctx)
5151
case *eventViewMode:
5252
root.setViewMode(ev.value)
5353
case *eventInputSearch:

oviewer/logdoc.go

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,16 @@ func (m *Document) Write(p []byte) (int, error) {
2929
s := m.store
3030
chunk := s.chunkForAdd(false, s.size)
3131
s.append(chunk, true, p)
32-
if len(chunk.lines) >= ChunkSize {
33-
chunk = NewChunk(s.size)
34-
s.mu.Lock()
35-
if len(s.chunks) > 2 {
36-
s.chunks[len(s.chunks)-2].lines = nil
37-
atomic.StoreInt32(&s.startNum, int32(ChunkSize*(len(s.chunks)-1)))
38-
}
39-
s.chunks = append(s.chunks, chunk)
40-
s.mu.Unlock()
32+
if len(chunk.lines) < ChunkSize {
33+
return len(p), nil
4134
}
35+
chunk = NewChunk(s.size)
36+
s.mu.Lock()
37+
if len(s.chunks) > 2 {
38+
s.chunks[len(s.chunks)-2].lines = nil
39+
atomic.StoreInt32(&s.startNum, int32(ChunkSize*(len(s.chunks)-1)))
40+
}
41+
s.chunks = append(s.chunks, chunk)
42+
s.mu.Unlock()
4243
return len(p), nil
4344
}

oviewer/mouse.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ func (root *Root) sendCopySelect() {
152152
root.postEvent(ev)
153153
}
154154

155-
// putClipboard writes the selection to the clipboard.
156-
func (root *Root) putClipboard(_ context.Context) {
155+
// copyToClipboard writes the selection to the clipboard.
156+
func (root *Root) copyToClipboard(_ context.Context) {
157157
x1 := root.x1
158158
x2 := root.x2
159159
y1 := root.y1
@@ -170,15 +170,15 @@ func (root *Root) putClipboard(_ context.Context) {
170170
}
171171
buff, err := root.rangeToString(x1, y1, x2, y2)
172172
if err != nil {
173-
root.debugMessage(fmt.Sprintf("putClipboard: %s", err.Error()))
173+
root.debugMessage(fmt.Sprintf("copyToClipboard: %s", err.Error()))
174174
return
175175
}
176176

177177
if len(buff) == 0 {
178178
return
179179
}
180180
if err := clipboard.WriteAll(buff); err != nil {
181-
log.Printf("putClipboard: %v", err)
181+
log.Printf("copyToClipboard: %v", err)
182182
}
183183
root.setMessage("Copy")
184184
}
@@ -201,8 +201,8 @@ func (root *Root) sendPaste() {
201201
root.postEvent(ev)
202202
}
203203

204-
// getClipboard writes a string from the clipboard.
205-
func (root *Root) getClipboard(_ context.Context) {
204+
// pasteFromClipboard writes a string from the clipboard.
205+
func (root *Root) pasteFromClipboard(_ context.Context) {
206206
input := root.input
207207
switch input.Event.Mode() {
208208
case Normal:
@@ -211,7 +211,7 @@ func (root *Root) getClipboard(_ context.Context) {
211211

212212
str, err := clipboard.ReadAll()
213213
if err != nil {
214-
log.Printf("getClipboard: %v", err)
214+
log.Printf("pasteFromClipboard: %v", err)
215215
return
216216
}
217217

oviewer/search.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ func condRegexpCompile(in string) *regexp.Regexp {
224224
}
225225

226226
// searchPosition returns the position where the search in the argument line matched.
227-
// searchPosition uses cache.
228227
func (root *Root) searchPosition(lN int, str string) [][]int {
229228
return root.searcher.FindAll(str)
230229
}

0 commit comments

Comments
 (0)