ObjFW
OFStdIOStream.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008-2025 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 
27 OF_ASSUME_NONNULL_BEGIN
28 
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  OF_RESERVE_IVARS(OFStdIOStream, 4)
57 }
58 
62 @property (readonly, nonatomic) bool hasTerminal;
63 
68 @property (readonly, nonatomic) int columns;
69 
74 @property (readonly, nonatomic) int rows;
75 
80 @property (readonly, nonatomic) int colors;
81 
99 @property OF_NULLABLE_PROPERTY (retain, nonatomic) OFColor *foregroundColor;
100 
118 @property OF_NULLABLE_PROPERTY (retain, nonatomic) OFColor *backgroundColor;
119 
126 @property (nonatomic, getter=isBold) bool bold;
127 
134 @property (nonatomic, getter=isItalic) bool italic;
135 
142 @property (nonatomic, getter=isUnderlined) bool underlined;
143 
150 @property (nonatomic, getter=isBlinking) bool blinking;
151 
152 #if defined(OF_WII) || defined(OF_NINTENDO_DS) || defined(OF_NINTENDO_3DS) || \
153  defined(DOXYGEN)
154 
160 + (void)setUpConsole;
161 #endif
162 
163 - (instancetype)init OF_UNAVAILABLE;
164 
169 - (void)reset;
170 
175 - (void)clear;
176 
181 - (void)eraseLine;
182 
189 - (void)setCursorColumn: (unsigned int)column;
190 
197 - (void)setCursorPosition: (OFPoint)position;
198 
205 - (void)setRelativeCursorPosition: (OFPoint)position;
206 @end
207 
208 #ifdef __cplusplus
209 extern "C" {
210 #endif
211 
216 extern OFStdIOStream *_Nullable OFStdIn;
217 
221 extern OFStdIOStream *_Nullable OFStdOut;
222 
226 extern OFStdIOStream *_Nullable OFStdErr;
227 
235 extern void OFLog(OFConstantString *format, ...);
236 
245 extern void OFLogV(OFConstantString *format, va_list arguments);
246 #ifdef __cplusplus
247 }
248 #endif
249 
250 OF_ASSUME_NONNULL_END
void OFLogV(OFConstantString *format, va_list arguments)
Logs the specified printf-style format to OFStdErr.
Definition: OFStdIOStream.m:125
This protocol is implemented by classes which can be observed for readiness for reading by OFKernelEv...
A class for storing a color.
Definition: OFColor.h:29
A class for storing constant strings using the @"" literal.
Definition: OFConstantString.h:41
OFStdIOStream * OFStdIn
The standard input as an OFStream.
Definition: OFStdIOStream.m:101
OFStdIOStream * OFStdOut
The standard output as an OFStream.
Definition: OFStdIOStream.m:102
A base class for different types of streams.
Definition: OFStream.h:278
OFStdIOStream * OFStdErr
The standard error as an OFStream.
Definition: OFStdIOStream.m:103
A class for providing standard input, output and error as OFStream.
Definition: OFStdIOStream.h:41
This protocol is implemented by classes which can be observed for readiness for writing by OFKernelEv...
void OFLog(OFConstantString *format,...)
Logs the specified printf-style format to OFStdErr.
Definition: OFStdIOStream.m:115
A point in 2D space.
Definition: OFObject.h:161