Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Jonny Schäfer
tubus
Commits
b624af94
Commit
b624af94
authored
Jan 08, 2016
by
Jonny Schäfer
Browse files
add termClose to restore the terminal state
parent
c576c707
Changes
3
Show whitespace changes
Inline
Side-by-side
error.go
View file @
b624af94
...
...
@@ -8,6 +8,7 @@ import (
func
errorCare
(
err
error
)
{
if
err
!=
nil
{
cliReset
()
termClose
()
log
.
Fatal
(
"An Error occured: "
,
err
,
"
\n\n
I am Sorry :("
)
}
}
logic.go
View file @
b624af94
...
...
@@ -328,6 +328,7 @@ func logicUnknown(command string) {
// logicQuit exits the program
func
logicQuit
(
none
string
)
{
cliReset
()
termClose
()
os
.
Exit
(
0
)
}
...
...
term.go
View file @
b624af94
...
...
@@ -8,6 +8,7 @@ import (
var
(
termTerminal
*
terminal
.
Terminal
termRestore
*
terminal
.
State
)
func
init
()
{
...
...
@@ -19,7 +20,8 @@ func init() {
os
.
Stdout
,
}
_
,
err
:=
terminal
.
MakeRaw
(
int
(
os
.
Stdin
.
Fd
()))
var
err
error
termRestore
,
err
=
terminal
.
MakeRaw
(
int
(
os
.
Stdin
.
Fd
()))
errorCare
(
err
)
termTerminal
=
terminal
.
NewTerminal
(
stdio
,
""
)
...
...
@@ -29,3 +31,10 @@ func init() {
func
termReadLine
()
(
string
,
error
)
{
return
termTerminal
.
ReadLine
()
}
// termClose restores the terminal to its original state
func
termClose
()
{
if
termRestore
!=
nil
{
terminal
.
Restore
(
int
(
os
.
Stdin
.
Fd
()),
termRestore
)
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment