Skip to content

Commit

Permalink
only display curses warning once
Browse files Browse the repository at this point in the history
  • Loading branch information
SilenZcience committed Oct 26, 2023
1 parent 4ad2007 commit ed7e413
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cat_win/util/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ class Editor:
"""
Editor
"""
loading_failed = False

def __init__(self, file: str, file_encoding: str, debug_mode: bool = False) -> None:
"""
defines an Editor object.
Expand Down Expand Up @@ -621,11 +623,16 @@ def open(cls, file: str, file_encoding: str, write_func, on_windows_os: bool,
(bool):
indicates whether or not the editor has written any content to the provided files
"""
if Editor.loading_failed:
return False

if CURSES_MODULE_ERROR:
print("The Editor could not be loaded. No Module 'curses' was found.", file=sys.stderr)
if on_windows_os:
print('If you are on Windows OS, try pip-installing ', end='', file=sys.stderr)
print("'windows-curses'.", file=sys.stderr)
print(file=sys.stderr)
Editor.loading_failed = True
return False
# if not (sys.stdin.isatty() | sys.stdout.isatty()):
# print("The Editor could not be loaded.", file=sys.stderr)
Expand Down

0 comments on commit ed7e413

Please sign in to comment.