Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add internal/platform/utils_js.go to allow building under wasm #74

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
readline
========

[![Godoc](https://godoc.org/github.com/ergochat/readline?status.svg)](https://godoc.org/github.com/ergochat/readline)
[![Godoc](https://godoc.org/github.com/cogentcore/readline?status.svg)](https://godoc.org/github.com/cogentcore/readline)

This is a pure Go implementation of functionality comparable to [GNU Readline](https://en.wikipedia.org/wiki/GNU_Readline), i.e. line editing and command history for simple TUI programs.

It is a fork of [chzyer/readline](https://github.com/chzyer/readline).


* Relative to the upstream repository, it is actively maintained and has numerous bug fixes
- See our [changelog](docs/CHANGELOG.md) for details on fixes and improvements
- See our [migration guide](docs/MIGRATING.md) for advice on how to migrate from upstream
Expand All @@ -21,7 +22,7 @@ import (
"fmt"
"log"

"github.com/ergochat/readline"
"github.com/cogentcore/readline"
)

func main() {
Expand Down
4 changes: 2 additions & 2 deletions complete.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"fmt"
"sync/atomic"

"github.com/ergochat/readline/internal/platform"
"github.com/ergochat/readline/internal/runes"
"github.com/cogentcore/readline/internal/platform"
"github.com/cogentcore/readline/internal/runes"
)

type AutoCompleter interface {
Expand Down
2 changes: 1 addition & 1 deletion complete_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"strings"

"github.com/ergochat/readline/internal/runes"
"github.com/cogentcore/readline/internal/runes"
)

// PrefixCompleter implements AutoCompleter via a recursive tree.
Expand Down
2 changes: 1 addition & 1 deletion docs/MIGRATING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Migrating

ergochat/readline is largely API-compatible with the most commonly used functionality of chzyer/readline. See our [godoc page](https://pkg.go.dev/github.com/ergochat/readline) for the current state of the public API; if an API you were using has been removed, its replacement may be readily apparent.
ergochat/readline is largely API-compatible with the most commonly used functionality of chzyer/readline. See our [godoc page](https://pkg.go.dev/github.com/cogentcore/readline) for the current state of the public API; if an API you were using has been removed, its replacement may be readily apparent.

Here are some guidelines for APIs that have been removed or changed:

Expand Down
2 changes: 1 addition & 1 deletion example/readline-demo/readline-demo.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"strings"
"time"

"github.com/ergochat/readline"
"github.com/cogentcore/readline"
)

func usage(w io.Writer) {
Expand Down
2 changes: 1 addition & 1 deletion example/readline-multiline/readline-multiline.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package main
import (
"strings"

"github.com/ergochat/readline"
"github.com/cogentcore/readline"
)

func main() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strconv"
"strings"

"github.com/ergochat/readline"
"github.com/cogentcore/readline"
)

var letters = []rune("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
Expand Down
2 changes: 1 addition & 1 deletion example/readline-pass-strength/readline-pass-strength.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ package main
import (
"fmt"

"github.com/ergochat/readline"
"github.com/cogentcore/readline"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/ergochat/readline
module github.com/cogentcore/readline

go 1.19

Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
2 changes: 1 addition & 1 deletion history.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"sync"

"github.com/ergochat/readline/internal/runes"
"github.com/cogentcore/readline/internal/runes"
)

type hisItem struct {
Expand Down
37 changes: 37 additions & 0 deletions internal/platform/utils_js.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//go:build js

package platform

import (
"syscall"

"github.com/cogentcore/readline/internal/term"
)

const (
IsWindows = false
)

func SuspendProcess() {
}

// GetScreenSize returns the width, height of the terminal or -1,-1
func GetScreenSize() (width int, height int) {
width, height, err := term.GetSize(int(syscall.Stdout))
if err == nil {
return width, height
} else {
return 0, 0
}
}

func DefaultIsTerminal() bool {
return term.IsTerminal(int(syscall.Stdin)) && term.IsTerminal(int(syscall.Stdout))
}

func DefaultOnWidthChanged(f func()) {
DefaultOnSizeChanged(f)
}

func DefaultOnSizeChanged(f func()) {
}
2 changes: 1 addition & 1 deletion internal/platform/utils_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"sync"
"syscall"

"github.com/ergochat/readline/internal/term"
"github.com/cogentcore/readline/internal/term"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion internal/platform/utils_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ package platform
import (
"syscall"

"github.com/ergochat/readline/internal/term"
"github.com/cogentcore/readline/internal/term"
)

const (
Expand Down
4 changes: 2 additions & 2 deletions operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import (
"sync"
"sync/atomic"

"github.com/ergochat/readline/internal/platform"
"github.com/ergochat/readline/internal/runes"
"github.com/cogentcore/readline/internal/platform"
"github.com/cogentcore/readline/internal/runes"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion readline.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sync"
"syscall"

"github.com/ergochat/readline/internal/platform"
"github.com/cogentcore/readline/internal/platform"
)

type Instance struct {
Expand Down
2 changes: 1 addition & 1 deletion runebuf.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"sync"

"github.com/ergochat/readline/internal/runes"
"github.com/cogentcore/readline/internal/runes"
)

type runeBuffer struct {
Expand Down
4 changes: 2 additions & 2 deletions terminal.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import (
"sync/atomic"
"time"

"github.com/ergochat/readline/internal/ansi"
"github.com/ergochat/readline/internal/platform"
"github.com/cogentcore/readline/internal/ansi"
"github.com/cogentcore/readline/internal/platform"
)

const (
Expand Down
2 changes: 1 addition & 1 deletion undo.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package readline

import (
"github.com/ergochat/readline/internal/ringbuf"
"github.com/cogentcore/readline/internal/ringbuf"
)

type undoEntry struct {
Expand Down
2 changes: 1 addition & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"sync"
"syscall"

"github.com/ergochat/readline/internal/term"
"github.com/cogentcore/readline/internal/term"
)

const (
Expand Down