void CCommandLineDisplay::InputEnter (void)

//	InputEnter
//
//	Invoke input

	{
	AppendHistory(m_sInput);
	Output(m_sInput, INPUT_COLOR);
	ClearInput();
	ClearHint();
	}
void
JXPathInput::BoundsMoved
	(
	const JCoordinate dx,
	const JCoordinate dy
	)
{
	JXInputField::BoundsMoved(dx, dy);

	const JRect ap = GetAperture();
	if (ap.left != 0)
		{
		SetHint(GetText());
		}
	else
		{
		ClearHint();
		}
}
void CCommandLineDisplay::AutoCompleteSearch (void)

//	AutocompleteSearch
//
//	Searches the global symbol table for matches to the current command.

	{
	const CString sCurCmd = GetCurrentCmd();
	CString sCommon;
	CString sHelp;

	ClearHint();
	if (sCurCmd.IsBlank())
		return;

	//	Get the list of global symbols

	ICCItem *pGlobals = g_pUniverse->GetCC().GetGlobals();

	int iMatches = 0;

	for (int i = 0; i < pGlobals->GetCount(); i++)
		{
		CString sGlobal = pGlobals->GetKey(i);

		//	Partial match
		if (strStartsWith(sGlobal, sCurCmd))
			{
			if (iMatches == 0)
				sCommon = sGlobal;
			//	If we have multiple matching commands then find the longest common stem
			else
				{
				int iLen = min(sCommon.GetLength(), sGlobal.GetLength());
				char *pPos1 = sCommon.GetPointer();
				char *pPos2 = sGlobal.GetPointer();
				int i;
				for (i = 0; i < iLen; i++)
					{
					if (CharLower((LPTSTR)(BYTE)(*pPos1)) != CharLower((LPTSTR)(BYTE)(*pPos2)))
						break;
					pPos1++;
					pPos2++;
					}
				sCommon.Truncate(i);
				m_sHint.Append(CONSTLIT(" "));
				}
			//	Append the command to the auto complete hint
			m_sHint.Append(sGlobal);
			iMatches++;
			}

		if (strEquals(sGlobal, sCurCmd))
			{
			//	Exact match - get help text
			ICCItem *pItem = pGlobals->GetElement(i);
			if (pItem->IsPrimitive())
				sHelp = pItem->GetHelp();
			}
		}

	//	If the common stem is longer than the current command, then auto complete
	if (sCommon.GetLength() > sCurCmd.GetLength())
		Input(strSubString(sCommon, sCurCmd.GetLength(), -1));

	//	If we only have one match then no need to show hint as we have either
	//	auto completed or will show help text insead
	if (iMatches == 1)
		m_sHint = NULL_STR;

	if (!sHelp.IsBlank())
		{
		if (!m_sHint.IsBlank())
			m_sHint.Append(CONSTLIT("\n"));
		m_sHint.Append(sHelp);
		}
	}
예제 #4
0
	void CHitDialog::ShowHint(cocos2d::Layer* layer,int x,int y,std::string str,unsigned long Color, bool drawUp,
		unsigned long bColor /* = 0 */,std::string RightStr/* ="" */)
	{
		
		if(m_Layer)Hide();
		CBaseDialog::Show(layer);
		m_Layer = cocos2d::Layer::create();
		m_Layer->retain();
		layer->addChild(m_Layer);
		ClearHint();
		HintX = x;
		HintY = y;
		HintWidth = 0;
		HintWidthLeft = 0;
		HintHeight = 0;
		HintUp = drawUp;
		HintColor = Color;
		BackColor = bColor;

		int n = 0;
		std::string data;
		//计算左边文字宽高
		while(true)
		{
			n++;
			if(n > 2000)break;
			if(str.length() == 0)break;
			if((int)str.find("\\") >= 0)
			{
				str = GetValidStr3Ex(str,data,'\\');
			}else if((int)str.find("^") >= 0)
			{
				str = GetValidStr3Ex(str,data,'^');
			}else //无法解析道具说明的\\符号
			{
				HintList.push_back(str);
				break;
			}
			int w = GetStrWidth(data) + 8;
			if(w > HintWidth) HintWidth = w;
			if(data.length() > 1)
			{
				HintList.push_back(data);
			}
		}
		HintWidthLeft = HintWidth;
		HintHeight = (TextWidth("A") + 3) * (int)HintList.size() + 3 * 2;
		 //计算右边文字宽高 并更新整体宽度高度
		n = 0;
		int leftWidth =0;
		while(true)
		{
			n++;
			if(n > 2000)break;
			if(RightStr.length() == 0)break;
			if((int)RightStr.find("\\") >= 0)
			{
				RightStr = GetValidStr3Ex(RightStr,data,'\\');
			}else if((int)RightStr.find("^") >= 0)
			{
				RightStr = GetValidStr3Ex(RightStr,data,'^');
			}	
			int w = GetStrWidth(data) + 8;
			if(w > leftWidth) leftWidth = w;
			if(data.length() > 0)
			{
				HintListRight.push_back(data);
			}
		}
		n = (TextWidth("A") + 3) * (int)HintListRight.size() + 3 * 2;
		if(leftWidth > 0) HintWidth = HintWidthLeft + leftWidth + 10;
		if(n > HintHeight) HintHeight = n;
		if(HintUp) HintY = HintY - HintHeight;
		//超出屏幕范围的处理 2013.9.24
		if(HintY + HintHeight > SCREENHEIGHT)
		{
			HintY = SCREENHEIGHT  - HintHeight;
		}
		DrawHint();

	}