diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2014-03-29 14:19:45 -0700 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2014-03-29 14:19:45 -0700 |
commit | d4fafeb6d66e415e85c67700e5a370765c09bb93 (patch) | |
tree | 7e208d860649e8651180b281ec715a96169a9dbe /reader.h | |
parent | 844b01cb6be2ab3a3f7070112c94604b43710835 (diff) | |
parent | 31bf50b2d495222925371556169f61c1c5a81ed7 (diff) |
Merge branch 'master' into 1218_rebase
Conflicts:
builtin.cpp
builtin_commandline.cpp
highlight.cpp
input.cpp
input.h
reader.cpp
screen.cpp
screen.h
Diffstat (limited to 'reader.h')
-rw-r--r-- | reader.h | 59 |
1 files changed, 56 insertions, 3 deletions
@@ -22,6 +22,52 @@ class parser_t; class completion_t; class history_t; +/* Helper class for storing a command line */ +class editable_line_t +{ + public: + + /** The command line */ + wcstring text; + + /** The current position of the cursor in the command line */ + size_t position; + + const wcstring &get_text() const + { + return text; + } + + /* Gets the length of the text */ + size_t size() const + { + return text.size(); + } + + bool empty() const + { + return text.empty(); + } + + void clear() + { + text.clear(); + position = 0; + } + + wchar_t at(size_t idx) + { + return text.at(idx); + } + + editable_line_t() : text(), position(0) + { + } + + /* Inserts the string at the cursor position */ + void insert_string(const wcstring &str); +}; + /** Read commands from \c fd until encountering EOF */ @@ -120,7 +166,7 @@ size_t reader_get_cursor_pos(); Get the current selection range in the command line. Returns false if there is no active selection, true otherwise. */ -bool reader_get_selection(size_t &start, size_t &len); +bool reader_get_selection(size_t *start, size_t *len); /** Return the value of the interrupted flag, which is set by the sigint @@ -246,10 +292,18 @@ int reader_shell_test(const wchar_t *b); /** Test whether the interactive reader is in search mode. - \return o if not in search mode, 1 if in search mode and -1 if not in interactive mode + \return 0 if not in search mode, 1 if in search mode and -1 if not in interactive mode */ int reader_search_mode(); +/** + Test whether the interactive reader has visible pager contents. + + \return 0 if it has pager contents, 1 if it does not have pager contents, and -1 if not in interactive mode + */ +int reader_has_pager_contents(); + + /* Given a command line and an autosuggestion, return the string that gets shown to the user. Exposed for testing purposes only. */ wcstring combine_command_and_autosuggestion(const wcstring &cmdline, const wcstring &autosuggestion); @@ -259,5 +313,4 @@ bool reader_expand_abbreviation_in_command(const wcstring &cmdline, size_t curso /* Apply a completion string. Exposed for testing only. */ wcstring completion_apply_to_command_line(const wcstring &val_str, complete_flags_t flags, const wcstring &command_line, size_t *inout_cursor_pos, bool append_only); - #endif |