Pass console config to torrentdetail and format_utils, add an option to disable three dots when trimming columns(they piss me off)
This commit is contained in:
parent
163870afd9
commit
47ba11be1b
|
@ -170,10 +170,7 @@ DEFAULT_PREFS = {
|
|||
"downloaded_width":13,
|
||||
"uploaded_width":13,
|
||||
"owner_width":10,
|
||||
"ignore_duplicate_lines": False,
|
||||
"move_selection": True,
|
||||
"third_tab_lists_all": False,
|
||||
"torrents_per_tab_press": 15
|
||||
"disable_three_dots": False
|
||||
}
|
||||
|
||||
column_pref_names = ["queue","name","size","state",
|
||||
|
@ -349,7 +346,7 @@ class AllTorrents(BaseMode, component.Component):
|
|||
for torrent_id in self._sorted_ids:
|
||||
ts = self.curstate[torrent_id]
|
||||
newnames.append(ts["name"])
|
||||
newrows.append((format_utils.format_row([column.get_column_value(name,ts) for name in self.__columns],self.column_widths),ts["state"]))
|
||||
newrows.append((format_utils.format_row([column.get_column_value(name,ts) for name in self.__columns],self.column_widths, self.config),ts["state"]))
|
||||
|
||||
self.numtorrents = len(state)
|
||||
self.formatted_rows = newrows
|
||||
|
|
|
@ -80,11 +80,14 @@ def format_priority(prio):
|
|||
else:
|
||||
return pstring
|
||||
|
||||
def trim_string(string, w, have_dbls):
|
||||
def trim_string(string, w, have_dbls, console_config):
|
||||
if w <= 0:
|
||||
return ""
|
||||
elif w == 1:
|
||||
return u" "
|
||||
if console_config["disable_three_dots"]:
|
||||
return u" "
|
||||
else:
|
||||
return u"…"
|
||||
elif have_dbls:
|
||||
# have to do this the slow way
|
||||
chrs = []
|
||||
|
@ -100,11 +103,17 @@ def trim_string(string, w, have_dbls):
|
|||
if width != w:
|
||||
chrs.pop()
|
||||
chrs.append('.')
|
||||
return u"%s "%("".join(chrs))
|
||||
if console_config["disable_three_dots"]:
|
||||
return u"%s "%("".join(chrs))
|
||||
else:
|
||||
return u"%s… "%("".join(chrs))
|
||||
else:
|
||||
return u"%s "%(string[0:w-1])
|
||||
if console_config["disable_three_dots"]:
|
||||
return u"%s "%(string[0:w-1])
|
||||
else:
|
||||
return u"%s… "%(string[0:w-2])
|
||||
|
||||
def format_column(col, lim):
|
||||
def format_column(col, lim, console_config):
|
||||
dbls = 0
|
||||
if haveud and isinstance(col,unicode):
|
||||
# might have some double width chars
|
||||
|
@ -115,12 +124,13 @@ def format_column(col, lim):
|
|||
dbls += 1
|
||||
size = len(col)+dbls
|
||||
if (size >= lim - 1):
|
||||
return trim_string(col,lim,dbls>0)
|
||||
return trim_string(col,lim,dbls>0, console_config)
|
||||
else:
|
||||
return "%s%s"%(col," "*(lim-size))
|
||||
|
||||
def format_row(row, column_widths):
|
||||
return "".join([format_column(row[i],column_widths[i]) for i in range(0,len(row))])
|
||||
|
||||
def format_row(row,column_widths, console_config):
|
||||
return "".join([format_column(row[i],column_widths[i], console_config) for i in range(0,len(row))])
|
||||
|
||||
import re
|
||||
_strip_re = re.compile("\{!.*?!\}")
|
||||
|
@ -230,4 +240,4 @@ def pad_string(string, length, character=" ", side="right"):
|
|||
if side == "left":
|
||||
return "%s%s" % (character * diff, string)
|
||||
elif side == "right":
|
||||
return "%s%s" % (string, character * diff)
|
||||
return "%s%s" % (string, character * diff)
|
||||
|
|
|
@ -311,12 +311,8 @@ class InterfacePane(BasePane):
|
|||
def __init__(self, offset, parent, width):
|
||||
BasePane.__init__(self,offset,parent,width)
|
||||
self.add_header("General")
|
||||
self.add_checked_input("ignore_duplicate_lines","Do not store duplicate input in history",parent.console_config["ignore_duplicate_lines"])
|
||||
self.add_checked_input("move_selection","Move selection when moving torrents in the queue",parent.console_config["move_selection"])
|
||||
self.add_checked_input("third_tab_lists_all","Third tab lists all remaining torrents in legacy mode",parent.console_config["third_tab_lists_all"])
|
||||
self.add_int_spin_input("torrents_per_tab_press","Torrents per tab press",parent.console_config["torrents_per_tab_press"], 5, 100)
|
||||
|
||||
self.add_header("Columns To Display", True)
|
||||
self.add_checked_input("disable_three_dots","Do not append three dots symbol when trimming columns",parent.console_config["disable_three_dots"])
|
||||
self.add_header("Columns To Display")
|
||||
for cpn in deluge.ui.console.modes.alltorrents.column_pref_names:
|
||||
pn = "show_%s"%cpn
|
||||
self.add_checked_input(pn,
|
||||
|
|
|
@ -333,7 +333,7 @@ class TorrentDetail(BaseMode, component.Component):
|
|||
r = format_utils.format_row(["%s%s %s"%(" "*depth,xchar,fl[0]),
|
||||
deluge.common.fsize(fl[2]),fl[5],
|
||||
format_utils.format_priority(fl[6])],
|
||||
self.column_widths)
|
||||
self.column_widths, self.console_config)
|
||||
|
||||
self.add_string(off,"%s%s"%(color_string,r),trim=False)
|
||||
off += 1
|
||||
|
|
Loading…
Reference in New Issue