ObjFW  Diff

Differences From Artifact [6cdf6f1d25]:

To Artifact [dd50353974]:


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
 * file.
 */

#include "config.h"

#include <math.h>

#include <unistd.h>

#ifdef HAVE_SYS_IOCTL_H
# include <sys/ioctl.h>
#endif
#ifdef HAVE_SYS_TTYCOM_H
# include <sys/ttycom.h>
#endif

#import "OFDate.h"
#import "OFStdIOStream.h"
#import "OFTimer.h"

#import "ProgressBar.h"

#define GIBIBYTE (1024 * 1024 * 1024)







<
<
<
<
<
<
<
<
<







14
15
16
17
18
19
20









21
22
23
24
25
26
27
 * file.
 */

#include "config.h"

#include <math.h>










#import "OFDate.h"
#import "OFStdIOStream.h"
#import "OFTimer.h"

#import "ProgressBar.h"

#define GIBIBYTE (1024 * 1024 * 1024)
89
90
91
92
93
94
95
96
97
98
99

100
101
102
103
104
105
106
107
108
109
110
111
112
113
{
	_received = received;
}

- (void)_drawProgress
{
	float bars, percent;
	unsigned short barWidth;
#if defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ)
	struct winsize ws;


	if (ioctl(0, TIOCGWINSZ, &ws) == 0 && ws.ws_col > 37)
		barWidth = ws.ws_col - 37;
	else
		barWidth = 0;
#else
	barWidth = 43;
#endif

	bars = (float)(_resumedFrom + _received) /
	    (float)(_resumedFrom + _length) * barWidth;
	percent = (float)(_resumedFrom + _received) /
	    (float)(_resumedFrom + _length) * 100;

	[of_stdout writeString: @"\r  ▕"];







|
<
<

>
|
|
|
|
|
|
<







80
81
82
83
84
85
86
87


88
89
90
91
92
93
94
95

96
97
98
99
100
101
102
{
	_received = received;
}

- (void)_drawProgress
{
	float bars, percent;
	int columns, barWidth;



	if ((columns = [of_stdout columns]) >= 0) {
		if (columns > 37)
			barWidth = columns - 37;
		else
			barWidth = 0;
	} else
		barWidth = 43;


	bars = (float)(_resumedFrom + _received) /
	    (float)(_resumedFrom + _length) * barWidth;
	percent = (float)(_resumedFrom + _received) /
	    (float)(_resumedFrom + _length) * 100;

	[of_stdout writeString: @"\r  ▕"];