Пример #1
0
/*
==================
CON_Show
==================
*/
static void CON_Show( void )
{
	CONSOLE_SCREEN_BUFFER_INFO binfo;
	COORD writeSize = { MAX_EDIT_LINE, 1 };
	COORD writePos = { 0, 0 };
	SMALL_RECT writeArea = { 0, 0, 0, 0 };
	COORD cursorPos;
	int i;
	CHAR_INFO line[ MAX_EDIT_LINE ];
	WORD attrib;

	GetConsoleScreenBufferInfo( qconsole_hout, &binfo );

	// if we're in the middle of printf, don't bother writing the buffer
	if( !qconsole_drawinput )
		return;

	writeArea.Left = 0;
	writeArea.Top = binfo.dwCursorPosition.Y; 
	writeArea.Bottom = binfo.dwCursorPosition.Y; 
	writeArea.Right = MAX_EDIT_LINE;

	// set color to white
	attrib = CON_ColorCharToAttrib( COLOR_WHITE );

	// build a space-padded CHAR_INFO array
	for( i = 0; i < MAX_EDIT_LINE; i++ )
	{
		if( i < qconsole_linelen )
		{
			if( Q_IsColorString( qconsole_line + i ) )
				attrib = CON_ColorCharToAttrib( *( qconsole_line + i + 1 ) );

			line[ i ].Char.AsciiChar = qconsole_line[ i ];
		}
		else
			line[ i ].Char.AsciiChar = ' ';

		line[ i ].Attributes = attrib;
	}

	if( qconsole_linelen > binfo.srWindow.Right )
	{
		WriteConsoleOutput( qconsole_hout, 
			line + (qconsole_linelen - binfo.srWindow.Right ),
			writeSize, writePos, &writeArea );
	}
	else
	{
		WriteConsoleOutput( qconsole_hout, line, writeSize,
			writePos, &writeArea );
	}

	// set curor position
	cursorPos.Y = binfo.dwCursorPosition.Y;
	cursorPos.X = qconsole_linelen > binfo.srWindow.Right ? binfo.srWindow.Right : qconsole_linelen;

	SetConsoleCursorPosition( qconsole_hout, cursorPos );
}
Пример #2
0
/*
==================
CON_Show
==================
*/
static void CON_Show( void )
{
	CONSOLE_SCREEN_BUFFER_INFO binfo;
	COORD                      writeSize = { MAX_EDIT_LINE, 1 };
	COORD                      writePos = { 0, 0 };
	SMALL_RECT                 writeArea = { 0, 0, 0, 0 };
	int                        i;
	CHAR_INFO                  line[ MAX_EDIT_LINE ];

	GetConsoleScreenBufferInfo( qconsole_hout, &binfo );

	// if we're in the middle of printf, don't bother writing the buffer
	if ( binfo.dwCursorPosition.X != 0 )
	{
		return;
	}

	writeArea.Left = 0;
	writeArea.Top = binfo.dwCursorPosition.Y;
	writeArea.Bottom = binfo.dwCursorPosition.Y;
	writeArea.Right = MAX_EDIT_LINE;

	// build a space-padded CHAR_INFO array
	for ( i = 0; i < MAX_EDIT_LINE; i++ )
	{
		if ( i < qconsole_linelen )
		{
			line[ i ].Char.AsciiChar = qconsole_line[ i ];
		}
		else
		{
			line[ i ].Char.AsciiChar = ' ';
		}

		line[ i ].Attributes = qconsole_attrib;
	}

	if ( qconsole_linelen > binfo.srWindow.Right )
	{
		WriteConsoleOutput( qconsole_hout,
		                    line + ( qconsole_linelen - binfo.srWindow.Right ),
		                    writeSize, writePos, &writeArea );
	}
	else
	{
		WriteConsoleOutput( qconsole_hout, line, writeSize,
		                    writePos, &writeArea );
	}
}
Пример #3
0
void MYclrwin(int left, int top, int right, int bottom) 
// efface une zone de l'écran
{     
  int i ;
  COORD dwCoord = {0, 0} ;
  COORD dwSize = {(right-left+1),(bottom-top+1)} ;
  HANDLE hScreen=GetStdHandle(STD_OUTPUT_HANDLE) ;
  CHAR_INFO Buffer[dwSize.X*dwSize.Y] ;
  SMALL_RECT Region[2] ;
  CONSOLE_SCREEN_BUFFER_INFO Info;
  
  if(GetConsoleScreenBufferInfo(hScreen, &Info))
  {
      for(i=0 ; i < dwSize.X*dwSize.Y ; i++)
      {
            Buffer[i].Char.AsciiChar=' ' ;
            Buffer[i].Attributes = Info.wAttributes ;
      }    
      Region[0].Left = left-1 ;
      Region[0].Right = right-1 ;
      Region[0].Top = top-1 ;
      Region[0].Bottom = bottom-1 ;
      WriteConsoleOutput(hScreen, (CHAR_INFO*) Buffer, dwSize, dwCoord, Region) ;
      gotoxy (left, top);
  }  
  
}
Пример #4
0
int main()
{
    int bossmap[5][5]=
                {
                 { 92,  0, 30,  0, 47},
                 {126,  4,197,  4,126},
                 {126, 17,197, 16,126},
                 {126,  4,197,  4,126},
                 { 47,111,  0,111, 92}
                };
    int i,j;
    CHAR_INFO boss[25];
    COORD zerozero={0,0},bosssz={5,5};
    SMALL_RECT bossrect={5,5,10,10};
    for(i=0;i<5;i++)
    {
        for(j=0;j<5;j++)
        {
            boss[j+5*i].Char.AsciiChar=bossmap[i][j];
            boss[j+5*i].Attributes=12;
        }
    }
    WriteConsoleOutput(GetStdHandle(STD_OUTPUT_HANDLE),boss,bosssz,zerozero,&bossrect);
    getch();
    return 0;
}
Пример #5
0
void
puttext (int left, int top, int right, int bottom, struct char_info * buf)
{ 
    int i, j, n;
    SMALL_RECT r;
    CHAR_INFO* buffer;
    COORD size;

    __fill_text_info();
    r = (SMALL_RECT) {__CONIO_LEFT + left - 1, __CONIO_TOP + top - 1,
      __CONIO_LEFT + right - 1, __CONIO_TOP + bottom - 1};
    size.X = right - left + 1;
    size.Y = bottom - top + 1;
    buffer = malloc (size.X * size.Y * sizeof(CHAR_INFO));

    for (i = n = 0; i < size.Y; i++)
    for (j = 0; j < size.X; j++)
    {
#ifdef UNICODE
        buffer[__CALC_POS(i, j)].Char.UnicodeChar = buf[n].letter;
#else
        buffer[__CALC_POS(i, j)].Char.AsciiChar = buf[n].letter;
#endif
        buffer[__CALC_POS(i, j)].Attributes = buf[n].attr;
        n++;
    }

    WriteConsoleOutput (GetStdHandle (STD_OUTPUT_HANDLE),
      buffer, size, (COORD) {0, 0}, &r);
    free (buffer);
}
Пример #6
0
void insline()
{
    int y=wherey() ;
    HANDLE hScreen = GetStdHandle(STD_OUTPUT_HANDLE) ;
    CONSOLE_SCREEN_BUFFER_INFO Info ;
    GetConsoleScreenBufferInfo(hScreen, &Info) ;
    {
        COORD dwBufferSize={Info.dwSize.X, Info.dwSize.Y - y} ;
        COORD dwBufferCoord={0,0} ;
        COORD coord={0, y-1} ; // pour FillConsoleOutputCharacter
        CHAR_INFO Buffer[dwBufferSize.Y][dwBufferSize.X] ;
        DWORD dwWritten;
        SMALL_RECT ReadRegion[2] ;
        ReadRegion[0].Left = 0 ;
        ReadRegion[0].Right = Info.dwSize.X-1 ;
        ReadRegion[0].Top = y-1 ;
        ReadRegion[0].Bottom = Info.dwSize.Y-2 ;
    
        ReadConsoleOutput(hScreen, (CHAR_INFO*)Buffer, dwBufferSize, dwBufferCoord, ReadRegion) ;
        ReadRegion[0].Top = y ;
        ReadRegion[0].Bottom = Info.dwSize.Y-1 ;
        WriteConsoleOutput(hScreen, (CHAR_INFO*)Buffer, dwBufferSize, dwBufferCoord, ReadRegion) ;
        FillConsoleOutputCharacter (hScreen, ' ', Info.dwSize.X, coord, &dwWritten); // Effacer ligne
        FillConsoleOutputAttribute (hScreen, Info.wAttributes, Info.dwSize.X, coord, &dwWritten);
    }    
}
Пример #7
0
void Console_PutText(int x1, int y1, int x2, int y2, CHAR_INFO *data)
{
	CONSOLE_SCREEN_BUFFER_INFO cinf;
	COORD dwBufferSize;
	COORD dwBufferCoord;
	SMALL_RECT WriteRegion;

	g_console.hWork = GetStdHandle(STD_OUTPUT_HANDLE);
	GetConsoleScreenBufferInfo(g_console.hWork, &cinf);

#ifndef LOCATE_ABSORUTE
	y1 += cinf.srWindow.Top;
	y2 += cinf.srWindow.Top;
#endif
	g_console.hWork = GetStdHandle(STD_OUTPUT_HANDLE);

	dwBufferSize.X = x2 - x1 + 1;
	dwBufferSize.Y = y2 - y1 + 1;
	dwBufferCoord.X = 0;
	dwBufferCoord.Y = 0;

	WriteRegion.Top = y1;
	WriteRegion.Left = x1;
	WriteRegion.Bottom = y2;
	WriteRegion.Right = x2;

	WriteConsoleOutput(
		g_console.hWork,
		data,
		dwBufferSize,
		dwBufferCoord,
		&WriteRegion
	);
}
void
ConsoleDebugger::OnWriteConsoleOutputW(Process *proc,
    ThreadInfo *threadInfo, Breakpoint *brkpt, PDWORD returnValue,
    DWORD direction)
{
    WCHAR buf[1024];
    PVOID ptr;
    DWORD n;
    WCHAR *p, *end;
    int maxbuf;
    COORD bufferSize;
    COORD bufferCoord;
    COORD curr;
    SMALL_RECT writeRegion;
    CHAR_INFO *charBuf, *pcb;
    SHORT x, y;

    if (*returnValue == 0) {
	return;
    }

    bufferSize = *((PCOORD) &threadInfo->args[2]);
    bufferCoord = *((PCOORD) &threadInfo->args[3]);
    ptr = (PVOID) threadInfo->args[4]; // Get the rectangle written
    if (ptr == 0L) return;
    ReadSubprocessMemory(proc, ptr, &writeRegion, sizeof(SMALL_RECT));

    ptr = (PVOID) threadInfo->args[1]; // Get character array
    if (ptr == 0L) return;

    n = bufferSize.X * bufferSize.Y * sizeof(CHAR_INFO);
    charBuf = new CHAR_INFO [n];

    ReadSubprocessMemory(proc, ptr, charBuf, n);

    for (y = 0; y <= writeRegion.Bottom - writeRegion.Top; y++) {
	pcb = charBuf + ((y + bufferCoord.Y) * bufferSize.X) + bufferCoord.X;
	p = buf;
	maxbuf = sizeof(buf);
	end = buf + maxbuf;
	for (x = 0; x <= writeRegion.Right - writeRegion.Left; x++, pcb++) {
	    *p++ = (CHAR) (pcb->Char.UnicodeChar & 0xff);
	    if (p == end) {
		WriteMaster((char *)buf, maxbuf);
		p = buf;
	    }
	}
	curr.X = writeRegion.Left;
	curr.Y = writeRegion.Top + y;
	n = writeRegion.Right - writeRegion.Left;
	CreateVtSequence(proc, curr, n);
	maxbuf = p - buf;
	WriteMaster((char *)buf, maxbuf);
	buf[maxbuf] = 0;
    }

    WriteConsoleOutput(hCopyScreenBuffer, charBuf, bufferSize, bufferCoord, &writeRegion);

    delete [] charBuf;
}
Пример #9
0
int puttext(int left, int top, int right, int bottom, void *source)
{
    int x, y ;
    HANDLE hScreen = GetStdHandle(STD_OUTPUT_HANDLE) ;
    COORD dwBufferSize={right-left+1, bottom-top+1} ;
    COORD dwBufferCoord={0,0} ;
    CHAR_INFO Buffer[dwBufferSize.Y][dwBufferSize.X] ;
    SMALL_RECT ReadRegion[2] ;
    ReadRegion[0].Left = left-1 ;
    ReadRegion[0].Right = right-1 ;
    ReadRegion[0].Top = top-1 ;
    ReadRegion[0].Bottom = bottom-1 ;
    
    for (x=0 ; x<dwBufferSize.X ; x++)
    {
       for (y=0 ; y<dwBufferSize.Y ; y++)
       {
          Buffer[y][x].Char.AsciiChar = *((char*)source+(2*(dwBufferSize.X*y+x))) ;  
          Buffer[y][x].Attributes = *((char*)source+(2*(dwBufferSize.X*y+x)+1)) ;  
       }    
    }    
    
    return WriteConsoleOutput(hScreen, (CHAR_INFO*) Buffer, dwBufferSize, 
            dwBufferCoord, ReadRegion) ;
}
Пример #10
0
JNIEXPORT void JNICALL Java_com_yifanlu_Josh_Josh_WRITECONSOLEOUTPUT
  (JNIEnv *env, jclass jcls, jlong pointer, jobjectArray data, jint sizeX, jint sizeY, jint coordX, jint coordY, jint writeLeft, jint writeTop, jint writeRight, jint writeBottom)
{
    HANDLE hConsole = pointerToHandle(pointer);
    CHAR_INFO *chiBuffer = new CHAR_INFO[sizeX * sizeY];
    COORD coordBufSize;
    COORD coordBufCoord;
	SMALL_RECT srctWriteRect;

    srctWriteRect.Top = writeTop; // Row start : ex 1
    srctWriteRect.Left = writeLeft; // Column start : ex 1
    srctWriteRect.Right = writeRight; // Column end : 9
    srctWriteRect.Bottom = writeBottom; // Row end : 2
    coordBufSize.X = sizeX; // Size 9 columns
    coordBufSize.Y = sizeY; // Size 2 rows
    coordBufCoord.X = 0; // Dest. row 1
    coordBufCoord.Y = 0; // Dest. col 1

	for(int x=0; x<(sizeX*sizeY); x++)
	{
		jintArray element = (jintArray)env->GetObjectArrayElement(data,x);
		jint *body = env->GetIntArrayElements(element, 0);
		chiBuffer[x].Char.UnicodeChar = (char)body[0];
		chiBuffer[x].Attributes = body[1];
	}

	WriteConsoleOutput(hConsole, chiBuffer,	coordBufSize, coordBufCoord, &srctWriteRect);
}
Пример #11
0
void
console_widget_NT_t::draw()
{
	if (console == NULL) {
		COORD c = {0, 0};
		DWORD z;
		if (!FillConsoleOutputCharacter
		    (buffer, blank.Char.AsciiChar, size.X * size.Y, c, &z))
			co_debug("FillConsoleOutputCharacter() error code %d\n",
				 GetLastError());
		if (!FillConsoleOutputAttribute
		    (buffer, blank.Attributes, size.X * size.Y, c, &z))
			co_debug("FillConsoleOutputAttribute() error code %d\n",
				 GetLastError());
		return;
	}

	co_console_cell_t *cell = console->screen;
	CHAR_INFO *ci = screen;
	int count = size.X * size.Y;

	do {
		ci->Attributes = cell->attr;
		(ci++)->Char.AsciiChar = (cell++)->ch;
	} while (--count);

	SMALL_RECT r = region;
	COORD c = {0, 0};

	if (!WriteConsoleOutput(buffer, screen, size, c, &r))
		co_debug("WriteConsoleOutput() error %d \n", GetLastError());
}
Пример #12
0
co_rc_t
console_widget_NT_t::op_putc(
		const co_console_unit &Y,
		const co_console_unit &X,
		const co_console_character &C)
{
	SMALL_RECT r;
	COORD c;

	if (Y >= size.Y || X >= size.X) {
		co_debug("putc error\n");
		return CO_RC(ERROR);
	}

	c.X = r.Left = r.Right = X;
	c.Y = r.Top = r.Bottom = Y;

	CHAR_INFO *ci = &screen[(size.X * r.Top) + r.Left];
	ci->Attributes = ((C & 0xFF00) >> 8);
	ci->Char.AsciiChar = (C & 0x00FF);

	if (!WriteConsoleOutput(buffer, screen, size, c, &r))
		co_debug("WriteConsoleOutput() error %d \n", GetLastError());
	return CO_RC(OK);
}
Пример #13
0
VALUE
rb_WriteConsoleOutput(VALUE self, VALUE h, VALUE buffer,
		      VALUE srcwid, VALUE srcht, VALUE startx,
		      VALUE starty, VALUE l, VALUE t, VALUE r, VALUE b)
{
    COORD coords;
    COORD size;
    SMALL_RECT to;

    HANDLE handle = ULongToPtr( NUM2ULONG( h ) );
    Check_Type( buffer, T_STRING );
    size.X=NUM2UINT( srcwid );
    size.Y=NUM2UINT( srcht );
    coords.X=NUM2INT( startx );
    coords.Y=NUM2INT( starty );
    to.Left   = NUM2INT( l );
    to.Top    = NUM2INT( t );
    to.Right  = NUM2INT( r );
    to.Bottom = NUM2INT( b );
    if (WriteConsoleOutput(handle,(CHAR_INFO *)RSTRING_PTR(buffer),
			   size,coords,&to)) {
       VALUE ret = rb_ary_new();
       rb_ary_push( ret, INT2FIX( to.Left   ) );
       rb_ary_push( ret, INT2FIX( to.Top    ) );
       rb_ary_push( ret, INT2FIX( to.Right  ) );
       rb_ary_push( ret, INT2FIX( to.Bottom ) );
       return ret;
    }
    return rb_getWin32Error();
}
Пример #14
0
void Grelha::testes()
{
    // testar dimensões
    cout << "> grelha" << endl;
    cout << "> width();// " << width() << endl;
    cout << "> height();// " << height() << endl;
    cout << "> size().X;// " << size().X << endl;
    cout << "> size().Y;// " << size().Y << endl;
    cout << "> dim().width;// " << dim().width << endl;
    cout << "> dim().height;// " << dim().height << endl;

    // testar offset
    cout << "> pos().X;// " << pos().X << endl;
    cout << "> pos().Y;// " << pos().Y << endl;
    pos(COORD{ 5, 6 });
    cout << "> pos(COORD {5,6});" << endl;
    cout << "> pos().X;// " << pos().X << endl;
    cout << "> pos().Y;// " << pos().Y << endl;

    // testar pos
    cout << "> el(COORD{5,29}).Char.UnicodeChar;// " << el(COORD{ 5, 5 }).Char.UnicodeChar << endl;
    fill('A', 9);
    el(COORD{ 5, 5 }, 'A');
    cout << "> el(COORD{ 5, 19 }, 'A');" << endl;
    cout << "> el(COORD{5,29}).Char.UnicodeChar;// " << el(COORD{ 5, 5 }).Char.UnicodeChar << endl;
    cout << "> (char) el(COORD{5,29}).Char.UnicodeChar;// " << (char) el(COORD{ 5, 5 }).Char.UnicodeChar << endl;

    WriteConsoleOutput(GetStdHandle(STD_OUTPUT_HANDLE), _buffer, size(), _pos, &_box);
}
Пример #15
0
void Sys_ConUpdateCmdLine(char *text)
{
	CHAR_INFO line[LINELEN], *ch;
	unsigned int i;
	COORD   linesize = { LINELEN, 1 };
	COORD   from = { 0, 0 };
	SMALL_RECT rect;

	line[0].Char.AsciiChar = '>';
	line[0].Attributes = CMDLINE_ATTRIB;
	for(i = 0, ch = line + 1; i < LINELEN - 1; i++, ch++)
	{
		if(i < strlen(text))
			ch->Char.AsciiChar = text[i];
		else
			ch->Char.AsciiChar = ' ';
		// Gray color.
		ch->Attributes = CMDLINE_ATTRIB;
	}
	rect.Left = 0;
	rect.Right = LINELEN - 1;
	rect.Top = cbInfo.dwSize.Y - 1;
	rect.Bottom = cbInfo.dwSize.Y - 1;
	WriteConsoleOutput(hcScreen, line, linesize, from, &rect);
	Sys_ConSetCursor(strlen(text) + 1, cbInfo.dwSize.Y - 1);
}
Пример #16
0
int	Console::ImgPut(const IMG * pImg, int left, int top)
{
	HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);

	COORD szBuf = {(short)pImg->cx, (short)pImg->cy};
	COORD coord = {0, 0};
	SMALL_RECT rect = {(short)left, (short)top, (short)(left + pImg->cx), (short)(top + pImg->cy)};

	CHAR_INFO * ciBuffer = (CHAR_INFO *)malloc((pImg->cx * pImg->cy) * sizeof(CHAR_INFO));
	if (ciBuffer != NULL)
	{
		int res;
		int y;
		for (y = 0; y < pImg->cy; ++y) // rows
		{
			int x;
			for (x = 0; x < pImg->cx; ++x) // in row
			{
				int idx = y * pImg->cx + x;
				ciBuffer[idx].Char.AsciiChar = pImg->charbuf[idx];
				ciBuffer[idx].Attributes = pImg->attrbuf[idx];
			}
		}
		res = WriteConsoleOutput(hStdOut, ciBuffer, szBuf, coord, &rect);
		free(ciBuffer);
		return res;
	}

	SetLastError(ERROR_OUTOFMEMORY);
	return 0; // error
} /* ImgPut() */
Пример #17
0
void BaseApp::Render()
{
	if (!WriteConsoleOutput(mConsole, mChiBuffer, mDwBufferSize, mDwBufferCoord, &mLpWriteRegion)) 
	{
		printf("WriteConsoleOutput failed - (%d)\n", GetLastError()); 
	}
}
Пример #18
0
BOOL
CallConsoleApi(
    IN WORD y
    )
{
    CHAR_INFO Buffer[10];
    COORD BufferSize;
    COORD BufferCoord;
    SMALL_RECT WriteRegion;
    int i;
    BOOL Success;

    BufferSize.X = 10;
    BufferSize.Y = 1;
    BufferCoord.X = 0;
    BufferCoord.Y = 0;
    WriteRegion.Left = 0;
    WriteRegion.Top = y;
    WriteRegion.Right = 14;
    WriteRegion.Bottom = y;
    for (i=0;i<10;i++) {
        Buffer[i].Char.AsciiChar = String[i];
        Buffer[i].Attributes = y;
    }
    Success = WriteConsoleOutput(GetStdHandle(STD_OUTPUT_HANDLE),
                                 Buffer,
                                 BufferSize,
                                 BufferCoord,
                                 &WriteRegion
                                );
    return Success;
}
Пример #19
0
void Common_Update()
{
	/*
	Capture key input
	*/
	unsigned int newButtons = 0;
	while (_kbhit())
	{
		int key = _getch();
		if (key == 0 || key == 224)
		{
			key = 256 + _getch(); // Handle multi-char keys
		}

		if (key == '1')    newButtons |= (1 << BTN_ACTION1);
		else if (key == '2')    newButtons |= (1 << BTN_ACTION2);
		else if (key == '3')    newButtons |= (1 << BTN_ACTION3);
		else if (key == '4')    newButtons |= (1 << BTN_ACTION4);
		else if (key == 256 + 75) newButtons |= (1 << BTN_LEFT);
		else if (key == 256 + 77) newButtons |= (1 << BTN_RIGHT);
		else if (key == 256 + 72) newButtons |= (1 << BTN_UP);
		else if (key == 256 + 80) newButtons |= (1 << BTN_DOWN);
		else if (key == 32)     newButtons |= (1 << BTN_MORE);
		else if (key == 27)     newButtons |= (1 << BTN_QUIT);
		else if (key == 112)    gPaused = !gPaused;
	}

	gPressedButtons = (gDownButtons ^ newButtons) & newButtons;
	gDownButtons = newButtons;

	/*
	Update the screen
	*/
	if (!gPaused)
	{
		for (unsigned int i = 0; i < NUM_COLUMNS * NUM_ROWS; i++)
		{
			gConsoleBuffer[i].Char.AsciiChar = gWriteBuffer[i];
			gConsoleBuffer[i].Attributes = FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
		}

		COORD bufferSize = { NUM_COLUMNS, NUM_ROWS };
		COORD bufferCoord = { 0, 0 };
		SMALL_RECT writeRegion = { 0, 0, NUM_COLUMNS - 1, NUM_ROWS - 1 };
		WriteConsoleOutput(gConsoleHandle, gConsoleBuffer, bufferSize, bufferCoord, &writeRegion);
		fflush(stdout);
	}

	/*
	Reset the write buffer
	*/
	gYPos = 0;
	memset(gWriteBuffer, ' ', sizeof(gWriteBuffer));

	if (Common_Private_Update)
	{
		Common_Private_Update(&gPressedButtons);
	}
}
Пример #20
0
int   PDC_clr_update(WINDOW *s)
/***********************************************************************/
{
   extern unsigned char atrtab[MAX_ATRTAB];

   register int   i=0,j=0;
   register chtype *srcp;
   WINDOW *w = NULL;
   bool rc=FALSE;
   COORD bufSize, bufPos;
   SMALL_RECT sr;

#ifdef PDCDEBUG
   if (trace_on) PDC_debug("PDC_clr_update() - called\n");
#endif

   w = curscr;
   if (w == (WINDOW *)NULL)
      return( ERR );
#if 0
   if (SP->full_redraw)
      PDC_clr_scrn(s); /* clear physical screen */
#endif

   s->_clear = FALSE;
   bufPos.X = bufPos.Y = 0;
   bufSize.X = COLS;
   bufSize.Y = 1;
   sr.Left = 0;
   sr.Right = COLS - 1;
   for (i = 0; i < LINES; i++)   /* update physical screen */
   {
      if (s != w)
         memcpy(w->_y[i], s->_y[i], COLS * sizeof(chtype));

      srcp = s->_y[i];

      sr.Top = i;
      sr.Bottom = i;

      for (j = 0; j < COLS; j++)
      {
         ci[j].Char.AsciiChar = *(srcp+j) & A_CHARTEXT;
         ci[j].Attributes = (chtype_attr(*(srcp+j)) & 0xFF00) >> 8 ;
#ifdef HIDE_ATTR
         ci[j].Attributes =  FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
#endif
      }
      WriteConsoleOutput(hConOut, ci, bufSize, bufPos, &sr);

      if (SP->refrbrk && (SP->cbreak || SP->raw_inp)) 
      {
         rc = PDC_breakout();
         if (rc)
            break;
      }
   }
   return( OK );
}
Пример #21
0
void write_scr(CHAR_INFO * buffer, int cx, int cy)
{
	HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
	COORD sz = { cx, cy };
	COORD xy = { 0, 0 };
	SMALL_RECT sr = { 0, 0, cx, cy };
	WriteConsoleOutput(h, buffer, sz, xy, &sr);
}
Пример #22
0
bool  PDC_transform_line(register int lineno)
/***********************************************************************/
{
   extern unsigned   char atrtab[MAX_ATRTAB];

   register int j=0;
   register chtype *srcp;
   int   x=0;
   int   endx=0;
   int   len=0;
   bool rc=FALSE;
   COORD bufSize, bufPos;
   SMALL_RECT sr;

#ifdef PDCDEBUG
   if (trace_on) PDC_debug("PDC_transform_line() - called: lineno=%d\n",lineno);
#endif

   if (curscr == (WINDOW *)NULL)
      return( FALSE );

   x = curscr->_firstch[lineno];
   endx = curscr->_lastch[lineno];
   srcp = curscr->_y[lineno] + x;
   len = endx-x+1;

   bufPos.X = bufPos.Y = 0;

   bufSize.X = len;
   bufSize.Y = 1;

   sr.Top = lineno;
   sr.Bottom = lineno;
   sr.Left = x;
   sr.Right = endx;

   for (j = 0; j < len; j++)
   {
      ci[j].Char.AsciiChar = *(srcp+j) & A_CHARTEXT;
      ci[j].Attributes = (chtype_attr(*(srcp+j)) & 0xFF00) >> 8 ;
#ifdef HIDE_ATTR
      ci[j].Attributes =  FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE;
#endif
   }

   WriteConsoleOutput(hConOut, ci, bufSize, bufPos, &sr);

   curscr->_firstch[lineno] = _NO_CHANGE;
   curscr->_lastch[lineno] = _NO_CHANGE;
   
   if (SP->refrbrk && (SP->cbreak || SP->raw_inp)) 
   {
      rc = PDC_breakout();
      if (rc)
         return(TRUE);
   }
   return(FALSE);
}
Пример #23
0
bool CnsMgr::Flip()
{
	if(!initialized)
		return false;
	COORD tmp_bufsz = {WND_W, WND_H};
	COORD tmp_bufcrd = {0, 0};
	SMALL_RECT tmp_writereg = {0, 0, WND_W-1, WND_H-1};
	return WriteConsoleOutput(h_mysb, buf, tmp_bufsz, tmp_bufcrd, &tmp_writereg);
}
Пример #24
0
void CMap::Draw()
{
    // If we don't need to update the screen, we just quit the function
    if(!m_bDrawScreen) return;

    // If we drawing, let's reset the flag so we don't draw again, unless needed
    m_bDrawScreen = false;

    SMALL_RECT drawRect = {0, 0, kMapWidth - 1, kMapHeight - 1}; // This is the drawing rectangle
    COORD bufferSize	= {kMapWidth , kMapHeight};	// This stores the size of our buffer
    COORD zeroZero		= {0, 0};					// This tells us the upper left corner to draw from
    DWORD dwResult		= 0;						// This stores the result of the draw operation
    char szCursor[2]	= "";						// This string stores the cursor tile character
    // Get an OUTPUT handle to our screen.
    HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);

    // Here we go through our normal map tile list and add them to our drawing screen buffer
    for(int i = 0; i < (int)m_vTiles.size(); i++)
    {
        // Here we get the CHAR_INFO of the current tile in our list
        m_screenBuffer[i] = m_vTiles[i].GetChar();
    }

    // Go through all of the items and draw their character/attribute to our map
    for(int i = 0; i < (int)m_vItems.size(); i++)
    {
        // Grab the position of the item and insert it into the map's screen buffer
        COORD index = m_vItems[i].GetIndex();
        int slot = index.X + index.Y * kMapWidth; // Change the background color to the map's
        m_screenBuffer[slot] = AddNewBackground(m_vItems[i].GetChar(), m_screenBuffer[slot]);
    }

    // Go through all of the npcs and draw their character/attribute to our map
    for(int i = 0; i < (int)m_vNpcs.size(); i++)
    {
        // Grab the position of the npc and insert it into the map's screen buffer
        COORD index = m_vNpcs[i].GetIndex();
        int slot = index.X + index.Y * kMapWidth; // Change the background color to the map's
        m_screenBuffer[slot] = AddNewBackground(m_vNpcs[i].GetChar(), m_screenBuffer[slot]);
    }

    // Go through all of the monsters and draw their character/attribute to our map
    for(int i = 0; i < (int)m_vMonsters.size(); i++)
    {
        // Grab the position of the monster and insert it into the map's screen buffer
        COORD index = m_vMonsters[i].GetIndex();
        int slot = index.X + index.Y * kMapWidth; // Change the background color to the map's
        m_screenBuffer[slot] = AddNewBackground(m_vMonsters[i].GetChar(), m_screenBuffer[slot]);
    }

    // Here we actually draw all the map and editor tiles to our screen
    WriteConsoleOutput(hOutput, m_screenBuffer, bufferSize, zeroZero, &drawRect);

    // After the map is drawn, let's draw the player over top of the map
    g_Player.Draw();
}
Пример #25
0
void drawCmdWindow()
{
    if (Touched_Global) {
        WriteConsoleOutput( hOutput[Double_Buffer_Switch], (CHAR_INFO *)screen_buffer, dwBufferSize,
                            dwBufferCoord, &rcRegion );
        SetConsoleActiveScreenBuffer(hOutput[Double_Buffer_Switch]);
        SetConsoleCursorPosition( hOutput[Double_Buffer_Switch], dwBufferSize );
        Double_Buffer_Switch = !Double_Buffer_Switch;
    }
}
Пример #26
0
// Writes the text at the (cx,cy).
void Sys_ConWriteText(CHAR_INFO * line, int len)
{
	COORD   linesize = { len, 1 };
	COORD   from = { 0, 0 };
	SMALL_RECT rect;

	rect.Left = cx;
	rect.Right = cx + len;
	rect.Top = cy;
	rect.Bottom = cy;
	WriteConsoleOutput(hcScreen, line, linesize, from, &rect);
}
Пример #27
0
static void win32_display(caca_display_t *dp)
{
    COORD size, pos;
    SMALL_RECT rect;
    CHAR_INFO *buffer = dp->drv.p->buffer;
    uint32_t const *cvchars = caca_get_canvas_chars(dp->cv);
    uint32_t const *cvattrs = caca_get_canvas_attrs(dp->cv);
    int width = caca_get_canvas_width(dp->cv);
    int height = caca_get_canvas_height(dp->cv);
    int n;

    /* Render everything to our screen buffer */
    for(n = height * width; n--; )
    {
        uint32_t ch = *cvchars++;
        uint16_t bgfg = caca_attr_to_ansi(*cvattrs);
        uint8_t fg = bgfg & 0xf;
        uint8_t bg = bgfg >> 4;

#if 0
        if(ch > 0x00000020 && ch < 0x00000080)
            dp->drv.p->buffer[i].Char.AsciiChar = (uint8_t)ch;
        else
            dp->drv.p->buffer[i].Char.AsciiChar = ' ';
#else
        if(n && *cvchars == CACA_MAGIC_FULLWIDTH)
            ;
        else if(ch > 0x00000020 && ch < 0x00010000)
            buffer->Char.UnicodeChar = (uint16_t)ch;
        else
            buffer->Char.UnicodeChar = (uint16_t)' ';
#endif

        buffer->Attributes = win32_fg_palette[fg < 0x10 ? fg : CACA_LIGHTGRAY]
                              | win32_bg_palette[bg < 0x10 ? bg : CACA_BLACK];
        cvattrs++;
        buffer++;
    }

    /* Blit the screen buffer */
    size.X = width;
    size.Y = height;
    pos.X = pos.Y = 0;
    rect.Left = rect.Top = 0;
    rect.Right = width - 1;
    rect.Bottom = height - 1;
#if 0
    WriteConsoleOutput(dp->drv.p->screen, dp->drv.p->buffer, size, pos, &rect);
#else
    /* FIXME: would this benefit from dirty rectangles? */
    WriteConsoleOutputW(dp->drv.p->screen, dp->drv.p->buffer, size, pos, &rect);
#endif
}
Пример #28
0
int Safe()
{
   if(danger)
    {
      WriteConsoleOutput("Safe!");
      IRCSay("Safe!");
      fprintf(stderr,"Safe!\n");
    }

   danger=0;

   return 1;
}
Пример #29
0
int Danger()
{
   if(!danger)
    {
      WriteConsoleOutput("Danger!");
      IRCSay("Danger!");
      fprintf(stderr,"Danger!\n");
    }

   danger=1;

   return 1;
}
Пример #30
0
  void flush()
  {
    HANDLE handle = GetStdHandle( STD_OUTPUT_HANDLE );

    SHORT width  = (SHORT) sys::get_terminal_width();
    SHORT height = (SHORT) sys::get_terminal_height();

    COORD size = { width, height };
    COORD src = { 0, 0};
    SMALL_RECT  dest = { 0, 0, width, height };

    WriteConsoleOutput(handle, (CHAR_INFO *)_console_buffer, size, src, &dest);
  }