Skip to content

Commit 9e63b94

Browse files
authored
Merge pull request #2 from jiro4989/feature/#1-signal
Ignore SIGTERM and SIGINT #1
2 parents b6fc90c + a0c2ce9 commit 9e63b94

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

nmi.nimble

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Package
22

3-
version = "1.0.2"
3+
version = "1.1.0"
44
author = "jiro4989"
55
description = "nmi display animations aimed to correct users who accidentally enter nmi instead of nim."
66
license = "MIT"

src/nmi.nim

+13-6
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ const
3838
+@@@
3939
"""
4040
appName = "nmi"
41-
version = &"""{appName} command version 1.0.2
41+
version = &"""{appName} command version 1.1.0
4242
Copyright (c) 2020 jiro4989
4343
Released under the MIT License.
4444
https://github.com/jiro4989/nmi"""
@@ -128,19 +128,26 @@ proc traverse(text: string, color: bool) =
128128
cursorUp(asciiHeight - 1)
129129
sleep 50
130130

131-
when isMainModule:
131+
when isMainModule and not defined modeTest:
132+
when not defined windows:
133+
from posix import onSignal, SIGTERM, SIGINT
134+
onSignal(SIGTERM, SIGINT):
135+
discard
136+
132137
let opts = commandLineParams().getCmdOpts()
133138
if opts.useHelp or opts.useVersion:
134139
quit 0
135140

141+
hideCursor()
142+
eraseScreen()
143+
setCursorPos(0, 0)
144+
traverse(nimAscii, opts.color)
145+
136146
proc closeFunc() {.noconv.} =
137147
showCursor()
138148
eraseScreen()
139149
quit 1
140150

141151
setControlCHook(closeFunc)
142-
hideCursor()
143-
eraseScreen()
144-
setCursorPos(0, 0)
145-
traverse(nimAscii, opts.color)
152+
146153
showCursor()

0 commit comments

Comments
 (0)