void CTextBox::OnBackSpaceWord()
{
    if ( IsFoucus() )
    {
        m_fCurXoffset -= m_fScaleSize;
        DeleteAChar();
        ParseText();
        UpdateCur();
    }
}
/* Sets new position */
void ConsoleGotoXY(uint8_t x, uint8_t y)
{
	if (cursor_x <= 80)
	    cursor_x = x;

	if (cursor_y <= 25)
	    cursor_y = y;

	/* Update hardware cursor to new position */
	UpdateCur(cursor_x, cursor_y);
}
/* Displays a character */
void ConsolePutc(unsigned char c)
{
    uint16_t attribute = (uint16_t)(_color << 8);

    /* backspace character */
    if (c == 0x08 && cursor_x)
        cursor_x--;

    /* tab character */
	else if (c == 0x09)
		cursor_x = (uint8_t)((cursor_x+8) & ~(8-1));

    /* carriage return */
    else if (c == '\r')
        cursor_x = 0;

    /* new line */
	else if (c == '\n') {
        cursor_x = 0;
        cursor_y++;
	}

    /* printable characters */
    else if(c >= ' ')
	{
		/* display character on screen */
        uint16_t* location = video_memory + (uint16_t)(cursor_y*80 + cursor_x);
        *location = (uint16_t)(c | attribute);
        cursor_x++;
    }

    /* if we are at edge of row, go to new line */
    if (cursor_x >= 80)
	{
        cursor_x = 0;
        cursor_y++;
    }

	/* if we are at the last line, scroll up */
	if (cursor_y >= 25)
		scroll();

    /* update hardware cursor */
	UpdateCur(cursor_x, cursor_y);
}
void CTextBox::OnInsertText( const TCHAR* data, int num )
{
    if ( IsFoucus() )
    {
        TString insertString( data, nNum );
        m_strText += insertString;
        auto glyphs = m_pFontFace->GetGlyphs( m_strText );
        m_fCurXoffset = 0;
        CRenderTarget* pCurTarget = CRenderManager::GetInstance()->GetCurrentRenderTarget();
        BEATS_ASSERT(pCurTarget != NULL);
        for ( auto glyph : glyphs )
        {
            m_fCurXoffset +=  glyph->GetWidth() * pCurTarget->GetScaleFactor();
        }
        ParseText();
        UpdateCur();
    }
}
void CTextBox::UpdateQuadP()
{
    super::UpdateQuadP();
    UpdateCur();
}