summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO4
-rw-r--r--PKGBUILD4
-rw-r--r--command_pyroscope.cc1
-rw-r--r--ui_pyroscope.cc86
4 files changed, 86 insertions, 9 deletions
diff --git a/.SRCINFO b/.SRCINFO
index 5f877dbd9d9f..d3e57c2e326f 100644
--- a/.SRCINFO
+++ b/.SRCINFO
@@ -38,7 +38,7 @@ pkgbase = rtorrent-ps
source = ui_pyroscope.patch
md5sums = b8b4009f95f8543244ae1d23b1810d7c
md5sums = b49903d3fa25a66c72db69570dfe8b47
- md5sums = 60f7773b8268ede73af9bb6df3569856
+ md5sums = 313581839dd8bcbd14b4759789adcada
md5sums = 56701bca42cc9b309637bf3f918ede12
md5sums = 22fae392c6e281dc438b39a5019e7e1b
md5sums = 3fd739c0d5a9442f0cdec9ed5a720eaa
@@ -58,7 +58,7 @@ pkgbase = rtorrent-ps
md5sums = 26faff00b306b6ef276a7d9e6d964994
md5sums = bd04a0699b80c8042e1cf63a7e0e4222
md5sums = d0a956f0eb4b53b66d83df2a8a4d16dc
- md5sums = e0d51843436d2aa348815251e21ebd15
+ md5sums = 4f51b9e66d63e24570d7f4c88fb6bf1d
md5sums = 2a71f0c478e8fe7bce464ac85c4bec44
md5sums = 0a2bbaf74c7160ba33876dcc2f050f14
diff --git a/PKGBUILD b/PKGBUILD
index a075ec76a105..636ab2f9f3bc 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -39,7 +39,7 @@ source=("https://github.com/rakshasa/$_pkgname/archive/$_pkgver.tar.gz"
'ui_pyroscope.patch')
md5sums=('b8b4009f95f8543244ae1d23b1810d7c'
'b49903d3fa25a66c72db69570dfe8b47'
- '60f7773b8268ede73af9bb6df3569856'
+ '313581839dd8bcbd14b4759789adcada'
'56701bca42cc9b309637bf3f918ede12'
'22fae392c6e281dc438b39a5019e7e1b'
'3fd739c0d5a9442f0cdec9ed5a720eaa'
@@ -59,7 +59,7 @@ md5sums=('b8b4009f95f8543244ae1d23b1810d7c'
'26faff00b306b6ef276a7d9e6d964994'
'bd04a0699b80c8042e1cf63a7e0e4222'
'd0a956f0eb4b53b66d83df2a8a4d16dc'
- 'e0d51843436d2aa348815251e21ebd15'
+ '4f51b9e66d63e24570d7f4c88fb6bf1d'
'2a71f0c478e8fe7bce464ac85c4bec44'
'0a2bbaf74c7160ba33876dcc2f050f14')
diff --git a/command_pyroscope.cc b/command_pyroscope.cc
index be4d09b8060b..e432cffe6473 100644
--- a/command_pyroscope.cc
+++ b/command_pyroscope.cc
@@ -1077,4 +1077,5 @@ void initialize_command_pyroscope() {
add_capability("rtorrent-ps"); // obvious
add_capability("colors"); // not monochrome
add_capability("canvas_v2"); // new PS 1.1 canvas with fully dynamic columns
+ add_capability("collapsed-views"); // pre-collapsed views
}
diff --git a/ui_pyroscope.cc b/ui_pyroscope.cc
index c03f0e68ac84..a535f8fee300 100644
--- a/ui_pyroscope.cc
+++ b/ui_pyroscope.cc
@@ -19,6 +19,7 @@ python -c 'print u"\u22c5 \u22c5\u22c5 \u201d \u2019 \u266f \u2622 \u260d \u2318
#include <cstdio>
#include <cwchar>
+#include <set>
#include <list>
#include <stdlib.h>
#include <unistd.h>
@@ -46,6 +47,7 @@ python -c 'print u"\u22c5 \u22c5\u22c5 \u201d \u2019 \u266f \u2622 \u260d \u2318
#define D_INFO(item) (item->info())
#include "rpc/object_storage.h"
+#include "rpc/parse.h"
// from command_pyroscope.cc
extern torrent::Tracker* get_active_tracker(torrent::Download* item);
@@ -174,8 +176,19 @@ std::string get_custom_string(core::Download* d, const char* name) {
}
+// get a value from arg, either parsing from a string, or arg already being a value
+int64_t parse_value_arg(const torrent::Object& arg) {
+ if (arg.is_string()) {
+ int64_t result;
+ rpc::parse_whole_value(arg.as_string().c_str(), &result);
+ return result;
+ }
+ return arg.as_value(); // this will throw if other types than string/value are passed
+}
+
+
// convert absolute timestamp to approximate human readable time diff (5 chars wide)
-std::string elapsed_time(unsigned long dt, unsigned long t0) {
+std::string elapsed_time(unsigned long dt, unsigned long t0) {
if (dt == 0) return std::string("⋆ ⋆⋆ ");
const char* unit[] = {"”", "’", "h", "d", "w", "m", "y"};
@@ -221,6 +234,9 @@ std::string num2(int64_t num) {
namespace display {
+// Visibility of canvas columns
+static std::set<int> column_hidden;
+
// function wrapper for what possibly is a macro
static int get_colors() {
@@ -559,6 +575,48 @@ void ui_pyroscope_download_list_redraw_item(Window* window, display::Canvas* can
}
+torrent::Object ui_column_hide(rpc::target_type target, const torrent::Object::list_type& args) {
+ for(torrent::Object::list_const_iterator itr = args.begin(), last = args.end(); itr != last; ++itr) {
+ int64_t colidx = parse_value_arg(*itr);
+ column_hidden.insert(colidx);
+ }
+
+ return torrent::Object();
+}
+
+
+torrent::Object ui_column_show(rpc::target_type target, const torrent::Object::list_type& args) {
+ for(torrent::Object::list_const_iterator itr = args.begin(), last = args.end(); itr != last; ++itr) {
+ int64_t colidx = parse_value_arg(*itr);
+ column_hidden.erase(colidx);
+ }
+
+ return torrent::Object();
+}
+
+
+torrent::Object ui_column_is_hidden(rpc::target_type target, const torrent::Object::list_type& args) {
+ if (args.size() != 1) {
+ throw torrent::input_error("ui.column.is_hidden takes exactly one argument!");
+ }
+ int64_t colidx = parse_value_arg(*args.begin());
+
+ return (int64_t) column_hidden.count(colidx);
+}
+
+
+torrent::Object ui_column_hidden_list() {
+ torrent::Object result = torrent::Object::create_list();
+ torrent::Object::list_type& resultList = result.as_list();
+
+ for (std::set<int>::const_iterator itr = column_hidden.begin(); itr != column_hidden.end(); itr++) {
+ resultList.push_back(*itr);
+ }
+
+ return result;
+}
+
+
// Render columns from `column_defs`, return total length
int render_columns(bool headers, bool narrow, rpc::target_type target, core::Download* item,
display::Canvas* canvas, int column, int pos, int offset,
@@ -567,10 +625,11 @@ int render_columns(bool headers, bool narrow, rpc::target_type target, core::Dow
int total = 0;
for (cols_itr = column_defs.begin(); cols_itr != last_col; ++cols_itr) {
- // Skip sort key (format is "sort:len:title")
- size_t header_colon = cols_itr->first.find(':');
- if (header_colon == std::string::npos) continue;
- const char* header_pos = cols_itr->first.c_str() + header_colon + 1;
+ // Handle index / sort key (format is "sort:len:title")
+ char* header_pos = 0;
+ int colidx = (int)strtol(cols_itr->first.c_str(), &header_pos, 10);
+ if (*header_pos++ != ':') continue; // 2nd field is missing
+ if (column_hidden.count(colidx)) continue; // column is hidden
// Check for 'sacrificial' marker
if (*header_pos == '?') {
@@ -979,6 +1038,11 @@ void initialize_command_ui_pyroscope() {
CMD2_ANY ("ui.canvas_color", _cxxstd_::bind(&display::ui_canvas_color_get));
CMD2_ANY_STRING ("ui.canvas_color.set", _cxxstd_::bind(&display::ui_canvas_color_set, _cxxstd_::placeholders::_2));
+ CMD2_ANY_LIST("ui.column.hide", &display::ui_column_hide);
+ CMD2_ANY_LIST("ui.column.show", &display::ui_column_show);
+ CMD2_ANY_LIST("ui.column.is_hidden", &display::ui_column_is_hidden);
+ CMD2_ANY("ui.column.hidden.list", _cxxstd_::bind(&display::ui_column_hidden_list));
+
PS_VARIABLE_COLOR("ui.color.progress0", "red");
PS_VARIABLE_COLOR("ui.color.progress20", "bold bright red");
PS_VARIABLE_COLOR("ui.color.progress40", "bold bright magenta");
@@ -1040,6 +1104,18 @@ void initialize_command_ui_pyroscope() {
// Bind '*' to toggle between collapsed and expanded display
"schedule2 = collapsed_view_toggle, 0, 0, ((ui.bind_key,download_list,*,view.collapsed.toggle=))\n"
+ // Collapse built-in views
+ "view.collapsed.toggle = main\n"
+ "view.collapsed.toggle = name\n"
+ "view.collapsed.toggle = started\n"
+ "view.collapsed.toggle = stopped\n"
+ "view.collapsed.toggle = complete\n"
+ "view.collapsed.toggle = incomplete\n"
+ "view.collapsed.toggle = hashing\n"
+ "view.collapsed.toggle = seeding\n"
+ "view.collapsed.toggle = leeching\n"
+ "view.collapsed.toggle = active\n"
+
// TODO: copy (parts of) timestamp cfg here (~/.pyroscope/rtorrent.d/timestamps.rc)
// Do NOT move it, since then rT vanilla gets unusable with rtcontrol.
// 'system.has' allows to have both.