-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SIGINT (Exiting RootWindow's Run Method) #8
Comments
I have added an options parameter to the |
@LokiMidgard Using the latest commit, I get the following error on the Run method of
|
I've added this line Line 179 in 9361d5f
In my tests this runs without problems, are you setting a Thread name somewhere explicit? |
No, I am not setting a thread name. Here is a PowerShell example which simply creates an empty grid: $NDPropertyDll = "C:\Users\thecliguy\.nuget\packages\ndproperty.core\0.13.12\lib\netstandard1.3\NDProperty.Core.dll"
Add-Type -Path $NDPropertyDll -PassThru
$NitoDisposablesDll = "C:\Users\thecliguy\.nuget\packages\nito.disposables\1.2.1\lib\netstandard1.0\Nito.Disposables.dll"
Add-Type -Path $NitoDisposablesDll -PassThru
$NitoAsyncDll = "C:\Users\thecliguy\.nuget\packages\nito.asyncex.context\5.0.0-pre-03\lib\netstandard1.3\Nito.AsyncEx.Context.dll"
Add-Type -Path $NitoAsyncDll -PassThru
$NitoTasksDll = "C:\Users\thecliguy\.nuget\packages\nito.asyncex.tasks\5.0.0-pre-03\lib\netstandard1.3\Nito.AsyncEx.Tasks.dll"
Add-Type -Path $NitoTasksDll -PassThru
$NsciDLL = "C:\Users\thecliguy\Documents\Scripts\NSCI_Tests\NSCI-master_24-06-18\NSCI-master\NSCI\bin\Debug\netstandard2.0\NSCI.dll"
Add-Type -Path $NsciDLL -PassThru
$Root = [NSCI.UI.RootWindow]::new()
$grid = [NSCI.UI.Controls.Layout.Grid]::new()
$Root.Content = $grid;
$Root.Run() I have also tried passing $NsciOptions = [NSCI.UI.NsciOptions]::new()
$Root = [NSCI.UI.RootWindow]::new($NsciOptions) |
Hm... |
That has fixed the error, but I cannot get ctrl + c to work in PowerShell. I have implemented the following, but when pressing ctrl + c nothing happens: $NsciOptions = [NSCI.UI.NsciOptions]::new()
$NsciOptions.TreatControlCAsInput = $False
$Root = [NSCI.UI.RootWindow]::new($NsciOptions) It works fine for me in C# though: var NsciOptions = new NSCI.UI.NsciOptions
{
TreatControlCAsInput = false
};
var root = new NSCI.UI.RootWindow(NsciOptions); Any ideas? Does it work in PowerShell for you? |
Unfrotunatly I have no idea. The I'm not sure whit the scripting stuff, maybe ctrl-c would terminate the process, but there was no process started. So only the executed function is terminated, but not additional threads that were spawned like UI and input thread. If that would be the case, then you would need to handle OnCancelPressed yourself and call Detach on the RootWindow. |
I've noticed wired behavior when the application was terminated via Most likely the input thread was still running. It was actually an endless loop, that was intended to live as long as the process. And when the process was killed it should vanish. But this did not happen in PowerShell. I no explicitly stop the Thread if the app was stoped like the UI thread before. However The thread is most likely currently blocking in So, for PowerShell you must handle the Ctrl+C command with a Detach yourself. |
@LokiMidgard OK, I have handled ctrl + c by assigning a ScriptBlock to $NsciOptions = [NSCI.UI.NsciOptions]::new()
$NsciOptions.TreatControlCAsInput = $False
$NsciOptions.OnCancelPressed = {$Root.Detach()}
$Root = [NSCI.UI.RootWindow]::new($NsciOptions) ctrl + c now exits the script but there are two problems... Problem 1: Problem 2: Possible solution: Here is some information on the If NSCI used the I can do some more research into implementing |
@LokiMidgard Your commit to terminate input thread when application stops (48336a4) has fixed problem 1 in my last comment. |
…ing screen as recommanded by @thecliguy in #8
If this would work, it would be nice. But as far as I know the C# I have disabled |
I still have this problem for the first charakter I type after termination. Maybe I need to operate on the inputstream directly instead of using the |
Sorry, I don't think the changes in f62db0e are a good idea. I think its better to revert those changes and implement VT escape sequence support has existed in *nix forever. In Windows, it was introduced into conhost in the Windows 10 Anniversary Update: https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences The reason the VT escape sequence was not working for you is because you have to explicitly enable Virtual Terminal Processing in NSCI for the Windows console. Please see this example: thecliguy@d21d392, where I have
It is not the best code because I am not a C# developer. |
I forgot to remove the changes from this commit in my code: f62db0e Its better they are removed. |
Up to now I explicitly tried to avoid native code and have a .net only implementation. The next thing that comes in mind is what happens on Systems previor to Windows 10 Anniversary Update. I still would like to use the alternate screenbuffer, currently I have some problems with the line break of the last char and I hope the alternate screen buffer could prevent this. By the way, thanks for your implementation. I will look at it in the next days. |
If you don't mind we can continue this in #16. |
Conventionally, console applications respond to CTRL+C as a
SIGINT
signal and not as keyboard input.SIGINT
can be intercepted by an application so that it can perform a clean exit.Windows doesn't have many examples of interactive console applications, but one example is the text editor Vim. Upon intercepting a
SIGINT
Vim prompts the user to exit the program by using its quit syntax:On Linux, there are many examples of console applications which respond to
SIGINT
, such as:Ideally NSCI would give the programmer the option to simply ignore
SIGINT
or to take some action.The text was updated successfully, but these errors were encountered: