コード例 #1
0
ファイル: Console.cpp プロジェクト: jsj2008/100-things
void Console::SelectionDelete()
{
	if( sel_start != -1 || sel_length != 0 ) {
		
		std::string before, after;
		if( sel_length > 0 ) {
			before = input_line.substr( 0, sel_start );
			after = input_line.substr( sel_start + sel_length );
			input_line_pos = sel_start;
		}
		else {
			before = input_line.substr( 0, sel_start + sel_length );
			after = input_line.substr( sel_start );
			input_line_pos = sel_start + sel_length;
		}
		InputLineSet( before + after );
	}
	SelectionClear();
}
コード例 #2
0
ButcherView::~ButcherView()
{
    DoChangedEvent(ButcherViewChangedEvent::VC_DESTROY);

    SelectionClear(false);
}
コード例 #3
0
ファイル: Console.cpp プロジェクト: jsj2008/100-things
bool Console::HandleEvent( hgeInputEvent &e )
{
	if( !is_active ) {
		if( e.type == INPUT_KEYDOWN && e.key == HGEK_F1 ) {
			Activate();
		}
		else {
			return true;
		}
	}
	else if( e.type == INPUT_KEYDOWN && e.key == HGEK_F1 ) {
		Deactivate();
		return true;
	}
	
	if( e.type == INPUT_KEYDOWN ) 
	{		
		if( e.key == HGEK_ENTER && input_line.size() > 0 ) {
			InputLineExecute();
		}
		else if( e.key == HGEK_SPACE ) {
			SelectionDelete();
			InputLineAddChar( ' ', input_line_pos );
			InputLineMoveRight();
		}
		else if( e.key == HGEK_BACKSPACE ) {
			if( SelectionIsActive() ) {
				SelectionDelete();
			}
			else {
				InputLineDeleteChar( input_line_pos - 1 );
				InputLineMoveLeft();
			}
		}
		else if( e.key == HGEK_A && hge->Input_GetKeyState( HGEK_CTRL ) ) {
			SelectionAll();
		}
		else if( e.key == HGEK_C && hge->Input_GetKeyState( HGEK_CTRL ) ) {
			SelectionCopy();
		}
		else if( e.key == HGEK_V && hge->Input_GetKeyState( HGEK_CTRL ) ) {
			SelectionPaste( input_line_pos );
		}
		else if( e.key == HGEK_DELETE ) {
			if( SelectionIsActive() ) {
				SelectionDelete();
			}
			else {
				InputLineDeleteChar( input_line_pos );
			}
		}
		else if( e.key == HGEK_UP ) {
			SelectionClear();
			if( IsSuggestionLocked() ) {
				MoveUpInSuggestion();
			}
			else {
				MoveBackInHistory();
			}
		}
		else if( e.key == HGEK_DOWN ) {
			SelectionClear();
			if( IsHistoryLocked() ) {
				MoveForwardInHistory();
			}
			else {
				MoveDownInSuggestion();
			}
		}
		else if( e.key == HGEK_TAB ) {
			if( IsSuggestionLocked() ) {
				AutoCompleteSuggestion();
			}
		}
		else if( e.key == HGEK_LEFT ) {
			if( hge->Input_GetKeyState( HGEK_SHIFT ) ) {
				SelectionMoveLeft();
			}
			else {
				SelectionClear();
			}
			InputLineMoveLeft();
		}
		else if( e.key == HGEK_RIGHT ) {
			if( hge->Input_GetKeyState( HGEK_SHIFT ) ) {
				SelectionMoveRight();
			}
			else {
				SelectionClear();
			}
			InputLineMoveRight();
		}
		else if( e.chr > 32 ) {
			SelectionDelete();
			InputLineAddChar( e.chr, input_line_pos );
			InputLineMoveRight();
		}
		else {
			return true;
		}
		blink_timer.Restart();
	}
	return false;
}
コード例 #4
0
ファイル: Console.cpp プロジェクト: jsj2008/100-things
Console::Console()
{
	Settings::Get().AddListener( this );
	
	fnt.reset( new hgeFont( "fnt/arial10.fnt" ) );
	fnt->SetColor( 0xFF45DD57 );
	
	x = 10; y = 10;
	w = 400;
	h = 300;
	
	cmd_pos = -1;
	input_line_pos = 0;
	
	sugg_pos = -1;
	
	text_off_left = 5;
	text_off_down = 5;
	text_off_top = 5;
	
	line_height = fnt->GetHeight() - 2;
	
	back.reset( new hgeSprite( 0, 0, 0, w, h ) );
	q.reset( new hgeQuad() );
	
	blinkie_time = 0.5;
	
	suggestion_box_width = 0;
	
	show_debug = false;
	is_active = false;
	
	opacity = 0xDD;
	fnt_opacity = 0xFF;
	blinkie_opacity = 0x55;
	selection_opacity = 0x66;
	delimiter_opacity = 0x22;
	
	fnt_color = 0x45DD57;
	fnt_history_color = 0x45DD57;
	fnt_history_line_sign_color = 0x1AA12A;
	fnt_highlight_color = 0xEBF230;
	fnt_suggestion_color = 0x45DD57;
	blinkie_color = 0x7A7A7A;
	selection_color = 0x7A7A7A;
	
	large_back_color = 0x515151;
	suggestion_back_color = 0x5C5C5C;
	delimiter_color = 0x2C2C2C;
	
	SelectionClear();
	blink_timer.Start();
	
	showDebug.reset( new Dator<bool>( show_debug ) );
	Settings::Get().RegisterVariable( "console_show_debug", boost::weak_ptr<BaseDator>( showDebug ) );
	
	clearHistory.reset( new ColdDator( boost::bind( &Console::Clear, this ) ) );
	Settings::Get().RegisterVariable( "console_clear", boost::weak_ptr<BaseDator>( clearHistory ) );
	
	showCommands.reset( new ColdDator( boost::bind( &Console::ShowCommands, this ) ) );
	Settings::Get().RegisterVariable( "console_show_commands", boost::weak_ptr<BaseDator>( showCommands ) );
	
	showCommandsValues.reset( new ColdDator( boost::bind( &Console::ShowCommandsValues, this ) ) );
	Settings::Get().RegisterVariable( "console_show_commands_values", boost::weak_ptr<BaseDator>( showCommandsValues ) );
}