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


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

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


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

示例1: WordListSet

int SCI_METHOD LexerBase::WordListSet(int n, const char *wl) {
	if (n < numWordLists) {
		WordList wlNew;
		wlNew.Set(wl);
		if (*keyWordLists[n] != wlNew) {
			keyWordLists[n]->Set(wl);
			return 0;
		}
	}
	return -1;
}
开发者ID:Aahanbhatt,项目名称:robomongo,代码行数:11,代码来源:LexerBase.cpp

示例2: PropertyUpdateNotification

void LexerMake::PropertyUpdateNotification(void *, int PropOffset)
{
  switch (PropOffset)
  {
    case PROP_OFFSET(LexerMake, functionStrings):
      if (functionStrings.empty())
        functionStrings = defaultFunctionStrings;
      functions.Set(functionStrings.c_str());
      break;
    case PROP_OFFSET(LexerMake, directiveStrings):
      if (directiveStrings.empty())
        directiveStrings = defaultDirectiveStrings;
      directives.Set(directiveStrings.c_str());
      break;
    case PROP_OFFSET(LexerMake, nmakeDirectiveStrings):
      if (nmakeDirectiveStrings.empty())
        nmakeDirectiveStrings = defaultNmakeDirectiveStrings;
      nmakeDirectives.Set(nmakeDirectiveStrings.c_str());
      break;
  }
}
开发者ID:gstavi,项目名称:npp,代码行数:21,代码来源:LexMake.cpp

示例3: ColouriseEclDoc

static void ColouriseEclDoc(Sci_PositionU startPos, Sci_Position length, int initStyle, WordList *keywordlists[],
                            Accessor &styler) {
	WordList &keywords0 = *keywordlists[0];
	WordList &keywords1 = *keywordlists[1];
	WordList &keywords2 = *keywordlists[2];
	WordList &keywords3 = *keywordlists[3]; //Value Types
	WordList &keywords4 = *keywordlists[4];
	WordList &keywords5 = *keywordlists[5];
	WordList &keywords6 = *keywordlists[6];	//Javadoc Tags
	WordList cplusplus;
	cplusplus.Set("beginc endc");

	bool stylingWithinPreprocessor = false;

	CharacterSet setOKBeforeRE(CharacterSet::setNone, "(=,");
	CharacterSet setDoxygen(CharacterSet::setLower, "[email protected]\\&<>#{}[]");
	CharacterSet setWordStart(CharacterSet::setAlpha, "_", 0x80, true);
	CharacterSet setWord(CharacterSet::setAlphaNum, "._", 0x80, true);
	CharacterSet setQualified(CharacterSet::setNone, "uUxX");

	int chPrevNonWhite = ' ';
	int visibleChars = 0;
	bool lastWordWasUUID = false;
	int styleBeforeDCKeyword = SCE_ECL_DEFAULT;
	bool continuationLine = false;

	if (initStyle == SCE_ECL_PREPROCESSOR) {
		// Set continuationLine if last character of previous line is '\'
		Sci_Position lineCurrent = styler.GetLine(startPos);
		if (lineCurrent > 0) {
			int chBack = styler.SafeGetCharAt(startPos-1, 0);
			int chBack2 = styler.SafeGetCharAt(startPos-2, 0);
			int lineEndChar = '!';
			if (chBack2 == '\r' && chBack == '\n') {
				lineEndChar = styler.SafeGetCharAt(startPos-3, 0);
			} else if (chBack == '\n' || chBack == '\r') {
				lineEndChar = chBack2;
			}
			continuationLine = lineEndChar == '\\';
		}
	}

	// look back to set chPrevNonWhite properly for better regex colouring
	if (startPos > 0) {
		Sci_Position back = startPos;
		while (--back && IsSpaceEquiv(styler.StyleAt(back)))
			;
		if (styler.StyleAt(back) == SCE_ECL_OPERATOR) {
			chPrevNonWhite = styler.SafeGetCharAt(back);
		}
	}

	StyleContext sc(startPos, length, initStyle, styler);

	for (; sc.More(); sc.Forward()) {
		if (sc.atLineStart) {
			if (sc.state == SCE_ECL_STRING) {
				// Prevent SCE_ECL_STRINGEOL from leaking back to previous line which
				// ends with a line continuation by locking in the state upto this position.
				sc.SetState(SCE_ECL_STRING);
			}
			// Reset states to begining of colourise so no surprises
			// if different sets of lines lexed.
			visibleChars = 0;
			lastWordWasUUID = false;
		}

		// Handle line continuation generically.
		if (sc.ch == '\\') {
			if (sc.chNext == '\n' || sc.chNext == '\r') {
				sc.Forward();
				if (sc.ch == '\r' && sc.chNext == '\n') {
					sc.Forward();
				}
				continuationLine = true;
				continue;
			}
		}

		// Determine if the current state should terminate.
		switch (sc.state) {
			case SCE_ECL_ADDED:
			case SCE_ECL_DELETED:
			case SCE_ECL_CHANGED:
			case SCE_ECL_MOVED:
			if (sc.atLineStart)
					sc.SetState(SCE_ECL_DEFAULT);
				break;
			case SCE_ECL_OPERATOR:
				sc.SetState(SCE_ECL_DEFAULT);
				break;
			case SCE_ECL_NUMBER:
				// We accept almost anything because of hex. and number suffixes
				if (!setWord.Contains(sc.ch)) {
					sc.SetState(SCE_ECL_DEFAULT);
				}
				break;
			case SCE_ECL_IDENTIFIER:
				if (!setWord.Contains(sc.ch) || (sc.ch == '.')) {
					char s[1000];
//.........这里部分代码省略.........
开发者ID:OFFIS-Automation,项目名称:Framework,代码行数:101,代码来源:LexECL.cpp

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

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

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