Re: [dev] [ubase] pager

2017-02-10 Thread Marc André Tanner
On Fri, Feb 10, 2017 at 12:08:21PM -0800, Leander S. Harding wrote:
> Search is indispensably useful and needful overall for general command
> output, which is why it should be implemented with a powerful/good ui
> at the multiplexer/TE layer, so that you're not maintaining two or
> more search facilities with similar-but-slightly-differing features.
> 
> This though leads me toward the implementation of a suckless
> scrollback+select/yank/urlpick/etc handler that comes with a 'pager'
> util that just toggles its scroll-lock state like this. Like an even
> more suckless dvtm with the one extra feature that's on my mind right
> now. :)

Latest dvtm pipes the scroll back buffer content to external tools such
as dvtm-pager(1) (by default a shell wrapper around less(1) preserving
color escape codes) and dvtm-editor(1) a small utility invoking $EDITOR
for copy mode. That way your regular editor features can be used to
search, select and copy parts of the scroll back buffer content.

-- 
 Marc André Tanner >< http://www.brain-dump.org/ >< GPG key: 10C93617



Re: [dev] [ubase] pager

2017-02-10 Thread Leander S. Harding
Search is indispensably useful and needful overall for general command
output, which is why it should be implemented with a powerful/good ui
at the multiplexer/TE layer, so that you're not maintaining two or
more search facilities with similar-but-slightly-differing features.

This though leads me toward the implementation of a suckless
scrollback+select/yank/urlpick/etc handler that comes with a 'pager'
util that just toggles its scroll-lock state like this. Like an even
more suckless dvtm with the one extra feature that's on my mind right
now. :)

On Fri, Feb 10, 2017 at 11:31 AM, Mattias Andrée  wrote:
> Some pagers also support search, which can be very useful.
>
> On Fri, 10 Feb 2017 11:28:04 -0800
> "Leander S. Harding"  wrote:
>
>>  Personally, I've always thought that the VTxx escape
>> sequence family is missing one: enable/disable
>> scroll-lock. Then, your 'pager' just consists of printing
>> the scroll-lock sequences at the beginning and end of
>> output and using your multiplexer's scrolling feature,
>> and can be accomplished like Eric mentioned above via
>> aliases easily, too.
>>
>>  -Leander
>>
>> On Fri, Feb 10, 2017 at 1:53 AM, hiro <23h...@gmail.com>
>> wrote:
>> > the problem is when i *know* stuff fill be very long,
>> > but I still want to start reading from the beginning.
>> > in tmux i don't know how to start scrolling from top of
>> > my last command. I don't want to scroll there manually.
>> > also in page i can use pgup/down in tmux i have to do
>> > crazy emacs-combinations first.
>> >
>> > On 2/10/17, Eric Pruitt  wrote:
>> >> On Fri, Feb 10, 2017 at 08:26:11AM +0100, robin
>> >> wrote:
>> >>> I usually pipe into less whenever something overflows
>> >>> the terminal height, but having to type 2>&1 to see
>> >>> stderr is a bit cumbersome. In dvtm Shift-PageUp is
>> >>> much easier.
>> >>
>> >> I use a generic wrapper function in Bash:
>> >>
>> >> #   $1  Name or path of the command to execute.
>> >> #   $2  White-space separated list of options to
>> >> pass to the command #   when stdout is a TTY. If
>> >> there are no TTY-dependent options #   this should
>> >> be "--". #   $@  Arguments to pass to command.
>> >> #
>> >> function -paginate()
>> >> {
>> >> local errfd=1
>> >>
>> >> local command="$1"
>> >> local tty_specific_args="$2"
>> >> shift 2
>> >>
>> >> if [[ -t 1 ]]; then
>> >> test "$tty_specific_args" != "--" ||
>> >> tty_specific_args="" test -t 2 || errfd=2
>> >> "$command" $tty_specific_args "$@"
>> >> 2>&"$errfd" | less -X -F -R return
>> >> 2>"${PIPESTATUS[0]/141/0}"  # Ignore SIGPIPE failures.
>> >> fi
>> >>
>> >> "$command" "$@"
>> >> }
>> >>
>> >> Then I have around 30 aliases for various commands I
>> >> use like this:
>> >>
>> >> alias cat='-paginate cat --'
>> >> alias grep='-paginate grep --color=always'
>> >> alias ps='-paginate ps --cols=$COLUMNS
>> >> --sort=uid,pid -N --ppid 2 -p 2'
>> >>
>> >> Output is only paginated when stdout is a TTY so I can
>> >> still use pipes, and the less flags ensure that less
>> >> will exit if the output fits on one screen. I also use
>> >> tmux, but I find less to be less painful to use than
>> >> copy mode in tmux when I don't need to actually copy
>> >> text.
>> >>
>> >> Eric
>> >>
>> >>
>> >
>>
>



Re: [dev] [ubase] pager

2017-02-10 Thread Mattias Andrée
Some pagers also support search, which can be very useful.

On Fri, 10 Feb 2017 11:28:04 -0800
"Leander S. Harding"  wrote:

>  Personally, I've always thought that the VTxx escape
> sequence family is missing one: enable/disable
> scroll-lock. Then, your 'pager' just consists of printing
> the scroll-lock sequences at the beginning and end of
> output and using your multiplexer's scrolling feature,
> and can be accomplished like Eric mentioned above via
> aliases easily, too.
> 
>  -Leander
> 
> On Fri, Feb 10, 2017 at 1:53 AM, hiro <23h...@gmail.com>
> wrote:
> > the problem is when i *know* stuff fill be very long,
> > but I still want to start reading from the beginning.
> > in tmux i don't know how to start scrolling from top of
> > my last command. I don't want to scroll there manually.
> > also in page i can use pgup/down in tmux i have to do
> > crazy emacs-combinations first.
> >
> > On 2/10/17, Eric Pruitt  wrote:  
> >> On Fri, Feb 10, 2017 at 08:26:11AM +0100, robin
> >> wrote:  
> >>> I usually pipe into less whenever something overflows
> >>> the terminal height, but having to type 2>&1 to see
> >>> stderr is a bit cumbersome. In dvtm Shift-PageUp is
> >>> much easier.  
> >>
> >> I use a generic wrapper function in Bash:
> >>
> >> #   $1  Name or path of the command to execute.
> >> #   $2  White-space separated list of options to
> >> pass to the command #   when stdout is a TTY. If
> >> there are no TTY-dependent options #   this should
> >> be "--". #   $@  Arguments to pass to command.
> >> #
> >> function -paginate()
> >> {
> >> local errfd=1
> >>
> >> local command="$1"
> >> local tty_specific_args="$2"
> >> shift 2
> >>
> >> if [[ -t 1 ]]; then
> >> test "$tty_specific_args" != "--" ||
> >> tty_specific_args="" test -t 2 || errfd=2
> >> "$command" $tty_specific_args "$@"
> >> 2>&"$errfd" | less -X -F -R return
> >> 2>"${PIPESTATUS[0]/141/0}"  # Ignore SIGPIPE failures.
> >> fi
> >>
> >> "$command" "$@"
> >> }
> >>
> >> Then I have around 30 aliases for various commands I
> >> use like this:
> >>
> >> alias cat='-paginate cat --'
> >> alias grep='-paginate grep --color=always'
> >> alias ps='-paginate ps --cols=$COLUMNS
> >> --sort=uid,pid -N --ppid 2 -p 2'
> >>
> >> Output is only paginated when stdout is a TTY so I can
> >> still use pipes, and the less flags ensure that less
> >> will exit if the output fits on one screen. I also use
> >> tmux, but I find less to be less painful to use than
> >> copy mode in tmux when I don't need to actually copy
> >> text.
> >>
> >> Eric
> >>
> >>  
> >  
> 



pgpaZqz0RSDm6.pgp
Description: OpenPGP digital signature


Re: [dev] [ubase] pager

2017-02-10 Thread Leander S. Harding
 Personally, I've always thought that the VTxx escape sequence family is
 missing one: enable/disable scroll-lock. Then, your 'pager' just consists
 of printing the scroll-lock sequences at the beginning and end of output
 and using your multiplexer's scrolling feature, and can be accomplished
 like Eric mentioned above via aliases easily, too.

 -Leander

On Fri, Feb 10, 2017 at 1:53 AM, hiro <23h...@gmail.com> wrote:
> the problem is when i *know* stuff fill be very long, but I still want
> to start reading from the beginning. in tmux i don't know how to start
> scrolling from top of my last command. I don't want to scroll there
> manually. also in page i can use pgup/down in tmux i have to do crazy
> emacs-combinations first.
>
> On 2/10/17, Eric Pruitt  wrote:
>> On Fri, Feb 10, 2017 at 08:26:11AM +0100, robin wrote:
>>> I usually pipe into less whenever something overflows the terminal
>>> height, but having to type 2>&1 to see stderr is a bit cumbersome. In
>>> dvtm Shift-PageUp is much easier.
>>
>> I use a generic wrapper function in Bash:
>>
>> #   $1  Name or path of the command to execute.
>> #   $2  White-space separated list of options to pass to the command
>> #   when stdout is a TTY. If there are no TTY-dependent options
>> #   this should be "--".
>> #   $@  Arguments to pass to command.
>> #
>> function -paginate()
>> {
>> local errfd=1
>>
>> local command="$1"
>> local tty_specific_args="$2"
>> shift 2
>>
>> if [[ -t 1 ]]; then
>> test "$tty_specific_args" != "--" || tty_specific_args=""
>> test -t 2 || errfd=2
>> "$command" $tty_specific_args "$@" 2>&"$errfd" | less -X -F -R
>> return "${PIPESTATUS[0]/141/0}"  # Ignore SIGPIPE failures.
>> fi
>>
>> "$command" "$@"
>> }
>>
>> Then I have around 30 aliases for various commands I use like this:
>>
>> alias cat='-paginate cat --'
>> alias grep='-paginate grep --color=always'
>> alias ps='-paginate ps --cols=$COLUMNS --sort=uid,pid -N --ppid 2 -p 2'
>>
>> Output is only paginated when stdout is a TTY so I can still use pipes,
>> and the less flags ensure that less will exit if the output fits on one
>> screen. I also use tmux, but I find less to be less painful to use than
>> copy mode in tmux when I don't need to actually copy text.
>>
>> Eric
>>
>>
>



Re: [dev] [ubase] pager

2017-02-10 Thread hiro
the problem is when i *know* stuff fill be very long, but I still want
to start reading from the beginning. in tmux i don't know how to start
scrolling from top of my last command. I don't want to scroll there
manually. also in page i can use pgup/down in tmux i have to do crazy
emacs-combinations first.

On 2/10/17, Eric Pruitt  wrote:
> On Fri, Feb 10, 2017 at 08:26:11AM +0100, robin wrote:
>> I usually pipe into less whenever something overflows the terminal
>> height, but having to type 2>&1 to see stderr is a bit cumbersome. In
>> dvtm Shift-PageUp is much easier.
>
> I use a generic wrapper function in Bash:
>
> #   $1  Name or path of the command to execute.
> #   $2  White-space separated list of options to pass to the command
> #   when stdout is a TTY. If there are no TTY-dependent options
> #   this should be "--".
> #   $@  Arguments to pass to command.
> #
> function -paginate()
> {
> local errfd=1
>
> local command="$1"
> local tty_specific_args="$2"
> shift 2
>
> if [[ -t 1 ]]; then
> test "$tty_specific_args" != "--" || tty_specific_args=""
> test -t 2 || errfd=2
> "$command" $tty_specific_args "$@" 2>&"$errfd" | less -X -F -R
> return "${PIPESTATUS[0]/141/0}"  # Ignore SIGPIPE failures.
> fi
>
> "$command" "$@"
> }
>
> Then I have around 30 aliases for various commands I use like this:
>
> alias cat='-paginate cat --'
> alias grep='-paginate grep --color=always'
> alias ps='-paginate ps --cols=$COLUMNS --sort=uid,pid -N --ppid 2 -p 2'
>
> Output is only paginated when stdout is a TTY so I can still use pipes,
> and the less flags ensure that less will exit if the output fits on one
> screen. I also use tmux, but I find less to be less painful to use than
> copy mode in tmux when I don't need to actually copy text.
>
> Eric
>
>



Re: [dev] [ubase] pager

2017-02-09 Thread robin
On Thu, Feb 09, 2017 at 07:09:23PM +0100, Josuah Demangeon wrote:
> roqbin.a.t.peder...@gmail.com:
> 
> > I vaguely remember pagers discussed in a thread, and the conclusion was
> > that pagers are unecessary because its the job of something like dvtm or
> > tmux.
> 
> I also like to have the multiplexer managing the scrolling, but for dvtm, 
> what provides the scrolling (and copy) is the $PAGER (and the $EDITOR) itself.
> 

Maybe that makes more sense, to separate concern even further by letting the
muxer only mux, and let the pager only... page?

I usually pipe into less whenever something overflows the terminal height,
but having to type 2>&1 to see stderr is a bit cumbersome.
In dvtm Shift-PageUp is much easier.



Re: [dev] [ubase] pager

2017-02-09 Thread hiro
tmux doesn't have a usable pager imo.



Re: [dev] [ubase] pager

2017-02-09 Thread Josuah Demangeon
roqbin.a.t.peder...@gmail.com:

> I vaguely remember pagers discussed in a thread, and the conclusion was
> that pagers are unecessary because its the job of something like dvtm or
> tmux.

I also like to have the multiplexer managing the scrolling, but for dvtm, what 
provides the scrolling (and copy) is the $PAGER (and the $EDITOR) itself.



Re: [dev] [ubase] pager

2017-02-09 Thread robin
On Thu, Feb 02, 2017 at 07:45:28PM +0100, Mattias Andrée wrote:
> Hi!
> 
> I'm going to write a pager for ubase, and, because
> it is a necessary component of the pager, I will
> also implement ul(1). ul(1) will be used by the
> pager which is necessary to get properly formatted
> output when piping man(1) or groff(1) to the pager.
> 
> 
> Mattias Andrée

I vaguely remember pagers discussed in a thread, and the conclusion was
that pagers are unecessary because its the job of something like dvtm or tmux.



Re: [dev] [ubase] pager

2017-02-04 Thread Mattias Andrée
On Sat, 4 Feb 2017 12:13:03 +0100
Josuah Demangeon  wrote:

> On February 4, 2017 10:49:52 AM GMT+01:00, "Mattias
> Andrée"  wrote:
> > On Sat, 4 Feb 2017 10:22:24 +0100
> > Josuah Demangeon  wrote:
> >   
> > > On February 4, 2017 2:03:16 AM GMT+01:00, "Mattias
> > > Andrée"  wrote:  
> > > > 
> > > > Well, this is embarrassing, I forgot to check you
> > > > program before starting on ul(1). However, I just
> > > > ran
> > > >
> > > > MAN_KEEP_FORMATTING=y man man | ./iode
> > > 
> > > I made escape sequences tooglable with flags, maybe
> > > that is the reason.
> > > 
> > > You can try enabling colour interpreting with +R (or
> > > disabling it with -R).  Either as command-line flag
> > > or as keybinding.  
> > 
> > Silly me, I thought it was -R.  
> 
> It is what is written on the man page and what less
> does.  I should update it.
> 
> Maybe -R is a better idea.  Maybe it is what sbase used
> to have.
> 
> >It works, but if you place
> > util-linux's ul(1) between man(1) and iode you will see
> > a problem.  
> 
> I see ^O (shift-in) characters at the end of bold
> sequences.  Is that what you mean?  Less does not handle
> these neither, but I can, I could just set it to ignore
> them.

For some reason ul(1) produces ESC ( B, which means switch
to US ASCII character set. These can be ignored, and less(1)
does ignore them.

> 
> > I'm working on libgraffiti which ul(1) will use, it will
> > support all escape sequences (I have read long lists of
> > escape sequences to find a pattern that recognise all
> > of them) along will things like combining marks. This
> > library will also be useful for pagers, terminals, and
> > similar programs.
> >
> > iode seem to be able to do everything needed to view
> > man pages, but unlike ul(1) and most(1) it doesn't
> > support e.g. `printf 'aaa\r___'`, but it doesn't have
> > to as ul(1) can be used.  
> 
> This will be very convenient, I was not aware of such a
> diversity
> 
> > I would recommend making +R the default, what would
> > probably reduce confusion for users.  
> 
> Yes, I will change it after line folding.
> 
> Do not hesitate to ask for explanation if something is
> unclear in the source.
> 



pgpSnEcgZaRwu.pgp
Description: OpenPGP digital signature


Re: [dev] [ubase] pager

2017-02-04 Thread Josuah Demangeon


On February 4, 2017 10:49:52 AM GMT+01:00, "Mattias Andrée"  
wrote:
> On Sat, 4 Feb 2017 10:22:24 +0100
> Josuah Demangeon  wrote:
> 
> > On February 4, 2017 2:03:16 AM GMT+01:00, "Mattias
> > Andrée"  wrote:
> > > 
> > > Well, this is embarrassing, I forgot to check you
> > > program before starting on ul(1). However, I just ran
> > >
> > >   MAN_KEEP_FORMATTING=y man man | ./iode  
> > 
> > I made escape sequences tooglable with flags, maybe that
> > is the reason.
> > 
> > You can try enabling colour interpreting with +R (or
> > disabling it with -R).  Either as command-line flag or as
> > keybinding.
> 
> Silly me, I thought it was -R.

It is what is written on the man page and what less does.  I should update it.

Maybe -R is a better idea.  Maybe it is what sbase used to have.

>It works, but if you place
> util-linux's ul(1) between man(1) and iode you will see
> a problem.

I see ^O (shift-in) characters at the end of bold sequences.  Is that what you 
mean?  Less does not handle these neither, but I can, I could just set it to 
ignore them.

> I'm working on libgraffiti which ul(1) will use, it will
> support all escape sequences (I have
 read long lists of
> escape sequences to find a pattern that recognise all
> of them) along will things like combining marks. This
> library will also be useful for pagers, terminals, and
> similar programs.
>
> iode seem to be able to do everything needed to view
> man pages, but unlike ul(1) and most(1) it doesn't
> support e.g. `printf 'aaa\r___'`, but it doesn't have
> to as ul(1) can be used.

This will be very convenient, I was not aware of such a diversity

> I would recommend making +R the default, what would
> probably reduce confusion for users.

Yes, I will change it after line folding.

Do not hesitate to ask for explanation if something is unclear in the source.



Re: [dev] [ubase] pager

2017-02-04 Thread Mattias Andrée
On Sat, 4 Feb 2017 10:22:24 +0100
Josuah Demangeon  wrote:

> On February 4, 2017 2:03:16 AM GMT+01:00, "Mattias
> Andrée"  wrote:
> > 
> > Well, this is embarrassing, I forgot to check you
> > program before starting on ul(1). However, I just ran
> >
> > MAN_KEEP_FORMATTING=y man man | ./iode  
> 
> I made escape sequences tooglable with flags, maybe that
> is the reason.
> 
> You can try enabling colour interpreting with +R (or
> disabling it with -R).  Either as command-line flag or as
> keybinding.

Silly me, I thought it was -R. I works, but if you place
util-linux's ul(1) between man(1) and iode you will see
a problem.

I'm working on libgraffiti which ul(1) will use, it will
support all escape sequences (I have read long lists of
escape sequences to find a pattern that recognise all
of them) along will things like combining marks. This
library will also be useful for pagers, terminals, and
similar programs.

iode seem to be able to do everything needed to view
man pages, but unlike ul(1) and most(1) it doesn't
support e.g. `printf 'aaa\r___'`, but it doesn't have
to as ul(1) can be used.

I would recommend making +R the default, what would
probably reduce confusion for users.

> 
> > and it is not able to display it properly, which is the
> > only thing I have implemented in ul(1) so far. But I'll
> > see if there are parts that can be reused.
> > 
> > maandree  
> 
> There is also +/-N for line number, and I am trying line
> wrapping / stripping with +/-S in a "folding" branch.
> 
> I will iddle in #suckless if that helps.
> 



pgpe7VuQ7lsib.pgp
Description: OpenPGP digital signature


Re: [dev] [ubase] pager

2017-02-04 Thread Josuah Demangeon


On February 4, 2017 2:03:16 AM GMT+01:00, "Mattias Andrée"  
wrote:
> 
> Well, this is embarrassing, I forgot to check you program
> before starting on ul(1). However, I just ran
>
>   MAN_KEEP_FORMATTING=y man man | ./iode

I made escape sequences tooglable with flags, maybe that is the reason.

You can try enabling colour interpreting with +R (or disabling it with -R).  
Either as command-line flag or as keybinding.

> and it is not able to display it properly, which is the
> only thing I have implemented in ul(1) so far. But I'll
> see if there are parts that can be reused.
> 
> maandree

There is also +/-N for line number, and I am trying line wrapping / stripping 
with +/-S in a "folding" branch.

I will iddle in #suckless if that helps.



Re: [dev] [ubase] pager

2017-02-03 Thread Mattias Andrée
On Thu, 2 Feb 2017 20:42:06 +0100
Josuah Demangeon  wrote:

> I started such a tool recently.  It is probably not
> suckless, as it is already 1600 loc, but can properly
> display a man page, colour escape codes and content from
> UTF-8-test.txt and UTF8-demo.txt without ncurses.
> 
> http://github.com/josuah/iode
> 
> If this one sucks, I would be glad to see the
> implementation, as I will learn a lot from it.
> 
> I have also seen rirc (irc client) that does not use
> ncurses for its interface.
> 
> http://github.com/rcr/rirc/blob/master/draw.c
> 

Well, this is embarrassing, I forgot to check you program
before starting on ul(1). However, I just ran

MAN_KEEP_FORMATTING=y man man | ./iode

and it is not able to display it properly, which is the
only thing I have implemented in ul(1) so far. But I'll
see if there are parts that can be reused.

maandree


pgpM43HF0vrpf.pgp
Description: OpenPGP digital signature


Re: [dev] [ubase] pager

2017-02-02 Thread Mattias Andrée
On Thu, 2 Feb 2017 20:42:06 +0100
Josuah Demangeon  wrote:

> I started such a tool recently.  It is probably not
> suckless, as it is already 1600 loc, but can properly
> display a man page, colour escape codes and content from
> UTF-8-test.txt and UTF8-demo.txt without ncurses.
> 
> http://github.com/josuah/iode
> 
> If this one sucks, I would be glad to see the
> implementation, as I will learn a lot from it.
> 
> I have also seen rirc (irc client) that does not use
> ncurses for its interface.
> 
> http://github.com/rcr/rirc/blob/master/draw.c
> 

It doesn't look too bad, but I would prefer everything
to be in one file. I think might make it easier to navigate
the code. But I will take a closer look at it and see if
can be cannibalised.


pgpS9SaSxZ38r.pgp
Description: OpenPGP digital signature


Re: [dev] [ubase] pager

2017-02-02 Thread Josuah Demangeon
I started such a tool recently.  It is probably not suckless, as it is already 
1600 loc, but can properly display a man page, colour escape codes and content 
from UTF-8-test.txt and UTF8-demo.txt without ncurses.

http://github.com/josuah/iode

If this one sucks, I would be glad to see the implementation, as I will learn a 
lot from it.

I have also seen rirc (irc client) that does not use ncurses for its interface.

http://github.com/rcr/rirc/blob/master/draw.c



[dev] [ubase] pager

2017-02-02 Thread Mattias Andrée
Hi!

I'm going to write a pager for ubase, and, because
it is a necessary component of the pager, I will
also implement ul(1). ul(1) will be used by the
pager which is necessary to get properly formatted
output when piping man(1) or groff(1) to the pager.


Mattias Andrée


pgpAfVdp6vTnN.pgp
Description: OpenPGP digital signature