aboutsummaryrefslogtreecommitdiffstats
path: root/epy.py
diff options
context:
space:
mode:
authorwustho <benawiadha@gmail.com>2020-04-17 20:48:51 +0700
committerwustho <benawiadha@gmail.com>2020-04-17 20:48:51 +0700
commit3848d56d21a8e429a9997643c70de613f7f7f7fb (patch)
tree374a80bbb88502b11b0ea29fc01ffc52ff3b6766 /epy.py
parenteb489327635f16933a57bbfb76556365f5ad551e (diff)
downloadepy-3848d56d21a8e429a9997643c70de613f7f7f7fb.tar.gz
Infinite string from input_prompt() and truncated title in choice_win() and text_win().
Diffstat (limited to 'epy.py')
-rwxr-xr-xepy.py18
1 files changed, 14 insertions, 4 deletions
diff --git a/epy.py b/epy.py
index 8add622..c485d94 100755
--- a/epy.py
+++ b/epy.py
@@ -402,6 +402,9 @@ def text_win(textfunc):
title, raw_texts, key = textfunc(*args, **kwargs)
+ if len(title) > cols-8:
+ title = title[:cols-8]
+
texts = []
for i in raw_texts.splitlines():
texts += textwrap.wrap(i, wi - 6)
@@ -463,6 +466,9 @@ def choice_win(allowdel=False):
title, ch_list, index, key = listgen(*args, **kwargs)
+ if len(title) > cols-8:
+ title = title[:cols-8]
+
chwin.box()
chwin.keypad(True)
chwin.addstr(1, 2, title)
@@ -676,7 +682,7 @@ def bookmarks(ebookpath):
return idx
-def input_prompt(prompt, maxlen=25):
+def input_prompt(prompt):
rows, cols = SCREEN.getmaxyx()
stat = curses.newwin(1, cols, rows-1, 0)
if COLORSUPPORT:
@@ -714,12 +720,16 @@ def input_prompt(prompt, maxlen=25):
curses.echo(0)
curses.curs_set(0)
return curses.KEY_RESIZE
- elif len(init_text) <= maxlen:
+ # elif len(init_text) <= maxlen:
+ else:
init_text += chr(ipt)
stat.clear()
stat.addstr(0, 0, prompt, curses.A_REVERSE)
- stat.addstr(0, len(prompt), init_text)
+ stat.addstr(
+ 0, len(prompt),
+ init_text if len(prompt+init_text) < cols else "..."+init_text[len(prompt)-cols+4:]
+ )
stat.refresh()
except KeyboardInterrupt:
stat.clear()
@@ -892,7 +902,7 @@ def searching(pad, src, width, y, ch, tot):
SCREEN.clear()
SCREEN.addstr(
rows-1, 0,
- " Finished searching: " + SEARCHPATTERN[1:] + " ",
+ " Finished searching: " + SEARCHPATTERN[1:cols-22] + " ",
curses.A_REVERSE
)
SCREEN.refresh()