⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scim_chewing_imengine.cpp

📁 scim 修改过的可以在手机上运行的代码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
			case SCIM_KEY_Escape:				chewing_handle_Esc( ctx );				break;			case SCIM_KEY_Delete:				chewing_handle_Del( ctx );				break;			case SCIM_KEY_Home:				chewing_handle_Home( ctx );				break;			case SCIM_KEY_End:				chewing_handle_End( ctx );				break;			case SCIM_KEY_Tab:				chewing_handle_Tab( ctx );				break;			case SCIM_KEY_Caps_Lock:				chewing_handle_Capslock( ctx );				break;			case SCIM_KEY_Shift_L:			case SCIM_KEY_Shift_R:			case SCIM_KEY_Control_L:			case SCIM_KEY_Control_R:			case SCIM_KEY_Alt_L:			case SCIM_KEY_Alt_R:                SCIM_DEBUG_IMENGINE( 2 ) <<                    "Unused keys, End Process Key\n";				return true;			default:                SCIM_DEBUG_IMENGINE( 2 ) <<                    "Begin OnKeyDefault\n";				chewing_handle_Default( ctx, key.get_ascii_code() );                SCIM_DEBUG_IMENGINE( 2 ) <<                    "End OnKeyDefault\n";				break;		}	}	else if ( key.mask == SCIM_KEY_ShiftMask ) {		switch ( key.code ) {			case SCIM_KEY_Left:				chewing_handle_ShiftLeft( ctx );				break;			case SCIM_KEY_Right:				chewing_handle_ShiftRight( ctx );				break;			case SCIM_KEY_space:				chewing_handle_ShiftSpace( ctx );				chewing_set_ShapeMode( ctx, !chewing_get_ShapeMode( ctx ) );				refresh_letter_property();				break;			/* Workaround with shift */			case SCIM_KEY_Home:			case SCIM_KEY_Page_Up:			case SCIM_KEY_Page_Down:			case SCIM_KEY_End:			case SCIM_KEY_Begin:			case SCIM_KEY_Insert:			case SCIM_KEY_Delete:				break;			default:				chewing_handle_Default( ctx, key.get_ascii_code() );				break;		}	}	else if ( key.mask == SCIM_KEY_ControlMask ) {		if ( 			key.code <= SCIM_KEY_9 && 			key.code >= SCIM_KEY_0 ) {			chewing_handle_CtrlNum( ctx, key.get_ascii_code() );		}	}	have_input = true;    SCIM_DEBUG_IMENGINE( 2 ) <<        "End Process Key\n";	return commit( ctx->output );}void ChewingIMEngineInstance::move_preedit_caret( unsigned int pos ){}void ChewingIMEngineInstance::select_candidate ( unsigned int index ){	chewing_handle_Default( ctx, '1' + index );	commit( ctx->output );}void ChewingIMEngineInstance::update_lookup_table_page_size(		unsigned int page_size ){	//XXX should not directly access data member.	ctx->data->config.selectAreaLen = page_size * 2;	m_lookup_table.set_page_size (page_size);}void ChewingIMEngineInstance::lookup_table_page_up(){	chewing_handle_Space( ctx );	commit( ctx->output );}void ChewingIMEngineInstance::lookup_table_page_down(){	chewing_handle_Space( ctx );	commit( ctx->output );}void ChewingIMEngineInstance::reset(){	chewing_Reset( ctx );	/* Configure Keyboard Type */	chewing_set_KBType( ctx, chewing_KBStr2Num( 				(char *) m_factory->m_KeyboardType.c_str() ));		/* Configure selection keys definition */	int i = 0;	for (; m_factory->m_selection_keys[i] &&	       i <= m_factory->m_selection_keys_num; i++) {		config.selKey[i] = m_factory->m_selection_keys[i];	}	config.selKey[i] = '\0';	m_lookup_table.init( m_factory->m_selection_keys,	                     m_factory->m_selection_keys_num );}void ChewingIMEngineInstance::focus_in(){    SCIM_DEBUG_IMENGINE( 2 ) <<        "Focus In\n";	initialize_all_properties ();}void ChewingIMEngineInstance::focus_out(){    SCIM_DEBUG_IMENGINE( 2 ) <<        "Focus Out\n";    if (have_input == true) {		chewing_handle_Enter( ctx );        commit( ctx->output );        have_input = false;    }}void ChewingIMEngineInstance::trigger_property( const String& property ){	if ( property == SCIM_PROP_CHIENG ) {		chewing_handle_Capslock( ctx );		commit( ctx->output );	} else if ( property == SCIM_PROP_LETTER ) {		chewing_set_ShapeMode( ctx, !chewing_get_ShapeMode( ctx ) );	}	refresh_all_properties ();}bool ChewingIMEngineInstance::commit( ChewingOutput *pgo ){	AttributeList attr;    SCIM_DEBUG_IMENGINE( 2 ) <<        "IMEngine Instance Commit\n";	// commit string	m_commit_string = L"";	if ( pgo->keystrokeRtn & KEYSTROKE_COMMIT ) {		for ( int i = 0; i < pgo->nCommitStr; i++ ) {			m_commit_string += utf8_mbstowcs((char *)pgo->commitStr[ i ].s, 					MAX_UTF8_SIZE);            SCIM_DEBUG_IMENGINE( 2 ) << "Commit Add: " <<                (char *)pgo->commitStr[ i ].s << "\n";		}		commit_string( m_commit_string );	}	m_preedit_string = L"";	// preedit string	// XXX show Interval	for ( int i = 0; i < pgo->chiSymbolCursor; i++ ) {		m_preedit_string += utf8_mbstowcs((char *)pgo->chiSymbolBuf[ i ].s, MAX_UTF8_SIZE);		SCIM_DEBUG_IMENGINE( 2 ) << "PreEdit Add: " <<			(char *)pgo->chiSymbolBuf[ i ].s << "\n";	}	// zuin string	for ( int i = 0, j = 0; i < ZUIN_SIZE; i++ ) {		if ( pgo->zuinBuf[ i ].s[ 0 ] != '\0' ) {			m_preedit_string += utf8_mbstowcs((char *)pgo->zuinBuf[ i ].s, 					MAX_UTF8_SIZE);			attr.push_back(Attribute(pgo->chiSymbolCursor + j, 1,					SCIM_ATTR_DECORATE, SCIM_ATTR_DECORATE_REVERSE));			j++;		}	}	for ( int i = pgo->chiSymbolCursor; i < pgo->chiSymbolBufLen; i++ ) {        	m_preedit_string += utf8_mbstowcs((char *)pgo->chiSymbolBuf[ i ].s, 				MAX_UTF8_SIZE);	}	for ( int i = 0; i < pgo->nDispInterval; i++ ) {		if ( pgo->dispInterval[ i ].to - pgo->dispInterval[ i ].from > 1 ) {			attr.push_back(				Attribute(					pgo->dispInterval[ i ].from,					pgo->dispInterval[ i ].to - pgo->dispInterval[ i ].from,					SCIM_ATTR_DECORATE,					SCIM_ATTR_DECORATE_UNDERLINE));			attr.push_back(				Attribute(					pgo->dispInterval[ i ].from,					pgo->dispInterval[ i ].to - pgo->dispInterval[ i ].from,					SCIM_ATTR_BACKGROUND,	m_factory->m_preedit_bgcolor[i % SCIM_CONFIG_IMENGINE_CHEWING_PREEDIT_BGCOLOR_NUM] ));		}	}	// cursor decoration	if ( pgo->zuinBuf[ 0 ].s[ 0 ] == '\0' )		attr.push_back(			Attribute(				pgo->chiSymbolCursor, 				1, 				SCIM_ATTR_DECORATE, SCIM_ATTR_DECORATE_REVERSE));	// update display	update_preedit_string( m_preedit_string, attr );	update_preedit_caret( pgo->chiSymbolCursor );	// show preedit string	if ( m_preedit_string.empty() ) {		hide_preedit_string();	}	else {		show_preedit_string();	}		// show lookup table        if ( !pgo->pci )            return true;	if ( pgo->pci->nPage != 0 ) {		m_lookup_table.update( pgo->pci );		update_lookup_table( m_lookup_table );		show_lookup_table();	}	else {		hide_lookup_table();	}		// show aux string	m_aux_string = L"";	if ( pgo->bShowMsg ) {		for ( int i = 0; i < pgo->showMsgLen; i++ ) {            m_aux_string += utf8_mbstowcs((char *)pgo->showMsg[ i ].s, MAX_UTF8_SIZE);		}		update_aux_string( m_aux_string );		show_aux_string();		pgo->showMsgLen = 0;	}	else {		hide_aux_string();	}	if ( pgo->keystrokeRtn & KEYSTROKE_ABSORB )		return true;	if ( pgo->keystrokeRtn & KEYSTROKE_IGNORE )		return false;	return true;}bool ChewingIMEngineInstance::match_key_event(		const KeyEventList &keylist,		const KeyEvent &key ){	KeyEventList::const_iterator kit;	for (kit = keylist.begin(); kit != keylist.end(); ++kit) {		if (key.code == kit->code && key.mask == kit->mask)			if (key.is_key_press() || m_prev_key.code == key.code)				return true;	}	return false;}void ChewingIMEngineInstance::initialize_all_properties (){	PropertyList proplist;	proplist.push_back (_chieng_property);	proplist.push_back (_letter_property);	register_properties (proplist);	refresh_all_properties ();}void ChewingIMEngineInstance::refresh_all_properties (){	refresh_chieng_property ();	refresh_letter_property ();}void ChewingIMEngineInstance::refresh_chieng_property (){	if ( chewing_get_ChiEngMode( ctx ) != CHINESE_MODE )		_chieng_property.set_label (_("Eng"));	else		_chieng_property.set_label (_("Chi"));	update_property (_chieng_property);}void ChewingIMEngineInstance::refresh_letter_property (){	if ( chewing_get_ShapeMode( ctx ) != FULLSHAPE_MODE )		_letter_property.set_label (_("Half"));	else		_letter_property.set_label (_("Full"));	update_property (_letter_property);}ChewingLookupTable::ChewingLookupTable()	: LookupTable( _selection_keys_num ){}ChewingLookupTable::~ChewingLookupTable(){}WideString ChewingLookupTable::get_candidate( int index ) const{	WideString m_converted_string;	int no = pci->pageNo * pci->nChoicePerPage;	m_converted_string = utf8_mbstowcs(			(char *) pci->totalChoiceStr[ no + index ],			(int) strlen( (char *) pci->totalChoiceStr[ no + index ] ));	return m_converted_string;}AttributeList ChewingLookupTable::get_attributes( int index ) const{	return AttributeList();}unsigned int ChewingLookupTable::number_of_candidates() const{	return pci->nTotalChoice;}void ChewingLookupTable::clear(){}void ChewingLookupTable::init(String selection_keys, int selection_keys_num){	std::vector< WideString > labels;        SCIM_DEBUG_IMENGINE( 2 ) <<        "LookupTable Init\n";	char buf[ 2 ] = { 0, 0 };	for ( int i = 0; i < selection_keys_num; ++i ) {		buf[ 0 ] = selection_keys[i];		labels.push_back( utf8_mbstowcs( buf ) );	}	set_candidate_labels( labels );}void ChewingLookupTable::update( ChoiceInfo *ci ){	pci = ci;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -