diff options
author | ridiculousfish <corydoras@ridiculousfish.com> | 2014-03-15 14:00:18 -0700 |
---|---|---|
committer | ridiculousfish <corydoras@ridiculousfish.com> | 2014-03-15 14:00:18 -0700 |
commit | 2442ae60dba9e7120170fba7c0cb307a3609b375 (patch) | |
tree | 458f547d15fa25b80d60f1a19e9b76d802701e77 /reader.cpp | |
parent | 6c096191ba0b13c3396c4b130daf64f5a9f75267 (diff) |
Remove old fish_pager source and implementation
Diffstat (limited to 'reader.cpp')
-rw-r--r-- | reader.cpp | 138 |
1 files changed, 0 insertions, 138 deletions
@@ -1347,144 +1347,6 @@ static void completion_insert(const wchar_t *val, complete_flags_t flags) data->suppress_autosuggestion = true; } -/* Return an escaped path to fish_pager */ -static wcstring escaped_fish_pager_path(void) -{ - wcstring result; - const env_var_t bin_dir = env_get_string(L"__fish_bin_dir"); - if (bin_dir.missing_or_empty()) - { - /* This isn't good, hope our normal command stuff can find it */ - result = L"fish_pager"; - } - else - { - result = escape_string(bin_dir + L"/fish_pager", ESCAPE_ALL); - } - return result; -} - -/** - Run the fish_pager command to display the completion list. If the - fish_pager outputs any text, it is inserted into the input - backbuffer. - - \param prefix the string to display before every completion. - \param is_quoted should be set if the argument is quoted. This will change the display style. - \param comp the list of completions to display -*/ -static void run_pager(const wcstring &prefix, int is_quoted, const std::vector<completion_t> &comp) -{ - wcstring msg; - wcstring prefix_esc; - char *foo; - - shared_ptr<io_buffer_t> in_buff(io_buffer_t::create(true, 3)); - shared_ptr<io_buffer_t> out_buff(io_buffer_t::create(false, 4)); - - // The above may fail e.g. if we have too many open fds - if (in_buff.get() == NULL || out_buff.get() == NULL) - return; - - wchar_t *escaped_separator; - - if (prefix.empty()) - { - prefix_esc = L"\"\""; - } - else - { - prefix_esc = escape_string(prefix, 1); - } - - - const wcstring pager_path = escaped_fish_pager_path(); - const wcstring cmd = format_string(L"%ls -c 3 -r 4 %ls -p %ls", - // L"valgrind --track-fds=yes --log-file=pager.txt --leak-check=full ./%ls %d %ls", - pager_path.c_str(), - is_quoted?L"-q":L"", - prefix_esc.c_str()); - - escaped_separator = escape(COMPLETE_SEP_STR, 1); - - editable_line_t *el = &data->command_line; - - for (size_t i=0; i< comp.size(); i++) - { - long base_len=-1; - const completion_t &cmpl = comp.at(i); - - wcstring completion_text; - wcstring description_text; - - // Note that an empty completion is perfectly sensible here, e.g. tab-completing 'foo' with a file called 'foo' and another called 'foobar' - if ((cmpl.flags & COMPLETE_REPLACES_TOKEN) && match_type_shares_prefix(cmpl.match.type)) - { - // Compute base_len if we have not yet - if (base_len == -1) - { - const wchar_t *begin, *buff = el->text.c_str(); - - parse_util_token_extent(buff, el->position, &begin, 0, 0, 0); - base_len = el->position - (begin-buff); - } - - completion_text = escape_string(cmpl.completion.c_str() + base_len, ESCAPE_ALL | ESCAPE_NO_QUOTED); - } - else - { - completion_text = escape_string(cmpl.completion, ESCAPE_ALL | ESCAPE_NO_QUOTED); - } - - - if (! cmpl.description.empty()) - { - description_text = escape_string(cmpl.description, true); - } - - /* It's possible (even common) to have an empty completion with no description. An example would be completing 'foo' with extant files 'foo' and 'foobar'. But fish_pager ignores blank lines. So if our completion text is empty, always include a description, even if it's empty. - */ - msg.reserve(msg.size() + completion_text.size() + description_text.size() + 2); - msg.append(completion_text); - if (! description_text.empty() || completion_text.empty()) - { - msg.append(escaped_separator); - msg.append(description_text); - } - msg.push_back(L'\n'); - } - - free(escaped_separator); - - foo = wcs2str(msg.c_str()); - in_buff->out_buffer_append(foo, strlen(foo)); - free(foo); - - term_donate(); - parser_t &parser = parser_t::principal_parser(); - io_chain_t io_chain; - io_chain.push_back(out_buff); - io_chain.push_back(in_buff); - parser.eval(cmd, io_chain, TOP); - term_steal(); - - out_buff->read(); - - const char zero = 0; - out_buff->out_buffer_append(&zero, 1); - - const char *out_data = out_buff->out_buffer_ptr(); - if (out_data) - { - const wcstring str = str2wcstring(out_data); - size_t idx = str.size(); - while (idx--) - { - input_unreadch(str.at(idx)); - } - } -} - struct autosuggestion_context_t { wcstring search_string; |