zsh-users
 help / color / mirror / code / Atom feed
* Interactive line wrapping
@ 2016-04-26  2:40 Samuel Williams
  0 siblings, 0 replies; only message in thread
From: Samuel Williams @ 2016-04-26  2:40 UTC (permalink / raw)
  To: zsh-users

[-- Attachment #1: Type: text/plain, Size: 2424 bytes --]

Hello

I'm working on a command-line framework for Ruby (
https://github.com/ioquatix/samovar) and I've been wondering about the best
way to implement line wrapping, and wondering how this fits in with ZSH
since that's the shell I'm using predominantly.

Ideally, if you have a block of text, e.g.

    [--option] This option does this that and the other thing and several
other things.

If the user makes the terminal narrower, it would be wrapped, e.g.

    [--option] This option does this that and the other
thing and several other things.

However, this wrapping is not ideal. The ideal wrapping output would be
something like this:

    [--option] This option does this that and the other
               thing and several other things.

I see two ways to implement this:

1/ Detect the width of the terminal before outputting anything and manually
wrap the text.
2/ Implement a curses based output mechanism which supports interactively
re-flowing the text.
3/ Expecting the terminal to implement it somehow.

I was wondering if ZSH supports any method for interactive line wrapping?

In particular, even if I support 1 or 2 above, I was thinking to use a
special token \e[0;0m which would indicate a line wrapping marker. In the
case a line would wrap, the indentation would be that until the most
recently encountered wrapping marker. This could be used both in the
interactive case or non-interactive case. The above output would therefore
look like:

    *\e[0;0m*[--option] *\e[0;0m*This option does this that and the other
thing and several other things.

Any subsequent wrapping would happen at the most recent marker which was on
the original line.

It's still not clear to me several situations though:

a/ How to wrap words that are too long, use a hyphen?
b/ How to compute the indentation of multi-byte characters? Tabs?
Potentially rather than computing an indent using spaces, perhaps replace
the text with replacement whitespace characters, so that tabs, and wide
characters have the equivalent whitespace width.

Finally, I had the crazy idea that something like this could be implemented
directly at the terminal layer so that all applications could benefit from
it. It seems like a logical thing to have w.r.t. presentation of text, in
the presence of resizable terminals. Perhaps this already exists and I
don't know about it?

Any ideas or feedback would be most appreciated.

Kind regards,
Samuel

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2016-04-26  2:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-26  2:40 Interactive line wrapping Samuel Williams

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).