Codebase list xd / a225b02
New upstream version 4.00.00 Frank B. Brokken 1 year, 10 months ago
102 changed file(s) with 2492 addition(s) and 1270 deletion(s). Raw diff Collapse all Expand all
0 options
01 command
12 alternatives
2 filter
3 selector
34 history
0 #define PROJECT "xd"
0 #define PROJECT "xd"
11 #define CXX "g++"
2 #define CXXFLAGS "--std=c++2a -fdiagnostics-color=never -Wall -O2 -g"
3 #define LDFLAGS ""
2 #define CXXFLAGS "--std=c++20 -fdiagnostics-color=never -Wall -O2 -g"
3 #define LDFLAGS ""
44 #define CPOPTS
55
66 // ONLY USE ABSOLUTE DIRECTORY NAMES:
0 Xd is made available under the copyright rules of the Gnu Public License
1 (cf. https://www.gnu.org/licenses/agpl-3.0.html)
0
10 ===============================
21 XD
32 by
3231
3332 ======================================================================
3433 xd by Frank B. Brokken (f.b.brokken@rug.nl)
35 xd V3.00.0 1994-2008
34 xd V4.00.00 1994-2022
3635
3736 Usage: xd [options] args
3837 Where:
4039 parentheses):
4140 --all (-a) - skip `ignore' specification in the
4241 configuration file
42 --block-size (-b) size - show the alternatives in blocks of max.
43 'size' alternatives (spacebar to continue)
4344 --config-file (-c) <file> - path to the config file to use
4445 ($HOME/.xdrc)
45 --add-root <when> - search expansions from /
46 (if-empty)
47 --directories <which> - which directories to show?
48 (all)
46 --add-root <when> - search expansions from / (if-empty)
47 --directories <which> - which directories to show? (default: all)
48 --generalized-search (-g) - use the GDS mode
4949 --help (-h) - provide this help
50 --start-at <origin> - where to start the search?
51 (home)
50 --history <fname> - use <fname> to store info about choices
51 (no history unless specified)
52 --history-lifetime <spec> - specify the max. lifetime of previously made
53 choices. Use <int>[DWMY] for a lifetime of
54 Days, Months, Weeks, or Years
55 --history-position <where = TOP> - where to put the previously made choices
56 (TOP, BOTTOM)
57 --history-maxsize <size = UINT_MAX> - display at most <size> previously
58 made choices
59 --history-separate - separate previously made choices from new ones
60 by a blank line (not with --block-size)
61 --input - a non-selection character ends XD and is entered
62 into the shell's input stream
63 --start-at <origin> - where to start the search? (default: home dir.)
64 --traditional - use the traditional mode
5265 --version (-v) - show version information and terminate
5366 --verbose (-V) - show xd's actions in detail
5467 args - arguments, possibly containing directory separators [/-].
5871 Multiple arguments or arguments separated by / or - define the
5972 initial characters of subsequently nested subdirectories.
6073
61 If the first argument starts with . expansion starts at the current
62 directory; if it's 0 expansion starts in the user's home directory;
63 if it's / expansion starts at the root; if it's a number (1 .. 9)
74 If the first argument starts with . expansion starts at the user's
75 home directory; if it's 0 expansion starts in the current directory;
76 if it's / expansion starts at the root; if it's a number (1 .. 9)
6477 expansion starts at parent <number>; otherwise expansion starts
6578 at the location defined by the configuration file
6679
6881 selection is requested from a displayed list of alternatives.
6982
7083 Use 'man xd' or read the xdrc file provided with the distribution
71 for details about xd's configuration file
84 for details about "xd's configuration file
7285 ======================================================================
7386
7487
+0
-1
TODO less more
0 nothing
0 #define VERSION "3.29.02"
1 #define YEARS "1994-2021"
0 #define VERSION "4.00.00"
1 #define YEARS "1994-2022"
66 #include <string>
77 #include <memory>
88
9
9 #include "../enums/enums.h"
1010 #include "../command/command.h"
1111 #include "../history/history.h"
12
13 namespace FBB
14 {
15 class ArgConfig;
16 }
1712
1813
1914 // If, when looking for /t*/m*/ps*/ the initial path /t*/m* does not exist
2318 // subpatterns of the pruned path (e.g., t*/mp*) are not considered (and so:
2419 // not globbed)
2520
21 class Options;
2622
2723 class Alternatives: public std::deque<std::string>
2824 {
29 std::string d_homeDir;
30 FBB::ArgConfig &d_arg;
31 bool d_separate;
32 size_t d_nInHistory;
25 Options const &d_options;
3326
34 bool d_home; // true: search from $HOME
35 bool d_dirs; // true: search all dirs (also via links)
27 size_t d_nInHistory; // nr of items in the history
3628
29 bool d_fromHome; // true: search from $HOME
30 bool d_allDirs; // true: search all dirs (also via links)
31 TriState d_addRoot; // true: always also search /, ifEmpty: only if
32 // search from $HOME fails
3733
38 enum TriState
39 {
40 FALSE,
41 IF_EMPTY,
42 TRUE
43 };
34 Command d_command;
35 History d_history; // history constructor uses Options
4436
45 TriState d_addRoot; // true: always also search /, ifEmpty: only if
46 // search from $HOME fails
47 Command d_command;
48 History d_history;
49
50 static char const *s_triState[];
51 static char const *const *const s_triStateEnd;
52
53 static char const *s_startAt[];
54 static char const * const *const s_startAtEnd;
55
56 static char const *s_dirs[];
57 static char const *const *const s_dirsEnd;
58
59 static char const *s_merge[];
60 static char const *const *const s_mergeEnd;
61
62 static char s_defaultConfig[];
37 // static char const *s_merge[];
38 // static char const *const *const s_mergeEnd;
6339
6440 public:
6541 enum ViableResult
6844 RECEIVED_ALTERNATIVES,
6945 };
7046
71 Alternatives();
47 Alternatives(); // uses default
48
7249 ViableResult viable();
7350 void order();
7451 void update(size_t idx);
7653 size_t separateAt() const;
7754
7855 private:
79 static std::string getHome();
80
81 FBB::ArgConfig &configFile();
82
83 size_t set(char const *longKey, char const *const * const begin,
84 char const *const *const end,
85 size_t notFound);
86
8756 void getCwd(std::unique_ptr<char> *dest);
8857
8958 std::string determineInitialDirectory();
11483 static void addIgnored(std::string const &line,
11584 std::set<std::string> &ignoreSet);
11685
86 static bool dotPattern(std::string const &dirEntry,
87 GlobContext const &globContext);
88
11789 static bool matchIgnore(std::string const &ignore,
11890 std::string const &entry);
91
92 static bool trailingDotPatterns(std::string const &spec);
11993 };
12094
12195 inline void Alternatives::update(size_t index)
22 #include <sstream>
33 #include <algorithm>
44 #include <exception>
5
56 #include <bobcat/mstream>
67 #include <bobcat/glob>
78 #include <bobcat/stat>
8 #include <bobcat/argconfig>
99 #include <bobcat/ranger>
10
11 #include "../options/options.h"
1012
1113 using namespace std;
1214 using namespace FBB;
11
22 Alternatives::Alternatives()
33 :
4 d_homeDir(getHome()),
5 d_arg(configFile()),
6 d_separate(d_arg.option(0, "history-separate")),
4 d_options(Options::instance()),
75 d_nInHistory(0),
8 d_history(d_arg, d_homeDir)
6 d_fromHome(d_options.fromHome()),
7 d_allDirs(d_options.allDirs()),
8 d_addRoot(d_options.addRoot())
99 {}
11
22 void Alternatives::checkCase(string &head, size_t *idx) const
33 {
4 if ((d_arg.option('i') & 1) != 0) // even number of --icase specs
4 if ((d_options.icase() & 1) != 0) // even number of --icase specs
55 {
66 string mold("[..]");
77 int ch = head[*idx];
1313 *idx += 4;
1414 return;
1515 }
16 }
16 }
1717 ++*idx;
1818 }
+0
-25
alternatives/configfile.cc less more
0 #include "alternatives.ih"
1
2 ArgConfig &Alternatives::configFile()
3 {
4 ArgConfig &arg = ArgConfig::instance();
5
6 string confName;
7 if (arg.option(&confName, 'c'))
8 arg.open(confName);
9 else
10 {
11 confName = d_homeDir + s_defaultConfig;
12 Stat confStat(confName);
13 if (confStat)
14 {
15 if ((not confStat.mode()) & Stat::UR)
16 wmsg << "Can't read " << confName << endl;
17 else
18 arg.open(confName);
19 }
20 }
21 imsg << "Configuration file: " << confName << endl;
22
23 return arg;
24 }
0 #include "alternatives.ih"
1
2 char const *Alternatives::s_merge[] =
3 {
4 "false",
5 "true"
6 };
7 char const *const *const Alternatives::s_mergeEnd =
8 s_triState + sizeof(s_merge) / sizeof(char *);
9
10
11 char const *Alternatives::s_triState[] =
12 {
13 "never",
14 "if-empty",
15 "always"
16 };
17
18 char const *const *const Alternatives::s_triStateEnd =
19 s_triState + sizeof(s_triState) / sizeof(char *);
20
21
22 char const *Alternatives::s_startAt[] =
23 {
24 "root",
25 "home",
26 };
27
28 char const *const *const Alternatives::s_startAtEnd =
29 s_startAt + sizeof(s_startAt) / sizeof(char *);
30
31
32 char const *Alternatives::s_dirs[] =
33 {
34 "unique",
35 "all",
36 };
37
38 char const *const *const Alternatives::s_dirsEnd =
39 s_dirs + sizeof(s_dirs) / sizeof(char *);
40
41
42 char Alternatives::s_defaultConfig[] = ".xdrc"; // in $HOME
0 //#include "alternatives.ih"
1 //
2 //char const *Alternatives::s_merge[] =
3 //{
4 // "false",
5 // "true"
6 //};
7 //char const *const *const Alternatives::s_mergeEnd =
8 // s_triState + sizeof(s_merge) / sizeof(char *);
88 switch (d_command.action())
99 {
1010 case Command::FROM_CONFIG:
11 cwd = d_home ? d_homeDir : string("/");
11 cwd = d_fromHome ? d_options.homeDir() : string("/");
1212 rescan = true;
1313 break;
1414
1515 case Command::FROM_HOME:
16 cwd = d_homeDir;
16 cwd = d_options.homeDir();
1717 break;
1818
1919 case Command::FROM_ROOT:
3939 break;
4040 }
4141
42 if (d_addRoot != FALSE && (!d_home || !rescan))
42 if (d_addRoot != NEVER and (!d_fromHome || !rescan))
4343 {
4444 imsg << "Search does not start at the home dir: "
4545 "no additional search from the root" << endl;
4646
47 d_addRoot = FALSE;
47 d_addRoot = NEVER;
4848 }
4949
5050 imsg << "Resolved Cwd as: " << cwd << endl;
0 #include "alternatives.ih"
1
2 // static
3 bool Alternatives::dotPattern(string const &dirEntry,
4 GlobContext const &context)
5 {
6 if (dirEntry.find("/./") != string::npos // ignore */./* patterns
7 or
8 find_if(
9 context.ignore.begin(), context.ignore.end(),
10 [&](string const &ignore)
11 {
12 return matchIgnore(ignore, dirEntry);
13 }
14 )
15 != context.ignore.end()
16 )
17 {
18 imsg << "ignored" << endl;
19 return true;
20 }
21
22 return false;
23 }
1414 searchCmd.resize(searchCmd.length() - 1); // remove trailing /
1515
1616
17 imsg << "Merged search command: `" << searchCmd << "'\n"
18 "Starts at `" << initial << '\'' << endl;
17 if (searchCmd.empty())
18 imsg << "No merged search command\n";
19 else
20 imsg << "Merged search command: `" << searchCmd << "'\n";
21
22 imsg << "Searching starts at `" << initial << '\'' << endl;
1923
2024 globHead(initial, searchCmd, context);
2125
+0
-22
alternatives/gethome.cc less more
0 #include "alternatives.ih"
1
2 string Alternatives::getHome()
3 {
4 string homeDir;
5
6 char *cp = getenv("HOME"); // determine the homedir
7
8 if (!cp) // save it
9 homeDir = '/';
10 else
11 {
12 homeDir = cp;
13 if (*homeDir.rbegin() != '/')
14 homeDir += '/';
15 }
16 // home set with ending /
17
18 imsg << "Home directory: " << homeDir << endl;
19
20 return homeDir;
21 }
00 #include "alternatives.ih"
11
2 // static
23 void Alternatives::globFilter(char const *entry, GlobContext &context)
34 {
45 imsg << "Inspecting `" << entry << "': ";
56 // if a trailing / was removed reinstall it.
67 string dirEntry(entry);
7 if (*dirEntry.rbegin() != '/')
8 if (dirEntry.back() != '/')
89 dirEntry += '/';
910
1011 if (
11 dirEntry.find("/./") != string::npos // ignore */./* patterns
12 dotPattern(dirEntry, context)
1213 or
13 find_if(
14 context.ignore.begin(), context.ignore.end(),
15 [&](std::string const &ignore)
16 {
17 return matchIgnore(ignore, dirEntry);
18 }
19 )
20 != context.ignore.end()
14 trailingDotPatterns(entry)
2115 )
22 {
23 imsg << "ignored" << endl;
2416 return;
25 }
2617
27 string spec = entry;
28
29 if // ignore the . nd .. directories
30 (
31 spec.rfind("/.") == spec.length() - 2 ||
32 spec.rfind("/..") == spec.length() - 3
33 )
34 {
35 imsg << "dot-directory" << endl;
36 return;
37 }
38
39 Stat stat(entry);
18 Stat stat{ entry };
4019
4120 // check if the entry name (globbed) is equal to the true path name
4221 // if not, the globbed name is a link to the true path
43 if (!context.alternatives.d_dirs && stat.path() != spec)
22 if (not context.alternatives.d_allDirs && stat.path() != entry)
4423 {
4524 imsg << "symlink" << endl;
4625 return;
33 {
44 GlobContext context = {*this};
55
6 if (not d_arg.option('a'))
6 if (not d_options.all())
77 {
8 auto iters = d_arg.beginEndRE("^\\s*ignore\\s+\\S+\\s*$");
9
10 for (auto &line: ranger(iters.first, iters.second))
11 addIgnored(line, context.ignore);
8 for
9 (
10 auto iters = d_options.ignore();
11 auto &line: ranger(iters.first, iters.second)
12 )
13 addIgnored(line, context.ignore);
1214 }
1315
1416 ViableResult (Alternatives::*globFun)(string dir, GlobContext &context) =
15 d_arg.option('g') && !d_arg.option(0, "traditional") ?
16 &Alternatives::generalizedGlob
17 :
18 &Alternatives::glob;
17 (
18 d_options.generalized() and not d_options.traditional() ?
19 &Alternatives::generalizedGlob
20 :
21 &Alternatives::glob
22 );
1923
2024 ViableResult vr = (this->*globFun)(initial, context);
2125
22 if (d_addRoot == TRUE || (size() == 0 && d_addRoot == IF_EMPTY))
26 if (d_addRoot == ALWAYS || (size() == 0 && d_addRoot == IF_EMPTY))
2327 vr = (this->*globFun)("/", context);
2428
2529 if (vr == ONLY_CD)
2731
2832 return vr;
2933 }
34
35
36
37
0 ../icmconf.lib
00 #include "alternatives.ih"
11
2 bool Alternatives::matchIgnore(std::string const &ignore, string const &entry)
2 // static
3 bool Alternatives::matchIgnore(string const &ignore, string const &entry)
34 {
45 // returns true if entry matches an ignore string
56 return
6 *ignore.rbegin() != '*' ? // literal match required
7 ignore.back() != '*' ? // literal match required
78 ignore == entry
89 : // wildcard match of final * OK
910 entry.find(ignore.substr(0, ignore.length() - 1)) == 0;
11
22 size_t Alternatives::separateAt() const
33 {
4 if (not d_separate || d_nInHistory == size())
4 if (not d_options.separate() || d_nInHistory == size())
55 return UINT_MAX;
66
7 return
8 d_history.position() == History::TOP ?
9 d_nInHistory
10 :
11 size() - d_nInHistory;
7 return d_history.position() == TOP ? d_nInHistory : size() - d_nInHistory;
128 }
+0
-32
alternatives/set2.cc less more
0 #include "alternatives.ih"
1
2 size_t Alternatives::set(char const *longKey,
3 char const *const *const begin,
4 char const *const *const end,
5 size_t notFound)
6 {
7 string conf;
8
9 if (!d_arg.option(&conf, longKey))
10 {
11 imsg << "Option or config: No key `" << longKey << '\'' << endl;
12 return notFound;
13 }
14
15 char const *const *const ret =
16 find_if(begin, end, bind2nd(equal_to<string>(), conf));
17
18 if (ret != end)
19 {
20 imsg << "Option or config `" << longKey << " " << conf << "' found" <<
21 endl;
22
23 return ret - begin;
24 }
25
26 imsg << "`" << longKey << " " << conf <<
27 "' not supported. Using the default `" << begin[notFound] <<
28 "'." << endl;
29
30 return notFound;
31 }
0 #include "alternatives.ih"
1
2 // static
3 bool Alternatives::trailingDotPatterns(string const &spec)
4 {
5 if // ignore trailing . and .. directories
6 (
7 spec.rfind("/.") == spec.length() - 2
8 or
9 spec.rfind("/..") == spec.length() - 3
10 )
11 {
12 imsg << "dot-directory" << endl;
13 return true;
14 }
15
16 return false;
17 }
11
22 Alternatives::ViableResult Alternatives::viable()
33 {
4 d_home = set("start-at", s_startAt, s_startAtEnd, 1);
5 d_dirs = set("directories", s_dirs, s_dirsEnd, 1);
6 d_addRoot = static_cast<TriState>
7 (set("add-root", s_triState, s_triStateEnd, IF_EMPTY));
8
9 imsg << boolalpha << "Search from $HOME: " << d_home << '\n' <<
10 "Search all directories: " << d_dirs << '\n' <<
4 imsg << boolalpha << "Search from $HOME: " << d_fromHome << '\n' <<
5 "Search all directories: " << d_allDirs << '\n' <<
116 "Add root search if search from $HOME fails: " <<
12 s_triState[d_addRoot] << endl;
7 d_options.triStateStr() << endl;
138
149 if (globFrom(determineInitialDirectory()) == ONLY_CD)
1510 return ONLY_CD;
+0
-61
arguments.cc less more
0 #include "main.ih" // program header file
1
2 namespace // the anonymous namespace can be used here
3 {
4 ArgConfig::LongOption longOptions[] =
5 {
6 {"add-root", ArgConfig::Required},
7 {"directories", ArgConfig::Required},
8 {"homedir-char", ArgConfig::Required},
9 {"start-at", ArgConfig::Required},
10
11 {"history", ArgConfig::Optional},
12 {"history-lifetime", ArgConfig::Required},
13 {"history-maxsize", ArgConfig::Required}, // history/load.cc
14 {"history-separate", ArgConfig::None},
15 {"history-position", ArgConfig::Required}, // top, bottom
16
17 {"traditional", ArgConfig::None},
18
19 {"all", 'a'},
20 {"config-file", 'c'},
21 {"help", 'h'},
22 {"icase", 'i'},
23 {"generalized-search", 'g'},
24 {"version", 'v'},
25 {"verbose", 'V'},
26 };
27
28 ArgConfig::LongOption const *const longEnd =
29 longOptions +
30 sizeof(longOptions) / sizeof(ArgConfig::LongOption);
31 }
32
33 void arguments(int argc, char **argv)
34 {
35 char *last = argv[argc - 1]; // remove the / from the last
36 size_t idx = strlen(last) - 1; // cmd line argument
37 if (last[idx] == '/')
38 last[idx] = 0;
39
40 ArgConfig &arg = ArgConfig::initialize("ac:gihvV",
41 longOptions, longEnd, argc, argv);
42 arg.setCommentHandling(ArgConfig::RemoveComment);
43
44 streambuf *buf = cout.rdbuf(cerr.rdbuf()); // make sure that
45 try // versionHelp doesn't
46 { // write to cout
47 arg.versionHelp(usage, Icmbuild::version, 1);
48 cout.rdbuf(buf);
49 }
50 catch(...)
51 {
52 cout.rdbuf(buf);
53 throw;
54 }
55
56 imsg.reset(cerr);
57 imsg.setActive(arg.option('V'));
58
59 fmsg.reset(cerr);
60 }
9797 {
9898 precompileHeaders();
9999 system("icmbuild program " + strip);
100 run("oxref -fxs tmp/lib" LIBRARY ".a > " PROJECT ".xref");
100 run("oxref -r replacements -t main -fxs tmp/lib"
101 LIBRARY ".a tmp/main.o > " PROJECT ".xref");
101102 exit(0);
102103 }
103104
0 xd (4.00.00)
1
2 * Added option --input allowing xd to directly perform cd-commands and
3 to insert non-selection characters into the shell's input buffer.
4
5 * Added option --block-size to show alternative cd-directories in blocks of
6 fixed maximum sizes.
7
8 * Added the file LICENSE.txt specifying XD's (GPL) copyright rules.
9
10 * Updated the man-page.
11
12 * Updated the xdrc demo configuration file.
13
14 * Updated the xd.xref cross-reference listing.
15
16 * Added class Options to handle the options/configuration file.
17
18 * The class Filter was renamed to Selector.
19
20 -- Frank B. Brokken <f.b.brokken@rug.nl> Sun, 19 Jun 2022 12:50:49 +0200
21
022 xd (3.29.02)
123
224 * Repaired flaw in icmake/finall: it now checks for 'backtick' returning a
325 single, empty element.
426
27 -- Frank B. Brokken <f.b.brokken@rug.nl> Tue, 07 Sep 2021 18:43:12 +0200
28
529 xd (3.29.01)
630
731 * Removed -q from xd's build script
66 // determine the command as received and the kind of action according to
77 // the received pattern.
88
9 class Command: public std::vector<std::string>
9 struct Command: public std::vector<std::string>
1010 // stores the elements of the pattern
1111 {
12 int d_homedirChar = '.'; // default homedir char
13 std::string d_arguments;
14 static char const *s_action[];
15 static char const s_separators[]; // separating parts of nested dir
16 // names
17 public:
18 // modify commanddata.cc if Action is modified
19 enum Action // starting point as determined
20 { // by the first arg-character
21 FROM_CONFIG, // default: determined by config
22 FROM_HOME,
23 FROM_ROOT,
24 FROM_CWD,
25 FROM_PARENT, // relative to CWD
26 };
12 // modify commanddata.cc if Action is modified
13 enum Action // starting point as determined
14 { // by the first arg-character
15 FROM_CONFIG, // default: determined by config
16 FROM_HOME,
17 FROM_ROOT,
18 FROM_CWD,
19 FROM_PARENT, // relative to CWD
20 };
2721
2822 private:
2923 Action d_action;
3024 size_t d_parent;
3125
26 int d_homedirChar = '.'; // default homedir char
27 std::string d_arguments;
28
29 static char const *s_action[];
30 static char const s_separators[]; // separating parts of nested dir
31 // names
3232 public:
3333 Command();
3434
3939 private:
4040 void concatArgs();
4141 void determineAction();
42 void splitBase(); // split [0]'s characters into
43 // separate vector elements
4244 };
4345
4446 inline size_t Command::parent() const
33 #include <algorithm>
44 #include <iterator>
55
6 #include <bobcat/argconfig>
6 //#include <bobcat/argconfig>
77 #include <bobcat/string>
88 #include <bobcat/mstream>
99 #include <bobcat/exception>
1010
11 #include "../options/options.h"
12
1113 using namespace std;
1214 using namespace FBB;
22 Command::Command()
33 :
44 d_action(FROM_HOME),
5 d_parent(0)
5 d_parent(0),
6 d_homedirChar(Options::instance().homedirChar())
67 {
7 ArgConfig &argConfig = ArgConfig::instance();
8
9 if (string value; argConfig.option(&value, "homedir-char"))
10 {
11 d_homedirChar = value[0];
12 if ("0123456789/"s.find(d_homedirChar) != string::npos)
13 throw Exception{ 1 } << "Character `" << value[0] <<
14 "' cannot be used as homedir-character";
15 }
16
17 concatArgs();
8 concatArgs(); // concatenate arguments, separating them by /
9 // characters
1810
1911 determineAction();
2012
13 // store the individual arguments in the base class
14 // (string vector)
2115 String::split(this, d_arguments, s_separators);
2216
2317 // When are the elements of the first argument changed into initial chars
2822 // Can't 2 and 3 be combined to: size() == 1 ?
2923 // if (!subSpecs && size() && ArgConfig::instance().nArgs() == 1)
3024
31 if (size() == 1)
32 {
33 for_each(
34 front().begin() + 1, front().end(),
35 [&](char ch)
36 {
37 this->push_back(string(1, ch));
38 }
39 );
40 front().resize(1);
41 }
25 splitBase(); // split the base class if it contains only
26 // one string.
4227
4328 if (ArgConfig::instance().option('V'))
4429 {
4934 cerr << endl;
5035 }
5136 }
37
38
39
40
41
42
43
44
45
46
47
11
22 void Command::concatArgs()
33 {
4 ArgConfig &arg = ArgConfig::instance();
5
6 for_each(
7 arg.argPointers(), arg.argPointers() + arg.nArgs(),
8 [&](char const *arg)
9 {
10 (d_arguments += arg) += '/';
11 }
12 );
4 for(char const *arg: Options::instance().args())
5 (d_arguments += arg) += '/';
136
147 imsg << "Arguments: `" << d_arguments << '\'' << endl;
158 }
0 ../icmconf.lib
0 #include "command.ih"
1
2 void Command::splitBase()
3 {
4 if (size() != 1)
5 return;
6
7 for_each( // copy all spec. elements into Command's
8 front().begin() + 1, front().end(), // base object
9 [&](char ch)
10 {
11 push_back(string(1, ch));
12 }
13 );
14
15 front().resize(1); // keep the 1st character
16 }
0 #include <iostream>
1 #include <vector>
2
3 using namespace std;
4
5
6 enum
7 {
8 MIN_BLOCK_SIZE = 5
9 };
10
11 struct BlockStruct
12 {
13 size_t begin;
14 size_t end;
15 char const *prompt;
16 };
17
18
19 size_t d_blockSize;
20
21 void set(BlockStruct &dest, size_t end)
22 {
23 dest.begin = end;
24 dest.end = end + d_blockSize;
25 }
26
27 void set(BlockStruct &preLast, BlockStruct &last)
28 {
29 if (last.end - last.begin >= MIN_BLOCK_SIZE) // last block: big enough
30 return;
31
32 size_t preSize = (last.end - preLast.begin + 1) / 2;
33
34 preLast.end = preLast.begin + preSize;
35 last.begin = preLast.end;
36 }
37
38 void alternativeBlocks(size_t nAlternatives)
39 {
40 // # used blocks
41 size_t nBlocks = (nAlternatives + d_blockSize - 1) / d_blockSize;
42
43 if (nBlocks == 1)
44 {
45 cout << "only 1 block\n";
46 return;
47 }
48
49 vector<BlockStruct> blocks(nBlocks, {0, 0, "-+" });
50
51 blocks.front().prompt = "+";
52 blocks.front().end = d_blockSize;
53
54 for (size_t idx = 1, end = blocks.size(); idx != end; ++idx)
55 set(blocks[idx], blocks[idx - 1].end);
56
57 blocks.back().prompt = "-";
58
59 if (blocks.back().end > nAlternatives) // back may not exceed
60 blocks.back().end = nAlternatives; // nAlternatives
61
62 set(*(blocks.rbegin() + 1), blocks.back()); // inspect the last two sizes
63
64
65 for (auto const &block: blocks)
66 cout << block.begin << " to " << block.end <<
67 " (" << (block.end - block.begin) << ")"
68 " with " << block.prompt << '\n';
69
70 }
71
72
73 int main(int argc, char **argv)
74 {
75 while (true)
76 {
77 cout << "nAlternatives blockSize: ";
78 size_t nAlt;
79 cin >> nAlt >> d_blockSize;
80
81 alternativeBlocks(nAlt);
82 }
83 }
157157 {
158158 shift = true;
159159 event(L_SHIFT, KEY_PRESSED);
160 keyCode & 63; // remove the shift-indicator
160 keyCode &= 63; // remove the shift-indicator
161161 }
162162 else if (not (keyCode & 64) and shift)
163163 {
0 // man tty_ioctl
1
2 #include <sys/ioctl.h>
3 #include <string>
4
5 using namespace std;
6
7 int main()
8 {
9 // string cmd{ "cd /home\nl" };
10 // for (char ch: cmd)
11 // ioctl(0, TIOCSTI, &ch);
12
13 ioctl(0, TIOCSTI, "l"); // add an extra s via the kbd to get 'ls'
14 }
3737
3838 The program bf(xd) is used to perform e+bf(X)tra fast bf(D)irectory
3939 changes. Usually to change a directory the user is required to enter a command
40 like, e.g., tt(cd /usr/local/bin), possibly with the aid of shell
41 completion. In many cases this is a tedious task: shell completion shows all
42 entries, including files, when we're only interested in directories and the
43 full specification of our intented directory may eventually require many
44 keyboard actions.
40 like, e.g., tt(cd /usr/local/bin), possibly using shell completion. Often this
41 is a tedious task: shell completion shows all entries, including files, when
42 we're only interested in directories and the full specification of our
43 intented directory may eventually require many keyboard actions.
44
45 Note: tt(xd) version 4.00.00 introduces several new modes of operation:
46 see section tt(VERSION 4.00.00) for details.
4547
4648 tt(Xd) was designed a long time ago (in the early 90s) to reduce the
4749 effort of changing directories. Often we're well aware to which directory we
48 want to change, and it's easy to produce the initial directory characters of
50 want to change, and it's easy to provide the initial directory characters of
4951 that directory. E.g., if the intent is to tt(cd) to tt(/usr/local/bin),
50 it's quite easy to produce the letters tt(ulb).
52 it's easy to specify the letters tt(ulb).
5153
5254 tt(Xd) capitalizes on this capability. By providing the initial directory
53 characters of directories tt(xd) determines the proper expansion allowing you
54 to change directories fast. So, entering the command tt(xd ulb) results in the
55 expansion tt(/usr/local/bin).
56
57 Often life is not that easy. Often there are multiple expansions from a
58 given set of initial characters. E.g., when entering tt(xd ulb) tt(xd) may
59 find several alternatives. E.g.,
55 characters of directories tt(xd) determines the expansion(s) allowing you to
56 do fast directory changes. So, after entering the command tt(xd ulb)
57 tt(xd) may directly perform the change-directory to tt(/usr/local/bin).
58
59 Often, however, multiple alternatives can match the specified series of
60 characters. E.g., when entering tt(xd ulb) tt(xd) may find several
61 alternatives, like
6062 verb(
6163 1: /usr/lib/base-config
6264 2: /usr/lib/bonobo
6365 3: /usr/lib/bonobo-activation
6466 4: /usr/local/bin
6567 )
66 If these are the alternatives, this is exactly what tt(xd) will show
67 you. Then, by simply pressing the tt(3) key (em(no) tt(Enter) key required)
68 tt(xd) will produce the required tt(/usr/local/bin).
69
70 Commands to tt(xd) can be specified so as to fine-tune tt(xd)'s behavior:
68 If these are the alternatives, then this is exactly what tt(xd) shows
69 you. Then, by simply pressing the tt(4) key (em(no) tt(Enter) key required)
70 tt(xd) performs the required tt(/usr/local/bin).
71
72 tt(Xd's) behavious can be fine-tuned in various ways:
7173 itemization(
72 it() By default (as specified by the configuration file, see below)
73 expansions may start at the user's home directory or at the system's root
74 directory.
75 it() Initial character bf(/): If the first character of the command is
74 it() by default (as specified by the configuration file, see below) tt(xd)
75 looks for expansions starting at the user's home directory or at the system's
76 root directory;
77
78 it() initial character bf(/): if the first character of the command is
7679 tt(/) then all expansions are performed from the system's root
77 directory. E.g., tt(xd /t) results in tt(/tmp) but not in tt(/home/user/tmp).
78 it() Initial character bf(.): If the first character of the command is
80 directory. E.g., tt(xd /t) produces tt(/tmp) but not tt(/home/user/tmp);
81
82 it() initial character bf(.): if the first character of the command is
7983 tt(.) then by default all expansions are performed from the user's home
8084 directory. E.g., tt(xd .t) results in tt(/home/user/tmp) but not in
8185 tt(/tmp). The home directory recognition character can be altered using the
82 tt(--homedir-char) option, see below (section bf(OPTIONS)).
83 it() Initial character bf(0): If the first character of the command is
86 tt(--homedir-char) option, see below (section bf(OPTIONS));
87
88 it() initial character bf(0): If the first character of the command is
8489 tt(0), then all expansions start at the current working directory. In fact,
8590 this is a specialization of the following, more general form:
86 it() Initial character bf(1..9): If the first character of the command is
91
92 it() initial character bf(1..9): If the first character of the command is
8793 a digit between tt(1) and tt(9) then all expansions start at that parent
8894 directory level of the current working directory (up to the system's root
8995 directory). E.g., if the current working directory is tt(/usr/share/doc) then
9096 tt(xd 2lb) will offer the alternative tt(/usr/local/bin): two steps up, then
9197 look for directories starting with tt(l) and therein directories starting with
92 tt(b).
93 it() Separators (space, and the forward slash (`tt(/)')): sometimes it is
98 tt(b);
99
100 it() separators (space, and the forward slash (`tt(/)')): sometimes it is
94101 clear that there are many alternatives and the intention is to reduce that
95102 number. By using separators subsequently nested directories must start with
96 the characters between the separators. E.g., tt(xd u l bi) never produces the
97 alternative tt(/usr/lib/base-config) anymore, since tt(base-config) does not
98 start with tt(bi). In this case only tt(/usr/local/bin) is produced. When used
99 as initial character in a pattern the forward slash always indicates the
100 root-directory.
103 the characters between the separators. E.g., tt(xd u l bi) doesn't produce
104 the alternative tt(/usr/lib/base-config) anymore, since tt(base-config) does
105 not start with tt(bi). In this case only tt(/usr/local/bin) is produced. When
106 used as initial character in a pattern the forward slash always indicates the
107 root-directory;
101108 COMMENT(
102109 Separators may be mixed (tt(xd u/l bi) is identical to tt(xd u l
103110 bi)). Since the tt(/) can also be used as a root-directory specification,
107114 to solve the conflict (which in practice hardly ever occurs).
108115 END)
109116
110 it() Search patterns may contain dots (like tt(.s)). In such cases the dot
117 it() search patterns may contain dots (like tt(.s)). In such cases the dot
111118 represents hidden directories. However, tt(xd) usually also finds patterns
112119 containing tt(/./), as the current directory matches the dot. Such patterns
113120 are considered spurious and are not reported.
114121 )
115122
116 If there's only one solution, tt(Xd) writes that directory to its standard
117 output stream. If there are multiple solutions, then a list of at most 62
118 alternatives (10 for the numbers 0..9, 26 for the letters a..z and 26 for the
119 letters A..Z) is written to the standard error stream from which the user
120 may select an alternative by simply pressing the key associated with the
121 selection of choice. If no selection is requested any other key may be pressed
122 (e.g., the space bar or the tt(Enter) key). If there is no solutioon tt(xd)
123 writes the text tt(No Solutions) to the standard error stream.
123 If there's only one solution, tt(Xd) prepares for a directory change to
124 the solution's directory.
125
126 If there are multiple solutions, then by default (but see also section
127 tt(VERSION 4.00.00)) lists of at most 62 alternatives (10 for the numbers
128 0..9, 26 for the letters a..z and 26 for the letters A..Z) are written to the
129 standard error stream from which the user may select an alternative by simply
130 pressing the key associated with the selection of choice. If no selection is
131 requested any other key may be pressed (e.g., the space bar or the tt(Enter)
132 key). If there is no solutioon tt(xd) writes the text tt(No Solutions) to the
133 standard error stream.
124134
125135 When tt(xd) is given at least one argument, all its output is sent to the
126 standard error stream, but for the selected directory name which is written to
127 the standard output stream. If no selection is made or if the selection
128 process is aborted a single dot is written to the standard output
129 stream. Usually tt(xd) will be called by a shell alias, providing the
130 tt(cd) command with tt(xd)'s output (see below at the bf(SHELL SCRIPTS)
131 section) executing tt(cd `xd $*`). The default dot produced by tt(xd)
132 prevents an unintended change of directory.
136 standard error stream, except for the selected directory name which should
137 become the next working directory.
138
139 If no selection is made or if the
140 selection process is aborted a single dot is written to the standard output
141 stream. Usually tt(xd) will be called by a shell alias, providing the tt(cd)
142 command with tt(xd)'s output (see below at the bf(SHELL SCRIPTS) section)
143 executing tt(cd `xd $*`). The default dot produced by tt(xd) prevents an
144 unintended change of directory.
133145
134146 When tt(xd) is merely given an initial directory specification, like a
135147 single dot (tt(.)) or digit (a digit in the set tt([0..9])) then tt(xd)
137149 entering `tt(xd 5)' when the current working directory is `tt(/tmp)') results
138150 in writing the root directory (`tt(/)') to the standard output stream.
139151
140 If tt(xd) is called without arguments then em(usage) information is
152 If tt(xd) is called without arguments its em(usage) information is
141153 written to the standard error stream.
142154
143155 tt(Xd) may be further configured using options and a configuration file,
144156 discussed in the bf(OPTIONS) and bf(CONFIGURATION FILE) sections below.
145157
158 manpagesection(VERSION 4.00.00)
159
160 Starting with tt(xd) version 4.00.00 several major changes were implemented:
161 itemization(
162 it() tt(xd) may insert the tt(cd) command directly into the command shell
163 from where tt(xd) was called.
164
165 Before version 4.00.00 the selected directory was written to the
166 standard output stream, where a a shell alias or script, passes
167 tt(xd)'s output to the tt(cd) command (cf. section bf(SHELL
168 SCRIPTS)). In this mode of operation tt(xd) returns a single dot if no
169 selection is made, preventing an unintended change of directory.
170
171 This mode of operation is still tt(xd's) default mode of operation. By
172 specifying option tt(--input) (or by entering tt(input) in the
173 configuration file) the additional shell alias or script is no longer
174 necessary. In this tt(input) mode tt(xd) directly inserts the
175 requested tt(cd) command into the shell's input buffer. This mode has
176 an additional feature: if a key is pressed that is not assiciated with
177 a possible directory then the current directory is kept, and the
178 character corresponding to the pressed key is entered into the shell's
179 input buffer. E.g., if tt(xd ulb) shows a list of five alternatives,
180 but the tt(L) key is pressed then tt(xd) ends and the shell's input
181 buffer shows tt(l). Merely pressing tt(s) + Enter will then show the
182 current directory content. To merely end tt(xd) in this mode the space
183 bar or Enter key can be pressed;
184
185 it() the option tt(--block-size <nr>) (or specifying tt(block-size <nr>)
186 in the configuration file), the possible directories matching tt(xd's)
187 argument are listed in blocks of tt(<nr>) elements. The built-in
188 minimum block size is 5. If there are fewer alternatives then this
189 built-in minimum then the actually available alternatives are
190 displayed;
191
192 When alternatives are split up in blocks, a tt(+) is displayed after
193 listing the first block, a tt(-) is displayed after listing the last
194 block, and tt(-+) is displayed after listing the intermediate
195 blocks. In these cases, pressing - redisplays the previous block,
196 pressing + displays the next block;
197
198 Although these block-end prompts only show - and +, the characters ,
199 and < (usually combined in one key) can be used instead of -, while
200 . and > (also usually combined in one key) can be used instead of +.
201 )
202
203
146204 manpagesection(GENERALIZED DIRECTORY SEARCH)
147205
148 Starting with version 3.10.0 tt(xd) also supports generalized directory
149 search command processing (GDS). When GDS is requested separators are no
150 longer required, and tt(xd) will find all possible alternatives resulting from
151 all possible sequential combinations of the initial search command. GDS is
152 activated either by specifying the tt(-g) command line flag or by entering
153 tt(generalized-search) in tt(xd)'s configuration file. Alternatively, when the
154 latter is specified then the tt(--traditional) command line option will
155 suppress GDS.
206 tt(Xd) also supports generalized directory search commands (GDS). When GDS
207 is requested separators are no longer required, and tt(xd) finds all possible
208 alternatives resulting from all possible sequential combinations of the
209 initial search command. GDS is activated either by specifying the tt(-g)
210 option or by entering tt(generalized-search) in tt(xd)'s configuration
211 file. Alternatively, when the latter is specified then the tt(--traditional)
212 command line option suppresses GDS.
156213
157214 When using GDS each initial substring of the command to tt(xd) is
158215 considered as the initial characters of a directory. E.g., if the command
168225 it() tt(/tmp*/s*/)
169226 it() tt(/tmps*/)
170227 )
171 Using the traditional processing mode only the first one of these
228 With the traditional processing mode only the first one of these
172229 alternative patterns is considered.
173230
174 Multiple command line arguments, the slash and the underscore can still be
175 used with GDS in which case they force a directory change in the considered
176 patterns. E.g., with the command tt(xd tm/ps) the following patterns will be
177 considered:
231 Multiple command line arguments, the slash, and the underscore can still
232 be used with GDS. In this case they force a directory change using the
233 considered patterns. E.g., with the command tt(xd tm/ps) the following
234 patterns will be considered:
178235 itemization(
179236 it() tt(/t*/m*/p*/s*/)
180237 it() tt(/t*/m*/ps*/)
188245 manpagesection(RETURN VALUE)
189246
190247 tt(Xd) returns 0 to the operating system unless an error occurs (e.g.,
191 when a non-existing configuration file is specified), or tt(xd)'s version or
192 usage info is shown or requested.
248 when a non-existing configuration file is specified, or when tt(xd)
249 automatically (i.e., without having received option tt(--help)) shows its
250 usage info).
193251
194252 manpageoptions()
195253
196254 If available, single letter options are listed between parentheses
197255 following their associated long-option variants. Single letter options require
198256 arguments if their associated long options require arguments as well.
257
258 Most options can also be specified in tt(xd's) configuration file, in which
259 case the long option variants must be used, omitting the initial two dashes
260 (see the section tt(CONFIGURATION FILE) below for specific details about the
261 configuration file.
262
263 By default the options can also be specified in the configuration
264 file. If an option cannot be specifiied in the configuration file it is
265 explicitly stated at its description.
266
267 Options that are specified as command-line options take priority over options
268 specified in the configuration file.
269
199270 itemization(
200271 it() loption(add-root) tt(condition)nl()
201272 If the search starts at the user's home directory an additional
202273 search starting at the system's root directory may be performed as well,
203 depending on the value specified for the tt(add-root) option. Alternatives are
204 tt(never) (no additional search is performed); tt(if-empty) (an additional
205 search is performed if the initial search did not yield any directory); or
206 tt(always) (an additional search is always performed). There is also a
207 configuration file directive tt(add-root) (see below).
208
274 depending on the value specified for the tt(add-root) option. Conditions are
275 quote(
276 itemization(
277 it() tt(never) (no additional search is performed),
278 it() tt(if-empty) (an additional search is performed if the initial
279 search did not yield any directory),
280 it() tt(always) (an additional search is always performed);
281 )
282 )
209283 it() loption(all) soption(a)nl()
210284 If the configuration file (see below) contains tt(ignore) directives
211 then these directives are ignored when computing the alternatives from which
212 the user may select a directory to change to.
285 then those directives are ignored when computing the alternatives from which
286 the user may select a directory to change to;
287
288 it() lsoption(block-size)(b)(nr)nl()
289 The possible directories matching tt(xd's) argument are listed in
290 blocks of tt(<nr>) elements. See also the previous section tt(VERSION
291 4.00.00),
213292
214293 it() lsoption(config-file)(c)(filename)nl()
215 The name of an tt(xd) configuration file. By default tt(xd)
216 looks for the file tt(.xdrc) in the user's home directory. The
217 existence of the default file is optional.
294 The name of an tt(xd) configuration file. By default tt(xd) looks for
295 the file tt(.xdrc) in the user's home directory. The existence of the
296 default file is optional.
297
298 This option cannot be specified in the configuration file;
218299
219300 it() loption(directories) tt(inclusion)nl()
220 Directories may be also be reached via symbolic links. The inclusion
221 type tt(all) adds these symbolic links to the list of alternatives. The
222 inclusion type tt(unique) prevents symbolic links from being added to
223 the list of alternatives. There is also a configuration file directive
224 tt(directories) (see below).
301 Directories may be also be reached via symbolic links. The (default)
302 inclusion type tt(all) adds these symbolic links to the list of
303 alternatives. The inclusion type tt(unique) prevents symbolic links
304 from being added to the list of alternatives;
305
306 it() loption(generalized-search) soption(g)nl()
307 When specified tt(xd) uses GDS unless the directive tt(traditional) is
308 specified in the configuration file;
309
310 it() loption(help) (soption(h))nl()
311 Basic usage information is written to the standard error stream,
312 whereafter tt(xd) terminates.
313
314 This option cannot be specified in the configuration file;
225315
226316 it() loption(homedir-char) tt(ch)nl()
227 By default an initial dot character (`tt(.)') initiates a search from
228 the user's home directory. There is a slight disadvantage to using the dot, as
229 it is also be the initial character of `hidden' directories. Assuming that you
230 have a directory tt(~/.ssh) then the command to xd to that directory would be
231 tt(xd ..s), the first dot being the home directory indicator, after which
232 tt(.s) is used to find tt(.ssh). The option tt(--homedir-char) can be used to
233 specify another character. Homedir characters cannot be digits or a slash
234 (`tt(/)') as these are used to specify, respectively, parent directories and
235 the computer's root directory. Characters like ``tt(, @ % ^)'' or maybe
236 `tt(H)' (assuming that it doesn't interfere with an existing directory
237 beginning with tt(H)) could be used as homedir-characters, other than the
238 default dot character.
239
240 Caveat: command shells by default interpret characters like ``tt(~ $ \ ' " ` <
241 > |)'' etc., which therefore should probably not be specified as
242 home directory specifiers.
243
244 There is also a configuration file directive tt(homedir-char) (see below).
245
246 it() loption(generalized-search) soption(g)nl()
247 When this option is specified tt(xd) uses GDS unless the
248 directive tt(traditional) is specified in the configuration file.
249
250 it() loption(help) (soption(h))nl()
251 Basic usage information is written to the standard error stream.
317 By default an initial dot character (`tt(.)') initiates a search from
318 the user's home directory. There is a slight disadvantage to using the
319 dot, as it is also be the initial character of `hidden'
320 directories. Assuming that you have a directory tt(~/.ssh) then the
321 command to xd to that directory would be tt(xd ..s), the first dot
322 being the home directory indicator, after which tt(.s) is used to find
323 tt(.ssh). The option tt(--homedir-char) can be used to specify another
324 character. Homedir characters cannot be digits or a slash (`tt(/)') as
325 these are used to specify, respectively, parent directories and the
326 computer's root directory. Characters like ``tt(, @ % ^)'' or maybe
327 `tt(H)' (assuming that it doesn't interfere with an existing directory
328 beginning with tt(H)) could be used as homedir-characters, other than
329 the default dot character.
330
331 Caveat: command shells by default interpret characters like ``tt(~ $ \
332 ' " ` < > |)'' etc., which therefore should probably not be specified
333 as home directory specifiers;
252334
253335 it() loption(history) tt([filename])nl()
254 A history of previously made choices is kept in the file
255 tt(filename). If tt(--history) is specified, but the filename is
256 left empty the history file tt($HOME/.xd.his) is used. This file should only
257 be modified by tt(xd) itself. If you can't resist editing it then use the
258 following example showing the format of the lines in the history file.
259 verb(
336 A history of previously made choices is kept in the file
337 tt(filename). If tt(--history) is specified, but the filename is left
338 empty the history file tt($HOME/.xd.his) is used. This file should
339 only be modified by tt(xd) itself. If you can't resist editing it then
340 use the following example showing the format of the lines in the
341 history file.
342 verb(
260343 1292596154 1 /home/frank/svn/xd/
261344 )
262 The first field is the time (in seconds since the epoch) the entry was
263 written, the second field is the number of times the entry has been selected
264 and the third field is the associated path.
345 The first field is the time (in seconds since the epoch) the entry was
346 written, the second field is the number of times the entry has been
347 selected and the third field is the associated path.
348
349 The following tt(history-...) options are only interpreted if the
350 tt(history) option is also specified.
265351
266352 it() loption(history-lifetime) tt(spec)nl()
267 The lifetime of the entries in the history file. The specification
268 consists of a number followed by tt(D, W, M) or tt(Y), representing,
269 resp. days, weeks, months, or years. A month is considered a period of 30
270 days, a year a period of 365 days. If the specification is omitted a lifetime
271 of tt(1M) (one month) is used. Entries older than tt(history-lifetime) are
272 disregarded as history-items and are removed from the history file.
353 The lifetime of the entries in the history file. The specification
354 consists of a number followed by tt(D, W, M) or tt(Y), representing,
355 resp. days, weeks, months, or years. A month is considered a period of
356 30 days, a year a period of 365 days. If the specification is omitted
357 a lifetime of tt(1M) (one month) is used. Entries older than
358 tt(history-lifetime) are disregarded as history-items and are removed
359 from the history file;
273360
274361 it() loption(history-maxsize) tt(nr)nl()
275 The maximum number of entries the history file may contain. By default
276 there is no limit. When tt(history-maxsize) is specified and more than the
277 maximum number of history items are found in the history file then the tt(nr)
278 most popular choices are kept. Usually the cut-off point will be somewhere
279 within a popularity category. In that case the most recently selected
280 alternatives within that category are kept.
362 The maximum number of entries the history file may contain. By default
363 there is no limit. When tt(history-maxsize) is specified and more than
364 the maximum number of history items are found in the history file then
365 the tt(nr) most popular choices are kept. Usually the cut-off point
366 will be somewhere within a popularity category. In that case the most
367 recently selected alternatives within that category are kept;
281368
282369 it() loption(history-position) tt([top|bottom])nl()
283 When this option is specified then previously found alternatives
284 are displayed either at the top of the list or at the bottom
285 of the list. If this option is omitted then the elements in the history will
286 be intermixed with new alternatives. The next option tt(history-separate) is
287 only used when this option is also specified. By merely specifying
288 tt(history-position) the history items are shown at the top of the list.
370 Previously found alternatives are displayed either at the top of the
371 list or at the bottom of the list. If this option is omitted then the
372 elements in the history are intermixed with new alternatives. The next
373 option tt(history-separate) is only used when this option is also
374 specified. By merely specifying tt(history-position) the history items
375 are shown at the top of the list;
289376
290377 it() loption(history-separate)nl()
291 When specified, a blank line is written between the items in the history
292 and new alternatives (not previously selected). This option is only
293 interpreted when the previous option is also specified.
294
295 it() loption(icase) soption(i)nl()
296 This option is used to specify case-insensitive pattern matching. E.g.,
297 specifying tt(xd /ub) returns the directory tt(/usr/bin), but not a directory
298 like tt(/UnSpecified/Books), which is returned by tt(xd /UB). However, tt(xd
299 -i /ub) (using any letter casing for the specification) returns both
300 directories. The option tt(icase) could of course be specified in the
301 configuration file, which which case case-insensitive matching is used by
302 default. In the latter case specifying tt(-i) as a command line option reverts
303 the matching procedure to case-sensitive directory matching. In general, when
304 an even number of em(icase) specifications is provided tt(xd) uses
305 case-sensitive directory matching, while an odd number of em(icase)
306 specifications results in case-insensitive directory matching.
378 When specified a blank line is written between the items in the
379 history and new alternatives (not previously selected). This option is
380 only interpreted when the previous option is also specified;
381
382 it() loption(icase) soption(i)nl()
383 Specify this option to use case-insensitive pattern matching. E.g.,
384 specifying tt(xd /ub) returns the directory tt(/usr/bin), but not a
385 directory like tt(/UnSpecified/Books), which is returned by tt(xd
386 /UB). However, tt(xd -i /ub) (using any letter casing for the
387 specification) returns both directories. The option tt(icase) could of
388 course be specified in the configuration file, which which case
389 case-insensitive matching is used by default. In the latter case
390 specifying tt(-i) as a command line option reverts the matching
391 procedure to case-sensitive directory matching. In general, when an
392 even number of em(icase) specifications is provided tt(xd) uses
393 case-sensitive directory matching, while an odd number of em(icase)
394 specifications results in case-insensitive directory matching;
395
396 it() bf(ignore) tt(path) nl()
397 This option cannot be specified as command-line option. Instead, the
398 configuration file may contain multiple tt(ignore) directives which
399 are (different from the way other directives are handled) all
400 interpreted. Each tt(ignore) directive is followed by a path
401 specification as shown in a list of alternatives produced by tt(xd) or
402 an initial substring of such a path terminating in a tt(*)
403 character. When tt(xd) encounters a path matching any of the
404 tt(ignore) directives (interpreting the final tt(*) as `any further
405 directory name' specification) it will not display that path in its
406 list of alternatives.
407
408 This directive is overruled by the tt(---all) command line option;
409
410 it() loption(input)nl()
411 tt(Xd) itself issues the tt(cd) command for the selected directory to
412 the shell, and enters other (non alternative-selecting characters)
413 into the shell's input. See also the previous section tt(VERSION
414 4.00.00).
415
416 To merely end tt(xd) press the Enter key or space-bar;
307417
308418 it() loption(start-at) tt(origin)nl()
309 Defines the default start location of directory searches. Origin
310 tt(home) results in all default searches to start at the user's home
311 directory. Origin tt(root) results in searches to begin at the disk's root
312 (tt(/)) directory. There is also a configuration file directive tt(start-at)
313 (see below).
419 Defines the default start location of directory searches. Origin
420 tt(home) (the default) results in all default searches to start at the
421 user's home directory. Origin tt(root) results in searches to begin at
422 the disk's root (tt(/)) directory;
314423
315424 it() loption(traditional)nl()
316 When this option is specified tt(xd) will not use GDS but will use its
317 traditional mode. It overrules a tt(generalized-search) directive specified in
318 the configuration file as well as the tt(-g) option.
425 tt(Xd) does not use GDS but uses its traditional mode. It overrules a
426 tt(generalized-search) directive specified in the configuration file
427 as well as the tt(-g) option;
319428
320429 it() loption(verbose) (soption(V))nl()
321 More extensive information about the actions taken by the tt(xd)
322 program is written to the standard error stream.
430 More extensive information about the actions taken by the tt(xd)
431 program is written to the standard error stream.
432
433 This option cannot be specified in the configuration file;
323434
324435 it() loption(version) (soption(v))nl()
325 tt(Xd)'s version number is written to the standard error stream.
436 tt(Xd)'s version number is written to the standard error stream
437 whereafter tt(xd) terminates.
438
439 This option cannot be specified in the configuration file.
326440 )
327441
328442
329443 manpagesection(CONFGURATION FILE)
330444
331445 The default configuration file is tt(.xdrc) in the user's home directory. It
332 may be overruled by the program's tt(--config-file) option.
446 may be overruled by the program's tt(--config-file) command-line option.
333447
334448 Empty lines are ignored. Information at and beyond tt(#)-characters is
335 interpreted as comment and is ignored as well.
336
337 All directives in tt(xd) configuration files follow the pattern
449 interpreted as comment and is also ignored.
450
451 Directives in tt(xd) configuration files follow the pattern
338452 verb(
339453 directive value
340454 )
341 but for some directives tt(value) is optional.
342
343 A line may at most contain one directive, but white space (including
344 comment at the end of the line) is OK. The same directive may be specified
345 multiple times, in which case the em(last) directive will be used (with the
346 exception of the em(ignore) directive, see below). All
347 directives are interpreted em(case sensitively). Non-empty lines
348 not beginning with a recognized directive are silently ignored.
349
350 The following directives can be used in the
351 configuration file. Default values are shown between parentheses.
352 itemization(
353 it() bf(add-root) tt(when) (if-empty)nl()
354 If the search starts at the user's home directory an additional
355 search starting at the system's root directory may be performed as well,
356 depending on the value specified for the tt(add-root) directive. nl()
357 If tt(when) is specified as tt(always) then an additional search is
358 always performed.nl()
359 If it is specified as tt(if-empty) then an additional search is
360 performed if the initial search (starting at the user's home directory) did
361 not yield any directory.nl()
362 If it is specified as tt(never) no additional search is
363 performed.
364
365 This directive is overruled by the tt(---add-root) command line option.
366
367 it() bf(directories) tt(which) (all)nl()
368 Directories may be also be reached via symbolic links. The
369 specification tt(all) will add these symbolic links to the list of
370 alternatives. The specification tt(unique) will prevent the symbolic links
371 from being added to the list of alternatives.
372
373 This directive is overruled by the tt(---directories) command line option.
374
375 it() bf(homedir-char) tt(ch)nl()
376 By default an initial dot character (`tt(.)') initiates a search from
377 the user's home directory. There is a slight disadvantage to using the dot, as
378 it is also be the initial character of `hidden' directories. Assuming that you
379 have a directory tt(~/.ssh) then the command to xd to that directory would be
380 tt(xd ..s), the first dot being the home directory indicator, after which
381 tt(.s) is used to find tt(.ssh). The specification tt(homedir-char ch) can be
382 used to specify another home directory indicating character tt(ch), as in:
383 verb(
384 homedir-char ,
385 )
386 Homedir characters cannot be digits or a
387 slash (`tt(/)') as these are used to specify, respectively, parent directories
388 and the computer's root directory. Characters like ``tt(, @ % ^)'' or maybe
389 `tt(H)' (assuming that it doesn't interfere with an existing directory
390 beginning with tt(H)) could be used as homedir-characters, other than the
391 default dot character.
392
393 Caveat: command shells by default interpret characters like ``tt(~ $ \ ' " ` <
394 > |)'' etc., which therefore should probably not be specified as
395 home directory specifiers.
396
397 This directive is overruled by the tt(---homedir-char) command line option.
398
399 it() bf(generalized-search) nl()
400 When this directive is specified tt(xd) will use GDS by default.
401
402 it() bf(history) tt([filename])nl()
403 A history of previously made choices is kept in the file
404 tt(filename). If tt(history) is specified, but the filename is
405 left empty the history file tt($HOME/.xd.his) is used. This file should only
406 be modified by tt(xd) itself. If you can't resist editing it then use the
407 following example showing the format of the lines in the history file.
408 verb(
409 1292596154 1 /home/frank/svn/xd/
410 )
411 The first field is the time (in seconds since the epoch) the entry was
412 written, the second field is the number of times the entry has been selected
413 and the third field is the associated path.
414
415 it() bf(history-lifetime) tt(spec)nl()
416 The lifetime of the entries in the history file. The specification
417 consists of a number followed by tt(D, W, M) or tt(Y), representing,
418 resp. days, weeks, months, or years. A month is considered a period of 30
419 days, a year a period of 365 days. If the specification is omitted a lifetime
420 of tt(1M) (one month) is used. Entries older than tt(history-lifetime) are
421 disregarded as history-items and are removed from the history file.
422
423 it() bf(history-maxsize) tt(nr)nl()
424 The maximum number of entries the history file may contain. By default
425 there is no limit. When tt(history-maxsize) is specified and more than the
426 maximum number of history items are found in the history file then the tt(nr)
427 latest choices are kept. Each previously made selection counts as one. If a
428 new alternative is selected it always becomes an element in the history list.
429
430 it() bf(history-position) tt([top|bottom])nl()
431 When specified alternatives found in the history will be displayed either
432 at the top of the list or at the bottom of the list. If this option is omitted
433 then the elements in the history will be intermixed with new alternatives. The
434 next directive tt(history-separate) is only used when this directive is also
435 specified. By merely specifying tt(history-position) the history items are
436 shown at the top of the list.
437
438 it() bf(history-separate)nl()
439 When specified, a blank line is written between the items in the history
440 and new alternatives (not previously selected). This directive is only
441 interpreted when the previous directive is also specified.
442
443 it() loption(icase) soption(i)nl()
444 This specification is used to request case-insensitive pattern
445 matching. If this option is entered in the configuration file then specifying
446 tt(xd /ub) returns the directory tt(/usr/bin) as welll as a directory like
447 (assuming it exists) tt(/UnSpecified/Books). When specified in the
448 configuration file, the command-line option tt(-i) reverts the matching
449 procedure back to case-sensitive directory matching. In general, when an even
450 number of em(icase) specifications is provided tt(xd) uses case-sensitive
451 directory matching, while an odd number of em(icase) specifications results in
452 case-insensitive directory matching.
453
454 it() bf(ignore) tt(path) nl()
455 The configuration file may contain multiple tt(ignore) directives
456 which are --different from the way other directives are handled-- all
457 interpreted. Each tt(ignore) directive is followed by a path specification as
458 shown in a list of alternatives produced by tt(xd) or an initial substring of
459 such a path terminating in a tt(*) character. When tt(xd) encounters a path
460 matching any of the tt(ignore) directives (with the tt(*) interpreted as `any
461 further directory name' specification) it will not display that path in its
462 list of alternatives.
463
464 This directive is overruled by the tt(---all) command line option.
465
466 it() bf(start-at) tt(value) (home) nl()
467 Defines the default start location of directory searches. Values
468 are tt(home) and tt(root). When tt(home) is specified all searches start at
469 the user's home directory. When tt(root) is specified searches start at the
470 disk's root (tt(/)) directory. If the directory is omitted or if another value
471 is specified then the default is used, which is tt(home).
472
473 This directive is overruled by the tt(---start-at) command line option.
474
475 it() bf(traditional) nl()
476 This directive may be used to request the use of tt(xd)'s traditional
477 mode. It overrules the tt(-g) command line option and the
478 tt(generalized-search) directive.
479 )
480
455 (for some directives there is no tt(value) term).
456
457 A line may at most contain one directive, but white space (including comment
458 at the end of the line) is OK. The same directive may be specified multiple
459 times, in which case the em(last) directive will be used (except for the
460 em(ignore) directive, which are all interpreted). All directives are
461 interpreted em(case sensitively) unless option tt(icase) is specified.
462 Non-empty lines not beginning with a recognized directive are silently
463 ignored.
481464
482465 manpagesection(SHELL SCRIPTS)
466
467 If the tt(input) option is specified (as command-line or configuration
468 file option) then this section can be ignored.
483469
484470 Assuming tt(xd) is installed in tt(/usr/bin) scripts can be defined around
485471 tt(xd) for various shell programs. This allows the shell to change directories
0 #ifndef INCLUDED_ENUMS_H_
1 #define INCLUDED_ENUMS_H_
2
3 enum TriState // used by Alternatives
4 {
5 NEVER,
6 IF_EMPTY,
7 ALWAYS
8 };
9
10 enum Position // used by History
11 {
12 TOP,
13 BOTTOM
14 };
15
16
17 #endif
+0
-8
filter/decided.cc less more
0 #include "filter.ih"
1
2 bool Filter::decided() const
3 {
4 d_alternatives.update(d_index);
5
6 return d_index != d_alternatives.size();
7 }
+0
-26
filter/filter.h less more
0 #ifndef _FILTER_H_
1 #define _FILTER_H_
2
3 #include <string>
4
5 #include "../alternatives/alternatives.h"
6
7 class Filter
8 {
9 size_t d_index;
10 Alternatives &d_alternatives;
11
12 public:
13 Filter(Alternatives &alternatives);
14
15 void select();
16 bool decided() const;
17
18 private:
19 void showAlternatives() const;
20 size_t show(size_t begin, char first, char last,
21 size_t separateAt) const;
22 void setIndex();
23 };
24
25 #endif
+0
-10
filter/filter.ih less more
0 #include "filter.h"
1
2 #include <iostream>
3 #include <iomanip>
4
5 #include <bobcat/onekey>
6 #include <bobcat/mstream>
7
8 using namespace std;
9 using namespace FBB;
+0
-7
filter/filter1.cc less more
0 #include "filter.ih"
1
2 Filter::Filter(Alternatives &alternatives)
3 :
4 d_index(alternatives.size()),
5 d_alternatives(alternatives)
6 {}
+0
-20
filter/select.cc less more
0 #include "filter.ih"
1
2 void Filter::select()
3 {
4 if (d_alternatives.size() == 0)
5 throw 0;
6
7 if (d_alternatives.size() == 1)
8 {
9 imsg << endl;
10 d_index = 0; // forced selection: one option
11 }
12 else
13 {
14 showAlternatives();
15 setIndex();
16 }
17
18 cout << d_alternatives[d_index] << endl;
19 }
+0
-23
filter/setindex.cc less more
0 #include "filter.ih"
1
2 void Filter::setIndex()
3 {
4 int c;
5 OneKey oneKey;
6
7 c = oneKey.get(); // get the replay
8
9 if (c == '0')
10 d_index = 9;
11 else if (isdigit(c))
12 d_index = c - '1';
13 else if (islower(c))
14 d_index = '9' - '0' + 1 + c - 'a';
15 else if (isupper(c))
16 d_index = '9' - '0' + 1 + 'z' - 'a' + 1 + c - 'A';
17 else
18 throw 1;
19
20 if (d_index > d_alternatives.size())
21 throw 1;
22 }
+0
-16
filter/show.cc less more
0 #include "filter.ih"
1
2 size_t Filter::show(size_t begin, char first, char last, size_t separateAt)
3 const
4 {
5 size_t end = min(begin + last - first + 1, d_alternatives.size());
6
7 for (; begin != end; ++begin, ++first)
8 {
9 if (begin == separateAt)
10 cerr << '\n';
11 cerr << setw(2) << first << ": " << d_alternatives[begin] << '\n';
12 }
13
14 return begin;
15 }
+0
-14
filter/showalternatives.cc less more
0 #include "filter.ih"
1
2 void Filter::showAlternatives() const
3 {
4 imsg << endl;
5
6 size_t separateAt = d_alternatives.separateAt();
7
8 size_t begin = show(0, '1', '9', separateAt);
9
10 begin = show(begin, '0', '0', separateAt);
11 begin = show(begin, 'a', 'z', separateAt);
12 begin = show(begin, 'A', 'Z', separateAt);
13 }
0 #include "main.ih"
1
2 int handle(exception_ptr ptr)
3 try
4 {
5 rethrow_exception(ptr);
6 }
7 catch(exception const &err) // handle exceptions
8 {
9 cerr << err.what() << '\n';
10
11 // preventa a directory change
12 noInput(); // if --input wasn't specified
13
14 return 1;
15 }
16 catch(int x)
17 {
18 if (ArgConfig::instance().option("hv"))
19 x = 0;
20 else if (x == 0)
21 cerr << "No Solutions\n";
22
23 noInput();
24
25 return x;
26 }
27
28
29
30
31
+0
-3
history/data.cc less more
0 #include "history.ih"
1
2 char History::s_defaultHistory[] = ".xd.his"; // in $HOME
0 inline History::HistoryInfo::HistoryInfo(size_t time, size_t count,
1 std::string const &path)
2 :
3 time(time),
4 count(count),
5 path(path)
6 {}
7
8 inline bool History::find(std::string const &path) const
9 {
10 return findIter(path) != d_history.end();
11 }
12
13 inline std::vector<History::HistoryInfo>::const_iterator
14 History::findIter(std::string const &path) const
15 {
16 return
17 find_if(
18 d_history.begin(), d_history.end(),
19 [&](HistoryInfo const &history)
20 {
21 return history.path == path;
22 }
23 );
24 }
25
26 inline Position History::position() const
27 {
28 return d_options.historyPosition();
29 }
30
31 inline bool History::rotate() const
32 {
33 return not d_historyFilename.empty() &&
34 d_options.historyPosition() == BOTTOM;
35 }
36
37 inline std::ostream &operator<<(std::ostream &out,
38 History::HistoryInfo const &hi)
39 {
40 return out << hi.time << ' ' << hi.count << ' ' << hi.path;
41 }
42
43
44
45
55 #include <iostream>
66 #include <algorithm>
77
8 namespace FBB
9 {
10 class ArgConfig;
11 }
8 #include "../enums/enums.h"
9 #include "../options/options.h"
1210
1311 class History
1412 {
15 public:
16 enum Position
17 {
18 TOP,
19 BOTTOM
20 };
13 struct HistoryInfo
14 {
15 size_t time;
16 size_t count;
17 std::string path;
2118
22 private:
23 struct HistoryInfo
24 {
25 size_t time;
26 size_t count;
27 std::string path;
19 HistoryInfo() = default;
20 HistoryInfo(size_t time, size_t count, std::string const &path);
21 };
2822
29 HistoryInfo() = default;
30 HistoryInfo(size_t time, size_t count, std::string const &path);
31 };
23 friend std::istream &operator>>(std::istream &in, HistoryInfo &hl);
24 friend std::ostream &operator<<(std::ostream &in,
25 HistoryInfo const &hl);
3226
33 friend std::istream &operator>>(std::istream &in, HistoryInfo &hl);
34 friend std::ostream &operator<<(std::ostream &in,
35 HistoryInfo const &hl);
27 Options const &d_options;
3628
37 FBB::ArgConfig &d_arg;
29 std::string d_historyFilename; // name of the history file
3830
39 size_t d_now; // current time
31 size_t d_now; // current time
4032
41 size_t d_oldest;
42 Position d_position; // TOP or BOTTOM (TOP)
43 std::string d_name; // name of the history file
44 // (empty: no history used)
33 std::vector<HistoryInfo> d_history;
4534
46 std::vector<HistoryInfo> d_history;
47
48 static char s_defaultHistory[];
35 static char s_defaultHistory[];
4936
5037 public:
51 History(FBB::ArgConfig &arg, std::string const &homeDir);
38 History();
39
40 Position position() const;
41
5242 void setLocation(size_t nInHistory);
5343 void save(std::string const &choice);
5444 bool rotate() const;
55 Position position() const;
45
5646 // see if a path is in the history
5747 bool find(std::string const &path) const;
5848
5949 private:
6050 std::vector<HistoryInfo>::const_iterator findIter(
6151 std::string const &path) const;
62
63
64 void load(std::string const &homeDir);
65 void setData();
52 void load();
6653
6754 static void maybeInsert(HistoryInfo const &historyInfo,
6855 std::vector<HistoryInfo> &history,
7259 static bool compareCounts(HistoryInfo const &first,
7360 HistoryInfo const &second);
7461
75 // static bool findEntry(HistoryInfo const &history,
76 // std::string const &entry);
77
7862 };
7963
80 inline History::HistoryInfo::HistoryInfo(size_t time, size_t count,
81 std::string const &path)
82 :
83 time(time),
84 count(count),
85 path(path)
86 {}
64 #include "history.f"
8765
88 inline History::Position History::position() const
89 {
90 return d_position;
91 }
92
93 inline std::vector<History::HistoryInfo>::const_iterator History::findIter(
94 std::string const &path) const
95 {
96 return
97 find_if(
98 d_history.begin(), d_history.end(),
99 [&](HistoryInfo const &history)
100 {
101 return history.path == path;
102 }
103 );
104 }
105
106 inline bool History::find(std::string const &path) const
107 {
108 return findIter(path) != d_history.end();
109 }
110
111 inline std::ostream &operator<<(std::ostream &out,
112 History::HistoryInfo const &hi)
113 {
114 return out << hi.time << ' ' << hi.count << ' ' << hi.path;
115 }
116
117 inline bool History::rotate() const
118 {
119 return d_name.length() && d_position == BOTTOM;
120 }
12166
12267 #endif
00 #include "history.h"
11
22 #include <climits>
3 #include <sstream>
34
45 #include <bobcat/a2x>
56 #include <bobcat/mstream>
6 #include <bobcat/argconfig>
77 #include <bobcat/string>
88
99 using namespace std;
00 #include "history.ih"
11
2 History::History(ArgConfig &arg, string const &homeDir)
2 History::History()
33 :
4 d_arg(arg),
5 d_now(time(0))
4 d_options(Options::instance()),
5 d_now(d_options.now())
66 {
7 setData();
8 load(homeDir);
7 if (not d_options.history().empty())
8 {
9 d_historyFilename = d_options.homeDir() + d_options.history();
10 load();
11 }
912 }
0 ../icmconf.lib
00 #include "history.ih"
11
2 void History::load(string const &homeDir)
2 void History::load()
33 {
4 if (d_arg.option(&d_name, "history") && d_name.empty())
5 d_name = homeDir + s_defaultHistory;
6
7 ifstream in(d_name);
4 ifstream in{ d_historyFilename };
85 if (!in)
96 {
10 imsg << "History file `" << d_name << "' not readable" << endl;
7 imsg << "History file `" << d_historyFilename << "' not readable" << endl;
118 return;
129 }
1310
14 imsg << "History file `" << d_name << '\'' << endl;
11 imsg << "History file `" << d_historyFilename << '\'' << endl;
1512
1613 for_each(
1714 istream_iterator<HistoryInfo>(in),
1815 istream_iterator<HistoryInfo>(),
1916 [&](HistoryInfo const &historyInfo)
2017 {
21 maybeInsert(historyInfo, d_history, d_oldest);
18 maybeInsert(historyInfo, d_history, d_options.historyLifetime());
2219 }
2320 );
2421 }
00 #include "history.ih"
1
2 // choice: chosen directory to cd to
13
24 void History::save(string const &choice)
35 {
4 if (d_name.empty()) // no history file in use
6 if (d_historyFilename.empty()) // no history file in use
57 return;
68
7 ofstream out(d_name);
9 ofstream out(d_historyFilename);
810 if (!out)
911 {
10 imsg << "cannot write history file `" << d_name << '\'' << endl;
12 imsg << "cannot write history file `" << d_historyFilename << '\'' <<
13 endl;
1114 return;
1215 }
1316
2528 sort(d_history.begin(), d_history.end(), compareTimes);
2629 // stable_sort(d_history.begin(), d_history.end(), compareCounts);
2730
28 string value;
29 size_t maxSize = d_arg.option(&value, "history-maxsize") ?
30 A2x(value)
31 :
32 UINT_MAX;
33
34 if (maxSize != UINT_MAX)
31 if (size_t maxSize = d_options.historyMaxSize(); maxSize != UINT_MAX)
3532 {
3633 imsg << "Max. history size: " << maxSize << endl;
3734
4239 copy(d_history.begin(), d_history.end(),
4340 ostream_iterator<HistoryInfo>(out, "\n"));
4441 }
42
+0
-46
history/setdata.cc less more
0 #include "history.ih"
1
2 void History::setData()
3 {
4 string value;
5
6 d_position =
7 d_arg.option(&value, "history-position") && value == "bottom" ?
8 BOTTOM
9 :
10 TOP;
11
12 imsg << "History elements at the " <<
13 (d_position == TOP ? "top" : "bottom") << endl;
14
15 if (not d_arg.option(&value, "history-lifetime"))
16 {
17 d_oldest = d_now - 24 * 60 * 60 * 30; // 1 month lifetime
18 imsg << "History lifetime: 1M" << endl;
19 return;
20 }
21
22 A2x a2x(value);
23
24 d_oldest = a2x;
25 if (a2x.lastFail())
26 {
27 imsg << "Cannot determine history-lifetime " << value <<
28 ", using 1M" << endl;
29
30 d_oldest = d_now - 24 * 60 * 60 * 30; // 1 month lifetime
31 }
32 else
33 {
34 int lastChar = toupper(*value.rbegin());
35
36 imsg << "History lifetime: " << d_oldest <<
37 static_cast<char>(lastChar) << endl;
38 d_oldest = d_now - d_oldest * 24 * 60 * 60 *
39 (
40 lastChar == 'W' ? 7 :
41 lastChar == 'M' ? 30 :
42 lastChar == 'Y' ? 365 : 1
43 );
44 }
45 }
55 #define LIBRARY "modules"
66 #define SHAREDREQ ""
77 #define IH ".ih"
8 #define PRECOMP "-x c++-header"
9 //#define CLS
10 //#define USE_ALL "a"
8 //#define PRECOMP "-x c++-header"
9
10 #define CLS
11
12 #define USE_ALL "a"
1113 #define SOURCES "*.cc"
1214 #define USE_ECHO ON
1315 #define TMP_DIR "tmp"
0 #define CLS
1 #define LIBRARY "modules"
2 #define SOURCES "*.cc"
3 #define OBJ_EXT ".o"
4 #define TMP_DIR "tmp"
5
6 #define USE_ECHO ON
7 #define IH ".ih"
8 //#define PRECOMP "-x c++-header"
9 //#define USE_ALL "a"
10
11 #define CXX "g++"
12 #define CXXFLAGS " --std=c++20 -Wall -O2 " \
13 " -fdiagnostics-color=never "
14
15 //#define REFRESH
16 //#define LDFLAGS "-s"
17 #define ADD_LIBRARIES "bobcat"
18 #define ADD_LIBRARY_PATHS ""
19
20 #define DEFCOM "library"
0 #include "main.ih" // program header file
0 #include "main.ih"
1
2 namespace
3 {
4 ArgConfig::LongOption longOpts[] =
5 {
6 {"add-root", ArgConfig::Required},
7 {"all", 'a'},
8 {"block-size", 'b'},
9 {"config-file", 'c'},
10 {"directories", ArgConfig::Required},
11 {"generalized-search", 'g'},
12 {"help", 'h'},
13 {"input", ArgConfig::None},
14 {"history", ArgConfig::Optional},
15 {"history-lifetime", ArgConfig::Required},
16 {"history-maxsize", ArgConfig::Required}, // history/load.cc
17 {"history-position", ArgConfig::Required}, // top, bottom
18 {"history-separate", ArgConfig::None},
19 {"homedir-char", ArgConfig::Required},
20 {"icase", 'i'},
21 {"start-at", ArgConfig::Required},
22 {"traditional", ArgConfig::None},
23 {"verbose", 'V'},
24 {"version", 'v'},
25 };
26 auto longEnd = longOpts + size(longOpts);
27 }
128
229 int main(int argc, char **argv)
330 try
431 {
5 arguments(argc, argv);
32 Options::initialize("ab:c:gihvV", longOpts, longEnd, argc, argv,
33 Icmbuild::version, usage);
634
735 Alternatives alternatives;
836 // select viable alternatives
1139
1240 alternatives.order(); // history alternatives first or last
1341
14 Filter filter(alternatives);
42 Selector selector(alternatives);
1543
16 filter.select(); // make the selection
44 selector.select(); // make the selection
1745
18 return filter.decided() ? 0 : 1; // return 0 to the OS if the filter
46 return selector.decided() ? 0 : 1; // return 0 to the OS if the selector
1947 // did do its work
2048 }
21 catch(exception const &err) // handle exceptions
49 catch(...)
2250 {
23 cerr << err.what() << endl;
24 cout << ".\n"; // to prevent a directory change
25 return 1;
51 return handle(current_exception());
2652 }
27 catch(int x)
28 {
29 if (x == 0)
30 cerr << "No Solutions\n";
3153
32 if (ArgConfig::instance().option("hv"))
33 return 0;
34
35 cout << ".\n";
36 return x;
37 }
55 #include <bobcat/argconfig>
66 #include <bobcat/mstream>
77
8 #include "options/options.h"
89 #include "alternatives/alternatives.h"
9 #include "filter/filter.h"
10 #include "selector/selector.h"
1011
1112 namespace Icmbuild
1213 {
1516 extern char author[];
1617 };
1718
18 void arguments(int argc, char **argv);
19 void usage(std::string const &progname);
20
2119 using namespace std;
2220 using namespace FBB;
21
22 int handle(exception_ptr ptr);
23 void noInput();
24 void usage(string const &progname);
25
0 #include "main.ih"
1
2 void noInput()
3 {
4 if (not Options::input())
5 cout << ".\n"; // prevents a directory change
6 }
0 #include "options.ih"
1
2 unique_ptr<Options> Options::s_options;
3
4 bool Options::s_input;
5
6 char Options::s_defaultConfig[] = ".xdrc"; // in $HOME
7 char Options::s_defaultHistory[] = ".xd.his"; // in $HOME
8
9 bool Options::s_fromHome[] = // values correspond to
10 { // s_startAt entries
11 true,
12 false,
13 true
14 };
15
16 string const Options::s_startAt[] =
17 {
18 "home",
19 "root",
20 ""
21 };
22 // the last element is used for the default value if
23 // valid alternatives aren't used
24 string const *Options::s_endStartAt = s_startAt + size(s_startAt) - 1;
25
26 bool Options::s_allDirs[] =
27 {
28 true,
29 false,
30 true
31 };
32
33 string const Options::s_dirs[] =
34 {
35 "all",
36 "unique",
37 ""
38 };
39
40 string const *Options::s_endDirs = s_dirs + size(s_dirs) - 1;
41
42 TriState Options::s_addRoot[] =
43 {
44 NEVER,
45 IF_EMPTY,
46 ALWAYS,
47 IF_EMPTY
48 };
49
50 string const Options::s_triState[] =
51 {
52 "never",
53 "if-empty",
54 "always",
55 ""
56 };
57
58 string const *Options::s_endTriState = s_triState + size(s_triState) - 1;
59
60
61
62
63
0 #include "options.ih"
1
2 size_t Options::find(char const *longOpt,
3 string const *begin, string const *end)
4 {
5 string value;
6 if (d_arg.option(&value, longOpt) == 0) // not specified, use the
7 { // default
8 imsg << "Option or configfile: No key `" << longOpt << '\'' << endl;
9 return end - begin;
10 }
11
12 auto ret = find_if(
13 begin, end,
14 [&](string const &entry)
15 {
16 return value == entry;
17 }
18 );
19
20 if (ret != end)
21 imsg << "Option or config `" << longOpt << ": " << value << '\'' <<
22 endl;
23 else
24 imsg << "`" << longOpt << " " << value <<
25 "' not supported. Using the default" << endl;
26
27 return ret - begin;
28 }
0 #include "options.ih"
1
2 // static
3 string Options::getHome()
4 {
5 string homeDir;
6
7 char *cp = getenv("HOME"); // determine the homedir
8
9 if (!cp) // save it
10 homeDir = '/';
11 else
12 {
13 homeDir = cp;
14 if (homeDir.back() != '/') // ensure final / at the homedir
15 homeDir += '/';
16 }
17
18 imsg << "Home directory: " << homeDir << endl;
19
20 return homeDir;
21 }
0 #include "options.ih"
1
2 int Options::homedirChar() const
3 {
4 string value;
5
6 if (d_arg.option(&value, "homedir-char") == 0)
7 return '.';
8
9 if ("0123456789/"s.find(value.front()) != string::npos)
10 throw Exception{ 1 } << "Character `" << value.front() <<
11 "' cannot be used as homedir-character";
12
13 return value.front();
14 }
0 ../icmconf.lib
0 #include "options.ih"
1
2 Options &Options::initialize(
3 char const *optString,
4 ArgConfig::LongOption const *const begin,
5 ArgConfig::LongOption const *const end,
6 int argc, char **argv, char const *version,
7 void (*usage)(string const &)
8 )
9 {
10 if (s_options)
11 throw Exception{} << "Options already initialized";
12
13 s_options = unique_ptr<Options>{
14 new Options{ optString, begin, end, argc, argv,
15 version, usage }
16 };
17
18 return *s_options;
19 }
0 #include "options.ih"
1
2 Options &Options::instance()
3 {
4 if (not s_options)
5 throw Exception{} << "Options not yet initialized";
6
7 return *s_options;
8 }
0 inline TriState Options::addRoot() const
1 {
2 return d_addRoot;
3 }
4
5 inline bool Options::all() const
6 {
7 return d_arg.option('a');
8 }
9
10 inline bool Options::allDirs() const
11 {
12 return d_allDirs;
13 }
14
15 inline FBB::Ranger<char const **> Options::args() const
16 {
17 return FBB::ranger(d_arg.argPointers(), d_arg.nArgs());
18 }
19
20 inline size_t Options::blockSize() const
21 {
22 return d_blockSize;
23 }
24
25
26 inline bool Options::fromHome() const
27 {
28 return d_fromHome;
29 }
30
31 inline bool Options::generalized() const
32 {
33 return d_arg.option('g');
34 }
35
36 inline size_t Options::historyLifetime() const
37 {
38 return d_historyLifetime;
39 }
40
41 inline size_t Options::historyMaxSize() const
42 {
43 return d_historyMaxSize;
44 }
45
46 inline std::string const &Options::history() const
47 {
48 return d_history;
49 }
50
51 inline std::string const &Options::homeDir() const
52 {
53 return d_homeDir;
54 }
55
56 inline size_t Options::icase() const
57 {
58 return d_arg.option('i');
59 }
60
61 // static
62 inline bool Options::input()
63 {
64 return s_input;
65 }
66
67 inline auto Options::ignore() const
68 {
69 return d_arg.beginEndRE("^\\s*ignore\\s+\\S+\\s*$");
70 }
71
72 inline size_t Options::now() const
73 {
74 return d_now;
75 }
76
77 inline Position Options::historyPosition() const
78 {
79 return d_historyPosition;
80 }
81
82 inline bool Options::separate() const
83 {
84 return d_separate;
85 }
86
87 inline bool Options::traditional() const
88 {
89 return d_arg.option(0, "traditional");
90 }
91
92
93 inline std::string const &Options::triStateStr() const
94 {
95 return s_triState[d_addRoot];
96 }
97
98
99
100
101
102
103
0 #ifndef INCLUDED_OPTIONS_
1 #define INCLUDED_OPTIONS_
2
3 #include <string>
4 #include <memory>
5
6 #include <bobcat/argconfig>
7 #include <bobcat/ranger>
8
9 #include "../enums/enums.h"
10
11 class Options
12 {
13 FBB::ArgConfig &d_arg;
14
15 bool d_allDirs;
16 TriState d_addRoot;
17 size_t d_blockSize;
18 bool d_fromHome;
19 std::string d_history; // history filename
20 size_t d_historyLifetime;
21 size_t d_historyMaxSize;
22 Position d_historyPosition;
23 std::string d_homeDir;
24 size_t d_now;
25 bool d_separate; // separate previously made choices from
26 // new ones by a blank line
27
28 static bool s_input;
29
30 static char s_defaultConfig[];
31 static char s_defaultHistory[];
32
33 static std::unique_ptr<Options> s_options;
34
35 static bool s_fromHome[];
36 static std::string const s_startAt[];
37 static std::string const *s_endStartAt;
38
39 static bool s_allDirs[];
40 static std::string const s_dirs[];
41 static std::string const *s_endDirs;
42
43 static TriState s_addRoot[];
44 static std::string const s_triState[];
45 static std::string const *s_endTriState;
46
47 public:
48 Options(Options const &other) = delete;
49
50 static Options &initialize(
51 char const *optString,
52 FBB::ArgConfig::LongOption const *const begin,
53 FBB::ArgConfig::LongOption const *const end,
54 int argc, char **argv, char const *version,
55 void (*usage)(std::string const &)
56 );
57 static Options &instance();
58
59 TriState addRoot() const; // .f
60
61 bool all() const; // option -a / --all // .f
62
63 bool allDirs() const; // .f
64
65 FBB::Ranger<char const **> args() const;
66
67 size_t blockSize() const; // .f
68
69 bool fromHome() const; // .f
70
71 bool generalized() const; // --generalized-search / -g .f
72
73 std::string const &history() const; // .f
74 size_t historyLifetime() const; // .f
75 size_t historyMaxSize() const; // .f
76
77 std::string const &homeDir() const; // .f
78
79 int homedirChar() const;
80
81 size_t icase() const; // .f
82
83 auto ignore() const; // .f
84
85 static bool input(); // .f
86
87 size_t now() const; // .f
88
89 Position historyPosition() const; // .f
90
91 bool separate() const; // .f
92
93 bool traditional() const; // --traditional .f
94
95 std::string const &triStateStr() const; // .f
96
97 private:
98 Options(char const *optString,
99 FBB::ArgConfig::LongOption const *const begin,
100 FBB::ArgConfig::LongOption const *const end,
101 int argc, char **argv, char const *version,
102 void (*usage)(std::string const &));
103
104 size_t find(char const *longOpt,
105 std::string const *begin, std::string const *end);
106
107 static std::string getHome();
108
109 std::string readConfigFile(); // ret. value not empty: imsg
110
111 void setBlockSize();
112
113 void setHistory(); // history filename
114 void setHistoryLifetime();
115 void setMaxSize();
116 void setPosition();
117
118 void versionHelp(char const *version,
119 void (*usage)(std::string const &)) const;
120
121 };
122
123 #include "options.f"
124
125 #endif
126
127
128
0 #include "options.h"
1
2 #include <ctime>
3
4 #include <iostream>
5 #include <string_view>
6 #include <algorithm>
7
8 #include <bobcat/exception>
9 #include <bobcat/mstream>
10 #include <bobcat/stat>
11
12 using namespace std;
13 using namespace FBB;
0 #define XERR
1 #include "options.ih"
2
3 Options::Options(char const *optString,
4 ArgConfig::LongOption const *const begin,
5 ArgConfig::LongOption const *const end,
6 int argc, char **argv, char const *version,
7 void (*usage)(std::string const &))
8 :
9 d_arg(ArgConfig::initialize(optString, begin, end, argc, argv)),
10 d_now(time(0)),
11 d_separate(d_arg.option(0, "history-separate"))
12 {
13 string_view last{ argv[argc - 1] }; // remove a last / from the last
14 if (last.back() == '/') // argv element
15 argv[argc - 1][last.length() - 1] = 0;
16
17 d_arg.setCommentHandling(ArgConfig::RemoveComment);
18
19 imsg.reset(cerr); // mstream messages go to cerr
20 imsg.setActive(d_arg.option('V'));
21
22 fmsg.reset(cerr);
23
24 d_homeDir = getHome();
25
26 string msg = readConfigFile();
27
28 s_input = d_arg.option(0, "input") != 0;
29
30 versionHelp(version, usage);
31
32 if (not msg.empty())
33 imsg << msg << endl;
34
35 if (s_input)
36 imsg << "shell-input a non selection/space character" << endl;
37 else
38 imsg << "xd ends at a non selection/space character" << endl;
39
40 d_fromHome = s_fromHome[ find("start-at", s_startAt, s_endStartAt) ];
41 d_allDirs = s_allDirs[ find("directories", s_dirs, s_endDirs) ];
42
43 d_addRoot = s_addRoot[ find("add-root", s_triState, s_endTriState) ];
44
45
46 setHistory(); // history filename
47 setMaxSize(); // history max size
48 setHistoryLifetime();
49 setPosition(); // history position
50 setBlockSize();
51 }
52
53
54
55
56
57
58
0 #include "options.ih"
1
2 string Options::readConfigFile()
3 {
4 string confName;
5 if (d_arg.option(&confName, 'c')) // at -c: read the specified
6 d_arg.open(confName); // configfile
7 else
8 { // otherwise
9 confName = d_homeDir + s_defaultConfig;
10
11 if (Stat confStat{ confName }; confStat)
12 {
13 if ((not confStat.mode()) & Stat::UR)
14 wmsg << "Can't read " << confName << endl;
15 else
16 d_arg.open(confName);
17 }
18 }
19
20 return "Configuration file: " + confName;
21 }
0 #include "options.ih"
1
2 void Options::setBlockSize()
3 {
4 string value;
5 d_blockSize = d_arg.option(&value, 'b') ? stoul(value) : UINT_MAX;
6
7 imsg << "Block size: " << d_blockSize << endl;
8 }
0 // --history
1 // ---------------------------------
2 // no empty non-empty
3 // default default as spec'd
4 // ----------------------------------
5
6 #include "options.ih"
7
8 void Options::setHistory() // history filename
9 {
10 if (not d_arg.option(&d_history, "history"))
11 {
12 imsg << "History file: not used" << endl;
13 return;
14 }
15
16 if (d_history.empty())
17 d_history = s_defaultHistory; // set default history filename
18
19 imsg << "History file: " << d_history << endl;
20 }
21
22
0 #include "options.ih"
1
2 void Options::setHistoryLifetime()
3 {
4 string value;
5
6 if (not d_arg.option(&value, "history-lifetime"))
7 {
8 d_historyLifetime = d_now - 24 * 60 * 60 * 30; // 1 month lifetime
9 imsg << "History lifetime: 1M" << endl;
10 return;
11 }
12
13 try
14 {
15 d_historyLifetime = stoul(value);
16 }
17 catch (...)
18 {
19 imsg << "Cannot determine history-lifetime " << value <<
20 ", using 1M" << endl;
21
22 d_historyLifetime = d_now - 24 * 60 * 60 * 30; // 1 month lifetime
23 return;
24 }
25
26 int lastChar = toupper(*value.rbegin());
27
28 imsg << "History lifetime: " << d_historyLifetime <<
29 static_cast<char>(lastChar) << endl;
30
31 d_historyLifetime = d_now - d_historyLifetime * 24 * 60 * 60 *
32 (
33 lastChar == 'W' ? 7 :
34 lastChar == 'M' ? 30 :
35 lastChar == 'Y' ? 365 : 1
36 );
37 }
0 #include "options.ih"
1
2 void Options::setMaxSize()
3 {
4 string value;
5 if (d_arg.option(&value, "history-maxsize"))
6 {
7 d_historyMaxSize = stoul(value);
8 imsg << "History max size: " << d_historyMaxSize << " elements" <<
9 endl;
10 }
11 else
12 {
13 d_historyMaxSize = UINT_MAX;
14 imsg << "History max size: none" << endl;
15 }
16 }
0 #include "options.ih"
1
2 void Options::setPosition()
3 {
4 string value;
5
6 d_historyPosition =
7 d_arg.option(&value, "history-position") && value == "bottom" ?
8 BOTTOM
9 :
10 TOP;
11
12 imsg << "History elements at the " <<
13 (d_historyPosition == TOP ? "top" : "bottom") << endl;
14
15 }
0 #include "options.ih"
1
2 void Options::versionHelp(char const *version,
3 void (*usage)(string const &)) const
4 {
5 streambuf *buf = cout.rdbuf(cerr.rdbuf()); // make sure that
6 try // versionHelp doesn't
7 { // write to cout
8
9 d_arg.versionHelp(usage, version, 1); // need at least 1 arg
10 cout.rdbuf(buf); // insert the help
11 }
12 catch(...)
13 {
14 cout.rdbuf(buf); // missing argument:
15 throw; // help is provided and
16 // ends the program
17 }
18
19 }
0 #std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >#std::string#
1 #, std::default_delete<Record>##
2 #std::__detail::_Node_iterator<std::pair<unsigned long const, std::unique_ptr<Record > >, false, false>#RecordMap::iterator#
3 #, std::hash<unsigned long>, std::equal_to<unsigned long>, std::allocator<std::pair<unsigned long const, IPbase::KeyMapStruct> >##
4 #[abi:cxx11]##
5 #std::set<std::string, std::less<std::string >, std::allocator<std::string > >#std::set<std::string>#
0 #include "selector.ih"
1
2 // alternatives is +.> or -,<
3 // if ch in alternatives, use alternatives.front() for accepted:
4 // accepted is + - or -+
5 //
6
7 // static
8 bool Selector::accept(int ch, string const &alternatives,
9 string const &accepted)
10 {
11 return alternatives.find(ch) != string::npos // +.> -,< or both
12 and
13 accepted.find(alternatives.front()) != string::npos;
14 }
0 #include "selector.ih"
1
2 Selector::Action Selector::action(Block const &block)
3 {
4 OneKey oneKey;
5
6 int ch = oneKey.get(); // get the reply
7
8 if (accept(ch, s_inc, block.prompt)) // go to the next block
9 return INC;
10
11 if (accept(ch, s_dec, block.prompt)) // to the previous block
12 return DEC;
13
14 string blockChars = s_allChars.substr(0, block.end - block.begin);
15
16 if (size_t idx = blockChars.find(ch); idx != string::npos)
17 d_index = block.begin + idx;
18 else
19 d_index = block.end;
20
21 //cerr << "action: ch = " << (char)ch << ", int: " << ch <<
22 //", d_index = " << d_index <<
23 //"selected: " << d_alternatives[d_index] << '\n';
24
25 if (ch == '\n') // change \n to ' ' to
26 ch = ' '; // prevent extra prompt
27
28 if (d_index < block.end) // directory was selected
29 chdir(); // chdir to the alt.[d_index]
30 else
31 noCD(ch); // at --input: shell-input
32 // the entered character
33 return INPUT;
34 }
0 #include "selector.ih"
1
2 vector<Selector::Block> Selector::blockVector(size_t nBlocks)
3 {
4 vector<Block> blocks(nBlocks, {0, 0, "-+" });
5
6 blocks.front().prompt = "+";
7 blocks.front().end = d_blockSize;
8
9 for (size_t idx = 1, end = blocks.size(); idx != end; ++idx)
10 set(blocks[idx], blocks[idx - 1].end);
11
12 blocks.back().prompt = "-";
13
14 if (blocks.back().end > d_index) // back may not exceed
15 blocks.back().end = d_index; // nAlternatives
16
17 set(*(blocks.rbegin() + 1), blocks.back()); // inspect the last two sizes
18
19 return blocks;
20 }
0 #include "selector.ih"
1
2 void Selector::chdir()
3 {
4 d_chdir = true;
5
6 if (d_ioctl) // --input was specified.
7 input("cd " + d_alternatives[d_index] + '\n');
8 else
9 cout << d_alternatives[d_index] << '\n';
10 }
0 #include "selector.ih"
1
2 string Selector::s_allChars{ "123456790"
3 "abcdefghijklmnopqrstuvwxyz"
4 "ABCDEFGHIJKLMNOPQRSTUVWXYZ" };
5
6 string Selector::s_inc{ "+.>" };
7 string Selector::s_dec{ "-,<" };
8
0 #include "selector.ih"
1
2 bool Selector::decided() const
3 {
4 if (not d_chdir)
5 return false;
6
7 d_alternatives.update(d_index);
8 return true;
9 }
0 ../icmconf.lib
0 #include "selector.ih"
1
2 // static
3 void Selector::input(string const &text)
4 {
5 Tty tty{ Tty::OFF };
6
7 for (char ch: text)
8 ioctl(0, TIOCSTI, &ch);
9 }
0 #include "selector.ih"
1
2 void Selector::noCD(int ch)
3 {
4 if (not d_ioctl)
5 cout << ".\n";
6 else // --input was specified.
7 {
8 if (not isblank(ch))
9 input(string{ static_cast<char>(ch) });
10 }
11 }
0 #include "selector.ih"
1
2 void Selector::select()
3 {
4 switch (d_alternatives.size())
5 {
6 case 0: // no alternatives, throw avoids
7 throw 0; // updating the alternatives hist.
8
9 case 1: // one alternative: do the cd
10 imsg << endl;
11 d_index = 0;
12 chdir();
13 break;
14
15 default: // otherwise: show all alternatives
16 showAlternatives(); // show the alternatives
17 break;
18 }
19 }
0 #ifndef _SELECTOR_H_
1 #define _SELECTOR_H_
2
3 #include <iosfwd>
4 #include <string>
5 #include <vector>
6
7 class Alternatives;
8
9 class Selector
10 {
11 enum
12 {
13 MIN_BLOCK_SIZE = 5
14 };
15
16 enum Action
17 {
18 DEC,
19 INC,
20 INPUT
21 };
22
23 struct Block
24 {
25 size_t begin;
26 size_t end;
27 std::string prompt;
28 };
29
30 Alternatives &d_alternatives;
31
32 size_t d_index; // constructor: #alternatives,
33 // at select(): selected alternative
34 size_t d_blockSize;
35 bool d_ioctl; // true: --input was specified
36 bool d_chdir; // a chdir decision was made
37
38 std::string d_selectChars; // d_blockSize substr of s_allChars
39
40 static std::string s_dec; // chars used to inc. the block-index
41 static std::string s_inc; // chars used to dec. the block-index
42 static std::string s_allChars; // all possible alternative selection
43 // chars.
44
45 public:
46 Selector(Alternatives &alternatives);
47
48 void select();
49 bool decided() const;
50
51 private:
52 static bool accept(int ch, std::string const &alternatives,
53 std::string const &accepted);
54 Action action(Block const &block);
55 std::vector<Block> blockVector(size_t nBlocks);
56
57 void chdir(); // changes dir to d_alt.[d_index]
58 static void input(std::string const &text);
59 void noCD(int ch);
60 // set bextBlock's begin/end
61 // fields
62 void set(Block &nextBlock, size_t lastEnd) const; // 1
63 void set(Block &beforeLast, Block &last); // 2
64 void setBlockSize();
65 void showAlternatives();
66 void show(Block const &block) const;
67
68 // unused:
69 // size_t show(size_t begin, char first, char last,
70 // size_t separateAt) const;
71 };
72
73 #endif
0 #include "selector.h"
1
2 #include <sys/ioctl.h>
3
4 #include <iostream>
5 #include <iomanip>
6
7 #include <bobcat/onekey>
8 #include <bobcat/mstream>
9 #include <bobcat/tty>
10
11 #include "../options/options.h"
12 #include "../alternatives/alternatives.h"
13
14 using namespace std;
15 using namespace FBB;
0 #include "selector.ih"
1
2 Selector::Selector(Alternatives &alternatives)
3 :
4 d_alternatives(alternatives),
5 d_index(d_alternatives.size()),
6 d_ioctl(Options::instance().input()),
7 d_chdir(false)
8 {
9 setBlockSize();
10
11 // d_selectChars = s_selectChars.substr(0, d_blockSize);
12 }
0 #include "selector.ih"
1
2 void Selector::set(Block &nextBlok, size_t lastEnd) const
3 {
4 nextBlok.begin = lastEnd;
5 nextBlok.end = lastEnd + d_blockSize;
6 }
0 #include "selector.ih"
1
2 void Selector::set(Block &beforeLast, Block &last)
3 {
4 if (last.end - last.begin >= MIN_BLOCK_SIZE) // last block: big enough
5 return;
6
7 size_t beforeSize = (last.end - beforeLast.begin + 1) / 2;
8
9 beforeLast.end = beforeLast.begin + beforeSize;
10 last.begin = beforeLast.end;
11 }
0 #include "selector.ih"
1
2 void Selector::setBlockSize()
3 {
4 // blockSize cannot exceed the #available
5 // selection chars or the #available
6 // alternatives
7 d_blockSize = Options::instance().blockSize();
8
9 if (d_blockSize < MIN_BLOCK_SIZE)
10 d_blockSize = MIN_BLOCK_SIZE;
11 else if (d_blockSize > d_index)
12 d_blockSize = d_index <= s_allChars.size() ? d_index
13 : s_allChars.size();
14 }
15
0 #include "selector.ih"
1
2 void Selector::show(Block const &block) const
3 {
4 imsg << endl;
5
6 for (
7 size_t chIdx = 0, idx = block.begin,
8 separateAt = d_alternatives.separateAt();
9 idx != block.end;
10 ++idx, ++chIdx
11 )
12 {
13 if (idx == separateAt)
14 cerr << '\n';
15 cerr << setw(2) << s_allChars[chIdx] << ": " <<
16 d_alternatives[idx] << '\n';
17 }
18
19 if (not block.prompt.empty())
20 cerr << ' ' << block.prompt << '\n';
21 }
22
0 #include "selector.ih"
1
2 void Selector::showAlternatives()
3 {
4 // # used blocks
5 size_t nBlocks = (d_index + d_blockSize - 1) / d_blockSize;
6
7 if (nBlocks == 1) // one block:
8 {
9 Block block{ 0, d_index, "" };
10 show(block); // show the alternatives
11 action(block); // and make a selection
12 return;
13 }
14
15 vector<Block> blocks = blockVector(nBlocks);
16
17 size_t idx = 0;
18 while (true)
19 {
20 show(blocks[idx]);
21 switch (action(blocks[idx]))
22 {
23 case Action::DEC:
24 --idx;
25 break;
26
27 case Action::INC:
28 ++idx;
29 break;
30
31 case Action::INPUT:
32 return;
33 }
34 }
35 }
36
37
38
00 // usage.cc
11
22 #include "main.ih"
3
4 namespace
5 {
6
7 char const info1[] =
8 R"( [options] args
9 Where:
10 [options] - optional arguments (short options and default values between
11 parentheses):
12 --all (-a) - skip `ignore' specification in the
13 configuration file
14 --block-size (-b) size - show the alternatives in blocks of max.
15 'size' alternatives (spacebar to continue)
16 --config-file (-c) <file> - path to the config file to use
17 ($HOME/.xdrc)
18 --add-root <when> - search expansions from / (if-empty)
19 --directories <which> - which directories to show? (default: all)
20 --generalized-search (-g) - use the GDS mode
21 --help (-h) - provide this help
22 --history <fname> - use <fname> to store info about choices
23 (no history unless specified)
24 --history-lifetime <spec> - specify the max. lifetime of previously made
25 choices. Use <int>[DWMY] for a lifetime of
26 Days, Months, Weeks, or Years
27 --history-position <where = TOP> - where to put the previously made choices
28 (TOP, BOTTOM)
29 --history-maxsize <size = UINT_MAX> - display at most <size> previously
30 made choices
31 --history-separate - separate previously made choices from new ones
32 by a blank line (not with --block-size)
33 --input - a non-selection character ends XD and is entered
34 into the shell's input stream
35 --start-at <origin> - where to start the search? (default: home dir.)
36 --traditional - use the traditional mode
37 --version (-v) - show version information and terminate
38 --verbose (-V) - show )";
39
40 char const info2[] =
41 R"('s actions in detail
42 args - arguments, possibly containing directory separators [/-].
43
44 )";
45
46 char const info3[] =
47 R"( eXchanges Directories by interpreting the characters of its
48 argument(s) as the initial characters of nested subdirectories.
49 Multiple arguments or arguments separated by / or - define the
50 initial characters of subsequently nested subdirectories.
51
52 If the first argument starts with . expansion starts at the user's
53 home directory; if it's 0 expansion starts in the current directory;
54 if it's / expansion starts at the root; if it's a number (1 .. 9)
55 expansion starts at parent <number>; otherwise expansion starts
56 at the location defined by the configuration file
57
58 When the specification results in multiple solutions, a final
59 selection is requested from a displayed list of alternatives.
60
61 Use 'man xd' or read the xdrc file provided with the distribution
62 for details about ")";
63
64 char const info4[] =
65 R"('s configuration file
66
67 )";
68
69 }
370
471 void usage(std::string const &progname)
572 {
774 progname << " by " << Icmbuild::author << "\n" <<
875 progname << " V" << Icmbuild::version << " " << Icmbuild::year << "\n"
976 "\n"
10 "Usage: " << progname << " [options] args\n"
11 "Where:\n"
12 " [options] - optional arguments (short options and default values "
13 "between\n"
14 " parentheses):\n"
15 " --all (-a) - skip `ignore' specification in the\n"
16 " configuration file\n"
17 " --config-file (-c) <file> - path to the config file to use\n"
18 " ($HOME/.xdrc)\n"
19 " --add-root <when> - search expansions from /\n"
20 " (if-empty)\n"
21 " --directories <which> - which directories to show?\n"
22 " (all)\n"
23 " --generalized-search (-g) - use the GDS mode\n"
24 " --help (-h) - provide this help\n"
25 " --history <fname> - use <fname> to store info about choices\n"
26 " (no history unless specified)\n"
27 " --history-lifetime <spec> - specify the max. lifetime of previously "
28 "made\n"
29 " choices. Use <int>[DWMY] for a lifetime\n"
30 " of Days, Months, Weeks, or Years\n"
31 " --history-position <where = TOP> - where to put the previously made "
32 "choices\n"
33 " (TOP, BOTTOM)\n"
34 " --history-maxsize <size = UINT_MAX> - display at most <size> "
35 "previously\n"
36 " made choices\n"
37 " --history-separate - separate previously made choices from new\n"
38 " ones by a blank line\n"
77 "Usage: " << progname << info1 << progname << info2 <<
78 progname << info3 << progname << info4;
79 }
3980
40 " --start-at <origin> - where to start the search? (home)\n"
41 " --traditional - use the traditional mode\n"
42 " --version (-v) - show version information and terminate\n"
43 " --verbose (-V) - show " << progname << "'s actions in "
44 "detail\n"
45 " args - arguments, possibly containing directory separators [/-].\n"
46 "\n" <<
47 progname <<
48 " eXchanges Directories by interpreting the characters of its\n"
49 "argument(s) as the initial characters of nested subdirectories.\n"
50 "Multiple arguments or arguments separated by / or - define the\n"
51 "initial characters of subsequently nested subdirectories.\n"
52 "\n"
53 "If the first argument starts with . expansion starts at the user's\n"
54 "home directory; if it's 0 expansion starts in the current directory;\n"
55 "if it's / expansion starts at the root; if it's a number (1 .. 9) \n"
56 "expansion starts at parent <number>; otherwise expansion starts\n"
57 "at the location defined by the configuration file\n"
58 "\n"
59 "When the specification results in multiple solutions, a final\n"
60 "selection is requested from a displayed list of alternatives.\n"
61 "\n"
62 "Use 'man xd' or read the xdrc file provided with the distribution\n"
63 "for details about " << progname << "'s configuration file\n"
64 "\n";
65 }
81
82
83
84
85
+0
-1
xd less more
0 xd
+531
-189
xd.xref less more
00 oxref by Frank B. Brokken (f.b.brokken@rug.nl)
1 oxref V1.00.06 2012-2015
2
3 CREATED Thu, 24 Jan 2019 10:58:07 +0000
4 CROSS REFERENCE FOR: -fxs tmp/libmodules.a
1 oxref V2.00.01 2012-2021
2
3 CREATED Sun, 19 Jun 2022 10:48:53 +0000
4 CROSS REFERENCE FOR: -r replacements -t main -fxs tmp/libmodules.a tmp/main.o
5
56 ----------------------------------------------------------------------
7 CROSS REFERENCE LISTING:
8
9 accept(int, std::string const&, std::string const&)
10 Full name: Selector::accept(int, std::string const&, std::string const&)
11 Source: accept.cc
12 Used By:
13 action.cc: Selector::action(Selector::Block const&)
14
15 action(Selector::Block const&)
16 Full name: Selector::action(Selector::Block const&)
17 Source: action.cc
18 Used By:
19 showalternatives.cc: Selector::showAlternatives()
620
721 add(char const*)
822 Full name: Alternatives::add(char const*)
9 Source: add.cc
23 Source: add.cc
1024 Used By:
1125 globfilter.cc: Alternatives::globFilter(char const*, Alternatives::GlobContext&)
1226
13 addIgnored(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&)
14 Full name: Alternatives::addIgnored(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::set<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::less<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > >&)
15 Source: addignored.cc
16 Used By:
17 globfrom.cc: Alternatives::globFrom(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
27 addIgnored(std::string const&, std::set<std::string>&)
28 Full name: Alternatives::addIgnored(std::string const&, std::set<std::string>&)
29 Source: addignored.cc
30 Used By:
31 globfrom.cc: Alternatives::globFrom(std::string)
32
33 Alternatives()
34 Full name: Alternatives::Alternatives()
35 Source: alternatives1.cc
36 Used By:
37 main.cc: main
1838
1939 author
2040 Full name: Icmbuild::author
21 Source: version.cc
22 Used By:
23 usage.cc: usage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
24
25 checkCase(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, unsigned long*) const
26 Full name: Alternatives::checkCase(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, unsigned long*) const
27 Source: checkcase.cc
28 Used By:
29 globpattern.cc: Alternatives::globPattern(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, unsigned long*, Alternatives::GlobContext&)
41 Source: version.cc
42 Used By:
43 usage.cc: usage(std::string const&)
44
45 blockVector(unsigned long)
46 Full name: Selector::blockVector(unsigned long)
47 Source: blockvector.cc
48 Used By:
49 showalternatives.cc: Selector::showAlternatives()
50
51 chdir()
52 Full name: Selector::chdir()
53 Source: chdir.cc
54 Used By:
55 action.cc: Selector::action(Selector::Block const&)
56 select.cc: Selector::select()
57
58 checkCase(std::string&, unsigned long*) const
59 Full name: Alternatives::checkCase(std::string&, unsigned long*) const
60 Source: checkcase.cc
61 Used By:
62 globpattern.cc: Alternatives::globPattern(std::string, std::string&, unsigned long*, Alternatives::GlobContext&)
3063
3164 Command()
3265 Full name: Command::Command()
33 Source: command1.cc
66 Source: command1.cc
3467 Used By:
3568 alternatives1.cc: Alternatives::Alternatives()
3669
3770 compareTimes(History::HistoryInfo const&, History::HistoryInfo const&)
3871 Full name: History::compareTimes(History::HistoryInfo const&, History::HistoryInfo const&)
39 Source: comparetimes.cc
40 Used By:
41 save.cc: History::save(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
72 Source: comparetimes.cc
73 Used By:
74 save.cc: History::save(std::string const&)
4275
4376 concatArgs()
4477 Full name: Command::concatArgs()
45 Source: concatargs.cc
78 Source: concatargs.cc
4679 Used By:
4780 command1.cc: Command::Command()
4881
49 configFile()
50 Full name: Alternatives::configFile()
51 Source: configfile.cc
52 Used By:
53 alternatives1.cc: Alternatives::Alternatives()
54
55 cxx11]()
56 Full name: Alternatives::determineInitialDirectory[abi:cxx11]()
57 Source: determineinitialdir.cc
58 Used By:
59 viable.cc: Alternatives::viable()
60
61 cxx11]()
62 Full name: Alternatives::getHome[abi:cxx11]()
63 Source: gethome.cc
64 Used By:
65 alternatives1.cc: Alternatives::Alternatives()
82 decided() const
83 Full name: Selector::decided() const
84 Source: decided.cc
85 Used By:
86 main.cc: main
6687
6788 determineAction()
6889 Full name: Command::determineAction()
69 Source: determineaction.cc
90 Source: determineaction.cc
7091 Used By:
7192 command1.cc: Command::Command()
7293
73 generalizedGlob(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, Alternatives::GlobContext&)
74 Full name: Alternatives::generalizedGlob(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, Alternatives::GlobContext&)
75 Source: generalizedglob.cc
76 Used By:
77 globfrom.cc: Alternatives::globFrom(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
94 determineInitialDirectory()
95 Full name: Alternatives::determineInitialDirectory()
96 Source: determineinitialdir.cc
97 Used By:
98 viable.cc: Alternatives::viable()
99
100 dotPattern(std::string const&, Alternatives::GlobContext const&)
101 Full name: Alternatives::dotPattern(std::string const&, Alternatives::GlobContext const&)
102 Source: dotpattern.cc
103 Used By:
104 globfilter.cc: Alternatives::globFilter(char const*, Alternatives::GlobContext&)
105
106 find(char const*, std::string const*, std::string const*)
107 Full name: Options::find(char const*, std::string const*, std::string const*)
108 Source: find.cc
109 Used By:
110 options1.cc: Options::Options(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
111
112 generalizedGlob(std::string, Alternatives::GlobContext&)
113 Full name: Alternatives::generalizedGlob(std::string, Alternatives::GlobContext&)
114 Source: generalizedglob.cc
115 Used By:
116 globfrom.cc: Alternatives::globFrom(std::string)
78117
79118 getCwd(std::unique_ptr<char, std::default_delete<char> >*)
80119 Full name: Alternatives::getCwd(std::unique_ptr<char, std::default_delete<char> >*)
81 Source: getcwd.cc
82 Used By:
83 determineinitialdir.cc: Alternatives::determineInitialDirectory[abi:cxx11]()
84
85 glob(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, Alternatives::GlobContext&)
86 Full name: Alternatives::glob(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, Alternatives::GlobContext&)
87 Source: glob.cc
88 Used By:
89 globfrom.cc: Alternatives::globFrom(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
120 Source: getcwd.cc
121 Used By:
122 determineinitialdir.cc: Alternatives::determineInitialDirectory()
123
124 getHome()
125 Full name: Options::getHome()
126 Source: gethome.cc
127 Used By:
128 options1.cc: Options::Options(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
129
130 glob(std::string, Alternatives::GlobContext&)
131 Full name: Alternatives::glob(std::string, Alternatives::GlobContext&)
132 Source: glob.cc
133 Used By:
134 globfrom.cc: Alternatives::globFrom(std::string)
90135
91136 globFilter(char const*, Alternatives::GlobContext&)
92137 Full name: Alternatives::globFilter(char const*, Alternatives::GlobContext&)
93 Source: globfilter.cc
94 Used By:
95 glob.cc: Alternatives::glob(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, Alternatives::GlobContext&)
96 globpattern.cc: Alternatives::globPattern(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, unsigned long*, Alternatives::GlobContext&)
97
98 globFrom(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
99 Full name: Alternatives::globFrom(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)
100 Source: globfrom.cc
138 Source: globfilter.cc
139 Used By:
140 glob.cc: Alternatives::glob(std::string, Alternatives::GlobContext&)
141 globpattern.cc: Alternatives::globPattern(std::string, std::string&, unsigned long*, Alternatives::GlobContext&)
142
143 globFrom(std::string)
144 Full name: Alternatives::globFrom(std::string)
145 Source: globfrom.cc
101146 Used By:
102147 viable.cc: Alternatives::viable()
103148
104 globHead(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, Alternatives::GlobContext&)
105 Full name: Alternatives::globHead(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, Alternatives::GlobContext&)
106 Source: globhead.cc
107 Used By:
108 generalizedglob.cc: Alternatives::generalizedGlob(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, Alternatives::GlobContext&)
109 globpattern.cc: Alternatives::globPattern(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, unsigned long*, Alternatives::GlobContext&)
110
111 globPattern(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, unsigned long*, Alternatives::GlobContext&)
112 Full name: Alternatives::globPattern(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >&, unsigned long*, Alternatives::GlobContext&)
113 Source: globpattern.cc
114 Used By:
115 globhead.cc: Alternatives::globHead(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, Alternatives::GlobContext&)
116
117 History(FBB::ArgConfig&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
118 Full name: History::History(FBB::ArgConfig&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
119 Source: history1.cc
149 globHead(std::string const&, std::string, Alternatives::GlobContext&)
150 Full name: Alternatives::globHead(std::string const&, std::string, Alternatives::GlobContext&)
151 Source: globhead.cc
152 Used By:
153 generalizedglob.cc: Alternatives::generalizedGlob(std::string, Alternatives::GlobContext&)
154 globpattern.cc: Alternatives::globPattern(std::string, std::string&, unsigned long*, Alternatives::GlobContext&)
155
156 globPattern(std::string, std::string&, unsigned long*, Alternatives::GlobContext&)
157 Full name: Alternatives::globPattern(std::string, std::string&, unsigned long*, Alternatives::GlobContext&)
158 Source: globpattern.cc
159 Used By:
160 globhead.cc: Alternatives::globHead(std::string const&, std::string, Alternatives::GlobContext&)
161
162 handle(std::__exception_ptr::exception_ptr)
163 Full name: handle(std::__exception_ptr::exception_ptr)
164 Source: handle.cc
165 Used By:
166 main.cc: main
167
168 History()
169 Full name: History::History()
170 Source: history1.cc
120171 Used By:
121172 alternatives1.cc: Alternatives::Alternatives()
122173
123 load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
124 Full name: History::load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
125 Source: load.cc
126 Used By:
127 history1.cc: History::History(FBB::ArgConfig&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
128
129 matchIgnore(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
130 Full name: Alternatives::matchIgnore(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
131 Source: matchignore.cc
132 Used By:
133 globfilter.cc: Alternatives::globFilter(char const*, Alternatives::GlobContext&)
174 homedirChar() const
175 Full name: Options::homedirChar() const
176 Source: homedirchar.cc
177 Used By:
178 command1.cc: Command::Command()
179
180 initialize(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
181 Full name: Options::initialize(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
182 Source: initialize.cc
183 Used By:
184 main.cc: main
185
186 input(std::string const&)
187 Full name: Selector::input(std::string const&)
188 Source: input.cc
189 Used By:
190 chdir.cc: Selector::chdir()
191 nocd.cc: Selector::noCD(int)
192
193 instance()
194 Full name: Options::instance()
195 Source: instance.cc
196 Used By:
197 command1.cc: Command::Command()
198 concatargs.cc: Command::concatArgs()
199 alternatives1.cc: Alternatives::Alternatives()
200 selector1.cc: Selector::Selector(Alternatives&)
201 setblocksize.cc: Selector::setBlockSize()
202 history1.cc: History::History()
203
204 load()
205 Full name: History::load()
206 Source: load.cc
207 Used By:
208 history1.cc: History::History()
209
210 matchIgnore(std::string const&, std::string const&)
211 Full name: Alternatives::matchIgnore(std::string const&, std::string const&)
212 Source: matchignore.cc
213 Used By:
214 dotpattern.cc: Alternatives::dotPattern(std::string const&, Alternatives::GlobContext const&)
134215
135216 maybeInsert(History::HistoryInfo const&, std::vector<History::HistoryInfo, std::allocator<History::HistoryInfo> >&, unsigned long)
136217 Full name: History::maybeInsert(History::HistoryInfo const&, std::vector<History::HistoryInfo, std::allocator<History::HistoryInfo> >&, unsigned long)
137 Source: maybeinsert.cc
138 Used By:
139 load.cc: History::load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
218 Source: maybeinsert.cc
219 Used By:
220 load.cc: History::load()
221
222 noCD(int)
223 Full name: Selector::noCD(int)
224 Source: nocd.cc
225 Used By:
226 action.cc: Selector::action(Selector::Block const&)
227
228 noInput()
229 Full name: noInput()
230 Source: noinput.cc
231 Used By:
232 handle.cc: handle(std::__exception_ptr::exception_ptr)
140233
141234 operator>>(std::istream&, History::HistoryInfo&)
142235 Full name: operator>>(std::istream&, History::HistoryInfo&)
143 Source: infoopextract.cc
144 Used By:
145 load.cc: History::load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
236 Source: infoopextract.cc
237 Used By:
238 load.cc: History::load()
239
240 Options(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
241 Full name: Options::Options(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
242 Source: options1.cc
243 Used By:
244 initialize.cc: Options::initialize(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
245
246 order()
247 Full name: Alternatives::order()
248 Source: order.cc
249 Used By:
250 main.cc: main
251
252 readConfigFile()
253 Full name: Options::readConfigFile()
254 Source: readconfigfile.cc
255 Used By:
256 options1.cc: Options::Options(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
146257
147258 s_action
148259 Full name: Command::s_action
149 Source: data.cc
260 Source: data.cc
150261 Used By:
151262 command1.cc: Command::Command()
152263
264 s_addRoot
265 Full name: Options::s_addRoot
266 Source: data.cc
267 Used By:
268 options1.cc: Options::Options(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
269
270 s_allChars
271 Full name: Selector::s_allChars
272 Source: data.cc
273 Used By:
274 action.cc: Selector::action(Selector::Block const&)
275 setblocksize.cc: Selector::setBlockSize()
276 show.cc: Selector::show(Selector::Block const&) const
277
278 s_allDirs
279 Full name: Options::s_allDirs
280 Source: data.cc
281 Used By:
282 options1.cc: Options::Options(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
283
284 s_dec
285 Full name: Selector::s_dec
286 Source: data.cc
287 Used By:
288 action.cc: Selector::action(Selector::Block const&)
289
153290 s_defaultConfig
154 Full name: Alternatives::s_defaultConfig
155 Source: data.cc
156 Used By:
157 configfile.cc: Alternatives::configFile()
291 Full name: Options::s_defaultConfig
292 Source: data.cc
293 Used By:
294 readconfigfile.cc: Options::readConfigFile()
158295
159296 s_defaultHistory
160 Full name: History::s_defaultHistory
161 Source: data.cc
162 Used By:
163 load.cc: History::load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
297 Full name: Options::s_defaultHistory
298 Source: data.cc
299 Used By:
300 sethistory.cc: Options::setHistory()
164301
165302 s_dirs
166 Full name: Alternatives::s_dirs
167 Source: data.cc
168 Used By:
169 viable.cc: Alternatives::viable()
170
171 s_dirsEnd
172 Full name: Alternatives::s_dirsEnd
173 Source: data.cc
174 Used By:
175 viable.cc: Alternatives::viable()
303 Full name: Options::s_dirs
304 Source: data.cc
305 Used By:
306 options1.cc: Options::Options(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
307
308 s_endDirs
309 Full name: Options::s_endDirs
310 Source: data.cc
311 Used By:
312 options1.cc: Options::Options(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
313
314 s_endStartAt
315 Full name: Options::s_endStartAt
316 Source: data.cc
317 Used By:
318 options1.cc: Options::Options(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
319
320 s_endTriState
321 Full name: Options::s_endTriState
322 Source: data.cc
323 Used By:
324 options1.cc: Options::Options(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
325
326 s_fromHome
327 Full name: Options::s_fromHome
328 Source: data.cc
329 Used By:
330 options1.cc: Options::Options(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
331
332 s_inc
333 Full name: Selector::s_inc
334 Source: data.cc
335 Used By:
336 action.cc: Selector::action(Selector::Block const&)
337
338 s_input
339 Full name: Options::s_input
340 Source: data.cc
341 Used By:
342 noinput.cc: noInput()
343 options1.cc: Options::Options(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
344 selector1.cc: Selector::Selector(Alternatives&)
345
346 s_options
347 Full name: Options::s_options
348 Source: data.cc
349 Used By:
350 initialize.cc: Options::initialize(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
351 instance.cc: Options::instance()
176352
177353 s_separators
178354 Full name: Command::s_separators
179 Source: data.cc
355 Source: data.cc
180356 Used By:
181357 command1.cc: Command::Command()
182358
183359 s_startAt
184 Full name: Alternatives::s_startAt
185 Source: data.cc
186 Used By:
360 Full name: Options::s_startAt
361 Source: data.cc
362 Used By:
363 options1.cc: Options::Options(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
364
365 s_triState
366 Full name: Options::s_triState
367 Source: data.cc
368 Used By:
369 options1.cc: Options::Options(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
187370 viable.cc: Alternatives::viable()
188371
189 s_startAtEnd
190 Full name: Alternatives::s_startAtEnd
191 Source: data.cc
192 Used By:
193 viable.cc: Alternatives::viable()
194
195 s_triState
196 Full name: Alternatives::s_triState
197 Source: data.cc
198 Used By:
199 viable.cc: Alternatives::viable()
200
201 s_triStateEnd
202 Full name: Alternatives::s_triStateEnd
203 Source: data.cc
204 Used By:
205 viable.cc: Alternatives::viable()
206
207 save(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
208 Full name: History::save(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
209 Source: save.cc
210 Used By:
211 decided.cc: Filter::decided() const
372 save(std::string const&)
373 Full name: History::save(std::string const&)
374 Source: save.cc
375 Used By:
376 decided.cc: Selector::decided() const
377
378 select()
379 Full name: Selector::select()
380 Source: select.cc
381 Used By:
382 main.cc: main
383
384 Selector(Alternatives&)
385 Full name: Selector::Selector(Alternatives&)
386 Source: selector1.cc
387 Used By:
388 main.cc: main
212389
213390 separateAt() const
214391 Full name: Alternatives::separateAt() const
215 Source: separateat.cc
216 Used By:
217 showalternatives.cc: Filter::showAlternatives() const
218
219 set(char const*, char const* const*, char const* const*, unsigned long)
220 Full name: Alternatives::set(char const*, char const* const*, char const* const*, unsigned long)
221 Source: set2.cc
222 Used By:
223 viable.cc: Alternatives::viable()
224
225 setData()
226 Full name: History::setData()
227 Source: setdata.cc
228 Used By:
229 history1.cc: History::History(FBB::ArgConfig&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
230
231 setIndex()
232 Full name: Filter::setIndex()
233 Source: setindex.cc
234 Used By:
235 select.cc: Filter::select()
236
237 show(unsigned long, char, char, unsigned long) const
238 Full name: Filter::show(unsigned long, char, char, unsigned long) const
239 Source: show.cc
240 Used By:
241 showalternatives.cc: Filter::showAlternatives() const
242
243 showAlternatives() const
244 Full name: Filter::showAlternatives() const
245 Source: showalternatives.cc
246 Used By:
247 select.cc: Filter::select()
248
249 usage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
250 Full name: usage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
251 Source: usage.cc
252 Used By:
253 arguments.cc: arguments(int, char**)
392 Source: separateat.cc
393 Used By:
394 show.cc: Selector::show(Selector::Block const&) const
395
396 set(Selector::Block&, Selector::Block&)
397 Full name: Selector::set(Selector::Block&, Selector::Block&)
398 Source: set2.cc
399 Used By:
400 blockvector.cc: Selector::blockVector(unsigned long)
401
402 set(Selector::Block&, unsigned long) const
403 Full name: Selector::set(Selector::Block&, unsigned long) const
404 Source: set1.cc
405 Used By:
406 blockvector.cc: Selector::blockVector(unsigned long)
407
408 setBlockSize()
409 Full name: Selector::setBlockSize()
410 Source: setblocksize.cc
411 Used By:
412 selector1.cc: Selector::Selector(Alternatives&)
413
414 setBlockSize()
415 Full name: Options::setBlockSize()
416 Source: setblocksize.cc
417 Used By:
418 options1.cc: Options::Options(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
419
420 setHistory()
421 Full name: Options::setHistory()
422 Source: sethistory.cc
423 Used By:
424 options1.cc: Options::Options(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
425
426 setHistoryLifetime()
427 Full name: Options::setHistoryLifetime()
428 Source: sethistorylifetime.cc
429 Used By:
430 options1.cc: Options::Options(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
431
432 setMaxSize()
433 Full name: Options::setMaxSize()
434 Source: setmaxsize.cc
435 Used By:
436 options1.cc: Options::Options(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
437
438 setPosition()
439 Full name: Options::setPosition()
440 Source: setposition.cc
441 Used By:
442 options1.cc: Options::Options(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
443
444 show(Selector::Block const&) const
445 Full name: Selector::show(Selector::Block const&) const
446 Source: show.cc
447 Used By:
448 showalternatives.cc: Selector::showAlternatives()
449
450 showAlternatives()
451 Full name: Selector::showAlternatives()
452 Source: showalternatives.cc
453 Used By:
454 select.cc: Selector::select()
455
456 splitBase()
457 Full name: Command::splitBase()
458 Source: splitbase.cc
459 Used By:
460 command1.cc: Command::Command()
461
462 trailingDotPatterns(std::string const&)
463 Full name: Alternatives::trailingDotPatterns(std::string const&)
464 Source: trailingdotpatterns.cc
465 Used By:
466 globfilter.cc: Alternatives::globFilter(char const*, Alternatives::GlobContext&)
467
468 usage(std::string const&)
469 Full name: usage(std::string const&)
470 Source: usage.cc
471 Used By:
472 main.cc: main
254473
255474 version
256475 Full name: Icmbuild::version
257 Source: version.cc
258 Used By:
259 arguments.cc: arguments(int, char**)
260 usage.cc: usage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
476 Source: version.cc
477 Used By:
478 usage.cc: usage(std::string const&)
479 main.cc: main
480
481 versionHelp(char const*, void (*)(std::string const&)) const
482 Full name: Options::versionHelp(char const*, void (*)(std::string const&)) const
483 Source: versionhelp.cc
484 Used By:
485 options1.cc: Options::Options(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
486
487 viable()
488 Full name: Alternatives::viable()
489 Source: viable.cc
490 Used By:
491 main.cc: main
261492
262493 year
263494 Full name: Icmbuild::year
264 Source: version.cc
265 Used By:
266 usage.cc: usage(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)
495 Source: version.cc
496 Used By:
497 usage.cc: usage(std::string const&)
498
499
500 ----------------------------------------------------------------------
501 CALL TREE FOR: main
502
503 main
504 +-handle(std::__exception_ptr::exception_ptr)
505 | +-noInput()
506 | +-Options::s_input
507 +-usage(std::string const&)
508 | +-Icmbuild::author
509 | +-Icmbuild::version
510 | +-Icmbuild::year
511 +-Icmbuild::version
512 +-Options::initialize(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
513 | +-Options::s_options
514 | +-Options::Options(char const*, FBB::LongOption__ const*, FBB::LongOption__ const*, int, char**, char const*, void (*)(std::string const&))
515 | +-Options::s_input
516 | +-Options::s_triState
517 | +-Options::s_startAt
518 | +-Options::s_dirs
519 | +-Options::s_endTriState
520 | +-Options::s_addRoot
521 | +-Options::s_endDirs
522 | +-Options::s_allDirs
523 | +-Options::s_endStartAt
524 | +-Options::s_fromHome
525 | +-Options::find(char const*, std::string const*, std::string const*)
526 | +-Options::getHome()
527 | +-Options::readConfigFile()
528 | | +-Options::s_defaultConfig
529 | +-Options::versionHelp(char const*, void (*)(std::string const&)) const
530 | +-Options::setHistory()
531 | | +-Options::s_defaultHistory
532 | +-Options::setMaxSize()
533 | +-Options::setHistoryLifetime()
534 | +-Options::setPosition()
535 | +-Options::setBlockSize()
536 +-Alternatives::Alternatives()
537 | +-Options::instance()
538 | | +-Options::s_options
539 | +-Command::Command()
540 | | +-Options::homedirChar() const
541 | | +-Options::instance()
542 | | | +-Options::s_options
543 | | +-Command::concatArgs()
544 | | | +-Options::instance()
545 | | | +-Options::s_options
546 | | +-Command::determineAction()
547 | | +-Command::s_separators
548 | | +-Command::splitBase()
549 | | +-Command::s_action
550 | +-History::History()
551 | +-Options::instance()
552 | | +-Options::s_options
553 | +-History::load()
554 | +-operator>>(std::istream&, History::HistoryInfo&)
555 | +-History::maybeInsert(History::HistoryInfo const&, std::vector<History::HistoryInfo, std::allocator<History::HistoryInfo> >&, unsigned long)
556 +-Alternatives::order()
557 +-Alternatives::viable()
558 | +-Options::s_triState
559 | +-Alternatives::determineInitialDirectory()
560 | | +-Alternatives::getCwd(std::unique_ptr<char, std::default_delete<char> >*)
561 | +-Alternatives::globFrom(std::string)
562 | +-Alternatives::addIgnored(std::string const&, std::set<std::string>&)
563 | +-Alternatives::generalizedGlob(std::string, Alternatives::GlobContext&)
564 | | +-Alternatives::globHead(std::string const&, std::string, Alternatives::GlobContext&)
565 | | +-Alternatives::globPattern(std::string, std::string&, unsigned long*, Alternatives::GlobContext&)
566 | | +-Alternatives::checkCase(std::string&, unsigned long*) const
567 | | +-Alternatives::globHead(std::string const&, std::string, Alternatives::GlobContext&) ==> 4
568 | | +-Alternatives::globFilter(char const*, Alternatives::GlobContext&)
569 | | +-Alternatives::add(char const*)
570 | | +-Alternatives::dotPattern(std::string const&, Alternatives::GlobContext const&)
571 | | | +-Alternatives::matchIgnore(std::string const&, std::string const&)
572 | | +-Alternatives::trailingDotPatterns(std::string const&)
573 | +-Alternatives::glob(std::string, Alternatives::GlobContext&)
574 | +-Alternatives::globFilter(char const*, Alternatives::GlobContext&)
575 | +-Alternatives::add(char const*)
576 | +-Alternatives::dotPattern(std::string const&, Alternatives::GlobContext const&)
577 | | +-Alternatives::matchIgnore(std::string const&, std::string const&)
578 | +-Alternatives::trailingDotPatterns(std::string const&)
579 +-Selector::decided() const
580 | +-History::save(std::string const&)
581 | +-History::compareTimes(History::HistoryInfo const&, History::HistoryInfo const&)
582 +-Selector::select()
583 | +-Selector::chdir()
584 | | +-Selector::input(std::string const&)
585 | +-Selector::showAlternatives()
586 | +-Selector::action(Selector::Block const&)
587 | | +-Selector::accept(int, std::string const&, std::string const&)
588 | | +-Selector::s_inc
589 | | +-Selector::s_dec
590 | | +-Selector::s_allChars
591 | | +-Selector::chdir()
592 | | | +-Selector::input(std::string const&)
593 | | +-Selector::noCD(int)
594 | | +-Selector::input(std::string const&)
595 | +-Selector::blockVector(unsigned long)
596 | | +-Selector::set(Selector::Block&, unsigned long) const
597 | | +-Selector::set(Selector::Block&, Selector::Block&)
598 | +-Selector::show(Selector::Block const&) const
599 | +-Alternatives::separateAt() const
600 | +-Selector::s_allChars
601 +-Selector::Selector(Alternatives&)
602 +-Options::s_input
603 +-Options::instance()
604 | +-Options::s_options
605 +-Selector::setBlockSize()
606 +-Options::instance()
607 | +-Options::s_options
608 +-Selector::s_allChars
+72
-52
xdrc less more
55 # file using the --config-file command line option then program defined
66 # defaults (shown here as well) will be used.
77
8 # All directives and values are interpreted case sensitively
8 # By default directives and values are interpreted case sensitively
99
1010 # When directives are provided repeatedly the last directive will be used
1111 # (except for ignore, which are all interpreted)
1212
13 # The program defined default is shown where applicable as a commented out
14 # example
13 # The commented-out examples show the default specifications or (if
14 # indicated so by extra comment) show the specification format
1515
1616
1717 # The add-root directive determines when to perform an additional search
18 #starting from the root (/) directory:
18 # starting from the root (/) directory:
1919 # always - an additional search is always performed.
2020 # if-empty - an additional search is performed if the initial search
2121 # did not yield any directory.
2222 # never - no additional search is performed.
2323 #add-root if-empty
2424
25 # The directories directive defines which directives are shown:
26 # all - show all alternatives, including symbolic links (symlinks)
27 # unique - do not show symlinks to directories
25 # The 'all' directive suppresses the 'ignore' directives.
26 #all # Not used by default, usually specified as command-line option
27
28
29 # The block-size directive specifies the max. number of directory alternatives
30 # that are displayed in a block.
31 #block-size 10 # by default no limit, the 10 used here is an example
32
33 # The directories directive defines which directives are shown:
34 # all - show all alternatives, including symbolic links (symlinks)
35 # unique - do not show symlinks to directories
2836 #directories all
2937
3038 # The generalized-search (GDS) on is specified bf(xd) directory separators are
3240 # all possible sequential combinations of the initial search command.
3341 # Directory separators are honored when specified, even when
3442 # generalized-search is specified. However, they are *required* if
35 # generalized-search is not specified or (same thing) if
36 #traditional
37 # is instead specified.
38 generalized-search
43 # generalized-search is not specified or (same thing) if 'traditional'
44 # is specified.
45 #generalized-search
3946
40 # The ignore directives (multiple ignore directives are all interpreted)
41 # defines directories that should not appear in alternative
42 # lists. Specifications may end in a final *, indicating that all
43 # directories matching the provided pattern will be ignored.
44 # There is no default. Some exampes:
45 # ignore /usr/lib/bonobo/
46 # ignore /usr/lib/bonobo-activation/
47 # or, using a wildcard:
48 # ignore /usr/lib/bonobo*
47 # The homedir-char directive defines the initial specification char used to
48 # specify the user's home-dir
49 #homedir-char .
50
51 # Specify the name of the history file if a history of previously made
52 # choices most be kept. If only the 'history' directive is specified the
53 # history file is $HOME/.xd.his
54 # The next history directives are only interpreted if the 'history'
55 # directive is specified
56 #history
57
58 # The lifetime of the entries in the history file.
59 # using D, W, M and Y to represent resp. days, weeks, months, or years.
60 #history-lifetime 1M
61
62 # The maximum number of entries the history file may contain.
63 #history-maxsize 50 # by default no limit, the 50 used here is an example
64
65 # Previously found directory alternatives are displayed either
66 # at the top of the list or at the bottom of the list. If omitted then the
67 # elements in the history are intermixed with new alternatives.
68 #history-position top # by default not used, here using 'top' as an example
69
70 # A blank line is written between the items in the history and new
71 # alternatives (not previously selected).
72 # This option is only interpreted when the previous option is also specified
73 #history-separate # by default not used
74
75 # The icase option is used to specify case-insensitive pattern matching. By
76 # default case sensitive pattern matching is used.
77 #icase # by default not used
78
79 # Multiple ignore specifications may be specified. Directories matching the
80 # specification will not show up in the list of alternatives. Specifications
81 # may end in a *
82 #ignore /usr/lib/bonobo* # by default not used: the specification is
83 # provided as an example
84
85 # The ignore directives (multiple ignore directives are all interpreted)
86 # defines directories that should not appear in alternative
87 # lists. Specifications may end in a final *, indicating that all
88 # directories matching the provided pattern will be ignored.
89 # There is no default. Some examples:
90 # ignore /usr/lib/bonobo/
91 # ignore /usr/lib/bonobo-activation/
92 # or, using wildcards:
93 # ignore /usr/lib/bonobo*
94
95 # Xd itself issues the tt(cd) command for the selected directory to the shell,
96 # and enters other (non alternative-selecting characters) into the shell's
97 # input.
98 #input # by default not used
4999
50100 # The start-at directive defines the origin of the search:
51101 # home - start the search from the user's home dir.
52102 # root - start the search from the root (/) directory.
53103 #start-at home
54104
55 # Specify the name of the history file if a history of previously made
56 # choices most be kept. If only the 'history' directive is specified the
57 # history file will be $HOME/.xd.his
58 # Remaining history- directives only have an effect if the 'history'
59 # directive is also specified
60 #history
61
62 # Specify the maximum lifetime of history items. Use D(ays), W(eeks),
63 # M(onths) or Y(ears), prefixed by a number. By default 1M is used
64 #history-lifetime 1M
65
66 # Specify the maximum size of the history. By default no limit.
67 # The value shown serves as an example.
68 #history-maxsize 10
69
70 # Specify the postion of the history items. When merely the directive is
71 # specified the history items are shown at the top of the
72 # list. Alternatively, use 'history-position bottom'
73 #history-position top
74
75 # When history-position is specified then 'history-separate' can be used to
76 # insert a blank line between history items and new alternatives.
77 history-separate
78
79 # Multiple ignore specifications may be specified. Directories matching the
80 # specification will not show up in the list of alternatives. Specifications
81 # should end in a *
82 #ignore /usr/lib/bonobo*
83
84 # The icase option is used to specify case-insensitive pattern matching. By
85 # default case sensitive pattern matching is used.
86 #icase
105 # Xd does not use GDS but uses its traditional mode
106 #traditional # by default not used