Exemplo n.º 1
0
static void InternalLexOrFold(int foldOrLex, unsigned int startPos, int length,
	int initStyle, char *words[], WindowID window, char *props)
{
	// create and initialize a WindowAccessor (including contained PropSet)
	PropSet ps;
	ps.SetMultiple(props);
	WindowAccessor wa(window, ps);
	// create and initialize WordList(s)
	int nWL = 0;
	for (; words[nWL]; nWL++) ;	// count # of WordList PTRs needed
	WordList** wl = new WordList* [nWL + 1];// alloc WordList PTRs
	int i = 0;
	for (; i < nWL; i++) {
		wl[i] = new WordList();	// (works or THROWS bad_alloc EXCEPTION)
		wl[i]->Set(words[i]);
	}
	wl[i] = 0;
	// call our "internal" folder/lexer (... then do Flush!)
	if (foldOrLex)
		FoldCamlDoc(startPos, length, initStyle, wl, wa);
	else
		ColouriseCamlDoc(startPos, length, initStyle, wl, wa);
	wa.Flush();
	// clean up before leaving
	for (i = nWL - 1; i >= 0; i--)
		delete wl[i];
	delete [] wl;
}
Exemplo n.º 2
0
void EXT_LEXER_DECL Lex(unsigned int lexer, unsigned int startPos, int length, int initStyle,
                        char *words[], WindowID window, char *props)
{
   PropSet ps;
   ps.SetMultiple(props);
   WindowAccessor wa(window, ps);

   int nWL = 0;
   for (; words[nWL]; nWL++) ;
   WordList** wl = new WordList* [nWL + 1];
   int i = 0;
   for (; i<nWL; i++)
   {
      wl[i] = new WordList();
      wl[i]->Set(words[i]);
   }
   wl[i] = 0;

   ColorizeHaskellDoc(startPos, length, initStyle, wl, wa);
   wa.Flush();
   for (i=nWL-1;i>=0;i--)
      delete wl[i];
   delete [] wl;
}
Exemplo n.º 3
0
//  Scintilla lexer entry point.
void LexOrFold(bool foldOrLex, unsigned int startPos, int length, int initStyle,
               char *words[], WindowID window, char *props)
{

    // Create and initialize the WindowAccessor (including contained PropSet)
    PropSet ps;
    ps.SetMultiple(props);
    WindowAccessor wa(window, ps);

    //  Create and initialize WordList(s).
    //  If you have an extremely large word file, or lots of styling rules you may want to speed
    //  up processing by storing the wordlists instead of reprocessing them on each call.
    int nWL = 0;
    for (; words[nWL]; nWL++) ;	// count # of WordList PTRs needed
    WordList** wl = new WordList* [nWL + 1];// alloc WordList PTRs
    int i = 0;
    for (; i < nWL; i++) {
        wl[i] = new WordList();	// (works or THROWS bad_alloc EXCEPTION)
        wl[i]->Set(words[i]);
    }
    wl[i] = 0;


    // Set the currView handle to update at least once per lexer call.
    npp_plugin::hCurrViewNeedsUpdate();


    //  Call the internal folding and styling functions.
    // foldOrLex is false for lex and true for fold
    if (foldOrLex) {

        // This is a nice helpful routine to back up a line to fix broken folds.
        int lineCurrent = wa.GetLine(startPos);
        if (lineCurrent > 0) {
            lineCurrent--;
            int newStartPos = wa.LineStart(lineCurrent);
            length += startPos - newStartPos;
            startPos = newStartPos;
            initStyle = 0;
            if (startPos > 0) {
                initStyle = wa.StyleAt(startPos - 1);
            }
        }

        Fold_Doc(startPos, length, initStyle, wl, wa);

    }
    else {

        //  You may want to put a routine here to backtrack past leaking styles, typically
        //  multiline styles, or just put such logic in the Colour_Doc function itself.  Just
        //  be sure to do it prior to creating your Style Context.

        Colourise_Doc(startPos, length, initStyle, wl, wa);

    }

    //  The flush function is what actually finalizes settings the styles you just coloured.
    wa.Flush();

    // Clean up the wordlists before leaving.
    for (i = nWL - 1; i >= 0; i--)
        delete wl[i];
    delete [] wl;

}