...

Source file src/github.com/gdamore/tcell/v2/paste.go

Documentation: github.com/gdamore/tcell/v2

     1  // Copyright 2020 The TCell Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use file except in compliance with the License.
     5  // You may obtain a copy of the license at
     6  //
     7  //    http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package tcell
    16  
    17  import (
    18  	"time"
    19  )
    20  
    21  // EventPaste is used to mark the start and end of a bracketed paste.
    22  // An event with .Start() true will be sent to mark the start.
    23  // Then a number of keys will be sent to indicate that the content
    24  // is pasted in.  At the end, an event with .Start() false will be sent.
    25  type EventPaste struct {
    26  	start bool
    27  	t     time.Time
    28  }
    29  
    30  // When returns the time when this EventPaste was created.
    31  func (ev *EventPaste) When() time.Time {
    32  	return ev.t
    33  }
    34  
    35  // Start returns true if this is the start of a paste.
    36  func (ev *EventPaste) Start() bool {
    37  	return ev.start
    38  }
    39  
    40  // End returns true if this is the end of a paste.
    41  func (ev *EventPaste) End() bool {
    42  	return !ev.start
    43  }
    44  
    45  // NewEventPaste returns a new EventPaste.
    46  func NewEventPaste(start bool) *EventPaste {
    47  	return &EventPaste{t: time.Now(), start: start}
    48  }
    49  

View as plain text