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


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

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


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

示例1: ColouriseWord

static void ColouriseWord(StyleContext& sc, WordList& keywords, WordList& keywords2, WordList& keywords3, bool& apostropheStartsAttribute) {
    apostropheStartsAttribute = true;
    sc.SetState(SCE_SPICE_IDENTIFIER);
    std::string word;
    while (!sc.atLineEnd && !IsSeparatorOrDelimiterCharacter(sc.ch)) {
        word += static_cast<char>(tolower(sc.ch));
        sc.Forward();
    }
    if (keywords.InList(word.c_str())) {
        sc.ChangeState(SCE_SPICE_KEYWORD);
        if (word != "all") {
            apostropheStartsAttribute = false;
        }
    }
    else if (keywords2.InList(word.c_str())) {
        sc.ChangeState(SCE_SPICE_KEYWORD2);
        if (word != "all") {
            apostropheStartsAttribute = false;
        }
    }
    else if (keywords3.InList(word.c_str())) {
        sc.ChangeState(SCE_SPICE_KEYWORD3);
        if (word != "all") {
            apostropheStartsAttribute = false;
        }
    }
    sc.SetState(SCE_SPICE_DEFAULT);
}
开发者ID:6qat,项目名称:robomongo,代码行数:28,代码来源:LexSpice.cpp

示例2: ColouriseLabel

static void ColouriseLabel(StyleContext& sc, WordList& keywords, bool& apostropheStartsAttribute) {
	apostropheStartsAttribute = false;

	sc.SetState(SCE_ADA_LABEL);

	// Skip "<<"
	sc.Forward();
	sc.Forward();

	std::string identifier;

	while (!sc.atLineEnd && !IsSeparatorOrDelimiterCharacter(sc.ch)) {
		identifier += static_cast<char>(tolower(sc.ch));
		sc.Forward();
	}

	// Skip ">>"
	if (sc.Match('>', '>')) {
		sc.Forward();
		sc.Forward();
	} else {
		sc.ChangeState(SCE_ADA_ILLEGAL);
	}

	// If the name is an invalid identifier or a keyword, then make it invalid label
	if (!IsValidIdentifier(identifier) || keywords.InList(identifier.c_str())) {
		sc.ChangeState(SCE_ADA_ILLEGAL);
	}

	sc.SetState(SCE_ADA_DEFAULT);

}
开发者ID:6VV,项目名称:NewTeachingBox,代码行数:32,代码来源:LexAda.cpp

示例3: classifyWordBullant

static int classifyWordBullant(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler) {
  char s[100];
  s[0] = '\0';
  for (unsigned int i = 0; i < end - start + 1 && i < 30; i++) {
    s[i] = static_cast<char>(tolower(styler[start + i]));
    s[i + 1] = '\0';
  }
  int lev= 0;
  char chAttr = SCE_C_IDENTIFIER;
  if (isdigit(s[0]) || (s[0] == '.')){
    chAttr = SCE_C_NUMBER;
  }
  else {
    if (keywords.InList(s)) {
      chAttr = SCE_C_WORD;
      if (strcmp(s, "end") == 0)
        lev = -1;
      else if (strcmp(s, "method") == 0 ||
        strcmp(s, "case") == 0 ||
        strcmp(s, "class") == 0 ||
        strcmp(s, "debug") == 0 ||
        strcmp(s, "test") == 0 ||
        strcmp(s, "if") == 0 ||
        strcmp(s, "lock") == 0 ||
        strcmp(s, "transaction") == 0 ||
        strcmp(s, "trap") == 0 ||
        strcmp(s, "until") == 0 ||
        strcmp(s, "while") == 0)
        lev = 1;
    }
  }
  styler.ColourTo(end, chAttr);
  return lev;
}
开发者ID:Snake174,项目名称:PipmakAssistant,代码行数:34,代码来源:LexBullant.cpp

示例4: IsFoldingContainer

/**
 * This function detects keywords which are able to have a body. Note that it
 * uses the Fold Containers word description, not the containers description. It
 * only works when the style at that particular position is set on Containers
 * or Flow (number 3 or 4).
 *
 * \param  keywordslist The list of keywords that are scanned, they should only
 *         contain the start keywords, not the end keywords
 * \param  The actual keyword
 * \return 1 if it is a folding start-keyword, -1 if it is a folding end-keyword
 *         0 otherwise
 */
static inline int IsFoldingContainer(WordList &keywordslist, char * keyword) {
    if(
        strlen(keyword) > 3 &&
        keyword[0] == 'e' && keyword[1] == 'n' && keyword[2] == 'd') {
        if (keywordslist.InList(keyword + 3)) {
            return -1;
        }

    } else {
        if(keywordslist.InList(keyword)) {
            return 1;
        }
    }

    return 0;
}
开发者ID:Snake174,项目名称:PipmakAssistant,代码行数:28,代码来源:LexMagik.cpp

示例5: ClassifyWordSol

static void ClassifyWordSol(unsigned int start, unsigned int end, WordList &keywords, Accessor &styler, char *prevWord)
{
    char s[100];
    bool wordIsNumber = isdigit(styler[start]) != 0;
    for (unsigned int i = 0; i < end - start + 1 && i < 30; i++)
     {
           s[i] = styler[start + i];
           s[i + 1] = '\0';
     }
    char chAttr = SCE_SCRIPTOL_IDENTIFIER;
    if (0 == strcmp(prevWord, "class"))       chAttr = SCE_SCRIPTOL_CLASSNAME;
    else if (wordIsNumber)                    chAttr = SCE_SCRIPTOL_NUMBER;
    else if (keywords.InList(s))              chAttr = SCE_SCRIPTOL_KEYWORD;
    else for (unsigned int i = 0; i < end - start + 1; i++)  // test dotted idents
    {
        if (styler[start + i] == '.')
        {
            styler.ColourTo(start + i - 1, chAttr);
            styler.ColourTo(start + i, SCE_SCRIPTOL_OPERATOR);
        }
    }
    styler.ColourTo(end, chAttr);
    strcpy(prevWord, s);
}
开发者ID:JowC9V,项目名称:CLL-Synergie,代码行数:24,代码来源:LexScriptol.cpp

示例6: ColouriseYAMLLine

static void ColouriseYAMLLine(
	char *lineBuffer,
	unsigned int currentLine,
	unsigned int lengthLine,
	unsigned int startLine,
	unsigned int endPos,
	WordList &keywords,
	Accessor &styler) {

	unsigned int i = 0;
	bool bInQuotes = false;
	unsigned int indentAmount = SpaceCount(lineBuffer);

	if (currentLine > 0) {
		int parentLineState = styler.GetLineState(currentLine - 1);

		if ((parentLineState&YAML_STATE_MASK) == YAML_STATE_TEXT || (parentLineState&YAML_STATE_MASK) == YAML_STATE_TEXT_PARENT) {
			unsigned int parentIndentAmount = parentLineState&(~YAML_STATE_MASK);
			if (indentAmount > parentIndentAmount) {
				styler.SetLineState(currentLine, YAML_STATE_TEXT | parentIndentAmount);
				styler.ColourTo(endPos, SCE_YAML_TEXT);
				return;
			}
		}
	}
	styler.SetLineState(currentLine, 0);
	if (strncmp(lineBuffer, "---", 3) == 0) {	// Document marker
		styler.SetLineState(currentLine, YAML_STATE_DOCUMENT);
		styler.ColourTo(endPos, SCE_YAML_DOCUMENT);
		return;
	}
	// Skip initial spaces
	while ((i < lengthLine) && lineBuffer[i] == ' ') { // YAML always uses space, never TABS or anything else
		i++;
	}
	if (lineBuffer[i] == '\t') { // if we skipped all spaces, and we are NOT inside a text block, this is wrong
		styler.ColourTo(endPos, SCE_YAML_ERROR);
		return;
	}
	if (lineBuffer[i] == '#') {	// Comment
		styler.SetLineState(currentLine, YAML_STATE_COMMENT);
		styler.ColourTo(endPos, SCE_YAML_COMMENT);
		return;
	}
	while (i < lengthLine) {
		if (lineBuffer[i] == '\'' || lineBuffer[i] == '\"') {
			bInQuotes = !bInQuotes;
		} else if (lineBuffer[i] == ':' && !bInQuotes) {
			styler.ColourTo(startLine + i - 1, SCE_YAML_IDENTIFIER);
			styler.ColourTo(startLine + i, SCE_YAML_OPERATOR);
			// Non-folding scalar
			i++;
			while ((i < lengthLine) && isspacechar(lineBuffer[i]))
				i++;
			unsigned int endValue = lengthLine - 1;
			while ((endValue >= i) && isspacechar(lineBuffer[endValue]))
				endValue--;
			lineBuffer[endValue + 1] = '\0';
			if (lineBuffer[i] == '|' || lineBuffer[i] == '>') {
				i++;
				if (lineBuffer[i] == '+' || lineBuffer[i] == '-')
					i++;
				while ((i < lengthLine) && isspacechar(lineBuffer[i]))
					i++;
				if (lineBuffer[i] == '\0') {
					styler.SetLineState(currentLine, YAML_STATE_TEXT_PARENT | indentAmount);
					styler.ColourTo(endPos, SCE_YAML_DEFAULT);
					return;
				} else if (lineBuffer[i] == '#') {
					styler.SetLineState(currentLine, YAML_STATE_TEXT_PARENT | indentAmount);
					styler.ColourTo(startLine + i - 1, SCE_YAML_DEFAULT);
					styler.ColourTo(endPos, SCE_YAML_COMMENT);
					return;
				} else {
					styler.ColourTo(endPos, SCE_YAML_ERROR);
					return;
				}
			} else if (lineBuffer[i] == '#') {
				styler.ColourTo(startLine + i - 1, SCE_YAML_DEFAULT);
				styler.ColourTo(endPos, SCE_YAML_COMMENT);
				return;
			}
			styler.SetLineState(currentLine, YAML_STATE_VALUE);
			if (lineBuffer[i] == '&' || lineBuffer[i] == '*') {
				styler.ColourTo(endPos, SCE_YAML_REFERENCE);
				return;
			}
			if (keywords.InList(&lineBuffer[i])) { // Convertible value (true/false, etc.)
				styler.ColourTo(endPos, SCE_YAML_KEYWORD);
				return;
			} else {
				unsigned int i2 = i;
				while ((i < lengthLine) && lineBuffer[i]) {
					if (!(isascii(lineBuffer[i]) && isdigit(lineBuffer[i])) && lineBuffer[i] != '-' && lineBuffer[i] != '.' && lineBuffer[i] != ',') {
						styler.ColourTo(endPos, SCE_YAML_DEFAULT);
						return;
					}
					i++;
				}
				if (i > i2) {
//.........这里部分代码省略.........
开发者ID:JowC9V,项目名称:CLL-Synergie,代码行数:101,代码来源:LexYAML.cpp

示例7: FoldNoBoxVHDLDoc

//=============================================================================
// Folding the code
static void FoldNoBoxVHDLDoc(
  unsigned int startPos,
  int length,
  int,
  Accessor &styler)
{
  // Decided it would be smarter to have the lexer have all keywords included. Therefore I
  // don't check if the style for the keywords that I use to adjust the levels.
  char words[] =
    "architecture begin block case component else elsif end entity generate loop package process record then "
    "procedure function when";
  WordList keywords;
  keywords.Set(words);

  bool foldComment      = styler.GetPropertyInt("fold.comment", 1) != 0;
  bool foldCompact      = styler.GetPropertyInt("fold.compact", 1) != 0;
  bool foldAtElse       = styler.GetPropertyInt("fold.at.else", 1) != 0;
  bool foldAtBegin      = styler.GetPropertyInt("fold.at.Begin", 1) != 0;
  bool foldAtParenthese = styler.GetPropertyInt("fold.at.Parenthese", 1) != 0;
  //bool foldAtWhen       = styler.GetPropertyInt("fold.at.When", 1) != 0;  //< fold at when in case statements

  int  visibleChars     = 0;
  unsigned int endPos   = startPos + length;

  int lineCurrent       = styler.GetLine(startPos);
  int levelCurrent      = SC_FOLDLEVELBASE;
  if(lineCurrent > 0)
    levelCurrent        = styler.LevelAt(lineCurrent-1) >> 16;
  //int levelMinCurrent   = levelCurrent;
  int levelMinCurrentElse = levelCurrent;   //< Used for folding at 'else'
  int levelMinCurrentBegin = levelCurrent;  //< Used for folding at 'begin'
  int levelNext         = levelCurrent;

  /***************************************/
  int lastStart         = 0;
  char prevWord[32]     = "";

  /***************************************/
  // Find prev word
  // The logic for going up or down a level depends on a the previous keyword
  // This code could be cleaned up.
  int end = 0;
  unsigned int j;
  for(j = startPos; j>0; j--)
  {
    char ch       = styler.SafeGetCharAt(j);
    char chPrev   = styler.SafeGetCharAt(j-1);
    int style     = styler.StyleAt(j);
    int stylePrev = styler.StyleAt(j-1);
    if ((!IsCommentStyle(style)) && (stylePrev != SCE_VHDL_STRING))
    {
      if(IsAWordChar(chPrev) && !IsAWordChar(ch))
      {
        end = j-1;
      }
    }
    if ((!IsCommentStyle(style)) && (style != SCE_VHDL_STRING))
    {
      if(!IsAWordChar(chPrev) && IsAWordStart(ch) && (end != 0))
      {
        char s[32];
        unsigned int k;
        for(k=0; (k<31 ) && (k<end-j+1 ); k++) {
          s[k] = static_cast<char>(tolower(styler[j+k]));
        }
        s[k] = '\0';

        if(keywords.InList(s)) {
          strcpy(prevWord, s);
          break;
        }
      }
    }
  }
  for(j=j+static_cast<unsigned int>(strlen(prevWord)); j<endPos; j++)
  {
    char ch       = styler.SafeGetCharAt(j);
    int style     = styler.StyleAt(j);
    if ((!IsCommentStyle(style)) && (style != SCE_VHDL_STRING))
    {
      if((ch == ';') && (strcmp(prevWord, "end") == 0))
      {
        strcpy(prevWord, ";");
      }
    }
  }

  char  chNext          = styler[startPos];
  char  chPrev          = '\0';
  char  chNextNonBlank;
  int   styleNext       = styler.StyleAt(startPos);
  //Platform::DebugPrintf("Line[%04d] Prev[%20s] ************************* Level[%x]\n", lineCurrent+1, prevWord, levelCurrent);

  /***************************************/
  for (unsigned int i = startPos; i < endPos; i++)
  {
    char ch         = chNext;
    chNext          = styler.SafeGetCharAt(i + 1);
//.........这里部分代码省略.........
开发者ID:6VV,项目名称:NewTeachingBox,代码行数:101,代码来源:LexVHDL.cpp

示例8: 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

示例9: FoldNoBoxMAXScriptDoc

//=============================================================================
// 折叠代码
static void FoldNoBoxMAXScriptDoc(
  unsigned int startPos,
  int length,
  int,
  Accessor &styler)
{
	char words[] =
		"begin case else if end undefined unsupplied then local global level with"
		"function fn when while at in to time animate exit do on off for about as"
		"where continue try catch set undo and or not true false for by";
	WordList keywords;
	keywords.Set(words);

	bool foldComment      = styler.GetPropertyInt("fold.comment", 1) != 0;
	bool foldCompact      = styler.GetPropertyInt("fold.compact", 1) != 0;
	bool foldAtElse       = styler.GetPropertyInt("fold.at.else", 1) != 0;
	bool foldAtBegin      = styler.GetPropertyInt("fold.at.Begin", 1) != 0;
	bool foldAtParenthese = styler.GetPropertyInt("fold.at.Parenthese", 1) != 0;
  
	int  visibleChars     = 0;
	unsigned int endPos   = startPos + length;

	int lineCurrent       = styler.GetLine(startPos);
	int levelCurrent      = SC_FOLDLEVELBASE;
	if(lineCurrent > 0)
		levelCurrent        = styler.LevelAt(lineCurrent-1) >> 16;
	//int levelMinCurrent   = levelCurrent;
	int levelMinCurrentElse = levelCurrent;   //< Used for folding at 'else'
	int levelMinCurrentBegin = levelCurrent;  //< Used for folding at 'begin'
	int levelNext         = levelCurrent;
  
    /***************************************/
	int lastStart         = 0;
	char prevWord[32]     = "";
	/***************************************/
	// Find prev word
	// The logic for going up or down a level depends on a the previous keyword
	// This code could be cleaned up.
	int end = 0;
	unsigned int j;
	for(j = startPos; j>0; j--)
	{
		char ch       = styler.SafeGetCharAt(j);
		char chPrev   = styler.SafeGetCharAt(j-1);
		int style     = styler.StyleAt(j);
		int stylePrev = styler.StyleAt(j-1);
		if ((stylePrev != SCE_MAXSCRIPT_COMMENT) && (stylePrev != SCE_MAXSCRIPT_STRING))
		{
			if(IsAWordChar(chPrev) && !IsAWordChar(ch))
			{
				end = j-1;
			}
		}
		if ((style != SCE_MAXSCRIPT_COMMENT) && (style != SCE_MAXSCRIPT_STRING))
		{
			if(!IsAWordChar(chPrev) && IsAWordStart(ch) && (end != 0))
			{
				char s[32];
				unsigned int k;
				for(k=0; (k<31 ) && (k<end-j+1 ); k++)
				{
					s[k] = static_cast<char>(tolower(styler[j+k]));
				}
				s[k] = '\0';

				if(keywords.InList(s))
				{
					strcpy(prevWord, s);
					break;
				}
			}
		}
	}
	for(j=j+static_cast<unsigned int>(strlen(prevWord)); j<endPos; j++)
	{
		char ch       = styler.SafeGetCharAt(j);
		int style     = styler.StyleAt(j);
		if ((style != SCE_VHDL_COMMENT) && (style != SCE_VHDL_STRING))
		{
			if((ch == ';') && (strcmp(prevWord, "end") == 0))
			{
				strcpy(prevWord, ";");
			}
		}
	}

	
	char  chNext          = styler[startPos];
	char  chPrev          = '\0';
	char  chNextNonBlank;
	int   styleNext       = styler.StyleAt(startPos);
	
  /***************************************/
	for (unsigned int i = startPos; i < endPos; i++)
	{
		char ch         = chNext;
		chNext          = styler.SafeGetCharAt(i + 1);
		chPrev          = styler.SafeGetCharAt(i - 1);
//.........这里部分代码省略.........
开发者ID:jzsun,项目名称:MaxscriptEditor,代码行数:101,代码来源:LexMAXscript.cpp


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