当前位置: 首页>>代码示例>>C++>>正文


C++ WordList::Clear方法代码示例

本文整理汇总了C++中WordList::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ WordList::Clear方法的具体用法?C++ WordList::Clear怎么用?C++ WordList::Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WordList的用法示例。


在下文中一共展示了WordList::Clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: onEditCompleteWord

void Model::onEditCompleteWord()
{
	if (!static_cast<ModelStyle*>(m_pStyle)->autoComplete.useAutoComplete)
		return;

	setFocus();
	std::string primaryKwList = getAllKW();
	WordList fullWordList;
	fullWordList.Set(primaryKwList.c_str());
	fullWordList.InList("");
	primaryKwList = "";

	typedef std::vector<std::string> string_list;

	class compareStringScintilla {
	public:
		bool operator()(std::string A, std::string B) {
			return CompareNCaseInsensitive(A.c_str(), B.c_str(), A.length()) < 0;
		}
	};

	compareStringScintilla functor;

	WordListUtil getList(fullWordList);
	string_list basicList = getList.getNearestWords(std::string());
	std::sort(basicList.begin(), basicList.end(), functor);
	for (string_list::const_iterator it = basicList.begin(); it != basicList.end(); ++it)
	{
		primaryKwList += *it;
		if (it != basicList.end() - 1)
		{
			primaryKwList += " ";
		}
	}
	char currentLine[8000];
	int line = getCurrentLineNumber();
	sendEditor(SCI_GETLINE, line, reinterpret_cast<long>(currentLine));

	int currentPos = getCurrentPos() - getPositionFromLine(line);
	currentLine[currentPos] = '\0';

	int startPos = currentPos;
	int identifierLength = 0;
	std::wstring wCurrentLine = rdo::locale::convertToWStr(currentLine);
	std::wstring::const_reverse_iterator wCharIt = wCurrentLine.rbegin();
	while (wCharIt != wCurrentLine.rend())
	{
		if (!rdo::gui::lexer::isIdentifier(*wCharIt))
			break;
		++identifierLength;
		++wCharIt;
	}
	startPos -= rdo::locale::convertFromWStr(wCurrentLine.substr(wCurrentLine.length() - identifierLength)).length();

	const char*  userPattern = currentLine + startPos;
	unsigned int userPatternLength = currentPos - startPos;

	string_list prioritySortedKwList = getList.getNearestWords(userPattern);
	if (prioritySortedKwList.empty())
	{
		prioritySortedKwList = basicList;
	}

	string_list::const_iterator it = prioritySortedKwList.begin();
	std::string stWord = *it;
	std::sort(prioritySortedKwList.begin(), prioritySortedKwList.end(), functor);

	std::string foundKeyWords = "";
	for (string_list::const_iterator it = prioritySortedKwList.begin(); it != prioritySortedKwList.end(); ++it) 
	{
		foundKeyWords += (*it);
		if (it != prioritySortedKwList.end() - 1)
		{
			foundKeyWords += " ";
		}
	}
	const char* list;

	if (static_cast<ModelStyle*>(m_pStyle)->autoComplete.showFullList)
	{
		list = primaryKwList.c_str();
	}
	else
	{
		list = foundKeyWords.c_str();
		if (!list)
		{
			list = primaryKwList.c_str();
		}
	}

	if (list) 
	{
		std::string startKeyWord       = "";
		std::string startKeyWordScroll = stWord;
		bool useReplace = false;
		if (foundKeyWords.c_str())
		{
			fullWordList.Clear();
			fullWordList.Set(foundKeyWords.c_str());
//.........这里部分代码省略.........
开发者ID:Nikitaterm,项目名称:rdo_studio,代码行数:101,代码来源:model_edit.cpp


注:本文中的WordList::Clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。