Bug 304282 - zypper: progress bar does not redraw properly if window is smaller than text
Summary: zypper: progress bar does not redraw properly if window is smaller than text
Status: RESOLVED FIXED
: 458078 (view as bug list)
Alias: None
Product: openSUSE 11.4
Classification: openSUSE
Component: libzypp (show other bugs)
Version: Factory
Hardware: Other Other
: P4 - Low : Minor with 1 vote (vote)
Target Milestone: ---
Assignee: Dominik Heidler
QA Contact: Stanislav Visnovsky
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-08-24 11:59 UTC by Andreas Jaeger
Modified: 2011-04-11 14:51 UTC (History)
6 users (show)

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Jaeger 2007-08-24 11:59:53 UTC
Try running zypper search/zypper in with a terminal that is smaller than the repository.  You will get some interesting effects like the following:

$ zypper in gnomebreakpad
\ Reading repository 'http://download.opensuse.org/distribution/SL-OSS-factory/inst-sour| Reading repository 'http://download.opensuse.org/distribution/SL-OSS-factory/inst-sour/ Reading repository 'http://download.opensuse.org/distribution/SL-OSS-factory/inst-sour- Reading repository 'http://download.opensuse.org/distribution/SL-OSS-factory/inst-sour\ Reading repository 'http://download.opensuse.org/distribution/SL-OSS-factory/inst-sour| Reading repository 'http://download.opensuse.org/distribution/SL-OSS-factory/inst-sour/ Reading repository 'http://download.opensuse.org/distribution/SL-OSS-factory/inst-sour* Reading repository 'http://download.opensuse.org/distribution/SL-OSS-factory/inst-source/' cache
- Reading repository 'http://download.opensuse.org/distribution/SL-Factory-non-oss/inst-\ Reading repository 'http://download.opensuse.org/distribution/SL-Factory-non-oss/inst-| Reading repository 'http://download.opensuse.org/distribution/SL-Factory-non-oss/inst-* Reading repository 'http://download.opensuse.org/distribution/SL-Factory-non-oss/inst-source-extra/' cache
* Reading installed packages [100%]

See how the line is duplicated - instead of overdrawn.
Comment 1 Jan Kupec 2007-08-28 13:49:52 UTC
Yes, a known issue. Any hints how to fix it anyone? The CR character does not do its trick when the line is written over multiple console lines.
Comment 2 Stanislav Visnovsky 2007-09-04 08:01:29 UTC
To use COLUMNS environment variable to limit the size?
Comment 3 Jan Kupec 2007-09-04 14:08:06 UTC
Hm. I would cut the output to fit the width only as a last resort... 

But COLUMNS is a shell variable, and as such is not automatically visible to processes (AFAIK). How to get it into or read it from zypper?
Comment 4 Andreas Jaeger 2007-09-04 17:50:38 UTC
Use e.g.:
columns = getenv ("COLUMNS");

for details: man 3 getenv
Comment 5 Jan Kupec 2007-09-04 17:56:52 UTC
Andreas, COLUMNS is not an environment variable. getenv() will not get it, if it wasn't exported before zypper started. And even then, you won't get actual value if you resize your xterm on-the-fly.
Comment 6 Andreas Jaeger 2007-09-04 18:20:07 UTC
Jan, you're right.  Let's delete comments 4 and 5 ;-)

Werner, can you help us?
Comment 7 Dr. Werner Fink 2007-09-05 08:52:06 UTC
Simply switch the console into bold mode, e.g. on the prompt one
can do this with

  /suse/werner> tput bold

The escape sequence is simple \033[1m for the linux console. This can
be done also in a C/C++ program with the help of ncurses, see e.g.
manual page attrset(3ncurses) or wattrset(3ncurses), and the macros
A_BOLD/WA_BOLD.  Beside this ncurses uses well defined terminal
settings.
Comment 8 Martin Vidner 2007-09-05 12:39:26 UTC
Thanks Werner :-)
mvidner@valkyrie:~$ tput cols
178
Comment 9 Jan Kupec 2007-09-11 17:23:06 UTC
delaying to openSUSE 11
Comment 10 Michael Schröder 2008-04-17 11:09:03 UTC
FYI: The standard way to get the width is:

1) do a TIOCGWINSZ ioctl on fd 1 (this is what the stty command does, see also the tty_ioctl man page). If it succeeds and doesn't return 0 in the ws_col element, you have your width.
2) otherwise check the COLUMNS environment variable. If it is set and not zero, use it.
3) otherwise assume a line length of 80.
Comment 11 Michael Schröder 2008-04-17 11:10:31 UTC
(As Michael Matz just pointed out: if you're using readline, there's the rl_get_screen_size function)
Comment 12 Dr. Werner Fink 2008-04-17 11:29:23 UTC
Also using ncurses is usable to get the width/height of the terminal screen
called `stdscr' in ncurses.   For this the macros found in the manual page
getyx(3ncurses) can be used.
Comment 13 Jan Kupec 2008-04-17 11:54:22 UTC
Thanx Michaels :O)

@Werener: i can imagine curses have lots of usefull stuff for terminal output, but zypper does not need most of them, so it would be a little bit too much to have to depend on ncruses because of few functions...
Comment 14 Jan Kupec 2008-12-11 09:35:15 UTC
*** Bug 458078 has been marked as a duplicate of this bug. ***
Comment 15 Jan Kupec 2010-09-29 13:50:10 UTC
still relevant in 11.4
Comment 17 Dominik Heidler 2011-04-11 14:51:31 UTC
fixed in zypper 1.5.6 (git commit 2d3e98311094aa503b50e1a2f6d10bb5bcf02d9c)