终端或控制台中的就地进度输出 [英] In-place progress output in the terminal or console

查看:24
本文介绍了终端或控制台中的就地进度输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当您运行 git clone 时,它会就地更新进度.例如,接收到的对象的百分比就地发生了变化.

When you run git clone, it updates progress in place. For example, the percentage of the objects received changes in place.

user@athena:~/cloj/src$ git clone git://git.boinkor.net/slime.git
Initialized empty Git repository in /home/user/cloj/src/slime/.git/
remote: Counting objects: 15936, done.
remote: Compressing objects: 100% (5500/5500), done.
Receiving objects:  28% (4547/15936), 3.16 MiB | 165 KiB/s

这是怎么实现的?它使用 ncurses 还是更简单的东西,比如退格字符和常规字符输出的某种组合?

How is this acccomplished? Does it use ncurses or something even simpler, like some combination of backspace characters and regular character output?

我对如何从 Ruby 完成这种控制台输出特别感兴趣.

I'm especially interested in how this kind of console output could be accomplished from Ruby.

编辑

我原来的问题得到了回答.但这是一个附录.例如,当您使用 MPlayer 时,它不仅会更新一行以显示当前进度,还会更新上一行(例如,当您按下暂停键时).

My original question is answered. But here's an addendum. When you use MPlayer, for example, it not only updates a line to show current progress, but also the previous line (e.g. when you press pause).

 =====  PAUSE  =====
A:  79.9 (01:19.9) of 4718.0 ( 1:18:38.0)  0.3% 

如何就地更新两行输出?

How would you update two lines of output in-place?

推荐答案

使用回车.' ' 通常应该可以工作.

Use carriage return. ' ' should usually work.

这篇关于终端或控制台中的就地进度输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆