• Read with word-wrap

    From Dmxrob@STLWEST to All on Wednesday, February 13, 2019 13:30:31
    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. 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.

    Thanks,

    Rob

    dmxrob ■ BBSing from St. Louis, Missouri since 1988

    ---
    ■ Synchronet ■ Gateway to the West - St. Louis, Missouri - bbs.dmxrob.net
  • From Mortifis@ALLEYCAT to Dmxrob on Wednesday, February 13, 2019 16:53:17
    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. 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.

    Thanks,

    Rob

    Not sure if this will help, but in the web/msgs/reply.ssjs there is a block:

    template.body=msgbase.get_msg_body(false,parseInt(http_request.query.reply_to), true);
    if(this.word_wrap != undefined) {
    // quote_msg adds three chars to each line. Re-wrap to 76 chars...
    // with the extra three, we're still under 80 *.
    template.body=quote_msg(word_wrap(template.body,76),79);
    }
    else {
    template.body=template.body.replace(/^(.)/mg,"> $1");
    }

    might get you started on a solution

    ---
    ■ Synchronet ■ AlleyCat! BBS - http://alleycat.synchro.net:81
  • From Digital Man to Dmxrob on Wednesday, February 13, 2019 18:11:08
    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