Ask coding questions

← Back to all posts
Console size
h
realTronsi

I'm grabbing the console dimensions using ioctl, but the dimensions are inconsistent with the actual size.

Executing the same code (as provided below) works perfectly in the shell however, suggesting it's probably due to an underlying factor from how the console is implemented, which I do not know about.

Notice I do have a fallback, but it isn't being executed in this case as ioctl is not failing, but simply returning incorrect dimension.

I'm mainly focused on the rows as of now. ioctl returns a value of 24 for the rows in the console, while correctly displaying 30 when executed in the shell.

I just want to make sure this is a quirk unique to repl and not some technological error I've made.

Voters
AsharCada
hyungyulove
realTronsi
Comments
hotnewtop
19wintersp

As in, the output window in the Replit IDE is different to the result? That's expected, the IDE doesn't communicate the output window size back to the Docker container.

realTronsi

@19wintersp and the shell does?

realTronsi

@19wintersp and also side note: it has worked before, correctly displaying 30 while run in the console, but don't remember changing anything about the window detection

19wintersp

@realTronsi From what I know, the shell works differently to the Console, though I don't know exactly how, sorry. I'll have a look at some WS packets and tell you if I see anything.

19wintersp

@realTronsi Apparently, it does, after some very rudimentary tests. Resizing the Console sends no WebSocket messages, resizing the Shell does.

realTronsi

@19wintersp I see, are you just reading the outgoing packets or are you decoding the binary? Just curious

19wintersp

@realTronsi Just checking from DevTools, no decoding. Not very scientific, but ¯\_(ツ)_

realTronsi

@19wintersp hmm so is the console disconnected from the container completely? Meaning fallbacks such as escape sequences will be effectively useless as well

19wintersp

@realTronsi I think so, I think it's just an input/output thing.

realTronsi

@SixBeeps @Coder100 you guys make console stuff, perhaps you know something about this?