Example #1
0
bool RtfGenerator::initTheme(const string& themePath) {
   bool result = CodeGenerator::initTheme(themePath);

   styleTagOpen.push_back(getOpenTag(STANDARD, docStyle.getDefaultStyle()));
   styleTagOpen.push_back(getOpenTag(STRING, docStyle.getStringStyle()));
   styleTagOpen.push_back(getOpenTag(NUMBER, docStyle.getNumberStyle()));
   styleTagOpen.push_back(getOpenTag(SL_COMMENT, docStyle.getSingleLineCommentStyle()));
   styleTagOpen.push_back(getOpenTag(ML_COMMENT,docStyle.getCommentStyle()));
   styleTagOpen.push_back(getOpenTag(ESC_CHAR, docStyle.getEscapeCharStyle()));
   styleTagOpen.push_back(getOpenTag(DIRECTIVE, docStyle.getDirectiveStyle()));
   styleTagOpen.push_back(getOpenTag(DIRECTIVE_STRING, docStyle.getDirectiveStringStyle()));
   styleTagOpen.push_back(getOpenTag(LINENUMBER, docStyle.getLineStyle()));
   styleTagOpen.push_back(getOpenTag(SYMBOL, docStyle.getSymbolStyle()));

   styleTagClose.push_back(getCloseTag(docStyle.getDefaultStyle()));
   styleTagClose.push_back(getCloseTag(docStyle.getStringStyle()));
   styleTagClose.push_back(getCloseTag(docStyle.getNumberStyle()));
   styleTagClose.push_back(getCloseTag(docStyle.getSingleLineCommentStyle()));
   styleTagClose.push_back(getCloseTag(docStyle.getCommentStyle()));
   styleTagClose.push_back(getCloseTag(docStyle.getEscapeCharStyle()));
   styleTagClose.push_back(getCloseTag(docStyle.getDirectiveStyle()));
   styleTagClose.push_back(getCloseTag(docStyle.getDirectiveStringStyle()));
   styleTagClose.push_back(getCloseTag(docStyle.getLineStyle()));
   styleTagClose.push_back(getCloseTag(docStyle.getSymbolStyle()));

   return result;
 }
void AutoCompletion::insertMatchedChars(int character, const MatchedPairConf & matchedPairConf)
{
    const vector< pair<char, char> > & matchedPairs = matchedPairConf._matchedPairs;
    int caretPos = _pEditView->execute(SCI_GETCURRENTPOS);
    char *matchedChars = NULL;

    // User defined matched pairs should be checked firstly
    for (const std::pair<char, char>& matchedPair : matchedPairs)
    {
        if (int(matchedPair.first) == character)
        {
            char userMatchedChar[2] = {'\0', '\0'};
            userMatchedChar[0] = matchedPair.second;
            _pEditView->execute(SCI_INSERTTEXT, caretPos, (LPARAM)userMatchedChar);
            return;
        }
    }

    // if there's no user defined matched pair found, continue to check notepad++'s one

    const size_t closeTagLen = 256;
    char closeTag[closeTagLen];
    closeTag[0] = '\0';
    switch (character)
    {
    case int('('):
        if (matchedPairConf._doParentheses)
            matchedChars = ")";
        break;
    case int('['):
        if (matchedPairConf._doBrackets)
            matchedChars = "]";
        break;
    case int('{'):
        if (matchedPairConf._doCurlyBrackets)
            matchedChars = "}";
        break;
    case int('"'):
        if (matchedPairConf._doDoubleQuotes)
            matchedChars = "\"";
        break;
    case int('\''):
        if (matchedPairConf._doQuotes)
            matchedChars = "'";
        break;
    case int('>'):
    {
        if (matchedPairConf._doHtmlXmlTag && (_curLang == L_HTML || _curLang == L_XML))
        {
            getCloseTag(closeTag, closeTagLen, caretPos);
            if (closeTag[0] != '\0')
                matchedChars = closeTag;
        }
    }
    break;
    }

    if (matchedChars)
        _pEditView->execute(SCI_INSERTTEXT, caretPos, (LPARAM)matchedChars);
}
Example #3
0
	void XmlGenerator::initOutputTags(){
		openTags.push_back ( getOpenTag ( STY_NAME_STD ) );
		openTags.push_back ( getOpenTag ( STY_NAME_STR ) );
		openTags.push_back ( getOpenTag ( STY_NAME_NUM ) );
		openTags.push_back ( getOpenTag ( STY_NAME_SLC ) );
		openTags.push_back ( getOpenTag ( STY_NAME_COM ) );
		openTags.push_back ( getOpenTag ( STY_NAME_ESC ) );
		openTags.push_back ( getOpenTag ( STY_NAME_DIR ) );
		openTags.push_back ( getOpenTag ( STY_NAME_DST ) );
		openTags.push_back ( getOpenTag ( STY_NAME_LIN ) );
		openTags.push_back ( getOpenTag ( STY_NAME_SYM ) );

		closeTags.push_back ( getCloseTag ( STY_NAME_STD ) );
		closeTags.push_back ( getCloseTag ( STY_NAME_STR ) );
		closeTags.push_back ( getCloseTag ( STY_NAME_NUM ) );
		closeTags.push_back ( getCloseTag ( STY_NAME_SLC ) );
		closeTags.push_back ( getCloseTag ( STY_NAME_COM ) );
		closeTags.push_back ( getCloseTag ( STY_NAME_ESC ) );
		closeTags.push_back ( getCloseTag ( STY_NAME_DIR ) );
		closeTags.push_back ( getCloseTag ( STY_NAME_DST ) );
		closeTags.push_back ( getCloseTag ( STY_NAME_LIN ) );
		closeTags.push_back ( getCloseTag ( STY_NAME_SYM ) );
	}
Example #4
0
    void CodeGenerator::processRootState()
    {

	if (readAfterEOF && in!=&cin){
	   in->seekg (0, ios::end);
	   // output the last few lines or the complete file if not too big
	   if (in->tellg()>51200) {
	       in->seekg (-512, ios::end);
	       // output complete lines, ignore first line fragment
	       in->ignore(512, '\n');
	   } else {
	       in->seekg (0, ios::beg); // output complete file
	   }
	}

	string line;
	size_t i=0;
	bool tagOpen=false;
	while (true)
	{
	    if (!getline(*in, line))
	    {
		// imitate tail bahaviour, continue to read after EOF
		if (readAfterEOF)
		{
		    out->flush();
		    in->clear();
#ifdef WIN32
		    Sleep(250);
#else
		    sleep(1);
#endif
		}
		else
		{
		    //todo hier position merken, in der gui periodisch den dateizeiger auf diesen wert setzen und den neuen code einlesen
		    break;
		}
	    }
	    else
	    {
		i=0;
		size_t seqEnd=string::npos;
		while (i <line.length() )
		{
		    if (line[i]==0x1b)
		    {
		      // fix grep --colour .[K (1b 5b 4b) sequences
		      if (line.length()>i+2 && line[i+2]==0x4b){
			  seqEnd=i+2;
		      } else {

			  seqEnd=line.find_first_of('m', i+1);

			  //TODO vor ; das hier anfangen xterm: ^[]0;~^G^M^M
			  // http://www.mit.edu/afs/athena/system/x11r4/src/mit/clients/xterm/ctlseq2.txt
			  if (seqEnd==string::npos) {
			      if (line[i+1]==']') seqEnd=line.find(0x07, i+1);
			  }
			  if (seqEnd==string::npos) seqEnd=line.find(';', i+1);
			  if (seqEnd==string::npos) seqEnd=line.find('h', i+1);

			  if (!ignoreFormatting && seqEnd!=string::npos)
			  {
			      if (!elementStyle.isReset()){
				  *out <<getCloseTag();
				  tagOpen=false;
			      }
			      parseSequence(line, i, seqEnd);
			      if (!elementStyle.isReset()) {
				  *out <<getOpenTag();
				  tagOpen=true;
			      }
			  }
			}
			i= 1+ ((seqEnd!=string::npos)?seqEnd:i);
		    }
		    else
		    {
			*out << maskCharacter(line[i]);
			++i;
		    }
		}
		*out << newLineTag;
	    }
	}
	if (tagOpen){
		*out <<getCloseTag();
	}
	out->flush();
    }
Example #5
0
string RtfGenerator::getKeywordCloseTag ( unsigned int styleID )
{
    return getCloseTag ( docStyle.getKeywordStyle ( currentSyntax->getKeywordClasses() [styleID] ) );
}
Example #6
0
void RtfGenerator::initOutputTags ( )
{
    openTags.push_back ( getOpenTag ( STANDARD, docStyle.getDefaultStyle() ) );
    openTags.push_back ( getOpenTag ( STRING, docStyle.getStringStyle() ) );
    openTags.push_back ( getOpenTag ( NUMBER, docStyle.getNumberStyle() ) );
    openTags.push_back ( getOpenTag ( SL_COMMENT, docStyle.getSingleLineCommentStyle() ) );
    openTags.push_back ( getOpenTag ( ML_COMMENT,docStyle.getCommentStyle() ) );
    openTags.push_back ( getOpenTag ( ESC_CHAR, docStyle.getEscapeCharStyle() ) );
    openTags.push_back ( getOpenTag ( DIRECTIVE, docStyle.getPreProcessorStyle() ) );
    openTags.push_back ( getOpenTag ( DIRECTIVE_STRING, docStyle.getPreProcStringStyle() ) );
    openTags.push_back ( getOpenTag ( LINENUMBER, docStyle.getLineStyle() ) );
    openTags.push_back ( getOpenTag ( SYMBOL, docStyle.getOperatorStyle() ) );
    openTags.push_back ( getOpenTag ( STRING_INTERPOLATION, docStyle.getInterpolationStyle()) );

    closeTags.push_back ( getCloseTag ( docStyle.getDefaultStyle() ) );
    closeTags.push_back ( getCloseTag ( docStyle.getStringStyle() ) );
    closeTags.push_back ( getCloseTag ( docStyle.getNumberStyle() ) );
    closeTags.push_back ( getCloseTag ( docStyle.getSingleLineCommentStyle() ) );
    closeTags.push_back ( getCloseTag ( docStyle.getCommentStyle() ) );
    closeTags.push_back ( getCloseTag ( docStyle.getEscapeCharStyle() ) );
    closeTags.push_back ( getCloseTag ( docStyle.getPreProcessorStyle() ) );
    closeTags.push_back ( getCloseTag ( docStyle.getPreProcStringStyle() ) );
    closeTags.push_back ( getCloseTag ( docStyle.getLineStyle() ) );
    closeTags.push_back ( getCloseTag ( docStyle.getOperatorStyle() ) );
    closeTags.push_back ( getCloseTag ( docStyle.getInterpolationStyle() ) );
}
Example #7
0
	string XmlGenerator::getKeywordCloseTag ( unsigned int styleID )
	{
		return getCloseTag ( langInfo.getKeywordClasses() [styleID] );
	}
Example #8
0
string RtfGenerator::getMatchingCloseTag(unsigned int styleID){
  return getCloseTag(docStyle.getKeywordStyle(langInfo.getKeywordClasses()[styleID]));
}
void AutoCompletion::insertMatchedChars(int character, const MatchedPairConf & matchedPairConf)
{
	const vector< pair<char, char> > & matchedPairs = matchedPairConf._matchedPairs;
	int caretPos = _pEditView->execute(SCI_GETCURRENTPOS);
	char *matchedChars = NULL;

	// User defined matched pairs should be checked firstly
	for (size_t i = 0, len = matchedPairs.size(); i < len; ++i)
	{
		if (int(matchedPairs[i].first) == character)
		{
			char userMatchedChar[2] = {'\0', '\0'};
			userMatchedChar[0] = matchedPairs[i].second;
			_pEditView->execute(SCI_INSERTTEXT, caretPos, (LPARAM)userMatchedChar);
			return;
		}
	}

	// if there's no user defined matched pair found, continue to check notepad++'s one
	
	const size_t closeTagLen = 256;
	char closeTag[closeTagLen];
	closeTag[0] = '\0';
	switch (character)
	{
		case int('('):
			if (matchedPairConf._doParentheses)
			{
				matchedChars = ")";
				_insertedMatchedChars.add(MatchedCharInserted(char(character), caretPos - 1));
			}
		break;

		case int('['):
			if (matchedPairConf._doBrackets)
			{
				matchedChars = "]";
				_insertedMatchedChars.add(MatchedCharInserted(char(character), caretPos - 1));
			}
		break;

		case int('{'):
			if (matchedPairConf._doCurlyBrackets)
			{
				matchedChars = "}";
				_insertedMatchedChars.add(MatchedCharInserted(char(character), caretPos - 1));
			}
		break;

		case int('"'):
			if (matchedPairConf._doDoubleQuotes)
			{
				if (!_insertedMatchedChars.isEmpty())
				{
					int pos = _insertedMatchedChars.search('"', char(character), caretPos);
					if (pos != -1)
					{
						_pEditView->execute(SCI_DELETERANGE, pos, 1);
						_pEditView->execute(SCI_GOTOPOS, pos);
						return;
					}
				}

				matchedChars = "\"";
				_insertedMatchedChars.add(MatchedCharInserted(char(character), caretPos - 1));
			}
		break;
		case int('\''):
			if (matchedPairConf._doQuotes)
			{
				if (!_insertedMatchedChars.isEmpty())
				{
					int pos = _insertedMatchedChars.search('\'', char(character), caretPos);
					if (pos != -1)
					{
						_pEditView->execute(SCI_DELETERANGE, pos, 1);
						_pEditView->execute(SCI_GOTOPOS, pos);
						return;
					}
				}
				matchedChars = "'";
				_insertedMatchedChars.add(MatchedCharInserted(char(character), caretPos - 1));
			}
		break;

		case int('>'):
		{
			if (matchedPairConf._doHtmlXmlTag && (_curLang == L_HTML || _curLang == L_XML))
			{
				getCloseTag(closeTag, closeTagLen, caretPos);
				if (closeTag[0] != '\0')
					matchedChars = closeTag;
			}
		}
		break;

		case int(')') :
		case int(']') :
		case int('}') :
			if (!_insertedMatchedChars.isEmpty())
			{
				char startChar;
				if (character == int(')'))
				{
					if (!matchedPairConf._doParentheses)
						return;
					startChar = '(';
				}
				else if (character == int(']'))
				{
					if (!matchedPairConf._doBrackets)
						return;
					startChar = '[';
				}
				else // if (character == int('}'))
				{
					if (!matchedPairConf._doCurlyBrackets)
						return;
					startChar = '{';
				}

				int pos = _insertedMatchedChars.search(startChar, char(character), caretPos);
				if (pos != -1)
				{
					_pEditView->execute(SCI_DELETERANGE, pos, 1);
					_pEditView->execute(SCI_GOTOPOS, pos);
				}
				return;
			}
			break;

		default:
			if (!_insertedMatchedChars.isEmpty())
				_insertedMatchedChars.removeInvalidElements(MatchedCharInserted(char(character), caretPos - 1));
	}

	if (matchedChars)
		_pEditView->execute(SCI_INSERTTEXT, caretPos, (LPARAM)matchedChars);
}