gemini-browser

A text-based gemini browser
git clone git://git.laack.co/gemini-browser.git
Log | Files | Refs | README

interrupt.go (1228B)


      1 // Copyright 2015 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 // EventInterrupt is a generic wakeup event.  Its can be used to
     22 // to request a redraw.  It can carry an arbitrary payload, as well.
     23 type EventInterrupt struct {
     24 	t time.Time
     25 	v interface{}
     26 }
     27 
     28 // When returns the time when this event was created.
     29 func (ev *EventInterrupt) When() time.Time {
     30 	return ev.t
     31 }
     32 
     33 // Data is used to obtain the opaque event payload.
     34 func (ev *EventInterrupt) Data() interface{} {
     35 	return ev.v
     36 }
     37 
     38 // NewEventInterrupt creates an EventInterrupt with the given payload.
     39 func NewEventInterrupt(data interface{}) *EventInterrupt {
     40 	return &EventInterrupt{t: time.Now(), v: data}
     41 }