Confusing textwrap parameters, and request for RE help

Chris Angelico rosuav at gmail.com
Wed Mar 25 07:44:54 EDT 2020


On Wed, Mar 25, 2020 at 8:31 PM DL Neil via Python-list
<python-list at python.org> wrote:
> 1 what features does the terminal offer when a user 'clicks'?
> Is it only applicable to URLs and linked to the web-browser within
> "Preferred Applications"? Are you able to 'grab' that click from the
> app? eg MOUSEDOWN*.

In most terminal emulators, and certainly in xfce4-terminal, a URL can
be highlighted and right-clicked on.

Grabbing clicks IS possible, but that has other consequences, and is a
subject for a separate thread (which I may end up raising).

> 2 ultimately, you're on-a-hiding-to-nothing (apologies to
> non-English-English speakers: means 'no hope'!) given that URLs are
> defined by, but not length-limited by, RFC. Any 'limits' are applied by
> implementation/web-browser publishers. Currently in-use editions may
> vary widely, ie from 2K~64K. Any and all of which would blow terminal
> line-lengths right out-of-the-water.

Yeah, that part isn't too bad - what ends up happening is that the URL
doesn't get wrapped. It's not pretty but it's functional.

> However, may we return to my earlier question: could the app trap a
> 'click'? In which case, the app could store the actual-URI and provide
> its own Curie-like URL-shortening service, by substituting some
> (shorter!) 'click-here' text into the presentation. On the
> return-journey, in capturing the click, the app could substitute
> back-again before passing the full-length URI to the web-browser.

Yes, there are two ways that could be done: the hyperlink protocol,
which isn't supported in most terminal applications; or manually
handling all clicks, which quite possibly will end up being what
happens.

> * I've been looking at edX's "Creative Coding" online course. It is
> aimed at artists and animators learning to code, and thus aims to make
> the computer draw (instead of counting dollars-and-cents, per the usual
> course-format). Sadly it is JavaScript-based (the p5.js library). Why do
> things the easy way? Nah! Instead, I've been investigating a 'corner' of
> Python with which I have had no contact to date. The Pygame library
> offers a drawing "canvas", hence it gaining my attention. Plus, without
> the complication of a full-fat GUI, (I think) it will present text AND
> allow keyboard and mouse-key trapping - all from the comfort and glory
> of a terminal-based Python program...
>
> Have you ever poked into this dark corner of the pip-y-verse?
> Would you like a PoC (I'll call it 'coursework')? (tomorrow)
>

Never looked into that. I'm not really into art, sorry. (I once did a
ten-minute art jam on a topic of "video game characters", and my
chosen medium was... matplotlib. I'll let you guess at the details.)
Drawing's never been something I'm any good at.

ChrisA


More information about the Python-list mailing list