forked from ying32/govcl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clipboarddef.go
61 lines (51 loc) · 1.52 KB
/
clipboarddef.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//----------------------------------------
//
// Copyright © ying32. All Rights Reserved.
//
// Licensed under Apache License 2.0
//
//----------------------------------------
package vcl
import (
. "github.com/ying32/govcl/vcl/api"
"github.com/ying32/govcl/vcl/types"
)
func SetClipboard(newClipboard IObject) *TClipboard {
return AsClipboard(DSetClipboard(CheckPtr(newClipboard)))
}
func RegisterClipboardFormat(aFormat string) types.TClipboardFormat {
return DRegisterClipboardFormat(aFormat)
}
func PredefinedClipboardFormat(aFormat types.TPredefinedClipboardFormat) types.TClipboardFormat {
return DPredefinedClipboardFormat(aFormat)
}
func (c *TClipboard) HasFormat(aFormatID types.TClipboardFormat) bool {
return Clipboard_HasFormat(c.instance, aFormatID)
}
func (c *TClipboard) GetAsHtml(ExtractFragmentOnly bool) string {
return Clipboard_GetAsHtml(c.instance, ExtractFragmentOnly)
}
func (c *TClipboard) GetTextBuf(Buffer *string, BufSize int32) int32 {
return Clipboard_GetTextBuf(c.instance, Buffer, BufSize)
}
func (c *TClipboard) AsText() string {
mem := NewMemoryStream()
defer mem.Free()
if c.GetFormat(PredefinedClipboardFormat(types.PcfText), mem) {
size := mem.Size()
mem.SetPosition(0)
if size > 0 {
n, buff := mem.Read(int32(size))
if n > 0 && buff[len(buff)-1] == 0 {
return string(buff[:len(buff)-1])
} else {
return string(buff)
}
}
}
return ""
//return Clipboard_GetAsText(c.instance)
}
func (c *TClipboard) SetAsText(value string) {
Clipboard_SetAsText(c.instance, value)
}