Add callback support to console
This commit is contained in:
parent
800877cc7e
commit
f73feba12a
1 changed files with 7 additions and 2 deletions
|
|
@ -4,7 +4,7 @@ import macros, strutils
|
||||||
|
|
||||||
|
|
||||||
type
|
type
|
||||||
PrintCallback* = proc (con: pointer; c: cint): bool
|
PrintCallback* = proc (con: Console; c: char): bool
|
||||||
|
|
||||||
Font* = ref ConsoleFont
|
Font* = ref ConsoleFont
|
||||||
|
|
||||||
|
|
@ -65,7 +65,12 @@ proc toConsole(pconsole: ptr PrintConsole): Console =
|
||||||
result.fg = pconsole.fg
|
result.fg = pconsole.fg
|
||||||
result.bg = pconsole.bg
|
result.bg = pconsole.bg
|
||||||
result.flags = {}
|
result.flags = {}
|
||||||
#result.printCharCallback = cast[PrintCallback](pconsole.PrintChar)
|
|
||||||
|
result.pcon.PrintChar = proc (con: pointer, c: cint): bool {.cdecl.} =
|
||||||
|
let console = cast[ptr PrintConsole](con).toConsole()
|
||||||
|
if not console.printCharCallback.isNil:
|
||||||
|
return console.printCharCallback(console, c.char)
|
||||||
|
|
||||||
result.initialised = pconsole.consoleInitialised
|
result.initialised = pconsole.consoleInitialised
|
||||||
|
|
||||||
proc setFont*(console: Console; font: Font) =
|
proc setFont*(console: Console; font: Font) =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue