aboutsummaryrefslogtreecommitdiff
path: root/sd.go
diff options
context:
space:
mode:
Diffstat (limited to 'sd.go')
-rw-r--r--sd.go29
1 files changed, 21 insertions, 8 deletions
diff --git a/sd.go b/sd.go
index 26438f8..efe442c 100644
--- a/sd.go
+++ b/sd.go
@@ -2,9 +2,9 @@ package main
import (
"flag"
+ "fmt"
"os"
-
- "golang.org/x/term"
+ "os/exec"
)
var file = flag.String("f", "cards", "cards file")
@@ -12,12 +12,25 @@ var file = flag.String("f", "cards", "cards file")
func main() {
flag.Parse()
- // Put terminal into raw mode
- oldState, err := term.MakeRaw(int(os.Stdin.Fd()))
- if err != nil {
- panic(err)
- }
- defer term.Restore(int(os.Stdin.Fd()), oldState)
+ // https://stackoverflow.com/questions/14094190/function-similar-to-getchar
+ // disable input buffering
+ exec.Command("stty", "-F", "/dev/tty", "cbreak", "min", "1").Run()
+ // do not display entered characters on the screen
+ exec.Command("stty", "-F", "/dev/tty", "-echo").Run()
+ // restore the echoing state when exiting
+ defer exec.Command("stty", "-F", "/dev/tty", "echo").Run()
+ for {
+ fmt.Println("hello world")
+
+ var b []byte = make([]byte, 1)
+ os.Stdin.Read(b)
+ if string(b) == 'y' {
+ } else if string(b) == 'n' {
+
+ } else {
+
+ }
+ }
}