@@ -51,10 +51,14 @@ # include # include # undef Class # undef HAVE_ISATTY #endif + +#ifdef OF_MSDOS +# include +#endif #ifdef OF_WII_U # define BOOL WUT_BOOL # include # undef BOOL @@ -440,11 +444,17 @@ #endif } - (int)columns { -#if defined(HAVE_IOCTL) && defined(TIOCGWINSZ) && \ +#if defined(OF_MSDOS) + struct text_info ti; + + gettextinfo(&ti); + + return ti.screenwidth; +#elif defined(HAVE_IOCTL) && defined(TIOCGWINSZ) && \ !defined(OF_AMIGAOS) && !defined(OF_WII_U) struct winsize ws; if (ioctl(_fd, TIOCGWINSZ, &ws) != 0) return -1; @@ -455,11 +465,17 @@ #endif } - (int)rows { -#if defined(HAVE_IOCTL) && defined(TIOCGWINSZ) && \ +#if defined(OF_MSDOS) + struct text_info ti; + + gettextinfo(&ti); + + return ti.screenwidth; +#elif defined(HAVE_IOCTL) && defined(TIOCGWINSZ) && \ !defined(OF_AMIGAOS) && !defined(OF_WII_U) struct winsize ws; if (ioctl(_fd, TIOCGWINSZ, &ws) != 0) return -1; @@ -523,11 +539,15 @@ - (void)setCursorColumn: (unsigned int)column { if (!self.hasTerminal) return; +#ifdef OF_MSDOS + gotoxy(column + 1, wherey()); +#else [self writeFormat: @"\033[%uG", column + 1]; +#endif } - (void)setCursorPosition: (OFPoint)position { if (position.x < 0 || position.y < 0) @@ -534,25 +554,33 @@ @throw [OFInvalidArgumentException exception]; if (!self.hasTerminal) return; +#ifdef OF_MSDOS + gotoxy(position.x + 1, position.y + 1); +#else [self writeFormat: @"\033[%u;%uH", (unsigned)position.y + 1, (unsigned)position.x + 1]; +#endif } - (void)setRelativeCursorPosition: (OFPoint)position { if (!self.hasTerminal) return; +#ifdef OF_MSDOS + gotoxy(wherex() + position.x, wherey() + position.y); +#else if (position.x > 0) [self writeFormat: @"\033[%uC", (unsigned)position.x]; else if (position.x < 0) [self writeFormat: @"\033[%uD", (unsigned)-position.x]; 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