33 : ClientReader(client),
42 reader_.reset(
new DumbClientReader(client()));
45 prefix_ void senf::console::detail::LineEditorSwitcher::v_disablePrompt()
47 reader_->disablePrompt();
50 prefix_ void senf::console::detail::LineEditorSwitcher::v_enablePrompt()
52 reader_->enablePrompt();
55 prefix_ void senf::console::detail::LineEditorSwitcher::v_write(std::string
const &
data)
60 prefix_ unsigned senf::console::detail::LineEditorSwitcher::v_width()
63 return reader_->width();
71 : term::BaseTelnetProtocol(client.handle()), ClientReader(client),
75 editor_.
prompt(promptString());
77 senf::membind(&LineEditorClientReader::deleteCharOrExit,
this));
79 boost::bind(&term::bindings::complete,
85 prefix_ void senf::console::detail::LineEditorClientReader::v_setupFailed()
91 prefix_ void senf::console::detail::LineEditorClientReader::v_eof()
96 prefix_ void senf::console::detail::LineEditorClientReader::v_disablePrompt()
101 prefix_ void senf::console::detail::LineEditorClientReader::v_enablePrompt()
106 prefix_ void senf::console::detail::LineEditorClientReader::v_write(std::string
const &
data)
108 BaseTelnetProtocol::write(data);
111 prefix_ unsigned senf::console::detail::LineEditorClientReader::v_width()
114 return editor_.
width();
118 senf::console::detail::LineEditorClientReader::executeLine(std::string
const & text)
121 stream() << std::flush;
122 editor_.
prompt(promptString());
127 senf::console::detail::LineEditorClientReader::deleteCharOrExit(
term::LineEditor & editor)
129 if (editor.
text().empty())
132 term::bindings::deleteChar(editor);
135 prefix_ void senf::console::detail::LineEditorClientReader::
136 completePath(
term::LineEditor & editor,
unsigned & b,
unsigned & e, std::string & prefix,
137 std::vector<std::string> & completions)
139 std::string
const & t (editor.
text());
156 std::string base (t.substr(b,e));
160 parser.parsePath(base, cmd);
169 for (DirectoryNode::ChildrenRange::iterator i (cs.begin()); i != cs.end(); ++i)
170 completions.push_back(i->first + (i->second->followLink().isDirectory() ?
"/" :
" "));
174 ParseCommandInfo::TokensRange::const_iterator i (path.begin());
175 ParseCommandInfo::TokensRange::const_iterator
const i_end (boost::prior(path.end()));
177 for (; i != i_end; ++i)
178 if (*i == NoneToken()) {
179 if (i == path.begin()) {
180 dir = & client().
root();
184 else if (*i == WordToken(
"..")) {
186 if (parent) dir = parent;
189 else if (*i == WordToken(
"."))
196 catch (std::bad_cast &) {
199 prefix += i->value() +
"/";
204 GenericNode & node (cs.begin()->second->followLink());
205 if (!node.isDirectory())
208 prefix += cs.begin()->first +
"/";
216 for (DirectoryNode::ChildrenRange::iterator j (cs.begin()); j != cs.end(); ++j)
217 completions.push_back(j->first + (j->second->followLink().isDirectory() ?
"/" :
" "));
LineEditorClientReader(Client &client, LineEditorSwitcher &switcher)
Exception thrown when the parser detects an error.
ChildrenRange completions(std::string const &s) const
Return iterator range of completions for s.
void defineKey(keycode_t key, KeyBinding binding)
unspecified_keyword_type parser
Argument parser.
Config/console tree directory node.
u8 data[SPECTRAL_HT20_NUM_BINS]
boost::function< R(Args)> membind(R(T::*fn)(Args), T *ob)
boost::iterator_range< ChildMap::const_iterator > ChildrenRange
DirectoryNode & getDirectory(std::string const &name) const
Get directory child node (dereferencing links)
static bool isWordChar(char ch)
Check, if ch is a word character.
bool hasChild(std::string const &name) const
true, if there is a child with name name
void prompt(std::string const &text)
Single parsed console command.
TokensRange commandPath() const
Command path.
bool has_one_elt(Range r)
std::string const & text()
static keycode_t Ctrl(char ch)
Internal: ClientReader using senf::term::LineEditor for interactive input.
LineEditor public header.
boost::shared_ptr< DirectoryNode > parent() const
Parent node.
boost::iterator_range< token_iterator > TokensRange
friend DirectoryNode & root()
Get console root node.
Config/console node tree base-class.
Internal: Client reader switching between LineEditorClientReader or DumbClientReader.
LineEditorSwitcher(Client &client)