From c0f76bef1bc08b178370dbcea277a22ca44c41f7 Mon Sep 17 00:00:00 2001 From: Asmageddon Date: Sun, 27 May 2012 21:51:30 +0200 Subject: [PATCH] Highlight current primary sort column --- deluge/ui/console/modes/alltorrents.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/deluge/ui/console/modes/alltorrents.py b/deluge/ui/console/modes/alltorrents.py index 0e09f5786..aeb78b715 100644 --- a/deluge/ui/console/modes/alltorrents.py +++ b/deluge/ui/console/modes/alltorrents.py @@ -364,7 +364,29 @@ class AllTorrents(BaseMode, component.Component): if (self.column_widths[i] < 0): self.column_widths[i] = vw - self.column_string = "{!header!}%s"%("".join(["%s%s"%(self.__columns[i]," "*(self.column_widths[i]-len(self.__columns[i]))) for i in range(0,len(self.__columns))])) + self.column_string = "{!header!}" + + try: + primary_sort_col_name = prefs_to_names[self.config["sort_primary"]] + except: + primary_sort_col_name = "" + + for i, column in enumerate(self.__columns): + ccol = column + width = self.column_widths[i] + + #Trim the column if it's too long to fit + if len(ccol) > width: + ccol = ccol[:width - 1] + + # Padding + ccol += " " * (width - len(ccol)) + + # Highlight the primary sort column + if column == primary_sort_col_name: + ccol = "{!black,green,bold!}%s{!header!}" % ccol + + self.column_string += ccol def set_state(self, state, refresh):