• OSC 8 detection / support

    From Rob Swindell@1:103/705 to GitLab issue in main/sbbs on Thu Feb 13 18:13:44 2025
    open https://gitlab.synchro.net/main/sbbs/-/issues/872

    Clickable URIs/links in terminals is a standardized thing: https://github.com/Alhadis/OSC8-Adoption

    Detect that support (e.g. using ANSI cursor position request) and set a console flag for the session. Then allow custom strings when supported or use @-codes to do the special expansion when displaying URLs.
    --- SBBSecho 3.23-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Deucе@1:103/705 to GitLab note in main/sbbs on Sun Mar 30 03:04:52 2025
    https://gitlab.synchro.net/main/sbbs/-/issues/872#note_6954

    Actually, reading the spec again, there is no way to detect if it's implemented. :(
    --- SBBSecho 3.24-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Deucе@1:103/705 to GitLab note in main/sbbs on Mon Mar 31 15:31:32 2025
    https://gitlab.synchro.net/main/sbbs/-/issues/872#note_6958

    But on the plus side, it should also be transparent when the client doesn't support it (assuming the client isn't broken)
    --- SBBSecho 3.24-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Rob Swindell@1:103/705 to GitLab note in main/sbbs on Mon Mar 31 16:21:36 2025
    https://gitlab.synchro.net/main/sbbs/-/issues/872#note_6959

    So in the example, `printf '\033]8;;http://example.com\033\\This is a link\033]8;;\033\\\n'`, a non-broken but non-supporting terminal would just eat the URL and only display "This is a link"?
    --- SBBSecho 3.24-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Deucе@1:103/705 to GitLab note in main/sbbs on Mon Mar 31 18:46:28 2025
    https://gitlab.synchro.net/main/sbbs/-/issues/872#note_6960

    Right, there's two OSCs there... "\\033\]8;;http://example.com\\033\\\\" and "\\033\]8;;\\033\\\\". Those would be stripped.
    --- SBBSecho 3.24-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Deucе@1:103/705 to GitLab note in main/sbbs on Mon Mar 31 18:48:36 2025
    https://gitlab.synchro.net/main/sbbs/-/issues/872#note_6960

    Right, there's two OSCs there... "\\033\]8;;[http://example.com\033\\](http://example.com%5C%5C033%5C%5C%5C%5C)" and "\\033\]8;;\\033\\\\". Those would be stripped.
    --- SBBSecho 3.24-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Deucе@1:103/705 to GitLab note in main/sbbs on Mon Mar 31 18:48:56 2025
    https://gitlab.synchro.net/main/sbbs/-/issues/872#note_6960

    Right, there's two OSCs there... "\\033\]8;;http://example.com\033\\" and "\\033\]8;;\\033\\\\". Those would be stripped.
    --- SBBSecho 3.24-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Rob Swindell@1:103/705 to GitLab note in main/sbbs on Mon Mar 31 20:07:42 2025
    https://gitlab.synchro.net/main/sbbs/-/issues/872#note_6964

    Well, that's kind of lame. :-( I was hoping the URL would at least be *displayed* for terminals that don't support OSC 8. And that would've made autodetection easy too.
    --- SBBSecho 3.24-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)
  • From Rob Swindell@1:103/705 to GitLab note in main/sbbs on Mon Oct 19 14:55:52 2026
    https://gitlab.synchro.net/main/sbbs/-/work_items/872#note_10652

    The OSC 8 spec itself still defines no detection method, but SyncTERM/CTerm can now be asked directly. 6fed22aa9d (opera-49-felt, 2026-03-17) added OSC 8 support to CTerm along with a capability query:

    - Send `CSI = 6 n`
    - CTerm replies `CSI = 6 ; pA n`, where `pA` is 1 if OSC 8 hyperlinks are available and 0 if not (`src/conio/cterm.adoc`, "State/Mode Request/Report (`CTSMRR`)"; implemented in `src/conio/cterm_cterm.c`).

    That makes the original goal possible: show a short link label (e.g. "[click here]") to terminals that support OSC 8, and the full URL to all others, so a non-supporting terminal never silently eats the URL.

    Proposed design:

    1. **Detection.** Add `"\x1b[=6n"` to the terminal auto-detection probe in `answer.cpp`, before the first cursor position request, so the reply arrives before the `R` that ends the read loop. Parse `[=6;1n` in the same response loop that already handles the CTerm version and audio state replies, and set a new per-session flag (e.g. `term->hyperlinks`, next to `audio_apc`). Terminals that don't recognize `CSI = Ps n` ignore it.
    2. **Output helper.** One function (e.g. `term->hyperlink(uri, text)`) that emits `ESC ] 8 ; ; uri ESC \ text ESC ] 8 ; ; ESC \` when the flag is set, and the bare URI otherwise. CTerm only accepts `http`, `https`, `ftp`, and `ftps` URIs and silently ignores other schemes, which would leave the label visible with nothing to click, so `mailto:`, `telnet://`, etc. should always fall back to the plain URI.
    3. **Exposure.** A JS method (e.g. `console.hyperlink(uri, text)`) and an @-code for menu/display files (e.g. `@LINK:uri|text@`), both with the same fallback.

    Column tracking should already be safe: the Terminal class tracks outgoing DCS/OSC/PM/APC control strings, so the hidden URI shouldn't advance the cursor column or disturb word-wrap. Needs one test with a long URI.

    Limitation: only CTerm answers `CSI = 6 n`. xterm-family terminals that support OSC 8 (Windows Terminal, kitty, iTerm2, GNOME Terminal, etc.) won't reply, so they'd get the full URL. That's the safe direction to err. A per-user "force hyperlinks on" setting could cover them later, rather than guessing from the terminal type.

    *Authored by Claude (Claude Code), on behalf of @rswindell*
    --- SBBSecho 3.38-Linux
    * Origin: Vertrauen - [vert/cvs/bbs].synchro.net (1:103/705)