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

📄 chtxtout.cpp

📁 Windows上的MUD客户端程序
💻 CPP
📖 第 1 页 / 共 3 页
字号:
#endif
	{										// This is a loaded file

		pInfo->LoadFile( strFilename, pMsg->GetURL(), pMsg->GetHTML(),
							pMsg->GetType() );
	}

	return 0;
}


CH_IMPLEMENT_MESSAGE_HANDLER( textOutTextHandler )
{
	ChTextOutMainInfo*	pInfo = (ChTextOutMainInfo*)pMainInfo;
	string				strText;
	ChTextMsg*			pMsg = (ChTextMsg *)&msg;
	ChTextOutputWnd*	pWnd = pInfo->GetOutputWnd();
	chint32				lLen;

	pMsg->GetParams( strText );
	lLen = strText.GetLength();

	pWnd->AppendText( strText );

	#if defined( CH_VERBOSE )
	{
		TRACE1( "TEXT OUT: %s\n", (const char *)strText );
	}
	#endif	// defined( CH_VERBOSE )

	return 0;
}


CH_IMPLEMENT_MESSAGE_HANDLER( textOutFileHandler )
{
	ChTextOutMainInfo*	pInfo = (ChTextOutMainInfo*)pMainInfo;
	string				strFilename;
	chflag32			flOptions;
	ChFileMsg::FileCmd	cmd;
	ChFileMsg*			pMsg = (ChFileMsg*)&msg;

	pMsg->GetParams( cmd, strFilename, flOptions );

	if (ChFileMsg::fileOpenWrite == cmd)
	{
		pInfo->GetOutputWnd()->WriteFile( strFilename, flOptions );
	}
	else
	{
		pInfo->GetOutputWnd()->CloseFile();
	}

	return 0;
}


CH_IMPLEMENT_MESSAGE_HANDLER( textOutLoadFileHandler )
{
	ChTextOutMainInfo*	pInfo = (ChTextOutMainInfo*)pMainInfo;
	string				strURL;
	string				strFilename;
	string				strType;
	ChLoadFileMsg*		pMsg = (ChLoadFileMsg*)&msg;

	pMsg->GetParams( strURL, strFilename, strType );
	pInfo->LoadFile( strFilename, strURL, "", strType );

	return 0;
}


CH_IMPLEMENT_MESSAGE_HANDLER( textOutClearTextHandler )
{
	ChTextOutMainInfo*	pInfo = (ChTextOutMainInfo*)pMainInfo;
	ChTextOutputWnd*			pWnd = pInfo->GetOutputWnd();

	pWnd->NewPage();
	return 0;
}


CH_IMPLEMENT_MESSAGE_HANDLER( textOutResetHandler )
{
	ChTextOutMainInfo*	pInfo = (ChTextOutMainInfo*)pMainInfo;

	pInfo->GetPaneMgr()->DestroyAllPanes( pInfo->GetModuleID(), false );

	return 0;
}


CH_IMPLEMENT_MESSAGE_HANDLER( textOutSetScrollHandler )
{
	ChSetScrollMsg*		pMsg = (ChSetScrollMsg*)&msg;
	ChTextOutMainInfo*	pInfo = (ChTextOutMainInfo*)pMainInfo;
	ChTextOutputWnd*	pWnd = pInfo->GetOutputWnd();
	bool				boolAutoScroll;

	pMsg->GetParams( boolAutoScroll );

	pWnd->ShowAppend( boolAutoScroll );
	return 0;
}


CH_IMPLEMENT_MESSAGE_HANDLER( textOutShowModuleHandler )
{
	ChShowModuleMsg*	pMsg = (ChShowModuleMsg*)&msg;
	ChTextOutMainInfo*	pInfo = (ChTextOutMainInfo*)pMainInfo;

	pInfo->ShowModule( pMsg->IsShowing() );

	return 0;
}


CH_IMPLEMENT_MESSAGE_HANDLER( textOutPaneCmdHandler )
{
	ChPaneCmdMsg*		pMsg = (ChPaneCmdMsg*)&msg;
	ChTextOutMainInfo*	pInfo = (ChTextOutMainInfo*)pMainInfo;
	string				strPaneCmd;
	ChPane::ChPaneCmd	paneCmd;

	pMsg->GetParams( strPaneCmd );
											/* Check to see if this is a pane
												message.  If it is, send it to
												the pane command handler. */

	if (ChPane::GetPaneCmdAttr( strPaneCmd, paneCmd ))
	{
		bool	boolProcessed;

		boolProcessed = pInfo->DoPaneCommand( paneCmd, strPaneCmd );
		pMsg->SetProcessed( boolProcessed );
	}

	return 0;
}


CH_IMPLEMENT_MESSAGE_HANDLER( textOutPaneEventHandler )
{
	ChPaneEventMsg*	pMsg = (ChPaneEventMsg*)&msg;

	switch( pMsg->GetEvent() )
	{
		case ChPaneEventMsg::paneEventDisconnect:
		{
			const ChPane*	pPane = pMsg->GetPane();
			ChWnd*			pWnd = pPane->GetWindow();

			if (pPane->GetType() == ChPane::paneNormal)
			{
				pWnd->DestroyWindow();
				delete pWnd;
			}
			break;
		}

		case ChPaneEventMsg::paneEventClose:
		{
			pMsg->SetClose();
			break;
		}

		default:
		{
			break;
		}
	}
	return 0;
}


#if !defined( CH_UNIX )

CH_IMPLEMENT_MESSAGE_HANDLER( textOutGetPageCountHandler )
{
	ChTextOutMainInfo*	pInfo = (ChTextOutMainInfo*)pMainInfo;
	ChGetPageCountMsg*	pMsg = (ChGetPageCountMsg*)&msg;
	ChPageType			type;
	int					iPageCount;

	pMsg->GetParams( type );

	if (pInfo->IsShown())
	{
		switch( type )
		{
			case pagePreferences:
			{
				iPageCount = 1;
				break;
			}

			default:
			{
				iPageCount = 0;
				break;
			}
		}
	}
	else
	{
		iPageCount = 0;
	}

	return iPageCount;
}


CH_IMPLEMENT_MESSAGE_HANDLER( textOutGetPagesHandler )
{
	ChTextOutMainInfo*	pInfo = (ChTextOutMainInfo*)pMainInfo;
	ChGetPagesMsg*		pMsg = (ChGetPagesMsg*)&msg;
	ChPageType			type;
	chint16				sCount;
	chparam*			pPages;

	pMsg->GetParams( type, sCount, pPages );

	switch( type )
	{
		case pagePreferences:
		{
			ASSERT( 1 == sCount );

			#if defined( CH_MSW )
			{
				ChTextOutPrefsPage*	pPage;

				pPage = new ChTextOutPrefsPage;

				pPages[0] = (chparam)pPage;
			}
			#endif
			break;
		}

		default:
		{
			break;
		}
	}

	return 0;
}


CH_IMPLEMENT_MESSAGE_HANDLER( textOutGetPageDataHandler )
{
	ChTextOutMainInfo*	pInfo = (ChTextOutMainInfo*)pMainInfo;
	ChGetPageDataMsg*	pMsg = (ChGetPageDataMsg*)&msg;
	ChPageType			type;
	chint16				sCount;
	chparam*			pPages;

	pMsg->GetParams( type, sCount, pPages );

	switch( type )
	{
		case pagePreferences:
		{
			ASSERT( 1 == sCount );

			#if defined( CH_MSW )
			{
				if (pPages[0])
				{
					ChTextOutPrefsPage*	pPage = (ChTextOutPrefsPage*)pPages[0];
					chint32				lLines;

					pPage->OnCommit();

					lLines = pPage->GetLines();
					pInfo->SetBufferLimit( lLines );
				}
			}
			#endif	// defined( CH_MSW )
			break;
		}

		default:
		{
			break;
		}
	}

	return 0;
}


CH_IMPLEMENT_MESSAGE_HANDLER( textOutReleasePagesHandler )
{
	ChReleasePagesMsg*	pMsg = (ChReleasePagesMsg*)&msg;
	ChPageType			type;
	chint16				sCount;
	chparam*			pPages;

	pMsg->GetParams( type, sCount, pPages );

	switch( type )
	{
		case pagePreferences:
		{
			ASSERT( 1 == sCount );

			#if defined( CH_MSW )
			{
				if (pPages[0])
				{
					ChTextOutPrefsPage*	pPage = (ChTextOutPrefsPage*)pPages[0];

					delete pPage;
				}
			}
			#endif	// defined( CH_MSW )
			break;
		}

		default:
		{
			break;
		}
	}

	return 0;
}


#endif	// !defined( CH_UNIX )


CH_IMPLEMENT_MESSAGE_HANDLER( textOutCommandHandler )
{
	ChTextOutMainInfo*	pInfo = (ChTextOutMainInfo*)pMainInfo;
	ChCmdMsg*			pMsg = (ChCmdMsg*)&msg;

	pInfo->DoHook( *pMsg );

	return 0;
}


CH_IMPLEMENT_MESSAGE_HANDLER( textOutInlineHandler )
{
	ChTextOutMainInfo*	pInfo = (ChTextOutMainInfo*)pMainInfo;
	ChInlineMsg*		pMsg = (ChInlineMsg*)&msg;

	pInfo->DoHook( *pMsg );

	return 0;
}


CH_IMPLEMENT_MESSAGE_HANDLER( textOutHintHandler )
{
	ChTextOutMainInfo*	pInfo = (ChTextOutMainInfo*)pMainInfo;
	ChHintMsg*			pMsg = (ChHintMsg*)&msg;

	pInfo->DoHook( *pMsg );

	return 0;
}


CH_IMPLEMENT_MESSAGE_HANDLER( textOutInstallHookHandler )
{
	ChTextOutMainInfo*	pInfo = (ChTextOutMainInfo*)pMainInfo;
	ChInstallHookMsg*	pMsg = (ChInstallHookMsg*)&msg;
	ChModuleID			idHookModule;
	chint32				lMessage;

	pMsg->GetParams( idHookModule, lMessage );
	pInfo->InstallHook( lMessage, idHookModule );
	return 0;
}

CH_IMPLEMENT_MESSAGE_HANDLER( textOutPromoteHookHandler )
{
	ChTextOutMainInfo*	pInfo = (ChTextOutMainInfo*)pMainInfo;
	ChPromoteHookMsg*	pMsg = (ChPromoteHookMsg*)&msg;
	ChModuleID			idHookModule;
	bool				boolPromote;
	chint32				lMessage;

	pMsg->GetParams( idHookModule, boolPromote, lMessage );
	pInfo->PromoteHook( lMessage, idHookModule, boolPromote );
	return 0;
}

CH_IMPLEMENT_MESSAGE_HANDLER( textOutUninstallHookHandler )
{
	ChTextOutMainInfo*	pInfo = (ChTextOutMainInfo*)pMainInfo;
	ChUninstallHookMsg*	pMsg = (ChUninstallHookMsg*)&msg;
	ChModuleID			idHookModule;
	chint32				lMessage;

	pMsg->GetParams( idHookModule, lMessage );
	pInfo->UninstallHook( lMessage, idHookModule );
	return 0;
}


/*----------------------------------------------------------------------------
	Chaco menu handlers
----------------------------------------------------------------------------*/

CH_IMPLEMENT_MESSAGE_HANDLER( txtOutStdEditMenuHandler )
{
	chparam		retVal = 0;

	return retVal;
}

CH_IMPLEMENT_MESSAGE_HANDLER( OnTxtOutStdEditCopy )
{
	chparam				retVal = false;
	ChMenuMsg*			pMsg = (ChMenuMsg*)&msg;
	ChTextOutMainInfo*	pInfo = (ChTextOutMainInfo*)pMsg->GetItem()->GetData();
	ChTextOutputWnd*	pOut = pInfo->GetOutputWnd();

	pMsg->SetProcessed();

	switch( pMsg->GetMessage() )
	{
		case CH_MSG_MENU_SHOW:
		{
			chint32 lStart, lEnd;

			pOut->GetSel( lStart, lEnd );

			if ( lStart != lEnd )
			{
				pMsg->GetItem()->Enable();
			}
			else
			{
				pMsg->GetItem()->Enable( false );
			}
			pMsg->SetProcessed();
			break;
		}

		case CH_MSG_MENU_SELECT:
		{
			pOut->CopyToClipboard();
			pMsg->SetProcessed();
			break;
		}

		default:
		{
			break;
		}
	}
	return retVal;
}

CH_IMPLEMENT_MESSAGE_HANDLER( OnTxtOutStdEditCutPaste )
{
	ChMenuMsg*			pMsg = (ChMenuMsg*)&msg;

	pMsg->SetProcessed();

	if (CH_MSG_MENU_SHOW == pMsg->GetMessage())
	{
		pMsg->GetItem()->Enable( false );
		pMsg->SetProcessed();
	}

	return false;
}

⌨️ 快捷键说明

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