Article View: comp.lang.perl.misc
Article #7Re: a question about TUIs and raw input from ttys
From: Eli the Bearded
Date: Fri, 04 Dec 2026 05:41
Date: Fri, 04 Dec 2026 05:41
81 lines
5008 bytes
5008 bytes
In comp.lang.perl.misc, Ivan Shmakov <ivan@siamics.netREMOVE.invalid> wrote:
> Sounds like a buffering issue. Let's see.
Thanks for the write up. The actual issue was querying the terminal for
current cursor position excessively. That process is write an escape
sequence out, read what the terminal writes back. If you do that several
hundred times a second (left over code from earlier development), then
there's a good chance the human keyboard input is just going to corrupt
the cursor position output.
I changed the code to read the cursor position once and things "feel"
good now, even without sysread.
> Unless I be mistaken, the Curses' main feature is that it
> maintains a screen buffer. Which is handy for fullscreen
> applications, but less applicable for things like Readline
> - where using Termcap / Terminfo support alone, rather than
> the entire Curses library, makes more sense.
In C, I've used ncurses and it's a been a while, but at minimum it
provides the escape sequence definitions for the keys like "UP".
> And it annoys me to no end when an application refuses to consult
> the databases and just uses hardcoded ESC sequences instead.
Yeah, I can sympathize. But I'm writing a game for my own entertainment
(both the writing and the playing), so if I'm going to use termcap /
terminfo, I'm going to write that myself. But I've not made a priority
out of it.
> Like, "why, everyone now supports VT100 colors!" (VT100, VT220,
> VT320 had no support for colors, if XTerm FAQ is to be believed.)
I've used one of the VTs, probably a 220. It also had no escape key,
making it rather vi unfriendly.
>> wants to get input solved before moving on to maze generation
> Reminds me of [1], somehow.
> [1] http://linusakesson.net/games/autosokoban/
Maze generation is coded, in a demo tool for now. I still need to
adjust movement to account for not letting the game cursor move outside
the edges, because now the field is not always rectangular.
https://codeberg.org/elithebearded/flow-thy-pipes.git
Sample maze, using high-bit characters:
╭──────────────────────────────╮
│ │
│ △ △ △ ▟██▙ ▟███████████▷ │
│ █ █ █ █ █ █ █ █ █ │
│ █ █ █ █ █ █ █ █ █ │
│ ▜█████████ ▽ █ ▽ █ ▜██▷ │
│ █ █ █ │
│ █ █ █ │
╰────╮ ◁███ △ ███▙ ▽ ╭────╯
│ █ █ █ █ │
│ █ █ █ █ │
F L │ △ █ ▜███ ▜██▙ │ O W
│ █ █ █ █ │
│ █ █ █ █ │
╭────╯ ███▛ ◀███ ▟██▛ ╰────╮
│ █ █ █ │
│ █ █ █ │
│ ◁█████▛ ▟█████▛ ▜█████▙ △ │
│ █ █ █ █ │
│ █ █ █ █ │
│ ◁███████████▷ ◁███████████▛ │
│ │
╰──────────────────────────────╯
In the game, the cells (3x3) are rotated at level start and the player must
find the rotations to restore the maze. There will be separate scoring
for time taken and rotations performed, lower better for for both. I'm
using a fixed random seed, so levels are replayable, at least with same
libraries.
Elijah
------
riffing off an Android game someone seems to have AI coded
Technical Details
Message-ID:
<eli$2612040037@qaz.wtf>Path:
mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!panix!.POSTED.panix5.panix.com!qz!not-for-mailReferences:
<eli$2611290036@qaz.wtf> <wPRxP9j06Ip0AEM2@violet.siamics.net>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!panix!.POSTED.panix5.panix.com!qz!not-for-mail From: Eli the Bearded <*@eli.users.panix.com> Newsgroups: comp.lang.perl.misc Subject: Re: a question about TUIs and raw input from ttys Date: Fri, 4 Dec 2026 05:41:26 -0000 (UTC) Organization: Some absurd concept Message-ID: <eli$2612040037@qaz.wtf> References: <eli$2611290036@qaz.wtf> <wPRxP9j06Ip0AEM2@violet.siamics.net> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Injection-Date: Fri, 4 Dec 2026 05:41:26 -0000 (UTC) Injection-Info: reader2.panix.com; posting-host="panix5.panix.com:166.84.1.5"; logging-data="23765"; mail-complaints-to="abuse@panix.com" User-Agent: Vectrex rn 2.1 (beta) X-Liz: It's actually happened, the entire Internet is a massive game of Redcode X-Motto: "Erosion of rights never seems to reverse itself." -- kenny@panix X-US-Congress: Moronic Fucks. X-Attribution: EtB XFrom: is a real address Encrypted: double rot-13