From bae8cd712c167522a95a093296453a54dde4a524 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 25 May 2015 22:02:31 +0200 Subject: extended command and used it to optimize "lexer.test..." macros * EN may now be used for matching file names (similar to fnmatch(3)). This is used to check the current buffers file extension in the lexer configuration macros instead of using expensive Q-Register manipulations. This halves the overall startup time - it is now acceptable even with the current amount of lexer configurations. * EN may now be used for checking file types. session.tes has been simplified. * BREAKS macro portability (EN now has 2 string arguments). * The Globber class has been extended to allow filtering of glob results by file type. --- src/glob.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/glob.h') diff --git a/src/glob.h b/src/glob.h index e206b0d..a289228 100644 --- a/src/glob.h +++ b/src/glob.h @@ -21,6 +21,7 @@ #include #include +#include #include "sciteco.h" #include "parser.h" @@ -37,12 +38,14 @@ is_glob_pattern(const gchar *str) } class Globber { + GFileTest test; gchar *dirname; GDir *dir; GPatternSpec *pattern; public: - Globber(const gchar *pattern); + Globber(const gchar *pattern, + GFileTest test = G_FILE_TEST_EXISTS); ~Globber(); gchar *next(void); @@ -52,13 +55,22 @@ public: * Command states */ -class StateGlob : public StateExpectFile { +class StateGlob_pattern : public StateExpectFile { +public: + StateGlob_pattern() : StateExpectFile(true, false) {} + +private: + State *done(const gchar *str); +}; + +class StateGlob_filename : public StateExpectFile { private: State *done(const gchar *str); }; namespace States { - extern StateGlob glob; + extern StateGlob_pattern glob_pattern; + extern StateGlob_filename glob_filename; } } /* namespace SciTECO */ -- cgit v1.2.3