aboutsummaryrefslogtreecommitdiffstats
path: root/epy.py
diff options
context:
space:
mode:
authorbenadha <benawiadha@gmail.com>2021-10-25 21:34:47 +0700
committerbenadha <benawiadha@gmail.com>2021-10-25 21:34:47 +0700
commit22497026b099cb64eca32bdfff1b073db65d9b34 (patch)
treea592ae13b84bd4d4b0c4f043b232863d4a2eea13 /epy.py
parent10fcd25626bf2f4f577ec72b8ced1c33a054c109 (diff)
downloadepy-22497026b099cb64eca32bdfff1b073db65d9b34.tar.gz
Give styling to images
Diffstat (limited to 'epy.py')
-rwxr-xr-xepy.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/epy.py b/epy.py
index ba2ec0b..d50eec2 100755
--- a/epy.py
+++ b/epy.py
@@ -692,6 +692,7 @@ class HTMLtoLines(HTMLParser):
images: Mapping[int, str] = dict() # {line_num: path/in/zip}
sect: Mapping[str, int] = dict() # {section_id: line_num}
formatting: List[InlineStyle] = []
+
tmpital = []
for i in self.initital:
# handle uneven markup
@@ -723,6 +724,7 @@ class HTMLtoLines(HTMLParser):
if not textwidth:
return self.text
+
for n, i in enumerate(self.text):
startline = len(text)
# findsect = re.search(r"(?<= \(#).*?(?=\) )", i)
@@ -752,7 +754,13 @@ class HTMLtoLines(HTMLParser):
text += [" " + j for j in wraptmp] + [""]
elif n in self.idimgs:
images[len(text)] = self.imgs[n]
- text += [i.center(textwidth)] + [""]
+ text += [i.center(textwidth)]
+ formatting += [
+ InlineStyle(
+ row=len(text) - 1, col=0, n_letters=len(text[-1]), attr=curses.A_BOLD
+ )
+ ]
+ text += [""]
else:
text += textwrap.wrap(i, textwidth) + [""]
@@ -2789,7 +2797,12 @@ class Reader:
reading_state = ret_object
elif k in self.keymap.OpenImage and self.image_viewer:
- imgs_in_screen = list(set(range(reading_state.row, reading_state.row + rows * self.spread + 1)) & set(imgs.keys()))
+ imgs_in_screen = list(
+ set(
+ range(reading_state.row, reading_state.row + rows * self.spread + 1)
+ )
+ & set(imgs.keys())
+ )
if not imgs_in_screen:
k = NoUpdate()
continue
@@ -2812,7 +2825,7 @@ class Reader:
- DoubleSpreadPadding.RIGHT.value
- reading_state.textwidth
)
- + reading_state.textwidth // 2
+ + reading_state.textwidth // 2,
)
self.screen.refresh()
safe_curs_set(2)