mirror of
https://github.com/vidarh/ruby-x11
synced 2024-11-16 07:48:12 +01:00
Cleanups
This commit is contained in:
parent
cfff274350
commit
1e241f35c9
1 changed files with 7 additions and 21 deletions
|
@ -58,7 +58,7 @@ module X11
|
||||||
|
|
||||||
class String16
|
class String16
|
||||||
def self.pack(x)
|
def self.pack(x)
|
||||||
x.encode("UTF-16BE").force_encoding("ASCII-8BIT") + "\x00\x00"*(-x.length & 1)
|
x.encode("UTF-16BE").b + "\x00\x00"*(-x.length & 1)
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.unpack(socket, size)
|
def self.unpack(socket, size)
|
||||||
|
@ -71,28 +71,14 @@ module X11
|
||||||
|
|
||||||
|
|
||||||
class String8Unpadded
|
class String8Unpadded
|
||||||
def self.pack(x)
|
def self.pack(x) = x
|
||||||
x
|
def self.unpack(socket, size) = socket.read(size)
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
def self.unpack(socket, size)
|
|
||||||
val = socket.read(size)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
class Bool
|
class Bool
|
||||||
def self.pack(x)
|
def self.pack(x) = (x ? "\x01" : "\x00")
|
||||||
x ? "\x01" : "\x00"
|
def self.unpack(str) = (str[0] == "\x01")
|
||||||
end
|
def self.size = 1
|
||||||
|
|
||||||
def self.unpack(str)
|
|
||||||
str[0] == "\x01"
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.size
|
|
||||||
1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
KeyCode = Uint8
|
KeyCode = Uint8
|
||||||
|
|
Loading…
Reference in a new issue