September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -0,0 +1,25 @@
|
|||
// Kotlin Native version 0.3
|
||||
|
||||
import kotlinx.cinterop.*
|
||||
import win32.*
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
for (i in 0 until (80 * 25)) print("A") // fill 80 x 25 console with 'A's
|
||||
println()
|
||||
memScoped {
|
||||
val conOut = GetStdHandle(-11)
|
||||
val info = alloc<CONSOLE_SCREEN_BUFFER_INFO>()
|
||||
val pos = alloc<COORD>()
|
||||
GetConsoleScreenBufferInfo(conOut, info.ptr)
|
||||
pos.X = (info.srWindow.Left + 3).toShort() // column number 3 of display window
|
||||
pos.Y = (info.srWindow.Top + 6).toShort() // row number 6 of display window
|
||||
val c = alloc<wchar_tVar>()
|
||||
val len = alloc<IntVar>()
|
||||
ReadConsoleOutputCharacterW(conOut, c.ptr, 1, pos.readValue(), len.ptr)
|
||||
if (len.value == 1) {
|
||||
val ch = c.value.toChar()
|
||||
println("The character at column 3, row 6 is '$ch'")
|
||||
}
|
||||
else println("Something went wrong!")
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
--
|
||||
-- demo\rosetta\Positional_read.exw
|
||||
-- ================================
|
||||
--
|
||||
position(6,1) -- line 6 column 1 (1-based)
|
||||
puts(1,"abcdef")
|
||||
integer {ch,attr} = get_screen_char(6,3)
|
||||
printf(1,"\n\n=>%c",ch)
|
||||
{} = wait_key()
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
;;; Type definitions and constants
|
||||
|
||||
(typedef BOOL (enum BOOL FALSE TRUE))
|
||||
(typedef HANDLE cptr)
|
||||
(typedef WCHAR wchar)
|
||||
(typedef DWORD uint32)
|
||||
(typedef WORD uint16)
|
||||
(typedef SHORT short)
|
||||
|
||||
(typedef COORD
|
||||
(struct COORD
|
||||
(X SHORT)
|
||||
(Y SHORT)))
|
||||
|
||||
(typedef SMALL_RECT
|
||||
(struct SMALL_RECT
|
||||
(Left SHORT)
|
||||
(Top SHORT)
|
||||
(Right SHORT)
|
||||
(Bottom SHORT)))
|
||||
|
||||
(typedef CONSOLE_SCREEN_BUFFER_INFO
|
||||
(struct CONSOLE_SCREEN_BUFFER_INFO
|
||||
(dwSize COORD)
|
||||
(dwCursorPosition COORD)
|
||||
(wAttributes WORD)
|
||||
(srWindow SMALL_RECT)
|
||||
(dwMaximumWindowSize COORD)))
|
||||
|
||||
;;; Various constants
|
||||
|
||||
(defvarl STD_INPUT_HANDLE (- #x100000000 10))
|
||||
(defvarl STD_OUTPUT_HANDLE (- #x100000000 11))
|
||||
(defvarl STD_ERROR_HANDLE (- #x100000000 12))
|
||||
|
||||
(defvarl NULL cptr-null)
|
||||
(defvarl INVALID_HANDLE_VALUE (cptr-int -1))
|
||||
|
||||
;;; Foreign Function Bindings
|
||||
|
||||
(with-dyn-lib "kernel32.dll"
|
||||
(deffi GetStdHandle "GetStdHandle" HANDLE (DWORD))
|
||||
(deffi GetConsoleScreenBufferInfo "GetConsoleScreenBufferInfo"
|
||||
BOOL (HANDLE (ptr-out CONSOLE_SCREEN_BUFFER_INFO)))
|
||||
(deffi ReadConsoleOutputCharacter "ReadConsoleOutputCharacterW"
|
||||
BOOL (HANDLE (ptr-out (array 1 WCHAR))
|
||||
DWORD COORD (ptr-out (array 1 DWORD)))))
|
||||
|
||||
;;; Now the character at <2, 5> -- column 3, row 6.
|
||||
|
||||
(let ((console-handle (GetStdHandle STD_OUTPUT_HANDLE)))
|
||||
(when (equal console-handle INVALID_HANDLE_VALUE)
|
||||
(error "couldn't get console handle"))
|
||||
|
||||
(let* ((cinfo (new CONSOLE_SCREEN_BUFFER_INFO))
|
||||
(getinfo-ok (GetConsoleScreenBufferInfo console-handle cinfo))
|
||||
(coord (if getinfo-ok
|
||||
^#S(COORD X ,(+ 2 cinfo.srWindow.Left)
|
||||
Y ,(+ 5 cinfo.srWindow.Top))
|
||||
#S(COORD X 0 Y 0)))
|
||||
(chars (vector 1))
|
||||
(nread (vector 1))
|
||||
(read-ok (ReadConsoleOutputCharacter console-handle chars
|
||||
1 coord nread)))
|
||||
(when (eq getinfo-ok 'FALSE)
|
||||
(error "GetConsoleScreenBufferInfo failed"))
|
||||
(prinl cinfo)
|
||||
(when (eq read-ok 'FALSE)
|
||||
(error "ReadConsoleOutputCharacter failed"))
|
||||
(unless (plusp [nread 0])
|
||||
(error "ReadConsoleOutputCharacter read zero characters"))
|
||||
(format t "character is ~s\n" [chars 0])))
|
||||
Loading…
Add table
Add a link
Reference in a new issue