mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-11-17 18:45:10 +00:00
Print error message to stderr on unexpected exit
This commit is contained in:
parent
2aa739be81
commit
d64828ce6d
@ -241,7 +241,7 @@ func (r *LightRenderer) getBytesInternal(buffer []byte) []byte {
|
||||
c, ok := r.getch(false)
|
||||
if !ok {
|
||||
r.Close()
|
||||
errorExit()
|
||||
errorExit("Failed to read /dev/tty")
|
||||
}
|
||||
|
||||
retries := 0
|
||||
|
@ -25,7 +25,6 @@ int c_getcurx(WINDOW* win) {
|
||||
import "C"
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
@ -109,13 +108,11 @@ func (r *FullscreenRenderer) Init() {
|
||||
C.setlocale(C.LC_ALL, C.CString(""))
|
||||
tty := C.c_tty()
|
||||
if tty == nil {
|
||||
fmt.Println("Failed to open /dev/tty")
|
||||
errorExit()
|
||||
errorExit("Failed to open /dev/tty")
|
||||
}
|
||||
_screen = C.c_newterm(tty)
|
||||
if _screen == nil {
|
||||
fmt.Println("Invalid $TERM: " + os.Getenv("TERM"))
|
||||
errorExit()
|
||||
errorExit("Invalid $TERM: " + os.Getenv("TERM"))
|
||||
}
|
||||
C.set_term(_screen)
|
||||
if r.mouse {
|
||||
@ -380,7 +377,7 @@ func (r *FullscreenRenderer) GetChar() Event {
|
||||
case C.ERR:
|
||||
// Unexpected error from blocking read
|
||||
r.Close()
|
||||
errorExit()
|
||||
errorExit("Failed to read /dev/tty")
|
||||
case C.KEY_UP:
|
||||
return Event{Up, 0, nil}
|
||||
case C.KEY_DOWN:
|
||||
|
@ -6,9 +6,6 @@ import (
|
||||
"time"
|
||||
"unicode/utf8"
|
||||
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"runtime"
|
||||
|
||||
// https://github.com/gdamore/tcell/pull/135
|
||||
@ -123,12 +120,10 @@ var (
|
||||
func (r *FullscreenRenderer) initScreen() {
|
||||
s, e := tcell.NewScreen()
|
||||
if e != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", e)
|
||||
errorExit()
|
||||
errorExit(e.Error())
|
||||
}
|
||||
if e = s.Init(); e != nil {
|
||||
fmt.Fprintf(os.Stderr, "%v\n", e)
|
||||
errorExit()
|
||||
errorExit(e.Error())
|
||||
}
|
||||
if r.mouse {
|
||||
s.EnableMouse()
|
||||
|
@ -1,6 +1,7 @@
|
||||
package tui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
@ -284,7 +285,8 @@ func EmptyTheme() *ColorTheme {
|
||||
Border: colUndefined}
|
||||
}
|
||||
|
||||
func errorExit() {
|
||||
func errorExit(message string) {
|
||||
fmt.Fprintln(os.Stderr, message)
|
||||
os.Exit(2)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user