scriptcs icon indicating copy to clipboard operation
scriptcs copied to clipboard

Double Ctrl+C to exit

Open khellang opened this issue 11 years ago • 8 comments

We should add a "Press Ctrl+C again to exit" confirmation so you don't exit by accident, like Node. We should be able to use the Console.CancelKeyPress event for this. By setting the ConsoleCancelEventArgs.Cancel property to true, you can continue execution.

Cancel, which allows you to determine how to your application should respond to the user pressing Ctrl+C or Ctrl+Break. By default, the Cancel property is false, which causes program execution to terminate when the event handler exits. Changing its property to true specifies that the application should continue to execute.

Anyone up for it? :smile:

khellang avatar May 18 '14 22:05 khellang

I played around with it once but it's a minefield. Not in short because Console.CancelKeyPress goes off on some threadpool thread. But if anyone can get it working, :+1:. Maybe I was just being dumb.

adamralph avatar May 18 '14 22:05 adamralph

Or we can introduce a seperate set of keys to exit. This will be necessary once this come in (https://github.com/scriptcs/scriptcs/issues/685)

On Sun, May 18, 2014 at 3:44 PM, Adam Ralph [email protected]:

I played around with it once but it's a minefield. Not in short because Console.CancelKeyPress goes off on some threadpool thread. But if anyone can get it working, [image: :+1:]. Maybe I was just being dumb.

— Reply to this email directly or view it on GitHubhttps://github.com/scriptcs/scriptcs/issues/698#issuecomment-43455978 .

glennblock avatar May 19 '14 02:05 glennblock

For the sake of aligning with Python would Ctrl+Z, or Ctrl+D be a viable candidate?

organicit avatar May 25 '14 02:05 organicit

I personally prefer CTRl + C. Feels more intuitive for most C# devs.

Open to other opinions of course.

dschenkelman avatar May 25 '14 02:05 dschenkelman

@dschenkelman agree here ^C feels best from both *nix side and windows :)

BrendanThompson avatar May 25 '14 22:05 BrendanThompson

And I think, as far as the console goes, Ctrl+C or Ctrl+Break is our only (?) option...

khellang avatar May 25 '14 22:05 khellang

Question about the method 'Exit' in ScriptCs.Hosting.ScriptConsole.

https://github.com/scriptcs/scriptcs/blob/dev/src/ScriptCs.Hosting/ScriptConsole.cs

Are you folks intending to use that as the means of exiting the application? It looks like you are just wanting to call ResetColor in the places I see you using it. In particular I'm looking at Program.ParseArguments

https://github.com/scriptcs/scriptcs/blob/dev/src/ScriptCs/Program.cs

but, there are other places that I would imagine you do not want to actually exit the application.

musicm122 avatar Nov 05 '14 17:11 musicm122

I'll take a look

zvonimirr avatar Jul 06 '17 10:07 zvonimirr