Esempio n. 1
0
        /**
         * @brief Salt syntax highlighting.
         * @param text
         */
        void highlightBlockSalt(const QString &text) {

            highlightWords(text, QRegExp("(\\[[^\\]]+\\])"), format_keyword3);                       // Butoon [Some Text]
            highlightWords(text, QRegExp("(\\^[^\\^]+\\^)"), format_keyword3);                       // Droplist ^Some Text^
            highlightWords(text, QRegExp("(\"[^\"]+\")"), format_keyword3);                          // Input Field "Some Text"
            highlightWords(text, QRegExp("(\\[ ?\\]|\\[X\\]|\\( ?\\)|\\(X\\))"), format_keyword3);   // Checkbox, Radio button []  [ ]  [X]  ()  ( )  (X)
            highlightWords(text, QRegExp("(\\.\\.|~~|--|==|\\s\\|\\s)"), format_separator);          // Separator
            highlightWords(text, QRegExp("^\\s*(\\++)"), format_separator);                          // Tree Level
            highlightWords(text, REGEX_HTML_TAG, format_html);
            highlightWords(text, QRegExp("\\{([T/!#+-])"), format_separator);                        // Widget (Tab Strip, Tree) or Grid Lines
        }
// New version
int32_t Highlight::set ( SafeBuf *sb ,
		      //char        *buf        ,
		      //int32_t         bufLen     ,
		      Words       *words      ,
		      Matches     *matches    ,
		      bool         doStemming ,
		      bool         useAnchors ,
		      const char  *baseUrl    ,
		      const char  *frontTag   ,
		      const char  *backTag    ,
		      int32_t         fieldCode  ,
		      Query	  *q	      ) {
	// save stuff
	m_frontTag    = frontTag;
	m_backTag     = backTag;
	m_doStemming  = doStemming;
	m_didErrMsg   = false;
	m_fieldCode   = fieldCode;
	// should we do click and scroll
	m_useAnchors  = useAnchors;
	m_baseUrl     = baseUrl;
	// . set the anchor counts to 1000*i+1 for each possible query term num
	// . yes, i know, why +1? because we're assuming the query terms
	//   have been highlighted before us 
	for ( int32_t i = 0 ; i < MAX_QUERY_TERMS ; i++ ) 
		m_anchorCounts[i] = 1000*i + 1;
	// set lengths of provided front/back highlight tags
	if ( m_frontTag ) m_frontTagLen = gbstrlen ( frontTag );
	if ( m_backTag  ) m_backTagLen  = gbstrlen ( backTag  );
	// point to buffer to store highlighted text into
	//m_buf    = buf;
	//m_bufLen = bufLen;
	//m_bufPtr = buf;
	m_sb = sb;
	// save room for terminating \0
	//m_bufEnd = m_buf + m_bufLen - 1;

	if ( ! highlightWords ( words, matches, q ) ) return -1;

	// null terminate
	//*m_bufPtr = '\0';
	m_sb->nullTerm();
	// return the length
	return m_sb->length();//m_bufPtr - m_buf;
}
Esempio n. 3
0
        /**
         * @brief UML syntax highlighting.
         * @param text
         */
        void highlightBlockUml(const QString &text) {

            if(highlightRestOfLine(text, REGEX_MLC_ON, format_comment) == true) {
                multiLineComment=true;
            }

            if(highlightRestOfLine(text, REGEX_MLC_OFF, format_comment) == true) {
                multiLineComment=false;
            }

            if(multiLineComment == true) {
                setFormat(0, text.length(), format_comment);
                return;
            }

            //------------------------------------------------------------

            highlightWords(text, REGEX_KEYWORD, format_keyword);
            highlightWords(text, REGEX_KEYWORD2, format_keyword);

            highlightWords(text, REGEX_NOTE1,   format_keyword);
            highlightWord( text, REGEX_NOTE2,   format_keyword);

            highlightWords(text, REGEX_HTML_TAG, format_html);

            highlightWords(text, REGEX_MASK, format_mask );

            highlightWords(text, REGEX_COLOR, format_color );

            highlightWord(text, REGEX_SEPARATOR, format_separator);

            //    highlightWords(text, REGEX_ARROWS1, format_arrow);
            //    highlightWords(text, REGEX_ARROWS2, format_arrow);
            // 	highlightArrorws(text);

            //------------------------------------------------------------

            highlightWord(text, REGEX_SKIN,      format_skin);
            highlightWord(text, REGEX_OPTION,    format_option);

            highlightWord(text, REGEX_DECORATION, format_decoration);

            highlightRestOfLine(text, REGEX_COMMENT, format_comment);
        }
Esempio n. 4
0
        void highlightBlock(const QString &text)
        {
            qDebug() << codeType << ':' << text;

            if(text.size() == 0 || text.contains(REGEX_EMPTY)) return;

            if(REGEX_START_1.indexIn(text) > -1) {
                // Start 1: @start<TYPE>

                QString type = REGEX_START_1.cap(1);

                if(type == "uml") {
                    codeType = UML;
                } else if(type == "salt") {
                    codeType = SALT;
                } else if(type == "dot") {
                    codeType = DOT;
                } else if(type == "ditaa") {
                    codeType = DITAA;
                } else if(type == "jcckit") {
                    codeType = JCCKIT;
                } else {
                    codeType = UNKNOWN;
                    return;
                }

                highlightWord(text, REGEX_START_1, format_start_end);

                endtag = "@end" + type;
                return;
            }

            switch(codeType) {
                case UML:

                    if(REGEX_START_2.indexIn(text) > -1) {
                        // Start 2: @startuml + <TYPE>

                        QString type = REGEX_START_2.cap(1);

                        if(type == "salt") {
                            codeType = SALT;
                        } else if(type == "digraph" || type == "graph") {
                            codeType = DOT;
                        } else if(type == "ditaa") {
                            codeType = DITAA;
                        } else if(type == "jcckit") {
                            codeType = JCCKIT;
                        }
                        return;
                    }

                    highlightBlockUml(text);
                    break;
                case SALT:
                    highlightBlockSalt(text);
                    break;
                case DITAA:
                    highlightBlockDitaa(text);
                    break;
                case JCCKIT:
                    highlightBlockJcckit(text);
                    break;
                case DOT:
                    highlightBlockDot(text);
                    break;
                case PLANTUML:
                    // highlightBlockPlantUml(text);
                    break;
                default:
                    return;
            }

            if(codeType != UNKNOWN && highlightWord( text, QRegExp(endtag), format_start_end)) {
                return;
            } else if(highlightWords( text, QRegExp("@start\\w*\\b"), format_error)) {
                return;
            }
        }
Esempio n. 5
0
 /**
  * @brief Ditaa syntax highlighting.
  * @param text
  */
 void highlightBlockDitaa(const QString &text) {
     highlightWords(text, QRegExp("[+|:><^v/\\\\*.=-]"), format_line);
     highlightWords(text, QRegExp("[{](c|d|o|s|io|mo|tr)[}]"), format_comment);
     highlightWords(text, QRegExp("c[0-9A-Z]{3}"), format_color);
 }
Esempio n. 6
0
 /**
  * @brief Dot syntax highlighting.
  * @param text
  */
 void highlightBlockDot(const QString &text) {
     highlightWords(text, QRegExp("^(digraph|graph)"), format_keyword);
     highlightWords(text, QRegExp("^\\s*(subgraph)"), format_keyword);
     highlightWords(text, QRegExp("(->|--)"), format_arrow); // TODO Fix me!!!
 }