Beispiel #1
0
/*
====================
KeyDownEvent

Handles history and console scrollback
====================
*/
void idConsoleLocal::KeyDownEvent( int key )
{

	// Execute F key bindings
	if( key >= K_F1 && key <= K_F12 )
	{
		idKeyInput::ExecKeyBinding( key );
		return;
	}
	
	// ctrl-L clears screen
	if( key == K_L && ( idKeyInput::IsDown( K_LCTRL ) || idKeyInput::IsDown( K_RCTRL ) ) )
	{
		Clear();
		return;
	}
	
	// enter finishes the line
	if( key == K_ENTER || key == K_KP_ENTER )
	{
	
		common->Printf( "]%s\n", consoleField.GetBuffer() );
		
		cmdSystem->BufferCommandText( CMD_EXEC_APPEND, consoleField.GetBuffer() );	// valid command
		cmdSystem->BufferCommandText( CMD_EXEC_APPEND, "\n" );
		
		// copy line to history buffer
		
		if( consoleField.GetBuffer()[ 0 ] != '\n' && consoleField.GetBuffer()[ 0 ] != '\0' )
		{
			consoleHistory.AddToHistory( consoleField.GetBuffer() );
		}
		
		consoleField.Clear();
		consoleField.SetWidthInChars( LINE_WIDTH );
		
		const bool captureToImage = false;
		common->UpdateScreen( captureToImage );// force an update, because the command
		// may take some time
		return;
	}
	
	// command completion
	
	if( key == K_TAB )
	{
		consoleField.AutoComplete();
		return;
	}
	
	// command history (ctrl-p ctrl-n for unix style)
	
	if( ( key == K_UPARROW ) ||
			( key == K_P && ( idKeyInput::IsDown( K_LCTRL ) || idKeyInput::IsDown( K_RCTRL ) ) ) )
	{
		idStr hist = consoleHistory.RetrieveFromHistory( true );
		if( !hist.IsEmpty() )
		{
			consoleField.SetBuffer( hist );
		}
		return;
	}
	
	if( ( key == K_DOWNARROW ) ||
			( key == K_N && ( idKeyInput::IsDown( K_LCTRL ) || idKeyInput::IsDown( K_RCTRL ) ) ) )
	{
		idStr hist = consoleHistory.RetrieveFromHistory( false );
		if( !hist.IsEmpty() )
		{
			consoleField.SetBuffer( hist );
		}
		else // DG: if no more lines are in the history, show a blank line again
		{
			consoleField.Clear();
		} // DG end
		
		return;
	}
	
	// console scrolling
	if( key == K_PGUP )
	{
		PageUp();
		lastKeyEvent = eventLoop->Milliseconds();
		nextKeyEvent = CONSOLE_FIRSTREPEAT;
		return;
	}
	
	if( key == K_PGDN )
	{
		PageDown();
		lastKeyEvent = eventLoop->Milliseconds();
		nextKeyEvent = CONSOLE_FIRSTREPEAT;
		return;
	}
	
	if( key == K_MWHEELUP )
	{
		PageUp();
		return;
	}
	
	if( key == K_MWHEELDOWN )
	{
		PageDown();
		return;
	}
	
	// ctrl-home = top of console
	if( key == K_HOME && ( idKeyInput::IsDown( K_LCTRL ) || idKeyInput::IsDown( K_RCTRL ) ) )
	{
		Top();
		return;
	}
	
	// ctrl-end = bottom of console
	if( key == K_END && ( idKeyInput::IsDown( K_LCTRL ) || idKeyInput::IsDown( K_RCTRL ) ) )
	{
		Bottom();
		return;
	}
	
	// pass to the normal editline routine
	consoleField.KeyDownEvent( key );
}
int BlockableDisplayNode::Bottom()
{
	return Top() + Height();
}
Beispiel #3
0
	void ClipStack::Apply() const {
		if (sD3DMgr.IsCreated()) 
			sD3DMgr.GetRenderTarget()->SetClippingArea(Top());
	}
Beispiel #4
0
void CCell::Format(long left, long top, long right, long bottom, long flag)
{
	POINT pot;
	POSITION pos;
	CElement *pElement;

	switch(flag){
	case FM_A2L:
		pot.x=left-Left();
		pot.y=0;
		MoveInCell(pot);
		break;
	case FM_A2C:
		pot.x=(left-Left()+right-Right())/2;
		pot.y=0;
		MoveInCell(pot);
		break;
	case FM_A2R:
		pot.x=right-Right();
		pot.y=0;
		MoveInCell(pot);
		break;
	case FM_A2T:
		pot.x=0;
		pot.y=top-Top();
		MoveInCell(pot);
		break;
	case FM_A2M:
		pot.x=0;
		pot.y=(top-Top()+bottom-Bottom())/2;
		MoveInCell(pot);
		break;
	case FM_A2B:
		pot.x=0;
		pot.y=bottom-Bottom();
		MoveInCell(pot);
		break;
	case FM_A2CM:
		pot.x=(left-Left()+right-Right())/2;
		pot.y=(top-Top()+bottom-Bottom())/2;
		MoveInCell(pot);
		break;
	case FM_R2W:
		for(pos=m_Elements.GetHeadPosition();pos!=NULL;){		
			pElement=(CElement *)(m_Elements.GetNext(pos));
			pElement->Format(left,top,right,bottom,FM_R2W);
		}
		break;
	case FM_R2U:
		for(pos=m_Elements.GetHeadPosition();pos!=NULL;){		
			pElement=(CElement *)(m_Elements.GetNext(pos));
			pElement->Format(left,top,right,bottom,FM_R2U);
		}
		break;
	case FM_F2Z:
		pot.x=left+right-Left()-Right();
		pot.y=0;
		MoveInCell(pot);
		break;
	case FM_F2I:
		pot.x=0;
		pot.y=top+bottom-Top()-Bottom();
		MoveInCell(pot);
		break;
	case FM_S2G:
		break;
	}

}