diff options
author | xsmile | 2017-04-03 12:49:55 +0200 |
---|---|---|
committer | xsmile | 2017-04-03 12:49:55 +0200 |
commit | 1e361329df7798275282b491a58b38495d6e8679 (patch) | |
tree | 43d0bc18a8ac48bd3508a2d2cd5826b04c0ec5bc | |
parent | 22b8e44314300a39a782f51c39c1ac3f11c59af6 (diff) | |
download | aur-1e361329df7798275282b491a58b38495d6e8679.tar.gz |
update
-rw-r--r-- | .SRCINFO | 8 | ||||
-rw-r--r-- | PKGBUILD | 6 | ||||
-rw-r--r-- | command_pyroscope.cc | 77 | ||||
-rw-r--r-- | ps-view-filter-by_all.patch | 25 |
4 files changed, 111 insertions, 5 deletions
@@ -1,8 +1,8 @@ # Generated by mksrcinfo v8 -# Sat Mar 18 00:25:09 UTC 2017 +# Mon Apr 3 10:47:15 UTC 2017 pkgbase = rtorrent-ps pkgdesc = Extended rTorrent distribution with UI enhancements, colorization, and some added features - pkgver = 1.0.r32.g832b03d + pkgver = 1.0.r40.ge768454 pkgrel = 1 url = https://github.com/pyroscope/rtorrent-ps arch = any @@ -31,12 +31,13 @@ pkgbase = rtorrent-ps source = ps-ssl_verify_host_all.patch source = ps-throttle-steps_all.patch source = ps-ui_pyroscope_all.patch + source = ps-view-filter-by_all.patch source = pyroscope.patch source = ui_pyroscope.cc source = ui_pyroscope.h source = ui_pyroscope.patch md5sums = b8b4009f95f8543244ae1d23b1810d7c - md5sums = 01e9e7dddf9ebcdca81d88dfdd43b4dc + md5sums = 4fd2e4373b8dab7e37dd8684fe04a555 md5sums = 22fae392c6e281dc438b39a5019e7e1b md5sums = 3fd739c0d5a9442f0cdec9ed5a720eaa md5sums = 2137e16f8b881170fb92fb7a6c276193 @@ -45,6 +46,7 @@ pkgbase = rtorrent-ps md5sums = cef14e9011d4b4af92536b02f8b611c2 md5sums = ee76d57dfbc40e09eeaee3845d327d94 md5sums = 7a88f8ab5d41242fdf1428de0e2ca182 + md5sums = 26faff00b306b6ef276a7d9e6d964994 md5sums = bd04a0699b80c8042e1cf63a7e0e4222 md5sums = cd39a495ee93d9c77039fa74a9e9dc94 md5sums = 1258acfc82c50a8f452ace87fef0b416 @@ -3,7 +3,7 @@ _pkgname=rtorrent pkgname=rtorrent-ps _pkgver=0.9.6 -pkgver=1.0.r32.g832b03d +pkgver=1.0.r40.ge768454 pkgrel=1 pkgdesc='Extended rTorrent distribution with UI enhancements, colorization, and some added features' url='https://github.com/pyroscope/rtorrent-ps' @@ -22,12 +22,13 @@ source=("https://github.com/rakshasa/$_pkgname/archive/$_pkgver.tar.gz" 'ps-ssl_verify_host_all.patch' 'ps-throttle-steps_all.patch' 'ps-ui_pyroscope_all.patch' + 'ps-view-filter-by_all.patch' 'pyroscope.patch' 'ui_pyroscope.cc' 'ui_pyroscope.h' 'ui_pyroscope.patch') md5sums=('b8b4009f95f8543244ae1d23b1810d7c' - '01e9e7dddf9ebcdca81d88dfdd43b4dc' + '4fd2e4373b8dab7e37dd8684fe04a555' '22fae392c6e281dc438b39a5019e7e1b' '3fd739c0d5a9442f0cdec9ed5a720eaa' '2137e16f8b881170fb92fb7a6c276193' @@ -36,6 +37,7 @@ md5sums=('b8b4009f95f8543244ae1d23b1810d7c' 'cef14e9011d4b4af92536b02f8b611c2' 'ee76d57dfbc40e09eeaee3845d327d94' '7a88f8ab5d41242fdf1428de0e2ca182' + '26faff00b306b6ef276a7d9e6d964994' 'bd04a0699b80c8042e1cf63a7e0e4222' 'cd39a495ee93d9c77039fa74a9e9dc94' '1258acfc82c50a8f452ace87fef0b416' diff --git a/command_pyroscope.cc b/command_pyroscope.cc index 182456e35eb7..496017f21ec2 100644 --- a/command_pyroscope.cc +++ b/command_pyroscope.cc @@ -471,6 +471,80 @@ torrent::Object cmd_log_messages(const torrent::Object::string_type& arg) { } +torrent::Object +d_multicall_filtered(const torrent::Object::list_type& args) { + if (args.size() < 2) + throw torrent::input_error("d.multicall.filtered requires at least 2 arguments."); + torrent::Object::list_const_iterator arg = args.begin(); + + // Find the given view + core::ViewManager* viewManager = control->view_manager(); + core::ViewManager::iterator viewItr; + + if (!arg->as_string().empty()) + viewItr = viewManager->find(arg->as_string()); + else + viewItr = viewManager->find("default"); + + if (viewItr == viewManager->end()) + throw torrent::input_error("Could not find view."); + + // Make a filtered copy of the current item list + core::View::base_type dlist; + (*viewItr)->filter_by(*++arg, dlist); + + // Generate result by iterating over all items + torrent::Object resultRaw = torrent::Object::create_list(); + torrent::Object::list_type& result = resultRaw.as_list(); + ++arg; // skip to first command + + for (core::View::iterator item = dlist.begin(); item != dlist.end(); ++item) { + // Add empty row to result + torrent::Object::list_type& row = result.insert(result.end(), torrent::Object::create_list())->as_list(); + + // Call the provided commands and assemble their results + for (torrent::Object::list_const_iterator command = arg; command != args.end(); command++) { + const std::string& cmdstr = command->as_string(); + row.push_back(rpc::parse_command(rpc::make_target(*item), cmdstr.c_str(), cmdstr.c_str() + cmdstr.size()).first); + } + } + + return resultRaw; +} + + +torrent::Object::value_type apply_string_contains(bool ignore_case, const torrent::Object::list_type& args) { + if (args.size() < 2) { + throw torrent::input_error("string.contains[_i] takes at least two arguments!"); + } + + torrent::Object::list_const_iterator itr = args.begin(); + std::string text = itr->as_string(); + if (ignore_case) + std::transform(text.begin(), text.end(), text.begin(), ::tolower); + + for (++itr; itr != args.end(); ++itr) { + std::string substr = itr->as_string(); + if (ignore_case) + std::transform(substr.begin(), substr.end(), substr.begin(), ::tolower); + if (substr.empty() || text.find(substr) != std::string::npos) + return 1; + } + + return 0; +} + + +torrent::Object cmd_string_contains(rpc::target_type target, const torrent::Object::list_type& args) { + return apply_string_contains(false, args); +} + +// XXX: Will NOT work correctly for non-ASCII strings! +torrent::Object cmd_string_contains_i(rpc::target_type target, const torrent::Object::list_type& args) { + return apply_string_contains(true, args); +} + + // Backports from 0.9.2 #if (API_VERSION < 3) template <typename InputIterator, typename OutputIterator> OutputIterator @@ -543,8 +617,11 @@ void initialize_command_pyroscope() { CMD2_ANY_STRING("system.env", _cxxstd_::bind(&cmd_system_env, _cxxstd_::placeholders::_2)); CMD2_ANY("ui.current_view", _cxxstd_::bind(&cmd_ui_current_view)); CMD2_ANY_LIST("system.random", &apply_random); + CMD2_ANY_LIST("d.multicall.filtered", _cxxstd_::bind(&d_multicall_filtered, _cxxstd_::placeholders::_2)); #endif + CMD2_ANY_LIST("string.contains", &cmd_string_contains); + CMD2_ANY_LIST("string.contains_i", &cmd_string_contains_i); CMD2_ANY_LIST("compare", &apply_compare); CMD2_ANY("ui.bind_key", &apply_ui_bind_key); CMD2_VAR_VALUE("ui.bind_key.verbose", 1); diff --git a/ps-view-filter-by_all.patch b/ps-view-filter-by_all.patch new file mode 100644 index 000000000000..e6ccf4a3ed79 --- /dev/null +++ b/ps-view-filter-by_all.patch @@ -0,0 +1,25 @@ +--- orig-096/src/core/view.h 2015-09-03 21:03:30.000000000 +0200 ++++ rtorrent-0.9.6/src/core/view.h 2017-04-02 16:22:17.000000000 +0200 +@@ -122,2 +122,3 @@ + void filter(); ++ void filter_by(const torrent::Object& condition, base_type& result); + void filter_download(core::Download* download); +--- orig-096/src/core/view.cc 2015-09-03 21:03:30.000000000 +0200 ++++ rtorrent-0.9.6/src/core/view.cc 2017-04-02 16:25:49.000000000 +0200 +@@ -292,4 +296,16 @@ + } + ++ ++void ++View::filter_by(const torrent::Object& condition, View::base_type& result) ++{ ++ // std::copy_if(begin_visible(), end_visible(), result.begin(), view_downloads_filter(condition)); ++ view_downloads_filter matches = view_downloads_filter(condition); ++ for (iterator itr = begin_visible(); itr != end_visible(); ++itr) ++ if (matches(*itr)) ++ result.push_back(*itr); ++} ++ ++ + void + View::filter_download(core::Download* download) { |