From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10875 invoked by alias); 26 Apr 2016 02:40:43 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 21494 Received: (qmail 15304 invoked from network); 26 Apr 2016 02:40:42 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, HTML_MESSAGE,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:date:message-id:subject:from:to; bh=fuuB80SukffE2hZ0ho1hzSNQKJ4yNDh0uKHI9r/mbXg=; b=LZZofCMRwfhExBQGhCAXgkbzrLl3uV3eK6RtBAFN5FEcSg4ycqP2LNmaZCNsXgs9QD lP1B7YYiPvlwdlZ68caceG1Yu0gyLhCVFUe3tmTYK/PVNqECve2AzK7JRlVgDmKsLYtY 528PQRT9+a2U77n/ouQpcyCnKObwtwO3aos/LdvCajOPz0XuHQb5pf/zmIH4qLcytG1S /QE3JljOcXGYDzdUHPEQUsWTBJiJP3l7kvIokUw1RUP2OO+xCZPYBUV5runukJp3fjwG h6R+orHSlf47FANIaaUC03z+xY9ZvzflD+ofbCa7NTqY1wWqK09AII29sjWrcdLWpbnp uW8w== X-Gm-Message-State: AOPr4FXSX0aRAYRzAPhkBoaeaLtGKSveTtCWmyxEhcLA56/G6epgys7U+DD2bAeDzRFUjMt2R1U/Q7eXJj2Oxw== MIME-Version: 1.0 X-Received: by 10.112.150.165 with SMTP id uj5mr47838lbb.95.1461638440683; Mon, 25 Apr 2016 19:40:40 -0700 (PDT) Date: Tue, 26 Apr 2016 14:40:40 +1200 Message-ID: Subject: Interactive line wrapping From: Samuel Williams To: zsh-users@zsh.org Content-Type: multipart/alternative; boundary=047d7b3a83960c0e0505315a38ed --047d7b3a83960c0e0505315a38ed Content-Type: text/plain; charset=UTF-8 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 --047d7b3a83960c0e0505315a38ed--