Overview
Comment: | OFStdIOStream: Add -[columns] and -[rows] |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
b317a4d56d0b15939fee162ba13fea90 |
User & Date: | js on 2016-10-08 15:57:47 |
Other Links: | manifest | tags |
Context
2016-10-08
| ||
15:57 | OFZIPArchive: Fix ZIP64 support check-in: 7fed52573a user: js tags: trunk | |
15:57 | OFStdIOStream: Add -[columns] and -[rows] check-in: b317a4d56d user: js tags: trunk | |
15:57 | Never override CoreFoundations's forward handler check-in: c70fd7d7f3 user: js tags: trunk | |
Changes
Modified src/OFStdIOStream.h from [70525b9be4] to [5aa96c816e].
︙ | ︙ | |||
30 31 32 33 34 35 36 37 38 39 40 41 42 43 | OF_SUBCLASSING_RESTRICTED #endif @interface OFStdIOStream: OFStream { int _fd; bool _atEndOfStream; } @end #ifdef __cplusplus extern "C" { #endif /*! @file */ | > > > > > > > > > > > > > > > > | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | OF_SUBCLASSING_RESTRICTED #endif @interface OFStdIOStream: OFStream { int _fd; bool _atEndOfStream; } /*! * @brief Query the underlying terminal for the number of columns. * * @return The number of columns, or -1 if there is no underlying terminal or * the number of columns could not be queried */ - (int)columns; /*! * @brief Query the underlying terminal for the number of rows. * * @return The number of rows, or -1 if there is no underlying terminal or the * number of rows could not be queried */ - (int)rows; @end #ifdef __cplusplus extern "C" { #endif /*! @file */ |
︙ | ︙ |
Modified src/OFStdIOStream.m from [9d5e101a97] to [97ab3c33fb].
︙ | ︙ | |||
20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #include <stdlib.h> /* include any libc header to get the libc defines */ #ifdef __GLIBC__ # undef __USE_XOPEN #endif #include <errno.h> #include <unistd.h> #import "OFStdIOStream.h" #import "OFStdIOStream+Private.h" #import "OFDate.h" #import "OFApplication.h" #ifdef OF_WINDOWS # include "OFStdIOStream_Win32Console.h" | > > > > > > > | 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #include <stdlib.h> /* include any libc header to get the libc defines */ #ifdef __GLIBC__ # undef __USE_XOPEN #endif #include <errno.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 "OFStdIOStream.h" #import "OFStdIOStream+Private.h" #import "OFDate.h" #import "OFApplication.h" #ifdef OF_WINDOWS # include "OFStdIOStream_Win32Console.h" |
︙ | ︙ | |||
200 201 202 203 204 205 206 207 | return OF_RETAIN_COUNT_MAX; } - (void)dealloc { OF_DEALLOC_UNSUPPORTED } @end | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | return OF_RETAIN_COUNT_MAX; } - (void)dealloc { OF_DEALLOC_UNSUPPORTED } - (int)columns { #if defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ) struct winsize ws; if (ioctl(_fd, TIOCGWINSZ, &ws) != 0) return -1; return ws.ws_col; #else return -1; #endif } - (int)rows { #if defined(HAVE_SYS_IOCTL_H) && defined(TIOCGWINSZ) struct winsize ws; if (ioctl(_fd, TIOCGWINSZ, &ws) != 0) return -1; return ws.ws_row; #else return -1; #endif } @end |
Modified utils/ofhttp/ProgressBar.m from [6cdf6f1d25] to [dd50353974].
︙ | ︙ | |||
14 15 16 17 18 19 20 | * file. */ #include "config.h" #include <math.h> | < < < < < < < < < | 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 | { _received = received; } - (void)_drawProgress { float bars, percent; | | < < > | | | | | | < | 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 ▕"]; |
︙ | ︙ |