📄 clipboard.zc
字号:
//[c]Clipboard Objects
//[c]
//[of]:license
//[c] Code Browser - a folding text editor for programmers
//[c] Copyright (C) 2003-07 Marc Kerbiquet
//[c]
//[c] This program is free software; you can redistribute it and/or modify
//[c] it under the terms of the GNU General Public License as published by
//[c] the Free Software Foundation; either version 2 of the License, or
//[c] (at your option) any later version.
//[c]
//[c] This program is distributed in the hope that it will be useful,
//[c] but WITHOUT ANY WARRANTY; without even the implied warranty of
//[c] MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//[c] GNU General Public License for more details.
//[c]
//[c] You should have received a copy of the GNU General Public License
//[c] along with this program; if not, write to the Free Software
//[c] Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//[cf]
//[of]:imports
//[c]
import "base/types"
import "base/memory"
import "base/memory-buffer"
//[c]
import "win32/windows"
//[cf]
//[of]:constants
//[c]
public equ cf text = CF_TEXT
//[cf]
//[of]:structures
//[c]
public typedef clipboard format = UINT
//[cf]
//[c]
//[of]:initialize
//[of]:register clipboard format (name)
//[c]Register a private clipboard format
//[c]
public func register clipboard format (name: string)
return RegisterClipboardFormatA (name)
end
//[cf]
//[cf]
//[of]:enumerating
//[of]:each clipboard format
//[c]Enumerates all formats available in the clipboard
//[c]
public equ each clipboard format
def fmt = 0 : UINT
if OpenClipboard (nil) <> 0
repeat
fmt = EnumClipboardFormats (fmt)
if fmt == 0:d
break
end
yield (fmt : clipboard format)
end
CloseClipboard
end
end
//[cf]
//[cf]
//[of]:accessing
//[of]:get clipboard data (clipboard format)
//[c]Puts the content of the clipboard into the memory buffer
//[c]
public func get clipboard data (f: clipboard format, return b: memory buffer)
initialize (b)
def handle = GetClipboardData (f)
def buf = GlobalLock (handle)
append (b, buf : [] byte, GlobalSize (handle))
GlobalUnlock (handle)
end
//[cf]
//[of]:set clipboard data (clipboard format, base, size)
//[c]
public func set clipboard data (m: clipboard format, buf: [] byte, size: size)
def alloc = size
if m == cf text
alloc += 1
end
def handle = GlobalAlloc (GMEM_MOVEABLE|GMEM_DDESHARE, alloc)
def p = GlobalLock (handle)
copy (p, buf, size)
if m == cf text
p : [] char [size] = nul char
end
GlobalUnlock (handle)
SetClipboardData (m, handle)
end
//[cf]
//[of]:set clipboard content
//[c]Sets the clipboard content
//[c]
//[c] The clipboard is emptied and a parameter blocks must set
//[c] its new content.
//[c]
//[c]Example of use:
//[c]
//[c] set clipboard content
//[c] set clipboard data (format1, base1, size1)
//[c] set clipboard data (format2, base2, size2)
//[c] end
//[c]
public equ set clipboard content
OpenClipboard (nil)
EmptyClipboard
yield
CloseClipboard
end
//[cf]
//[cf]
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -