Exemple #1
0
void System::CreateBuffer(short width, short height)
{
	srWidth = width;
	srHeight = height;

	CONSOLE_CURSOR_INFO cci;
	COORD size = { srWidth, srHeight };
	SMALL_RECT rect;

	rect.Left = 0;
	rect.Top = 0;
	rect.Right = srWidth - 1;
	rect.Bottom = srHeight - 1;

	hBuffer[0] = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
	SetConsoleScreenBufferSize(hBuffer[0], size);
	SetConsoleWindowInfo(hBuffer[0], TRUE, &rect);

	hBuffer[1] = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
	SetConsoleScreenBufferSize(hBuffer[1], size);
	SetConsoleWindowInfo(hBuffer[1], TRUE, &rect);

	cci.dwSize = 1;
	cci.dwSize = FALSE;
	SetConsoleCursorInfo(hBuffer[0], &cci);
	SetConsoleCursorInfo(hBuffer[1], &cci);
}
Exemple #2
0
void _setcursortype(int cur_t)
{
    CONSOLE_CURSOR_INFO  ConsoleCursorInfo;

    if (!StdHandle)
    {
        StdHandle = TRUE;
        hStdout = GetStdHandle (STD_OUTPUT_HANDLE);
    } /* endif */

    switch (cur_t)
    {
    case _NORMALCURSOR:
    case _SOLIDCURSOR:
        GetConsoleCursorInfo (hStdout, &ConsoleCursorInfo);
        ConsoleCursorInfo.bVisible = TRUE;
        SetConsoleCursorInfo (hStdout, &ConsoleCursorInfo);
        break;

    case _NOCURSOR:
        GetConsoleCursorInfo (hStdout, &ConsoleCursorInfo);
        ConsoleCursorInfo.bVisible = FALSE;
        SetConsoleCursorInfo (hStdout, &ConsoleCursorInfo);
        break;

    } /* endswitch */
}
Exemple #3
0
bool Console::RemoveCursor(void) {
	CONSOLE_CURSOR_INFO cci;
	if (!GetConsoleCursorInfo(hStdOutput, &cci)) return false;
	cci.bVisible = false;
	if (!SetConsoleCursorInfo(hStdOutput, &cci)) return false;
	if (!GetConsoleCursorInfo(hStdError, &cci)) return false;
	cci.bVisible = false;
	if (!SetConsoleCursorInfo(hStdError, &cci)) return false;
	return true;
}
Exemple #4
0
inline const VKEY ConsoleUI::GetVkResponse(PCVKEY rgvkCriteria) const
{
	CONSOLE_CURSOR_INFO	cursorInfo;			// Console cursor information
	DWORD				dwInputMode;		// Console input mode flags
	bool				bValid = false;		// Loop termination flag
	INPUT_RECORD		recInput;			// INPUT_RECORD from console input
	DWORD				cEvents;			// Number of events read from console
	VKEY				vkInput;			// Virtual key code read from the console
	PCVKEY				pvk;				// Pointer to a virtual key code

	if(!rgvkCriteria) return NULL;			// No criteria codes to work with
	
	GetConsoleCursorInfo(m_hout, &cursorInfo);		// Get console cursor info
	
	cursorInfo.bVisible = FALSE;					// Turn off the cursor
	SetConsoleCursorInfo(m_hout, &cursorInfo);		// Set new cursor info
	
	// Remove the LINE_INPUT and ECHO_INPUT flags from the console input handle

	GetConsoleMode(m_hin, &dwInputMode);
	SetConsoleMode(m_hin, dwInputMode & ~ENABLE_LINE_INPUT & ~ENABLE_ECHO_INPUT);

	FlushConsoleInputBuffer(m_hin);					// Flush the console input buffer

	// Loop until the user presses one of the valid virtual keys
	
	while(!bValid) {

		vkInput = NULL;

		// Read in the next event from the console's input buffer, and discard
		// it if it's not a KEY_EVENT indicating a key down signal

		if(!ReadConsoleInput(m_hin, &recInput, 1, &cEvents)) break;
		
		if(recInput.EventType != KEY_EVENT) continue;		// Not a KEY_EVENT
		if(!recInput.Event.KeyEvent.bKeyDown) continue;		// Not a keydown event

		vkInput = recInput.Event.KeyEvent.wVirtualKeyCode;

		// Check to see if this virtual key code matches any of the specified
		// valid codes, and break the while() loop if it does

		for(pvk = rgvkCriteria; *pvk; pvk++) 
			if(vkInput == *pvk) { bValid = true; break; }
	};

	SetConsoleMode(m_hin, dwInputMode);				// Restore input mode flags
	
	cursorInfo.bVisible = TRUE;						// Turn the cursor back on
	SetConsoleCursorInfo(m_hout, &cursorInfo);		// Restore the cursor state
		
	return vkInput;
}
Exemple #5
0
void ScreenInit()
{
	CONSOLE_CURSOR_INFO cci;
	
	g_hScreen[0] = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL); // 화면 버퍼 1 생성 
	g_hScreen[1] = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL); // 화면 버퍼 2 생성
	
	cci.dwSize = 1;
	cci.bVisible = FALSE;
	SetConsoleCursorInfo(g_hScreen[0], &cci);
	SetConsoleCursorInfo(g_hScreen[1], &cci); // 커서 숨기기 13 - 16
}
Exemple #6
0
void Print::ScreenInit()
{
	CONSOLE_CURSOR_INFO cci;

	// 가상의 콘솔창 2개룰 만든다.
	m_hscreen[0] = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL);
	m_hscreen[1] = CreateConsoleScreenBuffer(GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL);

	// 커서 숨기기
	cci.dwSize = 1;
	cci.bVisible = FALSE;
	SetConsoleCursorInfo(m_hscreen[0], &cci);
	SetConsoleCursorInfo(m_hscreen[1], &cci);
}
Exemple #7
0
void Nocursortype()
{
	CONSOLE_CURSOR_INFO Info;
	Info.bVisible = FALSE;
	Info.dwSize = 20;
	SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &Info);
}
Exemple #8
0
void init(){
    system("mode con cols=165 lines=55");
    CONSOLE_CURSOR_INFO cci;
    cci.dwSize = 1;
    cci.bVisible = false;
    SetConsoleCursorInfo(hCon ,&cci);
}
/**
 * Prepare console on program initialization: change console font codepage
 * according to program options and hide cursor.
 */
void setup_console(void)
{
	HANDLE hOut;
	CONSOLE_CURSOR_INFO cci;

	int cp = (opt.flags&OPT_UTF8 ? CP_UTF8 : opt.flags&OPT_ANSI ? GetACP() : GetOEMCP());
	rhash_data.saved_console_codepage = -1;
	/* note: we are using numbers 1 = _fileno(stdout), 2 = _fileno(stderr) */
	/* cause _fileno() is undefined,  when compiling as strict ansi C. */
	if(cp > 0 && IsValidCodePage(cp) && (isatty(1) || isatty(2)) )
	{
		rhash_data.saved_console_codepage = GetConsoleOutputCP();
		SetConsoleOutputCP(cp);
		setlocale(LC_CTYPE, opt.flags&OPT_UTF8 ? "C" :
			opt.flags&OPT_ANSI ? ".ACP" : ".OCP");
		rsh_exit = rhash_exit;
	}

	if((opt.flags & OPT_PERCENTS) != 0) {
		hOut = GetStdHandle(STD_ERROR_HANDLE);
		if(hOut != INVALID_HANDLE_VALUE) {
			/* store current cursor size and visibility flag */
			GetConsoleCursorInfo(hOut, &cci);
			rhash_data.saved_cursor_size = (cci.bVisible ? cci.dwSize : 0);

			/* now hide cursor */
			cci.bVisible = 0;
			SetConsoleCursorInfo(hOut, &cci); /* hide cursor */
		}
	}
}
Exemple #10
0
void hidden(){//隐藏光标
	HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_CURSOR_INFO cci;
	GetConsoleCursorInfo(hOut, &cci);
	cci.bVisible = 0; //赋1为显示,赋0为隐藏
	SetConsoleCursorInfo(hOut, &cci);
}
Exemple #11
0
void TextBox::Hide() {
	CONSOLE_CURSOR_INFO newCci = { 100, false };
	SetConsoleCursorInfo(handle, &newCci);
	enableWrite = false;
	HANDLE handle = GetStdHandle(STD_OUTPUT_HANDLE);
	DWORD blackDw = (FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE);
	SetConsoleTextAttribute(handle, blackDw);
	COORD crd = { coord.X , coord.Y };
	SetConsoleCursorPosition(handle, crd);
	short length = (short)boxSize;
	if (border == BorderType::None) {
		for (short j = crd.X; j < (coord.X + length); j++) {
			COORD tmpCrd = { j , coord.Y };
			SetConsoleCursorPosition(handle, tmpCrd);
			cout << " ";
		}
	}
	else {
		for (short i = crd.Y; i < crd.Y + 3; i++) {
			for (short j = crd.X; j < (coord.X + length) + 2; j++) {
				COORD tmpCrd = { j , i };
				SetConsoleCursorPosition(handle, tmpCrd);
				cout << " ";
			}
		}
	}
}
Exemple #12
0
	Console::Console( const int width, const int height, const int bg_colour )
		: mConsoleHandle(nullptr), mForeGroundColour(15), mBackgroundColour(0)
	{
		assert(bg_colour >= 0 && bg_colour < 16);
		// Open i/o channel to console screen
// 		mHandle = CreateFile(TEXT("CONOUT$"),
// 			GENERIC_WRITE | GENERIC_READ,
// 			FILE_SHARE_READ | FILE_SHARE_WRITE,
// 			0L, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0L);
		AllocConsole();
		RedirectStandardIO();
		mConsoleHandle = GetStdHandle(STD_OUTPUT_HANDLE);

		mCursor.dwSize = 100;
		mCursor.bVisible = true;

		COORD console_size = {width, height};
		SetConsoleScreenBufferSize(mConsoleHandle, console_size);
		SetConsoleCursorInfo(mConsoleHandle, &mCursor);
		GetConsoleScreenBufferInfo(mConsoleHandle, &mConsoleInfo);

		SetBackgroundColour(bg_colour);
		SetTextColour(mForeGroundColour);
		Clear();
	}
Exemple #13
0
void Graphics::setCursorVisibility(bool isVisible)
{
	CONSOLE_CURSOR_INFO cci;
	GetConsoleCursorInfo(_console, &cci);
	cci.bVisible = isVisible;
	SetConsoleCursorInfo(_console, &cci);
}
Exemple #14
0
void consoleHideCursor(void) {
	HANDLE hdl;
	hdl = GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_CURSOR_INFO t;
	t.bVisible = false;
	SetConsoleCursorInfo(hdl, &t);
}
Exemple #15
0
// 커서 숨기기 : true, T(보이기), false, F(숨기기)
// 인터넷 참고
void CursorVisible(bool blnCursorVisible)    // Console.CursorVisible = false;
{
    CONSOLE_CURSOR_INFO cursorInfo;
    GetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursorInfo);
    cursorInfo.bVisible = blnCursorVisible;
    SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cursorInfo);
}
Exemple #16
0
int  set_console_cursor_shape( FILE* confp, int ins )
{
    CONSOLE_CURSOR_INFO  ci;
    HANDLE  hStdErr;
    int     cons_fd;

    if ( !confp )
    {
        errno = EINVAL;
        return -1;
    }

    if ( ! _isatty( cons_fd = fileno( confp ) ) )
    {
        errno = EBADF;
        return -1;
    }

    hStdErr = (HANDLE) _get_osfhandle( cons_fd );
    ASSERT( hStdErr && INVALID_HANDLE_VALUE != hStdErr );

    ci.bVisible = TRUE;
    ci.dwSize = ins ? 20 : 100; // (note: values are percent of cell height)

    if ( !SetConsoleCursorInfo( hStdErr, &ci ) )
    {
        errno = EIO;
        return -1;
    }

    return 0;
}
void CheckList::draw() {
	Component::draw();
	CONSOLE_CURSOR_INFO cci = { 100, TRUE };
	SetConsoleCursorInfo(_handle, &cci);
	int vector_size = _data.size();
	COORD temp = _position.getStartCord();
	temp.X++;
	temp.Y++;
	SetConsoleCursorPosition(_handle, temp);

	for (int i = 0; i < vector_size;i++){
		if (i == 0) {
	
			DWORD wAttr;
			if (needFirstYellow) {
				 wAttr = FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY;
				SetConsoleTextAttribute(_handle, wAttr);
				needFirstYellow = false;
			}
			cout << _data[i]<<endl;
			wAttr = _textColor | _backgroundColor;
			SetConsoleTextAttribute(_handle, wAttr);
			temp.Y++;
			
		}
		else {//next 
			SetConsoleCursorPosition(_handle, temp);
			cout << _data[i] << endl;
			temp.Y++;
		}
	}
}
Exemple #18
0
 void _hide_cursor(HANDLE handle)
 {
   CONSOLE_CURSOR_INFO cci;
   GetConsoleCursorInfo(handle, &cci);
   cci.bVisible = false;
   SetConsoleCursorInfo(handle, &cci);
 }
Exemple #19
0
void noCursor() // 커서를 없앤다
{
	CONSOLE_CURSOR_INFO CurInfo;
	CurInfo.dwSize = 1;
	CurInfo.bVisible = FALSE;
	SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &CurInfo);
}
//setting window size and hiding cursor
void Aesthetics::SetWindow(int Width, int Height)
{
	_COORD coord;
	coord.X = Width;
	coord.Y = Height;

	_SMALL_RECT Rect;
	Rect.Top = 0;
	Rect.Left = 0;
	Rect.Bottom = Height - 1;
	Rect.Right = Width - 1;

	HANDLE Handle = GetStdHandle(STD_OUTPUT_HANDLE);      // Get Handle
	SetConsoleScreenBufferSize(Handle, coord);            // Set Buffer Size
	SetConsoleWindowInfo(Handle, TRUE, &Rect);            // Set Window Size


	HANDLE hConsoleOutput;
	CONSOLE_CURSOR_INFO structCursorInfo;
	hConsoleOutput = GetStdHandle(STD_OUTPUT_HANDLE);
	GetConsoleCursorInfo(hConsoleOutput, &structCursorInfo);
	structCursorInfo.bVisible = FALSE;
	SetConsoleCursorInfo(hConsoleOutput, &structCursorInfo);

}
// draw the field
// argument - width and height of the field
// resizes console window for no reason
// prints instructions how to interact
void drawTable(COORD size)
{
	DWORD cWritten;
	HANDLE con = GetStdHandle(STD_OUTPUT_HANDLE);

	CONSOLE_CURSOR_INFO     cursorInfo;
	GetConsoleCursorInfo(con, &cursorInfo);
	cursorInfo.bVisible = false;
	SetConsoleCursorInfo(con, &cursorInfo);
	
	HWND console = GetConsoleWindow();
	RECT r;
	GetWindowRect(console, &r);
	MoveWindow(console, r.left, r.top, 800, 480, TRUE);

	FillConsoleOutputCharacter(con, '+', 1, { 0, 3 }, &cWritten);
	FillConsoleOutputCharacter(con, '+', 1, { size.X, 3 }, &cWritten);
	FillConsoleOutputCharacter(con, '-', size.X - 1, { 1, 3 }, &cWritten);
	FillConsoleOutputCharacter(con, '_', 4, { 3, 1 }, &cWritten);

	for (int i = 0; i < size.Y; ++i)
	{
		if (i != 3)
		{
			FillConsoleOutputCharacter(con, '|', 1, { 0, i }, &cWritten);
			FillConsoleOutputCharacter(con, '|', 1, { size.X, i }, &cWritten);
		}
	}

	print({size.X + 2, 1}, "COWS AND BULLS");
	print({size.X + 2, 3}, "0-9 - add digit");
	print({size.X + 2, 4}, "Backspace - remove last digit");
	print({size.X + 2, 5}, "Enter - confirm");
	print({size.X + 2, 6}, "Esc - quit");
}
void Console::showCursor(bool show)
{
	CONSOLE_CURSOR_INFO cursInfo;
	cursInfo.dwSize = 3;
	cursInfo.bVisible = show;
	SetConsoleCursorInfo(m_output, &cursInfo);
}
void WinConsoleHelper::ShowConsoleCursor(bool showFlag)
{
	CONSOLE_CURSOR_INFO cursorInfo;
	GetConsoleCursorInfo(hStdOut, &cursorInfo);
	cursorInfo.bVisible = showFlag;
	SetConsoleCursorInfo(hStdOut, &cursorInfo);
}
Exemple #24
0
// enables or disables underscore (the console cursor) visibility
void Console::SetMouseVisible(BOOL visible)
{
	CONSOLE_CURSOR_INFO cursor;
	cursor.dwSize = 1;
	cursor.bVisible = visible;
	SetConsoleCursorInfo(hScreen, &cursor);
}
 void cursor_visible(bool state){
     static auto handle = GetStdHandle(STD_OUTPUT_HANDLE);
     CONSOLE_CURSOR_INFO     cursorInfo;
     GetConsoleCursorInfo(handle, &cursorInfo);
     cursorInfo.bVisible = state; // set the cursor visibility
     SetConsoleCursorInfo(handle, &cursorInfo);
 }
Exemple #26
0
/*
==================
CON_Shutdown
==================
*/
void CON_Shutdown( void )
{
	SetConsoleMode( qconsole_hin, qconsole_orig_mode );
	SetConsoleCursorInfo( qconsole_hout, &qconsole_orig_cursorinfo );
	CloseHandle( qconsole_hout );
	CloseHandle( qconsole_hin );
}
Exemple #27
0
int PDC_curs_set(int visibility)
{
    CONSOLE_CURSOR_INFO cci;
    int ret_vis;

    PDC_LOG(("PDC_curs_set() - called: visibility=%d\n", visibility));

    ret_vis = SP->visibility;

    if (GetConsoleCursorInfo(pdc_con_out, &cci) == FALSE)
        return ERR;

    switch(visibility)
    {
    case 0:             /* invisible */
        cci.bVisible = FALSE;
        break;
    case 2:             /* highly visible */
        cci.bVisible = TRUE;
        cci.dwSize = 95;
        break;
    default:            /* normal visibility */
        cci.bVisible = TRUE;
        cci.dwSize = SP->orig_cursor;
        break;
    }

    if (SetConsoleCursorInfo(pdc_con_out, &cci) == FALSE)
        return ERR;

    SP->visibility = visibility;
    return ret_vis;
}
Exemple #28
0
/*
 * Initialization.
 * Set up the video system, and set the keyboard to binary mode.
 * Apparently, OS/2 doesn't allow control-BREAK to be disabled
 * when the keyboard is in binary mode, using signal.
 */
void ttopen()
{
    CONSOLE_SCREEN_BUFFER_INFO binfo;
    CONSOLE_CURSOR_INFO cinfo;

    /* Get handles for console output and input
     */
    hout = GetStdHandle(STD_OUTPUT_HANDLE);
    hin =  GetStdHandle(STD_INPUT_HANDLE);

    /* Save current keyboard mode, then disable line editing.
     */
    GetConsoleMode(hin, &conmode);
    SetConsoleMode(hin, 0);         /* disable line mode */

    /* Get screen size.
     */
    if (GetConsoleScreenBufferInfo(hout, &binfo) == TRUE)
    {
	windowrow = binfo.srWindow.Top;
	windowcol = binfo.srWindow.Left;
        nrow = binfo.srWindow.Bottom - windowrow + 1;
        ncol = binfo.srWindow.Right  - windowcol + 1;
    }

    /* Set block cursor
     */
    cinfo.dwSize = 100;     /* make it 100% visible */
    cinfo.bVisible = TRUE;
    SetConsoleCursorInfo(hout, &cinfo);
}
int main(void)
{
	RGBQUAD Buffer[300*300];
	HDC MyDC=GetDC(FindWindow("ConsoleWindowClass", NULL)), DesktopDC=GetDC(0);
	SetConsoleTitle("CHDC2DIB Example");
	system("mode con:cols=36 lines=18");
	CONSOLE_CURSOR_INFO cci;
	cci.bVisible=FALSE;
	cci.dwSize=10;
	SetConsoleCursorInfo(GetStdHandle(STD_OUTPUT_HANDLE), &cci);
	CHDC2DIB h2d;
	POINT Point;
	while(true)
	{
		GetCursorPos(&Point);
		h2d.HDC2DIB(DesktopDC, Buffer, Point.x-150, Point.y-150, 300, 300);
		for(int i=0;i<300;i++)
		{
			for(int j=0;j<300;j++)
			{
				int t=(300-j-1)*300+i;
				Buffer[t].rgbRed=255-Buffer[t].rgbRed;
				Buffer[t].rgbGreen=255-Buffer[t].rgbGreen;
				Buffer[t].rgbBlue=255-Buffer[t].rgbBlue;
			}
		}
		h2d.DIB2HDC(MyDC, Buffer, 0, 0, 300, 300);
		Sleep(10);
	}
	return 0;
}
Exemple #30
-6
// Initialize the console and set it to full screen mode
BOOL initConsole()
{
	hStdin = GetStdHandle(STD_INPUT_HANDLE); 
    hStdout = GetStdHandle(STD_OUTPUT_HANDLE); 
    if (hStdin == INVALID_HANDLE_VALUE || 
        hStdout == INVALID_HANDLE_VALUE) 
    {
        MessageBox(NULL, TEXT("GetStdHandle"),
            TEXT("Console Error"), MB_OK);
        return false;
    }

	ker.wRepeatCount = 0;

	SMALL_RECT windowSize = {0, 0, 79, 49};
    
    // Change the console window size:
    SetConsoleWindowInfo(hStdout, TRUE, &windowSize);

	COORD c = { 80, 50};

    //Change the internal buffer size:
    SetConsoleScreenBufferSize(hStdout, c);

	
	SetConsoleDisplayMode(hStdout,CONSOLE_FULLSCREEN_MODE, &c);

	//Hide Cursor in ConsoleWindow
    CONSOLE_CURSOR_INFO cursor = {1, 0}; 
    SetConsoleCursorInfo(hStdout, &cursor); 

	return true;
}