@@ -117,11 +117,10 @@ date.microsecond / 1000, me, getpid(), msg]; objc_autoreleasePoolPop(pool); } -#if defined(HAVE_ISATTY) && !defined(OF_WII_U) static int colorToANSI(OFColor *color) { if ([color isEqual: [OFColor black]]) return 30; @@ -156,11 +155,10 @@ if ([color isEqual: [OFColor white]]) return 97; return -1; } -#endif @implementation OFStdIOStream #ifndef OF_WINDOWS + (void)load { @@ -430,11 +428,13 @@ return OFMaxRetainCount; } - (bool)hasTerminal { -#if defined(HAVE_ISATTY) && !defined(OF_WII_U) +#if defined(OF_WII) + return true; +#elif defined(HAVE_ISATTY) && !defined(OF_WII_U) return isatty(_fd); #else return false; #endif } @@ -469,96 +469,81 @@ #endif } - (void)setForegroundColor: (OFColor *)color { -#if defined(HAVE_ISATTY) && !defined(OF_WII_U) int code; - if (!isatty(_fd)) + if (!self.hasTerminal) return; if ((code = colorToANSI(color)) == -1) return; [self writeFormat: @"\033[%um", code]; -#endif } - (void)setBackgroundColor: (OFColor *)color { -#if defined(HAVE_ISATTY) && !defined(OF_WII_U) int code; - if (!isatty(_fd)) + if (!self.hasTerminal) return; if ((code = colorToANSI(color)) == -1) return; [self writeFormat: @"\033[%um", code + 10]; -#endif } - (void)reset { -#if defined(HAVE_ISATTY) && !defined(OF_WII_U) - if (!isatty(_fd)) + if (!self.hasTerminal) return; [self writeString: @"\033[0m"]; -#endif } - (void)clear { -#if defined(HAVE_ISATTY) && !defined(OF_WII_U) - if (!isatty(_fd)) + if (!self.hasTerminal) return; [self writeString: @"\033[2J"]; -#endif } - (void)eraseLine { -#if defined(HAVE_ISATTY) && !defined(OF_WII_U) - if (!isatty(_fd)) + if (!self.hasTerminal) return; [self writeString: @"\033[2K"]; -#endif } - (void)setCursorColumn: (unsigned int)column { -#if defined(HAVE_ISATTY) && !defined(OF_WII_U) - if (!isatty(_fd)) + if (!self.hasTerminal) return; [self writeFormat: @"\033[%uG", column + 1]; -#endif } - (void)setCursorPosition: (OFPoint)position { if (position.x < 0 || position.y < 0) @throw [OFInvalidArgumentException exception]; -#if defined(HAVE_ISATTY) && !defined(OF_WII_U) - if (!isatty(_fd)) + if (!self.hasTerminal) return; [self writeFormat: @"\033[%u;%uH", (unsigned)position.y + 1, (unsigned)position.x + 1]; -#endif } - (void)setRelativeCursorPosition: (OFPoint)position { -#if defined(HAVE_ISATTY) && !defined(OF_WII_U) - if (!isatty(_fd)) + if (!self.hasTerminal) return; if (position.x > 0) [self writeFormat: @"\033[%uC", (unsigned)position.x]; else if (position.x < 0) @@ -566,8 +551,7 @@ if (position.y > 0) [self writeFormat: @"\033[%uB", (unsigned)position.y]; else if (position.y < 0) [self writeFormat: @"\033[%uA", (unsigned)-position.y]; -#endif } @end