mirror of
https://github.com/vlang/v.git
synced 2025-09-14 09:56:16 -04:00
builtin: windows definitions
This commit is contained in:
parent
1efdb88c55
commit
c947c140ee
@ -7,7 +7,25 @@ module builtin
|
|||||||
// g_original_codepage - used to restore the original windows console code page when exiting
|
// g_original_codepage - used to restore the original windows console code page when exiting
|
||||||
__global g_original_codepage = u32(0)
|
__global g_original_codepage = u32(0)
|
||||||
|
|
||||||
type C.BOOL = bool
|
pub type C.BOOL = bool
|
||||||
|
|
||||||
|
pub struct C.HINSTANCE {}
|
||||||
|
|
||||||
|
pub struct C.HICON {}
|
||||||
|
|
||||||
|
pub struct C.HCURSOR {}
|
||||||
|
|
||||||
|
pub struct C.HCURSOR {}
|
||||||
|
|
||||||
|
pub struct C.HBRUSH {}
|
||||||
|
|
||||||
|
pub struct C.HWND {}
|
||||||
|
|
||||||
|
pub struct C.HGLOBAL {}
|
||||||
|
|
||||||
|
pub struct C.HANDLE {}
|
||||||
|
|
||||||
|
pub struct C.LRESULT {}
|
||||||
|
|
||||||
// utf8 to stdout needs C.SetConsoleOutputCP(cp_utf8)
|
// utf8 to stdout needs C.SetConsoleOutputCP(cp_utf8)
|
||||||
fn C.GetConsoleOutputCP() u32
|
fn C.GetConsoleOutputCP() u32
|
||||||
|
@ -110,7 +110,7 @@ fn new_clipboard() &Clipboard {
|
|||||||
|
|
||||||
// check_availability returns true if the clipboard is ready to be used.
|
// check_availability returns true if the clipboard is ready to be used.
|
||||||
pub fn (cb &Clipboard) check_availability() bool {
|
pub fn (cb &Clipboard) check_availability() bool {
|
||||||
return cb.hwnd != C.HWND(C.NULL)
|
return cb.hwnd != unsafe { nil }
|
||||||
}
|
}
|
||||||
|
|
||||||
// has_ownership returns true if the contents of
|
// has_ownership returns true if the contents of
|
||||||
@ -143,7 +143,7 @@ fn to_wide(text string) C.HGLOBAL {
|
|||||||
len_required := C.MultiByteToWideChar(clipboard.cp_utf8, C.MB_ERR_INVALID_CHARS, text.str,
|
len_required := C.MultiByteToWideChar(clipboard.cp_utf8, C.MB_ERR_INVALID_CHARS, text.str,
|
||||||
text.len + 1, C.NULL, 0)
|
text.len + 1, C.NULL, 0)
|
||||||
buf := C.GlobalAlloc(C.GMEM_MOVEABLE, i64(sizeof(u16)) * len_required)
|
buf := C.GlobalAlloc(C.GMEM_MOVEABLE, i64(sizeof(u16)) * len_required)
|
||||||
if buf != C.HGLOBAL(C.NULL) {
|
if buf != unsafe { nil } {
|
||||||
mut locked := &u16(C.GlobalLock(buf))
|
mut locked := &u16(C.GlobalLock(buf))
|
||||||
C.MultiByteToWideChar(clipboard.cp_utf8, C.MB_ERR_INVALID_CHARS, text.str, text.len + 1,
|
C.MultiByteToWideChar(clipboard.cp_utf8, C.MB_ERR_INVALID_CHARS, text.str, text.len + 1,
|
||||||
locked, len_required)
|
locked, len_required)
|
||||||
@ -166,7 +166,7 @@ pub fn (mut cb Clipboard) set_text(text string) bool {
|
|||||||
} else {
|
} else {
|
||||||
// EmptyClipboard must be called to properly update clipboard ownership
|
// EmptyClipboard must be called to properly update clipboard ownership
|
||||||
C.EmptyClipboard()
|
C.EmptyClipboard()
|
||||||
if C.SetClipboardData(C.CF_UNICODETEXT, buf) == C.HANDLE(C.NULL) {
|
if C.SetClipboardData(C.CF_UNICODETEXT, buf) == unsafe { nil } {
|
||||||
println('SetClipboardData: Failed.')
|
println('SetClipboardData: Failed.')
|
||||||
C.CloseClipboard()
|
C.CloseClipboard()
|
||||||
C.GlobalFree(buf)
|
C.GlobalFree(buf)
|
||||||
@ -187,7 +187,7 @@ pub fn (mut cb Clipboard) get_text() string {
|
|||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
h_data := C.GetClipboardData(C.CF_UNICODETEXT)
|
h_data := C.GetClipboardData(C.CF_UNICODETEXT)
|
||||||
if h_data == C.HANDLE(C.NULL) {
|
if h_data == unsafe { nil } {
|
||||||
C.CloseClipboard()
|
C.CloseClipboard()
|
||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@ $if gcboehm ? {
|
|||||||
#flag -l ws2_32 -l crypt32 -l secur32 -l user32
|
#flag -l ws2_32 -l crypt32 -l secur32 -l user32
|
||||||
#include "vschannel.c"
|
#include "vschannel.c"
|
||||||
|
|
||||||
|
struct C.TlsContext {}
|
||||||
|
|
||||||
fn C.new_tls_context() C.TlsContext
|
fn C.new_tls_context() C.TlsContext
|
||||||
|
|
||||||
fn (req &Request) ssl_do(port int, method Method, host_name string, path string) !Response {
|
fn (req &Request) ssl_do(port int, method Method, host_name string, path string) !Response {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user