You are not logged in.

#1 2010-11-17 19:14:20

schuay
Package Maintainer (PM)
From: Austria
Registered: 2008-08-19
Posts: 564

pcurses, a ncurses libalpm package browser

pcurses is a (very) basic ncurses package browser sitting on top of libalpm.

Current features:

* pane based display of package list and infos
* chained filtering of packages by any combination of info fields using regexp
* sorting by any field
* searching by any combination of info fields using regexp
* custom colorcoding by any field
* command history in input modes

Next up: _performance improvements_, code cleanup,

A screenshot (as of 2010-11-20)

pcurses.th.png

Examples of some useful commands:

* jump to next package with name (or description) matching 'chat': ,chat
* filter by name (or description) containing 'chat': /chat
* filter by all packages built in october 2010: /b:Oct.*2010
* sort by download size: .z
* filter by all packages built in 2010, then all packages built by me:  /b:2010 , then /a:schuay
* clear all filters (display full package list): c
* color code by repository: ;r
* scroll through command history: while in input mode, up and down arrows

A quick tutorial (copy and pasted from the README):

QUICK TUTORIAL
--------------

Keybindings are displayed by pressing the 'h' (Help) key in pcurses.

Filtering takes the following syntax:

nd:game
1 23

1
is a list of field specifiers. These tell pcurses which fields to search. Field
specifiers are the highlighted characters in the field names in the info pane.
In this example, this means that the Name and Description are searched for the
phrase 'game'.

2
the character ':' separates the field specifier list from the search phrase. If
this character is not present, the entire string is interpreted as the search
phrase.

3
is the actual search phrase. If it contains only alphanumeric characters, a
simple and quick string search is used. Otherwise, it is treated as a regular
expression (which is a bit slower). The search is case INSENSITIVE.

1 and 2 are OPTIONAL.

These searches can be chained. This means that a search for 'n:^a', followed by
'b:2010' will show all packages beginning with the letter 'a' and having a build
date in the year 2010.

Previous filters are cleared by pressing the 'c' key.

A package is available at http://aur.archlinux.org/packages.php?ID=42685

Last edited by schuay (2010-11-23 12:42:34)

Offline

#2 2010-11-17 20:19:45

Chippeur
Member
Registered: 2010-01-25
Posts: 19

Re: pcurses, a ncurses libalpm package browser

Hello,

I think it's not a good idea the uppercase letter in the middle of word (like 'dEpends', pAckager') ^^.
For the look of boxes you can search #define ACS_ in ncurses.h, but man 'box' seems to be more appropriate.
the following line work for me:

box(w_border, ACS_VLINE, ACS_HLINE);

qmake for a CLI is certainly not necessary, please change.

I can't try because I haven't boost library for the moment. (ok it's good now)

Actually you call something like clear() (I think) on each movement on the window, it's really annoying when I keep my finger on KEY_DOWN.
Maybe you could see newpad() and prefresh() function smile.

Last edited by Chippeur (2010-11-17 20:40:09)


Sorry in advance for my poor english...

Offline

#3 2010-11-18 17:50:58

schuay
Package Maintainer (PM)
From: Austria
Registered: 2008-08-19
Posts: 564

Re: pcurses, a ncurses libalpm package browser

Chippeur wrote:

I think it's not a good idea the uppercase letter in the middle of word (like 'dEpends', pAckager') ^^.

It was easiest to implement quickly wink Changed to color highlighting for now.

Chippeur wrote:

For the look of boxes you can search #define ACS_ in ncurses.h, but man 'box' seems to be more appropriate.
the following line work for me:

box(w_border, ACS_VLINE, ACS_HLINE);

Thanks for that, applied.

Chippeur wrote:

qmake for a CLI is certainly not necessary, please change.

Again, mostly a convenience thing because it integrates so well with QtCreator. Just added a regular makefile and removed the qt makedep.

Chippeur wrote:

Actually you call something like clear() (I think) on each movement on the window, it's really annoying when I keep my finger on KEY_DOWN.
Maybe you could see newpad() and prefresh() function smile.

I never noticed this because konsole / gnome-terminal do not have this behavior. I'm going to read up on pad. Does ncurses have something similar to double buffering? Doing only partial screen updates sounds really involved..

Updated the screenshot above.

Offline

#4 2010-11-18 19:54:58

Chippeur
Member
Registered: 2010-01-25
Posts: 19

Re: pcurses, a ncurses libalpm package browser

I use rxvt-unicode (the behavior is the same on xterm).

I'm not sure of what you mean by 'double buffering' but I think you are right ncurses use one buffer for the physical screen and another for the virtual screen.

man refresh:
"In addition to all the  window  structures,  curses  keeps  two  data  structures  representing the terminal screen:
a physical screen, describing what is actually on  the  screen, and  a  virtual screen, describing what the programmer wants to have on the screen."

Last edited by Chippeur (2010-11-18 19:59:38)


Sorry in advance for my poor english...

Offline

#5 2010-11-19 21:04:38

Sara
Member
From: USA
Registered: 2009-07-09
Posts: 219
Website

Re: pcurses, a ncurses libalpm package browser

Could you add vim-like navigation? (i.e. j for down, k up, h left, l right). Would be very much appreciated. Also, perhaps an RC file to customize the colors. Thanks!

I have found this program exceptionally helpful as many math programs in the repos don't have "math" in the title, so when I search for new math programs in the repos, I don't find them. But with this program, it's a piece of cake to find them (using nd:math). Very neat.

[edit] As this program doesn't search the AUR (maybe it should?) I edited my post to reflect this.

Also, it is possible to search both name and descriptions with pacman, but the organized output of pcurses makes this much more practical to do (for me at least). [/edit]

Last edited by Sara (2010-11-19 23:50:39)


Registed Linux User 483618

Offline

#6 2010-11-19 23:38:44

schuay
Package Maintainer (PM)
From: Austria
Registered: 2008-08-19
Posts: 564

Re: pcurses, a ncurses libalpm package browser

Sara wrote:

Could you add vim-like navigation? (i.e. j for down, k up, h left, l right). Would be very much appreciated. Also, perhaps an RC file to customize the colors. Thanks!

I have found this program exceptionally helpful as many math programs in the AUR don't have "math" in the title, so when I search for new math programs in the AUR, I don't find them. But with this program, it's a piece of cake to find them (using nd:math). Very neat.

Yeah, I can do vim navigation at the next push.
An RC file is a possibility for the future but I've got other priorities first.
If you feel strongly about the colors, you can modify the following lines and rebuild the packages:
https://github.com/schuay/pcurses/blob/ … m.cpp#L240
If you come up with a nice color scheme, please feel free to post it here!

I'm glad you liked pcurses, but I should add that "pacman -Ss" also searches package names, descriptions and provides by default smile You can also choose to search the AUR web interface by name + description. Anyways, pcurses doesn't search the AUR, so I'm not sure what you meant.



By the way, I did some more work and added sorting functionality today.

Offline

#7 2010-11-19 23:43:05

Sara
Member
From: USA
Registered: 2009-07-09
Posts: 219
Website

Re: pcurses, a ncurses libalpm package browser

I'm glad you liked pcurses, but I should add that "pacman -Ss" also searches package names, descriptions and provides by default smile You can also choose to search the AUR web interface by name + description. Anyways, pcurses doesn't search the AUR, so I'm not sure what you meant.

You beat me to (by a few seconds) fixing my post to change AUR to "repos". I had seen so many packages, I thought (initially) it was searching the AUR, but then I realized that was not the case.

I do use "pacman -Ss" a lot, but pcurses is still more useful because the output is more organized.

Last edited by Sara (2010-11-19 23:44:19)


Registed Linux User 483618

Offline

#8 2010-11-19 23:54:19

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: pcurses, a ncurses libalpm package browser

@ Sara
If you want 'pacman -Ss' for AUR, there are many AUR helpers, like bauerbill etc. that can do that.

Sara wrote:

I do use "pacman -Ss" a lot, but pcurses is still more useful because the output is more organized.

Out of curiosity, what do you mean by "more organized"? You can 'pacman -Ssq math' to get just the package names if you like :-)

Offline

#9 2010-11-20 00:08:02

Sara
Member
From: USA
Registered: 2009-07-09
Posts: 219
Website

Re: pcurses, a ncurses libalpm package browser

karol wrote:

@ Sara
If you want 'pacman -Ss' for AUR, there are many AUR helpers, like bauerbill etc. that can do that.

Sara wrote:

I do use "pacman -Ss" a lot, but pcurses is still more useful because the output is more organized.

Out of curiosity, what do you mean by "more organized"? You can 'pacman -Ssq math' to get just the package names if you like :-)

But then I wouldn't see the descriptions, and if I'm looking for new software (i.e. I know nothing about the software), that's pivotal. I find the layout handy--I see all the software that matches my search criteria on the left, and on the right, I have a full view of all the package's information. That's what I mean by "more organized" smile.

I use an AUR helper to search the AUR, but it involves a lot of scrolling. So I thought pcurses would be a neater solution, given its nicer layout.


Registed Linux User 483618

Offline

#10 2010-11-20 11:00:41

schuay
Package Maintainer (PM)
From: Austria
Registered: 2008-08-19
Posts: 564

Re: pcurses, a ncurses libalpm package browser

Added a status bar and search functionality (jumping directly to the first found item instead of filtering).

Search takes the same syntax as filtering, currently the keybinding is ',' (comma).
Sorting only accepts a single field specifier, current keybinding '.' (period).

Next up: custom color coding.

Edit: Chippeur and karol, I think I've found a nice way to prevent screen flashing, see man wnoutrefresh.

Edit 2: pushed a fix for screen flickering, and added vim like movement (j: down, k: up)

Last edited by schuay (2010-11-20 11:33:29)

Offline

#11 2010-11-20 13:48:16

Chippeur
Member
Registered: 2010-01-25
Posts: 19

Re: pcurses, a ncurses libalpm package browser

good job, window refreshing works well now smile.


Sorry in advance for my poor english...

Offline

#12 2010-11-21 04:09:29

Sara
Member
From: USA
Registered: 2009-07-09
Posts: 219
Website

Re: pcurses, a ncurses libalpm package browser

schuay wrote:

Next up: custom color coding.

Thanks for the updates. About the custom color coding. I was able to edit the lines you specified, but I couldn't change the default background and foreground colors (I could only change the foreground and background colors for installed packages, packages installed as dependencies, etc). I read online that ncurses presumes that the default background color is black, so this might be the reason. Can this possibly be changed, as well? (I have a black on white terminal). Thanks for considering.


Registed Linux User 483618

Offline

#13 2010-11-21 11:11:12

schuay
Package Maintainer (PM)
From: Austria
Registered: 2008-08-19
Posts: 564

Re: pcurses, a ncurses libalpm package browser

Sara wrote:

I was able to edit the lines you specified, but I couldn't change the default background and foreground colors (I could only change the foreground and background colors for installed packages, packages installed as dependencies, etc).

That should be possible now. I added some short comments that explain which color pairs do what. For example, pane backgrounds are the second (=background) color in pair 5, and the status bar background corresponds to pair 1.

By 'custom color coding' I meant something else though: you will be able to specify how the package list colors are determined. Currently, they are fixed as displaying the 'Install status' fields (not installed = no color, asdeps = blue, explicit = green). When I'm done with this, you will be able to set this to other fields, like coloring by repo, license, packages, upgradeable state.

Maybe even something like using regexp grouping: b:^(\w*) would color by the build day of week (without this, coloring only makes sense for a few selected fields).

Offline

#14 2010-11-21 11:33:02

Chippeur
Member
Registered: 2010-01-25
Posts: 19

Re: pcurses, a ncurses libalpm package browser

For the color, if you want to use the transparency of the terminal for example (or just the default colors), the color number should be <b>-1</b>.
You have to call

  use_default_colors();

if you want to use the 'color -1'.
This is ncurses specific so the it should be something like that:

#ifdef NCURSES_VERSION
  use_default_colors();
#endif /* !NCURSES_VERSION */

man use_default_color for more information ^^

and if you want to choose the default color of the application you can more generally call:

#ifdef NCURSES_VERSION
  assume_default_colors(COLOR_YELLOW, COLOR_MAGENTA);
#endif /* !NCURSES_VERSION */

Sorry in advance for my poor english...

Offline

#15 2010-11-21 12:23:41

schuay
Package Maintainer (PM)
From: Austria
Registered: 2008-08-19
Posts: 564

Re: pcurses, a ncurses libalpm package browser

Chippeur wrote:

For the color, if you want to use the transparency of the terminal for example (or just the default colors), the color number should be <b>-1</b>.

Neat, thanks. Pushed smile

Offline

#16 2010-11-21 20:29:11

Sara
Member
From: USA
Registered: 2009-07-09
Posts: 219
Website

Re: pcurses, a ncurses libalpm package browser

schuay wrote:

That should be possible now. I added some short comments that explain which color pairs do what. For example, pane backgrounds are the second (=background) color in pair 5, and the status bar background corresponds to pair 1..

Now pcurses uses my default colors. Many thanks!


Registed Linux User 483618

Offline

#17 2010-12-05 22:11:01

schuay
Package Maintainer (PM)
From: Austria
Registered: 2008-08-19
Posts: 564

Re: pcurses, a ncurses libalpm package browser

Running a filter which produces a large result set should now be lots quicker (from 30+ seconds to ~1 second).

Not much happening here lately, mainly because I'm really busy. Things should pick up again during the christmas vacation smile

Offline

#18 2012-06-03 09:32:28

ilius
Member
From: Iran/Tehran
Registered: 2012-03-12
Posts: 3
Website

Re: pcurses, a ncurses libalpm package browser

What are packages in "cyan" color? (in Packages column)

Offline

#19 2012-06-03 11:39:58

schuay
Package Maintainer (PM)
From: Austria
Registered: 2008-08-19
Posts: 564

Re: pcurses, a ncurses libalpm package browser

ilius wrote:

What are packages in "cyan" color? (in Packages column)

Hi ilius,

the colors have configurable meanings. If you check the status bar at the bottom, it says (in my case) 'Colored by: Repo'.
This means that every repo will have a different color; for example community: white, extra:green, and so on.

You can change which fields colors represent by using the ';' command. ';h' will color the packages by architecture, ';t' by install state, etc.

Offline

#20 2012-06-06 03:57:59

ilius
Member
From: Iran/Tehran
Registered: 2012-03-12
Posts: 3
Website

Re: pcurses, a ncurses libalpm package browser

Thanks, schuay

1-A bug (I think):
$ pcurses -h
Usage: pcurses [-h] [-v]

2- A question: whats the full syntax of:
.: sort packages by specified field
For example how to make it descending? And what exactly can be used after colon?

Last edited by ilius (2012-06-06 03:58:16)

Offline

#21 2012-06-06 06:22:17

schuay
Package Maintainer (PM)
From: Austria
Registered: 2008-08-19
Posts: 564

Re: pcurses, a ncurses libalpm package browser

There is some more documentation in the README file (https://github.com/schuay/pcurses/blob/master/README), which is also conveniently located in the first post of this thread.

The fields that can be used are the highlighted letters displayed in the in the Info section - 'n' in Name, 'k' in Packager, etc. There is currently no way to alter sort ordering, it's fixed to ascending. You can go to the end of the list using the End key though smile

Let me know if something is still unclear.

Last edited by schuay (2012-06-06 06:31:42)

Offline

Board footer

Powered by FluxBB