From 76020d07f3b039571918dc273a49ae1481d77d2a Mon Sep 17 00:00:00 2001 From: refaktor Date: Fri, 27 Dec 2024 02:08:56 +0100 Subject: [PATCH] fix for wasm and keyboard --- evaldo/builtins.go | 6 +++--- util/util_wasm.go | 8 ++++++++ util/util_wasm_not.go | 16 ++++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 util/util_wasm.go create mode 100644 util/util_wasm_not.go diff --git a/evaldo/builtins.go b/evaldo/builtins.go index d085eaa1..027f2976 100644 --- a/evaldo/builtins.go +++ b/evaldo/builtins.go @@ -14,7 +14,6 @@ import ( "reflect" "sort" - "github.com/cszczepaniak/keyboard" "github.com/refaktor/rye/env" "github.com/refaktor/rye/term" @@ -8170,8 +8169,9 @@ var builtins = map[string]*env.Builtin{ Doc: "Accepts one value and returns it.", Fn: func(ps *env.ProgramState, arg0 env.Object, arg1 env.Object, arg2 env.Object, arg3 env.Object, arg4 env.Object) env.Object { // close the keyboard opened for terminal - fmt.Println("Closing keyboard in Exit") - keyboard.Close() + // fmt.Println("Closing keyboard in Exit") + // keyboard.Close() + util.BeforeExit() switch code := arg0.(type) { case env.Integer: os.Exit(int(code.Value)) diff --git a/util/util_wasm.go b/util/util_wasm.go new file mode 100644 index 00000000..01b4f56d --- /dev/null +++ b/util/util_wasm.go @@ -0,0 +1,8 @@ +//go:build wasm +// +build wasm + +package util + +func BeforeExit() { + +} diff --git a/util/util_wasm_not.go b/util/util_wasm_not.go new file mode 100644 index 00000000..574b36f8 --- /dev/null +++ b/util/util_wasm_not.go @@ -0,0 +1,16 @@ +//go:build !wasm +// +build !wasm + +package util + +import ( + "fmt" + "github.com/cszczepaniak/keyboard" + +) + + +func BeforeExit() { + fmt.Println("Closing keyboard in Exit") + keyboard.Close() +}