Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Interactive line wrapping
- X-seq: zsh-users 21494
- From: Samuel Williams <space.ship.traveller@xxxxxxxxx>
- To: zsh-users@xxxxxxx
- Subject: Interactive line wrapping
- Date: Tue, 26 Apr 2016 14:40:40 +1200
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to; bh=fuuB80SukffE2hZ0ho1hzSNQKJ4yNDh0uKHI9r/mbXg=; b=GgNnOZO4S0Ghz7XtOKdPDOR8+Er8YRfMauDNs8HzBEWMik8D3vTk1ENHyd40xBHrcE hfXG/T/AQiEW3CnuAPnE8jqesDbh4njeml6BcH/2GY3ge3uHXoHjHZ9efu22GhfkxS5V EWjJamNIasGpHn1CZ4Lb1U40+QhuDDKu2zu4ph+hA+pQ5C78eBV21eSXhXhQ/r3lMbAI 05y7nq050RIFc22ChY2HdQh6pSZUUt7CdxfxGhznxNjNvmz0BWW84yCbrwzopYPSTEkV /zGUMiyNzc58gMiafu/NQQByqE2biObdkz8vhZ8y7XfJfZjRIa8DABKuLaSxPXSR39Ap Wh4Q==
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author