diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-06-12 15:12:59 +0200 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2015-06-12 15:12:59 +0200 |
commit | 7919aca84cdea7746b60fec9795e9617c266dd1d (patch) | |
tree | 90db8c7d899b69014d085af0cf3327741691df6a /src/glob.cpp | |
parent | 3551924ccd580a59190ac80e25c59b729ec4f613 (diff) | |
download | sciteco-7919aca84cdea7746b60fec9795e9617c266dd1d.tar.gz |
support UNIX-shell-like tilde-expansions in file names and directories
* expands to the value of $HOME (the env variable instead of
the register which currently makes a slight difference).
* supported for tab-completions
* supported for all file-name accepting commands.
The expansion is done centrally in StateExpectFile::done().
A new virtual method StateExpectFile::got_file() has been
introduced to pass the expanded/processed file name to
command implementations.
* sciteco(7) has been updated: There is now a separate section
on file name arguments and file name handling in SciTECO.
This information is important but has been scattered across
the document previously.
* optimized is_glob_pattern() in glob.h
Diffstat (limited to 'src/glob.cpp')
-rw-r--r-- | src/glob.cpp | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/src/glob.cpp b/src/glob.cpp index 66d6736..4c1fa1f 100644 --- a/src/glob.cpp +++ b/src/glob.cpp @@ -238,22 +238,22 @@ Globber::~Globber() * have to edit that register anyway. */ State * -StateGlob_pattern::done(const gchar *str) +StateGlob_pattern::got_file(const gchar *filename) { BEGIN_EXEC(&States::glob_filename); - if (*str) { + if (*filename) { QRegister *glob_reg = QRegisters::globals["_"]; glob_reg->undo_set_string(); - glob_reg->set_string(str); + glob_reg->set_string(filename); } return &States::glob_filename; } State * -StateGlob_filename::done(const gchar *str) +StateGlob_filename::got_file(const gchar *filename) { BEGIN_EXEC(&States::start); @@ -287,16 +287,16 @@ StateGlob_filename::done(const gchar *str) pattern_str = glob_reg->get_string(); - if (*str) { + if (*filename) { /* * Match pattern against provided file name */ - if (g_pattern_match_simple(pattern_str, str) && - (!teco_test_mode || g_file_test(str, file_flags))) { + if (g_pattern_match_simple(pattern_str, filename) && + (!teco_test_mode || g_file_test(filename, file_flags))) { if (!colon_modified) { interface.ssm(SCI_BEGINUNDOACTION); - interface.ssm(SCI_ADDTEXT, strlen(str), - (sptr_t)str); + interface.ssm(SCI_ADDTEXT, strlen(filename), + (sptr_t)filename); interface.ssm(SCI_ADDTEXT, 1, (sptr_t)"\n"); interface.ssm(SCI_SCROLLCARET); interface.ssm(SCI_ENDUNDOACTION); @@ -310,11 +310,11 @@ StateGlob_filename::done(const gchar *str) * returning SUCCESS if at least one file matches */ Globber globber(pattern_str, file_flags); - gchar *filename = globber.next(); + gchar *globbed_filename = globber.next(); - matching = filename != NULL; + matching = globbed_filename != NULL; - g_free(filename); + g_free(globbed_filename); } else { /* * Match pattern against directory contents (globbing), @@ -322,14 +322,14 @@ StateGlob_filename::done(const gchar *str) */ Globber globber(pattern_str, file_flags); - gchar *filename; + gchar *globbed_filename; interface.ssm(SCI_BEGINUNDOACTION); - while ((filename = globber.next())) { - size_t len = strlen(filename); + while ((globbed_filename = globber.next())) { + size_t len = strlen(globbed_filename); /* overwrite trailing null */ - filename[len] = '\n'; + globbed_filename[len] = '\n'; /* * FIXME: Once we're 8-bit clean, we should @@ -337,9 +337,9 @@ StateGlob_filename::done(const gchar *str) * (there may be linebreaks in filename). */ interface.ssm(SCI_ADDTEXT, len+1, - (sptr_t)filename); + (sptr_t)globbed_filename); - g_free(filename); + g_free(globbed_filename); matching = true; } |