Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/pychart/runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@ def run_prompt():
try:
while True:
line = input("$ : ")
statement = line
while line:
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its fine for now just not a nice user experience to press enter 2 times... An alternative might be to allow a specific keybinding (shift+enter) to insert a newline to stdin and stdout. Otherwise we can also implement something along these lines

while line.endsWith('{'):
   ...

This way it adds a newline when needed not everytime.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes but what about

1 ==
1
;

There is just to many edge cases

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but shift enter thing sounds nice

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idk I feel like that should be an error lol, or maybe we make it so it waits until ;?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if(value) {
}

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think its fine for now just not a nice user experience to press enter 2 times... An alternative might be to allow a specific keybinding (shift+enter) to insert a newline to stdin and stdout. Otherwise we can also implement something along these lines

while line.endsWith('{'):
   ...

This way it adds a newline when needed not everytime.

It seems that detecting shift+enter is not the easiest because it's platform dependent, with there being difficulty covering major systems (I'm personally using Ubuntu WSL and the most commonly used library doesn't support it)

line = input('... ')
statement += '\n' + line

if line == ".exit":
break
run(statement)

result = run(line)
if result:
print(result)

except KeyboardInterrupt:
print("Keyboard Interrupt")
exit()
Expand Down