Update xutil.nim

This commit is contained in:
Billingsly Wetherfordshire 2013-10-08 18:04:58 -07:00
commit fd6f806194

View file

@ -1,6 +1,6 @@
import import
x, xlib, keysym x, xlib, keysym, unsigned
#const #const
# libX11* = "libX11.so" # libX11* = "libX11.so"
@ -356,7 +356,7 @@ proc XWMGeometry*(para1: PDisplay, para2: cint, para3: cstring, para4: cstring,
dynlib: libX11, importc.} dynlib: libX11, importc.}
proc XXorRegion*(para1: TRegion, para2: TRegion, para3: TRegion): cint{.cdecl, proc XXorRegion*(para1: TRegion, para2: TRegion, para3: TRegion): cint{.cdecl,
dynlib: libX11, importc.} dynlib: libX11, importc.}
when defined(MACROS): #when defined(MACROS):
proc XDestroyImage*(ximage: PXImage): cint proc XDestroyImage*(ximage: PXImage): cint
proc XGetPixel*(ximage: PXImage, x, y: cint): culong proc XGetPixel*(ximage: PXImage, x, y: cint): culong
proc XPutPixel*(ximage: PXImage, x, y: cint, pixel: culong): cint proc XPutPixel*(ximage: PXImage, x, y: cint, pixel: culong): cint
@ -373,40 +373,42 @@ when defined(MACROS):
#function XStringToContext(_string : Pchar) : TXContext; #function XStringToContext(_string : Pchar) : TXContext;
# implementation # implementation
when defined(MACROS): #when defined(MACROS):
proc XDestroyImage(ximage: PXImage): cint = proc XDestroyImage(ximage: PXImage): cint =
XDestroyImage = ximage[] .f.destroy_image(ximage) ximage.f.destroy_image(ximage)
proc XGetPixel(ximage: PXImage, x, y: cint): culong = proc XGetPixel(ximage: PXImage, x, y: cint): culong =
XGetPixel = ximage[] .f.get_pixel(ximage, x, y) ximage.f.get_pixel(ximage, x, y)
proc XPutPixel(ximage: PXImage, x, y: cint, pixel: culong): cint = proc XPutPixel(ximage: PXImage, x, y: cint, pixel: culong): cint =
XPutPixel = ximage[] .f.put_pixel(ximage, x, y, pixel) ximage.f.put_pixel(ximage, x, y, pixel)
proc XSubImage(ximage: PXImage, x, y: cint, width, height: cuint): PXImage = proc XSubImage(ximage: PXImage, x, y: cint, width, height: cuint): PXImage =
XSubImage = ximage[] .f.sub_image(ximage, x, y, width, height) ximage.f.sub_image(ximage, x, y, width, height)
proc XAddPixel(ximage: PXImage, value: clong): cint = proc XAddPixel(ximage: PXImage, value: clong): cint =
XAddPixel = ximage[] .f.add_pixel(ximage, value) ximage.f.add_pixel(ximage, value)
converter toInt (some: TKeySym): int = some.int
proc IsKeypadKey(keysym: TKeySym): bool = proc IsKeypadKey(keysym: TKeySym): bool =
IsKeypadKey = (keysym >= XK_KP_Space) and (keysym <= XK_KP_Equal) (keysym >= XK_KP_Space) and (keysym <= XK_KP_Equal)
proc IsPrivateKeypadKey(keysym: TKeySym): bool = proc IsPrivateKeypadKey(keysym: TKeySym): bool =
IsPrivateKeypadKey = (keysym >= 0x11000000) and (keysym <= 0x1100FFFF) (keysym >= 0x11000000) and (keysym <= 0x1100FFFF)
proc IsCursorKey(keysym: TKeySym): bool = proc IsCursorKey(keysym: TKeySym): bool =
IsCursorKey = (keysym >= XK_Home) and (keysym < XK_Select) (keysym >= XK_Home) and (keysym < XK_Select)
proc IsPFKey(keysym: TKeySym): bool = proc IsPFKey(keysym: TKeySym): bool =
IsPFKey = (keysym >= XK_KP_F1) and (keysym <= XK_KP_F4) (keysym >= XK_KP_F1) and (keysym <= XK_KP_F4)
proc IsFunctionKey(keysym: TKeySym): bool = proc IsFunctionKey(keysym: TKeySym): bool =
IsFunctionKey = (keysym >= XK_F1) and (keysym <= XK_F35) (keysym >= XK_F1) and (keysym <= XK_F35)
proc IsMiscFunctionKey(keysym: TKeySym): bool = proc IsMiscFunctionKey(keysym: TKeySym): bool =
IsMiscFunctionKey = (keysym >= XK_Select) and (keysym <= XK_Break) (keysym >= XK_Select) and (keysym <= XK_Break)
proc IsModifierKey(keysym: TKeySym): bool = proc IsModifierKey(keysym: TKeySym): bool =
IsModifierKey = ((keysym >= XK_Shift_L) And (keysym <= XK_Hyper_R)) Or ((keysym >= XK_Shift_L) And (keysym <= XK_Hyper_R)) Or
(keysym == XK_Mode_switch) Or (keysym == XK_Num_Lock) (keysym == XK_Mode_switch) Or (keysym == XK_Num_Lock)