src/render/rConsoleCout.cpp File Reference

#include "aa_config.h"
#include "rConsole.h"
#include "rFont.h"
#include "tConfiguration.h"
#include <stdio.h>
#include <fcntl.h>
#include <sstream>
#include <signal.h>

Include dependency graph for rConsoleCout.cpp:

Go to the source code of this file.

Defines

#define MAXLINE   1000

Functions

static void sr_HandleSigCont (int signal)
void sr_Unblock_stdin ()
void sr_Read_stdin ()

Variables

static int stdin_descriptor
static bool unblocked = false
static char line_in [MAXLINE+2]
static int currentIn = 0


Define Documentation

#define MAXLINE   1000

Definition at line 86 of file rConsoleCout.cpp.

Referenced by sr_Read_stdin().


Function Documentation

static void sr_HandleSigCont ( int  signal  )  [static]

Definition at line 57 of file rConsoleCout.cpp.

References sr_Unblock_stdin().

Referenced by sr_Unblock_stdin().

00058 {
00059     // con << "Continuing.\n";
00060 
00061     // unblock stdin again
00062     sr_Unblock_stdin();
00063 }

Here is the call graph for this function:

Here is the caller graph for this function:

void sr_Read_stdin (  ) 

Definition at line 90 of file rConsoleCout.cpp.

References rConsole::currentIn, line_in, tConfItemBase::LoadAll(), tConfItemBase::LoadPlayback(), MAXLINE, NULL, stdin_descriptor, and unblocked.

Referenced by sg_HostGame(), and update_settings().

00090                     {
00091     tConfItemBase::LoadPlayback( true );
00092 
00093     if ( !unblocked )
00094     {
00095         return;
00096     }
00097 #ifdef WIN32
00098     //  std::cerr << "\n";
00099 
00100     HANDLE stdinhandle = GetStdHandle(STD_INPUT_HANDLE);
00101     HANDLE stdouthandle = GetStdHandle(STD_OUTPUT_HANDLE);
00102     bool goon = true;
00103     while (goon)
00104     {
00105         unsigned long reallyread;
00106         INPUT_RECORD input;
00107         PeekConsoleInput(stdinhandle, &input, 1, &reallyread);
00108         if (reallyread > 0)
00109         {
00110             ReadConsoleInput(stdinhandle, &input, 1, &reallyread);
00111             if (input.EventType == KEY_EVENT)
00112             {
00113                 char key = input.Event.KeyEvent.uChar.AsciiChar;
00114                 DWORD written=0;
00115 
00116                 if (key && input.Event.KeyEvent.bKeyDown)
00117                 {
00118                     WriteConsole(stdouthandle, &key, 1, &written, NULL);
00119                     line_in[currentIn] = key;
00120 
00121                     if (key == 13 || currentIn>=MAXLINE-1){
00122                         line_in[currentIn]='\n';
00123                         line_in[currentIn+1]='\0';
00124                         std::stringstream s(line_in);
00125                         WriteConsole(stdouthandle, "\n", 1, &written, NULL);
00126                         tConfItemBase::LoadAll(s);
00127                         currentIn=0;
00128                     }
00129                     else
00130                         currentIn++;
00131                 }
00132             }
00133             //          bool ret=ReadFile(stdinhandle, &line_in[currentIn], 1, &reallyread, NULL);
00134         }
00135         else
00136             goon = false;
00137     }
00138 
00139 
00140 #else
00141     while ( read(stdin_descriptor,&line_in[currentIn],1)>0){
00142         if (line_in[currentIn]=='\n' || currentIn>=MAXLINE-1)
00143         {
00144             line_in[currentIn+1]='\0';
00145             std::stringstream s(line_in);
00146             tConfItemBase::LoadAll(s);
00147             currentIn=0;
00148         }
00149         else
00150             currentIn++;
00151     }
00152 #endif
00153 }

Here is the call graph for this function:

Here is the caller graph for this function:

void sr_Unblock_stdin (  ) 

Definition at line 65 of file rConsoleCout.cpp.

References sr_HandleSigCont(), stdin_descriptor, and unblocked.

Referenced by main(), and sr_HandleSigCont().

00065                        {
00066 #ifndef WIN32
00067     if ( !unblocked )
00068     {
00069         signal( SIGCONT, &sr_HandleSigCont );
00070     }
00071 #endif
00072 
00073     unblocked = true;
00074     stdin_descriptor=fileno(stdin);
00075 #ifndef WIN32
00076     // if (isatty(stdin_descriptor))
00077     {
00078         int flag=fcntl(stdin_descriptor,F_GETFL);
00079         fcntl(stdin_descriptor,F_SETFL,flag | O_NONBLOCK);
00080     }
00081 #endif
00082 }

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

int currentIn = 0 [static]

Definition at line 88 of file rConsoleCout.cpp.

Referenced by su_GetSDLInput(), and su_StoreSDLEvent().

char line_in[MAXLINE+2] [static]

Definition at line 87 of file rConsoleCout.cpp.

Referenced by sr_Read_stdin().

int stdin_descriptor [static]

Definition at line 54 of file rConsoleCout.cpp.

Referenced by sr_Read_stdin(), and sr_Unblock_stdin().

bool unblocked = false [static]

Definition at line 55 of file rConsoleCout.cpp.

Referenced by sr_Read_stdin(), and sr_Unblock_stdin().


Generated on Sat Mar 15 23:02:39 2008 for Armagetron Advanced by  doxygen 1.5.4