better performance by using links_only when needed
This commit is contained in:
parent
6b1b527b04
commit
a9b5c37b8a
51
offpunk.py
51
offpunk.py
|
@ -838,29 +838,32 @@ class HtmlRenderer(AbstractRenderer):
|
||||||
self.last_line_colors[pos].append("\x1b["+self.colors[color][o]+"m")
|
self.last_line_colors[pos].append("\x1b["+self.colors[color][o]+"m")
|
||||||
|
|
||||||
def _endline(self):
|
def _endline(self):
|
||||||
for c in self.opened:
|
if len(self.last_line) >= 0:
|
||||||
self._insert(c,open=False)
|
for c in self.opened:
|
||||||
newline = ""
|
self._insert(c,open=False)
|
||||||
#we insert the color code at the saved positions
|
newline = ""
|
||||||
while len (self.last_line_colors) > 0:
|
#we insert the color code at the saved positions
|
||||||
pos,colors = self.last_line_colors.popitem()
|
while len (self.last_line_colors) > 0:
|
||||||
#popitem itterates LIFO.
|
pos,colors = self.last_line_colors.popitem()
|
||||||
#So we go, backward, to the pos (starting at the end of last_line)
|
#popitem itterates LIFO.
|
||||||
newline = self.last_line[pos:] + newline
|
#So we go, backward, to the pos (starting at the end of last_line)
|
||||||
for c in colors:
|
newline = self.last_line[pos:] + newline
|
||||||
newline = c + newline
|
for c in colors:
|
||||||
self.last_line = self.last_line[:pos]
|
newline = c + newline
|
||||||
newline = self.last_line + newline
|
self.last_line = self.last_line[:pos]
|
||||||
if self.last_line_center:
|
newline = self.last_line + newline
|
||||||
newline = newline.strip().center(term_width())
|
if self.last_line_center:
|
||||||
self.last_line_center = False
|
newline = newline.strip().center(term_width())
|
||||||
|
self.last_line_center = False
|
||||||
|
else:
|
||||||
|
newline = newline.lstrip()
|
||||||
|
self.final_text += newline
|
||||||
|
self.last_line = ""
|
||||||
|
self.final_text += "\n"
|
||||||
|
for c in self.opened:
|
||||||
|
self._insert(c,open=True)
|
||||||
else:
|
else:
|
||||||
newline = newline.lstrip()
|
self.last_line = ""
|
||||||
self.final_text += newline
|
|
||||||
self.last_line = ""
|
|
||||||
self.final_text += "\n"
|
|
||||||
for c in self.opened:
|
|
||||||
self._insert(c,open=True)
|
|
||||||
|
|
||||||
@debug
|
@debug
|
||||||
def center_line(self):
|
def center_line(self):
|
||||||
|
@ -1359,7 +1362,7 @@ class GeminiItem():
|
||||||
|
|
||||||
# This method is used to load once the list of links in a gi
|
# This method is used to load once the list of links in a gi
|
||||||
# Links can be followed, after a space, by a description/title
|
# Links can be followed, after a space, by a description/title
|
||||||
def get_links(self,mode=None):
|
def get_links(self,mode="links_only"):
|
||||||
links = []
|
links = []
|
||||||
toreturn = []
|
toreturn = []
|
||||||
if not self.renderer:
|
if not self.renderer:
|
||||||
|
@ -1410,7 +1413,7 @@ class GeminiItem():
|
||||||
if self.is_cache_valid(): #and self.offline_only and not self.local:
|
if self.is_cache_valid(): #and self.offline_only and not self.local:
|
||||||
last_modification = self.cache_last_modified()
|
last_modification = self.cache_last_modified()
|
||||||
str_last = time.ctime(last_modification)
|
str_last = time.ctime(last_modification)
|
||||||
nbr = len(self.get_links())
|
nbr = len(self.get_links(mode="links_only"))
|
||||||
if self.local:
|
if self.local:
|
||||||
title += " (%s items) \x1b[0;31m(local file)"%nbr
|
title += " (%s items) \x1b[0;31m(local file)"%nbr
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in New Issue