Commit 0661ff87 authored by bitplane's avatar bitplane

Allow console device to fprintf output to a FILE* (via WindowId). Defaults to stdout

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2530 dfc29bdd-3216-0410-991c-e03cc46cb475
parent ffb7a5c3
......@@ -64,7 +64,7 @@ const u16 ASCIIArtCharsCount = 32;
//! constructor
CIrrDeviceConsole::CIrrDeviceConsole(const SIrrlichtCreationParameters& params)
: CIrrDeviceStub(params), IsDeviceRunning(true), IsWindowFocused(true), ConsoleFont(0)
: CIrrDeviceStub(params), IsDeviceRunning(true), IsWindowFocused(true), ConsoleFont(0), OutFile(stdout)
{
DeviceToClose = this;
......@@ -99,13 +99,17 @@ CIrrDeviceConsole::CIrrDeviceConsole(const SIrrlichtCreationParameters& params)
signal(SIGABRT, &sighandler);
signal(SIGTERM, &sighandler);
signal(SIGINT, &sighandler);
// set output stream
if (params.WindowId)
OutFile = (FILE*)(params.WindowId);
#endif
#ifdef _IRR_VT100_CONSOLE_
// reset terminal
printf("%cc", 27);
fprintf(OutFile, "%cc", 27);
// disable line wrapping
printf("%c[7l", 27);
fprintf(OutFile, "%c[7l", 27);
#endif
switch (params.DriverType)
......@@ -187,7 +191,7 @@ CIrrDeviceConsole::~CIrrDeviceConsole()
}
#ifdef _IRR_VT100_CONSOLE_
// reset terminal
printf("%cc", 27);
fprintf(OutFile, "%cc", 27);
#endif
}
......@@ -400,7 +404,7 @@ bool CIrrDeviceConsole::present(video::IImage* surface, void* windowId, core::re
for (u32 y=0; y<OutputBuffer.size(); ++y)
{
setTextCursorPos(0,y);
printf("%s", OutputBuffer[y].c_str());
fprintf(OutFile, "%s", OutputBuffer[y].c_str());
}
return surface != 0;
}
......@@ -434,7 +438,7 @@ void CIrrDeviceConsole::setTextCursorPos(s16 x, s16 y)
SetConsoleCursorPosition(WindowsSTDOut, Position);
#elif defined(_IRR_VT100_CONSOLE_)
// send escape code
printf("%c[%d;%dH", 27, y, x);
fprintf(OutFile, "%c[%d;%dH", 27, y, x);
#else
// not implemented
#endif
......
......@@ -2,7 +2,6 @@
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#ifndef __C_IRR_DEVICE_CONSOLE_H_INCLUDED__
#define __C_IRR_DEVICE_CONSOLE_H_INCLUDED__
......@@ -225,6 +224,8 @@ namespace irr
gui::IGUIFont *ConsoleFont;
core::array<SPostPresentText> Text;
FILE *OutFile;
#ifdef _IRR_WINDOWS_NT_CONSOLE_
HANDLE WindowsSTDIn, WindowsSTDOut;
u32 MouseButtonStates;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment