ObjFW
 
Loading...
Searching...
No Matches
OFStdIOStream.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008-2026 Jonathan Schleifer <js@nil.im>
3 *
4 * All rights reserved.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License version 3.0 only,
8 * as published by the Free Software Foundation.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
13 * version 3.0 for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * version 3.0 along with this program. If not, see
17 * <https://www.gnu.org/licenses/>.
18 */
19
20#import "OFStream.h"
21#import "OFKernelEventObserver.h"
22
23#ifdef OF_AMIGAOS
24# include <dos/dos.h>
25#endif
26
27OF_ASSUME_NONNULL_BEGIN
28
30
31@class OFColor;
32
42#if !defined(OF_WINDOWS) && !defined(OF_AMIGAOS) && !defined(OF_WII_U)
44#endif
45{
46#if defined(OF_AMIGAOS)
47 BPTR _handle;
48 bool _closable;
49#elif !defined(OF_WII_U)
50 int _fd;
51#endif
52 bool _atEndOfStream;
53 int _colors;
54 OFColor *_Nullable _foregroundColor, *_Nullable _backgroundColor;
55 bool _bold, _italic, _underlined, _blinking;
56 uintptr_t _cursorVisible; /* Change type on ABI bump */
57 OF_RESERVE_IVARS(OFStdIOStream, 3)
58}
59
63@property (readonly, nonatomic) bool hasTerminal;
64
69@property (readonly, nonatomic) int columns;
70
75@property (readonly, nonatomic) int rows;
76
81@property (readonly, nonatomic) int colors;
82
100@property OF_NULLABLE_PROPERTY (retain, nonatomic) OFColor *foregroundColor;
101
119@property OF_NULLABLE_PROPERTY (retain, nonatomic) OFColor *backgroundColor;
120
127@property (nonatomic, getter=isBold) bool bold;
128
135@property (nonatomic, getter=isItalic) bool italic;
136
143@property (nonatomic, getter=isUnderlined) bool underlined;
144
151@property (nonatomic, getter=isBlinking) bool blinking;
152
159@property (nonatomic, getter=isCursorVisible) bool cursorVisible;
160
161#if defined(OF_WII) || defined(OF_NINTENDO_DS) || defined(OF_NINTENDO_3DS) || \
162 defined(DOXYGEN)
170#endif
171
172- (instancetype)init OF_UNAVAILABLE;
173
178- (void)reset;
179
184- (void)clear;
185
190- (void)eraseLine;
191
198- (void)setCursorColumn: (unsigned int)column;
199
206- (void)setCursorPosition: (OFPoint)position;
207
214- (void)setRelativeCursorPosition: (OFPoint)position;
215
221- (void)setProgressIndicator: (float)progress;
222
227@end
228
229#ifdef __cplusplus
230extern "C" {
231#endif
233
237extern OFStdIOStream *_Nullable OFStdIn;
238
242extern OFStdIOStream *_Nullable OFStdOut;
243
247extern OFStdIOStream *_Nullable OFStdErr;
248
256extern void OFLog(OFConstantString *format, ...);
257
266extern void OFLogV(OFConstantString *format, va_list arguments);
267#ifdef __cplusplus
268}
269#endif
270
271OF_ASSUME_NONNULL_END
void OFLog(OFConstantString *format,...)
Logs the specified printf-style format to OFStdErr.
Definition OFStdIOStream.m:118
OFStdIOStream * OFStdIn
The standard input as an OFStream.
Definition OFStdIOStream.m:104
OFStdIOStream * OFStdOut
The standard output as an OFStream.
Definition OFStdIOStream.m:105
void OFLogV(OFConstantString *format, va_list arguments)
Logs the specified printf-style format to OFStdErr.
Definition OFStdIOStream.m:128
OFStdIOStream * OFStdErr
The standard error as an OFStream.
Definition OFStdIOStream.m:106
A class for storing a color.
Definition OFColor.h:31
A class for storing constant strings using the @"" literal.
Definition OFConstantString.h:42
instancetype init()
Initializes an already allocated object.
Definition OFObject.m:671
A class for providing standard input, output and error as OFStream.
Definition OFStdIOStream.h:42
bool bold
Whether bold is on on the underlying terminal.
Definition OFStdIOStream.h:127
bool italic
Whether italic is on on the underlying terminal.
Definition OFStdIOStream.h:135
void setUpConsole()
Sets up a console for OFStdOut / OFStdErr output on systems that don't have a console by default.
void eraseLine()
Erases the entire current line on the underlying terminal. Does nothing if there is no underlying ter...
Definition OFStdIOStream.m:997
bool cursorVisible
Whether the cursor of the underlying terminal is visible.
Definition OFStdIOStream.h:159
void clear()
Clears the entire underlying terminal. Does nothing if there is no underlying terminal.
Definition OFStdIOStream.m:985
void reset()
Resets all attributes (color, bold, etc.). Does nothing if there is no underlying terminal.
Definition OFStdIOStream.m:965
bool blinking
Whether blinking is on on the underlying terminal.
Definition OFStdIOStream.h:151
bool underlined
Whether underlined is on on the underlying terminal.
Definition OFStdIOStream.h:143
void removeProgressIndicator()
Removes the terminal's progress indicator.
Definition OFStdIOStream.m:1076
A base class for different types of streams.
Definition OFStream.h:280
This protocol is implemented by classes which can be observed for readiness for reading by OFKernelEv...
Definition OFKernelEventObserver.h:84
This protocol is implemented by classes which can be observed for readiness for writing by OFKernelEv...
Definition OFKernelEventObserver.h:98
A point in 2D space.
Definition OFObject.h:251