Subj : Read with word-wrap
To : Dmxrob
From : Digital Man
Date : Wed Feb 13 2019 06:11 pm
Re: Read with word-wrap
By: Dmxrob to All on Wed Feb 13 2019 01:30 pm
> I want to read in a text string up to 160 characters. Using
> console.getstr(maxlen=160) it is stopping at the 80th position (for a 80x25
> screen). Ideally what I'd like to happen is when it hits that border it
> would just wrap text.
When reading the last column, terminal behavior is not predictable (some
terminals will auto-wrap and others may not) - so getstr() avoids using the
last column. v3.16 and older versions of SBBS would not check the maxlen
argument and may cause the terminal to autowrap (again, depending on the
terminal) but this would also cause problems with editing the text entered
before the wrap (backspace, etc.) and the BBS's idea of what the user is seeing
or not seeing would get out of sync.
> I've seen this behaviour before on SBBS, but before I
> wrote some javascript to try and do it myself I wanted to see if there was a
> built-in method I'm just not seeing.
If you want to support multiple lines of input, the K_WRAP mode flag for
getstr() is probably what you want to use. It'll store (in a temporary buffer)
whatever text caused a wrap and use it in the next call to getstr(). So you
could call getstr(79, K_WRAP), then getstr(79) to 2 lines of 158 chars total
(for example).
There is no right-to-left type scrolling supported by getstr() for entering
lines wider than the terminal, but that would be a good/useful feature to have
(ala long string input in SCFG/echocfg/etc.).
digital man
This Is Spinal Tap quote #25:
Viv Savage: Have... a good... time... all the time. That's my philosophy.
Norco, CA WX: 50.0�F, 82.0% humidity, 2 mph SW wind, 0.03 inches rain/24hrs
---
� Synchronet � Vertrauen � Home of Synchronet � [vert/cvs/bbs].synchro.net