<jhass>
hey asterite, I could fix the read_nonblock issues by changing it to return what's available instead of insisting to read the specified length (by basically just ignoring the EAGAIN error).
<asterite>
if that fixes it, then go ahead :)
<asterite>
or tell me what to change, where
<jhass>
however I have no idea why the out of bounds happens. I mean it happens because the last row (array) in the grid turns into an empty one, but I have no idea why
<jhass>
the only assignments in the game logic are of [a][b]=, there's no .shift and no .clear
<jhass>
and no .pop
<asterite>
True, I just saw the empty array
<asterite>
Hmmm...
<asterite>
I see there: set_current_row [] of String
<asterite>
That's probably it, but I didn't really follow the code
<jhass>
yes but that just sets @current_row
<jhass>
it doesn't touch @grid at all
<jhass>
and @grid should be of Array(Array(Int32|Symbol))
<jhass>
so Array(String) doesn't really fit there
<asterite>
Right
<asterite>
My guess is that there's something wrong with read_nonblock that is scarmbles the memory or something like that
<asterite>
I mean, it touches other memory and scrwes that array, but I'm not sure
<jhass>
hm but then quite consistently it just damages the last array of the arrays in @grid?
<asterite>
(but you have to press the key and press enter, ugh)
<asterite>
The good thing is that the same logic seems to be ok :D
<asterite>
and we could also improve it by using the colorize file
<asterite>
the bad news is that we have to debug read_nonblock and deal with segfaults, etc. :-P
<jhass>
nope, sorry, doesn't work at all for my terminal
<asterite>
What terminal is that?
<jhass>
terminator on Archlinux
<jhass>
er, terminology by now
<asterite>
well, if it was terminator i would understand the segfaults...
<jhass>
oh, I didn't realize that you changed to wasd
<asterite>
Ah, yes, sorry
<jhass>
but not even the q worked for me
<asterite>
strange
<asterite>
but the other keys work?
<jhass>
hm yeah, strange
<jhass>
anyway, always pressing enter makes that almost not playable :P
<asterite>
Where did you get the original read_nonblock code… ruby?
<jhass>
pretty much iirc
<jhass>
meh, I think I defined the termios struct wrongly
<asterite>
Don't worry, we always miss the correct definitions the first time, specially when dealing with multiple platforms
<jhass>
so aliasing Tcflag to UInt64 fixes it for me
<jhass>
that stuff is defined in bits/termios.h
<jhass>
which is as system specific as it gets as I understood it
<jhass>
though since it's set to unsigned int there, the proper alias in crystal would be UInt I guess?
<jhass>
uh, that doesn't exist
<jhass>
so what's the crystal equivalent to C's unsigned int?
<asterite>
You have UInt8, UInt16, UInt32 and UInt64
<asterite>
so I guess UInt32
<jhass>
UInt32 is what I had it at and that's causing all the errors
<jhass>
UInt64 on my system seems to work flawless
<jhass>
but I wouldn't be surprised at all if that breaks on other systems
<jhass>
iirc C's unsigned int is 32bit or 64bit depending on the architecture
<asterite>
I think so
<asterite>
In my headers I see tcflag is unsigned long
<asterite>
so I guess UInt64
<asterite>
but I changed it and it still doesn't work, don't know why
<jhass>
see now why we need header parsing? :P
<asterite>
on the other hand it doesn't crash anymore
<asterite>
:-P
<asterite>
farelyknight is working on something that parses headers :)
<jhass>
if it doesn't crash anymore, what does "still doesn't work" mean?
<asterite>
because the input never matches the case
<jhass>
let me open a PR with all my changes so you can try
<asterite>
I mean, I can't play because the program reads the keyboard but it's never "\x1B[A" or any of those listed there
<asterite>
and I have to press two keys in the "read_keypress" method for it to do something
<asterite>
(but it never matches)
<asterite>
Specifically, it executes "input = io.read 1". I press a key, input is "\e", it does "io.read_nonblock 3" but there I have to press a key again :(