mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 01:45:36 +00:00
app: move system.ClipboardEvent to its own package
API change. Update your code with gofmt rule and goimports: gofmt -r "system.ClipboardEvent -> clipboard.Event" goimports Signed-off-by: Inkeliz <inkeliz@inkeliz.com> Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -52,6 +52,7 @@ import (
|
||||
"unsafe"
|
||||
|
||||
"gioui.org/f32"
|
||||
"gioui.org/io/clipboard"
|
||||
"gioui.org/io/key"
|
||||
"gioui.org/io/pointer"
|
||||
"gioui.org/io/system"
|
||||
@@ -647,7 +648,7 @@ func (w *window) ReadClipboard() {
|
||||
return
|
||||
}
|
||||
content := goString(env, C.jstring(c))
|
||||
w.callbacks.Event(system.ClipboardEvent{Text: content})
|
||||
w.callbacks.Event(clipboard.Event{Text: content})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import (
|
||||
"unsafe"
|
||||
|
||||
"gioui.org/f32"
|
||||
"gioui.org/io/clipboard"
|
||||
"gioui.org/io/key"
|
||||
"gioui.org/io/pointer"
|
||||
"gioui.org/io/system"
|
||||
@@ -223,7 +224,7 @@ func onTouch(last C.int, view, touchRef C.CFTypeRef, phase C.NSInteger, x, y C.C
|
||||
func (w *window) ReadClipboard() {
|
||||
runOnMain(func() {
|
||||
content := nsstringToString(C.gio_readClipboard())
|
||||
w.w.Event(system.ClipboardEvent{Text: content})
|
||||
w.w.Event(clipboard.Event{Text: content})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
"unicode/utf8"
|
||||
|
||||
"gioui.org/f32"
|
||||
"gioui.org/io/clipboard"
|
||||
"gioui.org/io/key"
|
||||
"gioui.org/io/pointer"
|
||||
"gioui.org/io/system"
|
||||
@@ -59,7 +60,7 @@ func NewWindow(win Callbacks, opts *Options) error {
|
||||
})
|
||||
w.clipboardCallback = w.funcOf(func(this js.Value, args []js.Value) interface{} {
|
||||
content := args[0].String()
|
||||
win.Event(system.ClipboardEvent{Text: content})
|
||||
win.Event(clipboard.Event{Text: content})
|
||||
return nil
|
||||
})
|
||||
w.addEventListeners()
|
||||
|
||||
@@ -14,6 +14,7 @@ import (
|
||||
"unsafe"
|
||||
|
||||
"gioui.org/f32"
|
||||
"gioui.org/io/clipboard"
|
||||
"gioui.org/io/key"
|
||||
"gioui.org/io/pointer"
|
||||
"gioui.org/io/system"
|
||||
@@ -108,7 +109,7 @@ func (w *window) contextView() C.CFTypeRef {
|
||||
func (w *window) ReadClipboard() {
|
||||
runOnMain(func() {
|
||||
content := nsstringToString(C.gio_readClipboard())
|
||||
w.w.Event(system.ClipboardEvent{Text: content})
|
||||
w.w.Event(clipboard.Event{Text: content})
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"gioui.org/app/internal/xkb"
|
||||
"gioui.org/f32"
|
||||
"gioui.org/internal/fling"
|
||||
"gioui.org/io/clipboard"
|
||||
"gioui.org/io/key"
|
||||
"gioui.org/io/pointer"
|
||||
"gioui.org/io/system"
|
||||
@@ -1134,14 +1135,14 @@ func (w *window) process() {
|
||||
r, err := w.disp.readClipboard()
|
||||
// Send empty responses on unavailable clipboards or errors.
|
||||
if r == nil || err != nil {
|
||||
w.w.Event(system.ClipboardEvent{})
|
||||
w.w.Event(clipboard.Event{})
|
||||
return
|
||||
}
|
||||
// Don't let slow clipboard transfers block event loop.
|
||||
go func() {
|
||||
defer r.Close()
|
||||
data, _ := ioutil.ReadAll(r)
|
||||
w.w.Event(system.ClipboardEvent{Text: string(data)})
|
||||
w.w.Event(clipboard.Event{Text: string(data)})
|
||||
}()
|
||||
}
|
||||
if writeClipboard != nil {
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"gioui.org/unit"
|
||||
|
||||
"gioui.org/f32"
|
||||
"gioui.org/io/clipboard"
|
||||
"gioui.org/io/key"
|
||||
"gioui.org/io/pointer"
|
||||
"gioui.org/io/system"
|
||||
@@ -513,7 +514,7 @@ func (w *window) readClipboard() error {
|
||||
hdr.Len = n
|
||||
content := string(utf16.Decode(u16))
|
||||
go func() {
|
||||
w.w.Event(system.ClipboardEvent{Text: content})
|
||||
w.w.Event(clipboard.Event{Text: content})
|
||||
}()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import (
|
||||
"unsafe"
|
||||
|
||||
"gioui.org/f32"
|
||||
"gioui.org/io/clipboard"
|
||||
"gioui.org/io/key"
|
||||
"gioui.org/io/pointer"
|
||||
"gioui.org/io/system"
|
||||
@@ -434,7 +435,7 @@ func (h *x11EventHandler) handleEvents() bool {
|
||||
break
|
||||
}
|
||||
str := C.GoStringN((*C.char)(unsafe.Pointer(text.value)), C.int(text.nitems))
|
||||
w.w.Event(system.ClipboardEvent{Text: str})
|
||||
w.w.Event(clipboard.Event{Text: str})
|
||||
case C.SelectionRequest:
|
||||
cevt := (*C.XSelectionRequestEvent)(unsafe.Pointer(xev))
|
||||
if cevt.selection != w.atoms.clipboard || cevt.property == C.None {
|
||||
|
||||
Reference in New Issue
Block a user