Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions WhiteStagEditor/sdlengine.nim
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
when defined(windows):
import windows
else:
quit "Currently only windows is supported!"
#quit "Currently only windows is supported!"
import sdl_ttf
import sdl

Expand Down Expand Up @@ -327,16 +327,17 @@ proc pollEvent*(self: PSdlEngine): event.PEvent =

proc readClipBoard*(self: PSdlEngine): PUTFString =
result = utf""
if OpenClipboard(0) != 0:
let clip = GetClipboardData(CF_UNICODETEXT)
var clipPtr = cast[TAddress](clip)
while true:
let rune = TRune(cast[PWideChar](clipPtr)[])
if rune == TRune(0):
break
result.append(rune)
clipPtr = clipPtr + sizeof(int16)
discard CloseClipboard()
when defined(Windows):
if OpenClipboard(0) != 0:
let clip = GetClipboardData(CF_UNICODETEXT)
var clipPtr = cast[TAddress](clip)
while true:
let rune = TRune(cast[PWideChar](clipPtr)[])
if rune == TRune(0):
break
result.append(rune)
clipPtr = clipPtr + sizeof(int16)
discard CloseClipboard()

when isMainModule:
import unittest
Expand All @@ -356,4 +357,4 @@ when isMainModule:

let result2 = engine.processSdlEvent(cast[ptr sdl.TEvent](addr mouseButtonEvent))
check result.kind == eventMouseButtonDown
check result2.doubleClick
check result2.doubleClick