kalk icon indicating copy to clipboard operation
kalk copied to clipboard

Ctrl-C quits application

Open dsuoch-intel opened this issue 4 years ago • 1 comments

When I get the syntax wrong, I get some helpful red text but the cursor remains on the original line. Unfortunately, my shell muscle memory makes me hit Ctrl-C which exits the app and I loose everything from my current session.

Kalk opens a dedicated window. AFAIK it's not an interactive shell (like Python or some other compilers / environments) that can be run via terminal where you might need to "abort".

I don't think Ctrl-C should quit the application without a warning. Preferably it would not do anything (except if something is selected, then of course it should copy as it currently does).

dsuoch-intel avatar Mar 25 '21 18:03 dsuoch-intel

Kalk opens a dedicated window. AFAIK it's not an interactive shell (like Python or some other compilers / environments) that can be run via terminal where you might need to "abort".

Hm, actually, you can run kalk from a terminal, so it's a kind of interactive shell, but in Python or pwsh, you can't quit with CTRL+C either so...

I could first change the behavior so that CTRL+C on an error line would skip it and go to the next line...

But as CTRL+C can be used also to copy/paste it can be tricky to copy and not trigger the exit... so yep, maybe I should remove this behavior entirely.

xoofx avatar Mar 25 '21 18:03 xoofx

When I exit a terminal session in Linux, I typically press CTRL-D that may work as an alternative that would be intuitive to many.

rlove avatar Nov 28 '22 03:11 rlove

For consistency, I suggest exiting on the platform-appropriate end-of-file character: i.e., ^D on Linux, and ^Z on Windows.

cerebrate avatar Dec 02 '22 06:12 cerebrate

For consistency, I suggest exiting on the platform-appropriate end-of-file character: i.e., ^D on Linux, and ^Z on Windows.

Hm, not a fan of ^Z on Windows, more used for Undo than exiting a program. If I try python.exe on Windows, the way to exit from it is to do CTRL+C. I'm not a fan, but at least it is more consistent. Not sure if there is a real agreement on command line exit on Windows?

xoofx avatar Dec 02 '22 07:12 xoofx

Hrm. That's curious, because that's not the way Python on Windows behaves for me. ^C for me produces a KeyboardInterrupt exception but doesn't exit:

 ❯ python
Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
KeyboardInterrupt
>>>

while ^Z does exit. One difference from Unix in that you have to hit enter after ^Z because Windows defaults to line-oriented input rather than character-oriented, but nevertheless, ^Z it is.

 ❯ python
Python 3.9.13 (tags/v3.9.13:6de2ca5, May 17 2022, 16:36:42) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> ^Z

 ❯

(My understanding is that ^D is used for command-line exit under Unix because it's ASCII EOT, used as the end-of-file marker, whereas Windows uses ^Z for backwards compatibility because it inherited that from DOS and in turn from CP/M; and so when writing to file from a command line, with cat > test or copy con test, a ^D or ^Z will end the write successfully, vis-a-vis ^C to interrupt/end and fail. I've seen a number of utilities ported from Unix to Windows maintain this convention on those grounds.)

cerebrate avatar Dec 02 '22 16:12 cerebrate

Hrm. That's curious, because that's not the way Python on Windows behaves for me. ^C for me produces a KeyboardInterrupt exception but doesn't exit:

Oh right, I was using a 2.x version but the 3.x version is behaving differently.

Ok, if that's the way, I can change it for consistency.

xoofx avatar Dec 02 '22 17:12 xoofx

Fixed by commit 4db963b and available soon in 0.8.1. I selected CTRL+Z for all platforms because CTRL+d was already used.

xoofx avatar Dec 03 '22 07:12 xoofx

I selected CTRL+Z for all platforms because CTRL+d was already used.

Here's a thought. Since ^D is an alias for DEL in kalk, it's not going to be used on an input line without text on it. Perhaps ^D could be used for exit only when typed on otherwise empty input lines, or even only when typed as the first character on a new input line (meaning typing text, deleting it all, and then ^D would not exit, thus preventing people from accidentally exiting when using it as DEL). That way, it could coexist with ^D in its current meaning, and still give Linux users their expectation.

On a related note, having tried out 0.8.1 now, could I suggest that the ^C behavior be changed from the current no-op to "abandon the current line (leaving it on screen), possibly with an error message, and issue a new prompt"? Again, that's just a consistent experience thing: most shells, python, etc., react to ^C this way.

cerebrate avatar Dec 04 '22 21:12 cerebrate

Another thing just occurred to me as I noticed it.

Taking over ^Z for exit in kalk will break the normal function of ^Z on Linux/Unix; namely, suspending the application and returning to the shell until it's resumed or placed in the background (fg or bg command). (This is built into shells, so not something kalk needs to handle itself.) Taking this over is going to result in a lot of exits where suspends were intended, I fear.

cerebrate avatar Dec 16 '22 21:12 cerebrate