Skip to content

Commit

Permalink
Move new-lines displayed for the ctrl+c message to default constant (
Browse files Browse the repository at this point in the history
  • Loading branch information
Electro707 committed Dec 29, 2023
1 parent 9ebfe12 commit 10c1764
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 9 deletions.
2 changes: 1 addition & 1 deletion questionary/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
DEFAULT_QUESTION_PREFIX = "?"

# Message shown when a user aborts a question prompt using CTRL-C
DEFAULT_KBI_MESSAGE = "Cancelled by user"
DEFAULT_KBI_MESSAGE = "\nCancelled by user\n"

# Default text shown when the input is invalid
INVALID_INPUT = "Invalid input"
Expand Down
4 changes: 0 additions & 4 deletions questionary/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ def ask(
try:
return self.unsafe_ask(patch_stdout)
except KeyboardInterrupt:
print("")
print(kbi_msg)
print("")
return {}

async def ask_async(
Expand All @@ -115,7 +113,5 @@ async def ask_async(
try:
return await self.unsafe_ask_async(patch_stdout)
except KeyboardInterrupt:
print("")
print(kbi_msg)
print("")
return {}
2 changes: 0 additions & 2 deletions questionary/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ def prompt(
try:
return unsafe_prompt(questions, answers, patch_stdout, true_color, **kwargs)
except KeyboardInterrupt:
print("")
print(kbi_msg)
print("")
return {}


Expand Down
4 changes: 2 additions & 2 deletions questionary/question.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async def ask_async(
sys.stdout.flush()
return await self.unsafe_ask_async(patch_stdout)
except KeyboardInterrupt:
print("\n{}\n".format(kbi_msg))
print("{}".format(kbi_msg))
return None

def ask(
Expand All @@ -63,7 +63,7 @@ def ask(
try:
return self.unsafe_ask(patch_stdout)
except KeyboardInterrupt:
print("\n{}\n".format(kbi_msg))
print("{}".format(kbi_msg))
return None

def unsafe_ask(self, patch_stdout: bool = False) -> Any:
Expand Down

0 comments on commit 10c1764

Please sign in to comment.