Path: utzoo!utgpu!utstat!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!bloom-beacon!gatech!emcard!stiatl!todd From: todd@stiatl.UUCP (Todd Merriman) Newsgroups: comp.sys.ibm.pc Subject: Re: Detecting ANSI.SYS Message-ID: <4009@stiatl.UUCP> Date: 2 Apr 89 13:44:19 GMT References: <1920@dataio.Data-IO.COM> Reply-To: todd@stiatl.UUCP (Todd Merriman) Organization: Sales Technologies Inc., Atlanta, GA Lines: 78 In article <1920@dataio.Data-IO.COM> bright@Data-IO.COM (Walter Bright) writes: >I'm looking for a reliable and portable way of determining if ANSI.SYS or >an equivalent driver (NANSI.SYS, FANSI.SYS, ANSI.COM, etc) is loaded. This can be achieved by transmitting the "cursor position report" escape sequence and waiting to see if anything comes back as in the following: #ifdef DOCUMENTATION /***************************************************************************** .MODULE isansi .LIBRARY clib .TYPE function .APPLICATION screen .SYSTEM msdos .SYSTEM vms .AUTHOR Todd Merriman .LANGUAGE C .DESCRIPTION Check for presence of ANSI terminal .ARGUMENTS boolean isansi() .NARRATIVE Isansi sends the report cursor escape sequence to the console. If nothing is transmitted back, the function returns 0. .RETURNS TRUE if an ANSI terminal is attached, FALSE otherwise. .ENDOC END DOCUMENTATION *****************************************************************************/ #endif /* DOCUMENTATION */ #include #include "csub.h" /**************************************************************************** Isansi *****************************************************************************/ boolean isansi() { conflush(); /* flush type-ahead */ cputs("\x1B[6n"); /* report cursor position command */ delay(50); /* delay 50 milliseconds */ if (!kbhit()) /* key-pressed? */ { conflush(); return 0; /* no cursor position came back */ } conflush(); return 1; } #ifdef TESTING /* test program */ /***************************************************************************** Main entry *****************************************************************************/ main (argc,argv) int argc; char *argv[]; { puts("ANSI terminal attached?"); puts(isansi()?("YES"):("NO")); puts("> End <"); exit(EXITNORMAL); } /* end of main */ #endif /* TESTING */ /***************************************************************************** End *****************************************************************************/ ...!gatech!stiatl!todd Todd Merriman * 404-377-TOFU * Atlanta, GA Note: I have no idea what my employer's views on the subject are.