[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: A one line change I wish to see by default.

From: Andrew L. Moore
Subject: Re: A one line change I wish to see by default.
Date: Mon, 11 Dec 2023 21:27:12 -0500
User-agent: Mozilla Thunderbird

On 12/11/23 10:52 AM, Antonio Diaz Diaz wrote:
Andrew L. Moore wrote:
Antonio wrote:
] So I guess the proposed "\x1B[A\r\x1B[J" may work for ed.


FWIW, I don't like the idea of adding ANSI escape sequences to ed and I would prefer not to add them unless there is a compelling reason to do so. (And even then, enabled with an option, not by default).

What compelling reason?
Terminfo/termcap and ncurses exist for a reason.  Not even graphical
editors hard code ANSI escape sequences.  So now you want to add ncurses
to ed?  If so, try rlwrap first (see below).

As for providing scrolling capabilities to a line editor, this can be
achieved by adding a scroll-back command (Z), which does not require
ncurses or hard-coded ANSI sequences.

For a concrete example, install github.com/slewsys/ed, open a long file

$ /usr/local/bin/ed -p '* ' long-file.txt
* 1z        <--- display first page
* +Z        <--- scroll down one line
* +Z        <--- display the next line, etc.


* -Z        <--- scroll up one line

ed can also be invoked with `rlwrap' to provide history capabilities,
etc. This makes using GNU ed's z command for scrolling by line a little

$ rlwrap /bin/ed -p '* ' long-file
* 1z        <--- display first page
* .=
49          <--- the number of lines that GNU ed displays per page
* -47z      <--- scroll down one line (i.e., lines per page - 2)
* -47z      <--- Hit the UP-ARROW (↑) key followed by RET, etc.
* -49z      <--- scroll up one line, etc.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]