Skip to content

Commit

Permalink
Merge pull request #492 from noborus/renameFunc
Browse files Browse the repository at this point in the history
Improved and changed the copy/paste function name
  • Loading branch information
noborus authored Feb 1, 2024
2 parents 754b1fb + d4815a2 commit 9735f61
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 19 deletions.
4 changes: 2 additions & 2 deletions oviewer/event.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ func (root *Root) eventLoop(ctx context.Context, quitChan chan<- struct{}) {
case *eventCloseDocument:
root.closeDocument()
case *eventCopySelect:
root.putClipboard(ctx)
root.copyToClipboard(ctx)
case *eventPaste:
root.getClipboard(ctx)
root.pasteFromClipboard(ctx)
case *eventViewMode:
root.setViewMode(ev.value)
case *eventInputSearch:
Expand Down
19 changes: 10 additions & 9 deletions oviewer/logdoc.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@ func (m *Document) Write(p []byte) (int, error) {
s := m.store
chunk := s.chunkForAdd(false, s.size)
s.append(chunk, true, p)
if len(chunk.lines) >= ChunkSize {
chunk = NewChunk(s.size)
s.mu.Lock()
if len(s.chunks) > 2 {
s.chunks[len(s.chunks)-2].lines = nil
atomic.StoreInt32(&s.startNum, int32(ChunkSize*(len(s.chunks)-1)))
}
s.chunks = append(s.chunks, chunk)
s.mu.Unlock()
if len(chunk.lines) < ChunkSize {
return len(p), nil
}
chunk = NewChunk(s.size)
s.mu.Lock()
if len(s.chunks) > 2 {
s.chunks[len(s.chunks)-2].lines = nil
atomic.StoreInt32(&s.startNum, int32(ChunkSize*(len(s.chunks)-1)))
}
s.chunks = append(s.chunks, chunk)
s.mu.Unlock()
return len(p), nil
}
14 changes: 7 additions & 7 deletions oviewer/mouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ func (root *Root) sendCopySelect() {
root.postEvent(ev)
}

// putClipboard writes the selection to the clipboard.
func (root *Root) putClipboard(_ context.Context) {
// copyToClipboard writes the selection to the clipboard.
func (root *Root) copyToClipboard(_ context.Context) {
x1 := root.x1
x2 := root.x2
y1 := root.y1
Expand All @@ -170,15 +170,15 @@ func (root *Root) putClipboard(_ context.Context) {
}
buff, err := root.rangeToString(x1, y1, x2, y2)
if err != nil {
root.debugMessage(fmt.Sprintf("putClipboard: %s", err.Error()))
root.debugMessage(fmt.Sprintf("copyToClipboard: %s", err.Error()))
return
}

if len(buff) == 0 {
return
}
if err := clipboard.WriteAll(buff); err != nil {
log.Printf("putClipboard: %v", err)
log.Printf("copyToClipboard: %v", err)
}
root.setMessage("Copy")
}
Expand All @@ -201,8 +201,8 @@ func (root *Root) sendPaste() {
root.postEvent(ev)
}

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

str, err := clipboard.ReadAll()
if err != nil {
log.Printf("getClipboard: %v", err)
log.Printf("pasteFromClipboard: %v", err)
return
}

Expand Down
1 change: 0 additions & 1 deletion oviewer/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ func condRegexpCompile(in string) *regexp.Regexp {
}

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

0 comments on commit 9735f61

Please sign in to comment.