Beispiel #1
0
void CConsoleEdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	if (!m_can_input)
		return;

	// 向上的按键
	if (nChar == 38)
	{
		strcpy(m_cmd,GetCommand());
		ReplaceCommand(m_cmd);
		return;
	}
	// 向下
	if (nChar == 40)
	{
		strcpy(m_cmd,GetCommand(FALSE));
		ReplaceCommand(m_cmd);
		return;
	}

	// left
	if (nChar == 37)
	{
		int nPos = GetCurrentPosition();
		if (nPos <= m_last_title_pos)
			return;
	}
	// delete
	if (nChar == 46)
	{
		int nPos = GetCurrentPosition();
		if (nPos < m_last_title_pos)
			return;
	}
	/**************改用字符比较********************/
	CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
}
Beispiel #2
0
BOOL CCLITerminal::ExecuteVirtualKey(CLISESSION *pSession, int nVKey)
{
	if (m_pCLIService->GetRunLevel() == RUNLEVEL_DEBUG)
		return TRUE;

	switch(pSession->nVKey) {
	  case VKEY_F1 :
		   if (!pSession->bLogined)
			   break;
		   strcpy(pSession->szCommand, (char *)m_pCLIService->m_szVirtualKey[0]);
		   WriteStream(pSession, pSession->szCommand);
		   pSession->nCmdLength = strlen(pSession->szCommand);
		   ExecuteCommand(pSession, FALSE, FALSE);
		   break;

	  case VKEY_F2 :
		   if (!pSession->bLogined)
			   break;
		   strcpy(pSession->szCommand, (char *)m_pCLIService->m_szVirtualKey[1]);
		   WriteStream(pSession, pSession->szCommand);
		   pSession->nCmdLength = strlen(pSession->szCommand);
		   ExecuteCommand(pSession, FALSE, FALSE);
		   break;

	  case VKEY_F3 :
		   if (!pSession->bLogined)
			   break;
		   strcpy(pSession->szCommand, (char *)m_pCLIService->m_szVirtualKey[2]);
		   WriteStream(pSession, pSession->szCommand);
		   pSession->nCmdLength = strlen(pSession->szCommand);
		   ExecuteCommand(pSession, FALSE, FALSE);
		   break;

	  case VKEY_F4 :
		   if (!pSession->bLogined)
			   break;
		   strcpy(pSession->szCommand, (char *)m_pCLIService->m_szVirtualKey[3]);
		   WriteStream(pSession, pSession->szCommand);
		   pSession->nCmdLength = strlen(pSession->szCommand);
		   ExecuteCommand(pSession, FALSE, FALSE);
		   break;

	  case VKEY_UP :
		   if (!pSession->bLogined || (pSession->nCurHistory <= 0))
			  break;
		   pSession->nCurHistory--;
		   ReplaceCommand(pSession, pSession->pszHistory[pSession->nCurHistory]);
		   break;

	  case VKEY_DOWN :
		   if (!pSession->bLogined)
			   break;
		   if (pSession->nCurHistory >= pSession->nHistoryCount)
		   {
			   if (pSession->nCmdLength != 0)
		   	   	   ReplaceCommand(pSession, "");
			   break;
		   }
		   pSession->nCurHistory++;
		   ReplaceCommand(pSession, pSession->pszHistory[pSession->nCurHistory]);
		   break;

	  case VKEY_LEFT :
		   break;

	  case VKEY_RIGHT :
		   break;

	  case VKEY_HOME :
		   break;

	  case VKEY_END :
		   break;

	  case VKEY_USERMENU :
		   if (pSession->nMode == CLIMODE_USER)
			   break;

		   if (pSession->nType == CLITYPE_TELNET)
       		   break;

		   pSession->nMode = CLIMODE_USER;
		   DisplayUserMenu(pSession);
		   break;
	}
	return TRUE;
}