Skip to content

Commit 7fded8a

Browse files
committed
Improve readme example, change DialogBox arg to , patch .gitignore, change lib version number.
1 parent 02439b5 commit 7fded8a

File tree

5 files changed

+157
-29
lines changed

5 files changed

+157
-29
lines changed

.gitignore

Lines changed: 130 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,132 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
pip-wheel-metadata/
24+
share/python-wheels/
25+
*.egg-info/
26+
.installed.cfg
27+
*.egg
28+
MANIFEST
29+
30+
# PyInstaller
31+
# Usually these files are written by a python script from a template
32+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
33+
*.manifest
34+
*.spec
35+
36+
# Installer logs
37+
pip-log.txt
38+
pip-delete-this-directory.txt
39+
40+
# Unit test / coverage reports
41+
htmlcov/
42+
.tox/
43+
.nox/
44+
.coverage
45+
.coverage.*
46+
.cache
47+
nosetests.xml
48+
coverage.xml
49+
*.cover
50+
*.py,cover
51+
.hypothesis/
52+
.pytest_cache/
53+
54+
# Translations
55+
*.mo
56+
*.pot
57+
58+
# Django stuff:
59+
*.log
60+
local_settings.py
61+
db.sqlite3
62+
db.sqlite3-journal
63+
64+
# Flask stuff:
65+
instance/
66+
.webassets-cache
67+
68+
# Scrapy stuff:
69+
.scrapy
70+
71+
# Sphinx documentation
72+
docs/_build/
73+
74+
# PyBuilder
75+
target/
76+
77+
# Jupyter Notebook
78+
.ipynb_checkpoints
79+
80+
# IPython
81+
profile_default/
82+
ipython_config.py
83+
84+
# pyenv
85+
.python-version
86+
87+
# pipenv
88+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
89+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
90+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
91+
# install all needed dependencies.
92+
#Pipfile.lock
93+
94+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
95+
__pypackages__/
96+
97+
# Celery stuff
98+
celerybeat-schedule
99+
celerybeat.pid
100+
101+
# SageMath parsed files
102+
*.sage.py
103+
104+
# Environments
105+
.env
106+
.venv
107+
env/
108+
venv/
109+
ENV/
110+
env.bak/
111+
venv.bak/
112+
113+
# Spyder project settings
114+
.spyderproject
115+
.spyproject
116+
117+
# Rope project settings
118+
.ropeproject
119+
120+
# mkdocs documentation
121+
/site
122+
123+
# mypy
124+
.mypy_cache/
125+
.dmypy.json
126+
dmypy.json
127+
128+
# Pyre type checker
129+
.pyre/
130+
1131
.vscode
2132
.idea
3-
4-
# Sphinx documentation
5-
/doc/build/

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,14 @@ import curses
7272
from visualdialog import DialogBox
7373

7474

75+
x, y = (0, 0)
76+
length, width = (35, 6)
77+
7578
def main(stdscr):
7679
curses.curs_set(False)
7780

78-
textbox = DialogBox(0, 0,
79-
35, 6,
81+
textbox = DialogBox(x, y,
82+
length, width,
8083
title="Demo")
8184
textbox.char_by_char(stdscr,
8285
"Hello world")

tests/test.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,15 @@ def main(stdscr):
1818

1919
curses.curs_set(0)
2020

21-
curses.start_color()
2221
curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK)
2322
curses.init_pair(2, curses.COLOR_CYAN, curses.COLOR_BLACK)
2423
curses.init_pair(3, curses.COLOR_GREEN, curses.COLOR_BLACK)
2524

2625
textbox = DialogBox(0, 0,
2726
40, 6,
28-
# ~ title="Tim-ats-d",
29-
title_colors_pair_nb=3,
30-
end_dialog_indicator="o")
27+
# title="Tim-ats-d",
28+
# title_colors_pair_nb=3,
29+
end_indicator="o")
3130

3231
textbox.confirm_dialog_key = (32, )
3332
textbox.panic_key = (10, )
@@ -44,9 +43,9 @@ def func(text: str):
4443
textbox.char_by_char(stdscr,
4544
reply,
4645
cargs=(reply, ),
47-
callback=func)
48-
# ~ text_attr=(curses.A_ITALIC, curses.A_BOLD),
49-
# ~ words_attr=special_words)
46+
callback=func,
47+
text_attr=(curses.A_ITALIC, curses.A_BOLD),
48+
words_attr=special_words)
5049

5150
with visualdialog.TextAttributes(stdscr, curses.A_BOLD, curses.A_ITALIC):
5251
...

visualdialog/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
A library to make easier dialog box in terminal.
33
"""
44

5-
__version__ = 0.6
5+
__version__ = 0.7
66
__author__ = "Timéo Arnouts"
77

88
from .dialog import DialogBox

visualdialog/dialog.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -72,21 +72,21 @@ def __init__(
7272
downtime_chars: Union[Tuple[str],
7373
List[str]] = (",", ".", ":", ";", "!", "?"),
7474
downtime_chars_delay: Numeric = .6,
75-
end_dialog_indicator: str = "►"):
75+
end_indicator: str = "►"):
7676
BaseTextBox.__init__(self,
7777
pos_x, pos_y,
7878
length, width,
7979
title,
8080
title_colors_pair_nb, title_text_attr,
8181
downtime_chars, downtime_chars_delay)
8282

83-
self.end_dialog_indicator_char = end_dialog_indicator
84-
self.end_dialog_indicator_pos_x = self.pos_x + self.length - 2
83+
self.end_indicator_char = end_indicator
84+
self.end_indicator_pos_x = self.pos_x + self.length - 2
8585

8686
if self.title:
87-
self.end_dialog_indicator_pos_y = self.pos_y + self.width + 1
87+
self.end_indicator_pos_y = self.pos_y + self.width + 1
8888
else:
89-
self.end_dialog_indicator_pos_y = self.pos_y + self.width - 1
89+
self.end_indicator_pos_y = self.pos_y + self.width - 1
9090

9191
self.text_wrapper = textwrap.TextWrapper(width=self.nb_char_max_line)
9292

@@ -96,26 +96,26 @@ def __enter__(self):
9696
def __exit__(self, type, value, traceback):
9797
...
9898

99-
def _display_end_dialog_indicator(
99+
def _display_end_indicator(
100100
self,
101101
win: CursesWindow,
102102
text_attr: CursesTextAttributesConstants = (curses.A_BOLD,
103103
curses.A_BLINK)):
104-
"""Displays an end of dialog indicator in the lower right corner
105-
of textbox.
104+
"""Displays an end indicator in the lower right corner of
105+
textbox.
106106
107107
:param win: ``curses`` window object on which the method
108108
will have effect.
109109
110110
:param text_attr: Text attributes of
111-
``end_dialog_indicator`` method. This defaults to
111+
``end_indicator`` method. This defaults to
112112
``(curses.A_BOLD, curses.A_BLINK)``.
113113
"""
114-
if self.end_dialog_indicator_char:
114+
if self.end_indicator_char:
115115
with TextAttributes(win, *text_attr):
116-
win.addch(self.end_dialog_indicator_pos_y,
117-
self.end_dialog_indicator_pos_x,
118-
self.end_dialog_indicator_char)
116+
win.addch(self.end_indicator_pos_y,
117+
self.end_indicator_pos_x,
118+
self.end_indicator_char)
119119

120120
def char_by_char(
121121
self,
@@ -249,7 +249,7 @@ def char_by_char(
249249
# Compensates for the space between words.
250250
offsetting_x += len(word) + 1
251251

252-
self._display_end_dialog_indicator(win)
252+
self._display_end_indicator(win)
253253
self.getkey(win)
254254

255255
def word_by_word(
@@ -321,7 +321,6 @@ def word_by_word(
321321
- Writing paragraph by paragraph.
322322
- Writing each line of the current paragraph, word by
323323
word.
324-
- Calling ``_display_end_dialog_indicator`` method.
325324
- Waits until a key contained in the class attribute
326325
``confirm_dialog_key`` was pressed before writing the
327326
following paragraph.
@@ -380,5 +379,5 @@ def word_by_word(
380379

381380
callback(*cargs)
382381

383-
self._display_end_dialog_indicator(win)
382+
self._display_end_indicator(win)
384383
self.getkey(win)

0 commit comments

Comments
 (0)