mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
Compare commits
2 Commits
9ad7fe5bed
...
dd63eef65e
Author | SHA1 | Date | |
---|---|---|---|
|
dd63eef65e | ||
|
f3bd56b0ed |
58
exp/textinput/textinput_noime.go
Normal file
58
exp/textinput/textinput_noime.go
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
// Copyright 2023 The Ebitengine Authors
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
//go:build (!darwin && !js && !windows) || ios
|
||||||
|
|
||||||
|
package textinput
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/hajimehoshi/ebiten/v2"
|
||||||
|
"github.com/hajimehoshi/ebiten/v2/internal/ui"
|
||||||
|
)
|
||||||
|
|
||||||
|
type textInput struct {
|
||||||
|
rs []rune
|
||||||
|
lastTick uint64
|
||||||
|
}
|
||||||
|
|
||||||
|
var theTextInput textInput
|
||||||
|
|
||||||
|
func (t *textInput) Start(x, y int) (chan State, func()) {
|
||||||
|
// AppendInputChars is updated only when the tick is updated.
|
||||||
|
// If the tick is not updated, return nil immediately.
|
||||||
|
tick := ui.Get().Tick()
|
||||||
|
if t.lastTick == tick {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
defer func() {
|
||||||
|
t.lastTick = tick
|
||||||
|
}()
|
||||||
|
|
||||||
|
s := newSession()
|
||||||
|
|
||||||
|
// This is a pseudo implementation with AppendInputChars without IME.
|
||||||
|
// This is tentative and should be replaced with IME in the future.
|
||||||
|
t.rs = ebiten.AppendInputChars(t.rs[:0])
|
||||||
|
if len(t.rs) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
s.ch <- State{
|
||||||
|
Text: string(t.rs),
|
||||||
|
Committed: true,
|
||||||
|
}
|
||||||
|
// Keep the channel as end() resets s.ch.
|
||||||
|
ch := s.ch
|
||||||
|
s.end()
|
||||||
|
return ch, nil
|
||||||
|
}
|
@ -1,25 +0,0 @@
|
|||||||
// Copyright 2023 The Ebitengine Authors
|
|
||||||
//
|
|
||||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
// you may not use this file except in compliance with the License.
|
|
||||||
// You may obtain a copy of the License at
|
|
||||||
//
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
//
|
|
||||||
// Unless required by applicable law or agreed to in writing, software
|
|
||||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
// See the License for the specific language governing permissions and
|
|
||||||
// limitations under the License.
|
|
||||||
|
|
||||||
//go:build (!darwin && !js && !windows) || ios
|
|
||||||
|
|
||||||
package textinput
|
|
||||||
|
|
||||||
type textInput struct{}
|
|
||||||
|
|
||||||
var theTextInput textInput
|
|
||||||
|
|
||||||
func (t *textInput) Start(x, y int) (chan State, func()) {
|
|
||||||
return nil, nil
|
|
||||||
}
|
|
2
go.mod
2
go.mod
@ -9,7 +9,7 @@ require (
|
|||||||
github.com/ebitengine/purego v0.8.0-alpha.4
|
github.com/ebitengine/purego v0.8.0-alpha.4
|
||||||
github.com/gen2brain/mpeg v0.3.2-0.20240412154320-a2ac4fc8a46f
|
github.com/gen2brain/mpeg v0.3.2-0.20240412154320-a2ac4fc8a46f
|
||||||
github.com/go-text/typesetting v0.1.1
|
github.com/go-text/typesetting v0.1.1
|
||||||
github.com/hajimehoshi/bitmapfont/v3 v3.2.0-alpha.3
|
github.com/hajimehoshi/bitmapfont/v3 v3.2.0-alpha.4
|
||||||
github.com/hajimehoshi/go-mp3 v0.3.4
|
github.com/hajimehoshi/go-mp3 v0.3.4
|
||||||
github.com/jakecoffman/cp v1.2.1
|
github.com/jakecoffman/cp v1.2.1
|
||||||
github.com/jezek/xgb v1.1.1
|
github.com/jezek/xgb v1.1.1
|
||||||
|
6
go.sum
6
go.sum
@ -13,8 +13,8 @@ github.com/go-text/typesetting v0.1.1/go.mod h1:d22AnmeKq/on0HNv73UFriMKc4Ez6EqZ
|
|||||||
github.com/go-text/typesetting-utils v0.0.0-20231211103740-d9332ae51f04 h1:zBx+p/W2aQYtNuyZNcTfinWvXBQwYtDfme051PR/lAY=
|
github.com/go-text/typesetting-utils v0.0.0-20231211103740-d9332ae51f04 h1:zBx+p/W2aQYtNuyZNcTfinWvXBQwYtDfme051PR/lAY=
|
||||||
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
||||||
github.com/hajimehoshi/bitmapfont/v3 v3.2.0-alpha.3 h1:gSxacUXbVZcffXOHl/BWGvf61LpJYLoEaZlsiLlWXPk=
|
github.com/hajimehoshi/bitmapfont/v3 v3.2.0-alpha.4 h1:0sMBL2GS9QPgSaExj8UmVpDk667RbT2SXVZprmwEPlY=
|
||||||
github.com/hajimehoshi/bitmapfont/v3 v3.2.0-alpha.3/go.mod h1:kTSlhZN34vbL4Okwi+H9N99DwGTFZ97f6VJKFNqMwIM=
|
github.com/hajimehoshi/bitmapfont/v3 v3.2.0-alpha.4/go.mod h1:/GmYyEKgzzM7dzJBsL7aS5iR83Dr666E5bhQLVVPYsw=
|
||||||
github.com/hajimehoshi/go-mp3 v0.3.4 h1:NUP7pBYH8OguP4diaTZ9wJbUbk3tC0KlfzsEpWmYj68=
|
github.com/hajimehoshi/go-mp3 v0.3.4 h1:NUP7pBYH8OguP4diaTZ9wJbUbk3tC0KlfzsEpWmYj68=
|
||||||
github.com/hajimehoshi/go-mp3 v0.3.4/go.mod h1:fRtZraRFcWb0pu7ok0LqyFhCUrPeMsGRSVop0eemFmo=
|
github.com/hajimehoshi/go-mp3 v0.3.4/go.mod h1:fRtZraRFcWb0pu7ok0LqyFhCUrPeMsGRSVop0eemFmo=
|
||||||
github.com/hajimehoshi/oto/v2 v2.3.1/go.mod h1:seWLbgHH7AyUMYKfKYT9pg7PhUu9/SisyJvNTT+ASQo=
|
github.com/hajimehoshi/oto/v2 v2.3.1/go.mod h1:seWLbgHH7AyUMYKfKYT9pg7PhUu9/SisyJvNTT+ASQo=
|
||||||
@ -37,7 +37,6 @@ golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5y
|
|||||||
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
|
golang.org/x/crypto v0.13.0/go.mod h1:y6Z2r+Rw4iayiXXAIxJIDAJ1zMW4yaTpebo8fPOliYc=
|
||||||
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||||
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||||
golang.org/x/image v0.18.0/go.mod h1:4yyo5vMFQjVjUcVk4jEQcU9MGy/rulF5WvUILseCM2E=
|
|
||||||
golang.org/x/image v0.19.0 h1:D9FX4QWkLfkeqaC62SonffIIuYdOk/UE2XKUBgRIBIQ=
|
golang.org/x/image v0.19.0 h1:D9FX4QWkLfkeqaC62SonffIIuYdOk/UE2XKUBgRIBIQ=
|
||||||
golang.org/x/image v0.19.0/go.mod h1:y0zrRqlQRWQ5PXaYCOMLTW2fpsxZ8Qh9I/ohnInJEys=
|
golang.org/x/image v0.19.0/go.mod h1:y0zrRqlQRWQ5PXaYCOMLTW2fpsxZ8Qh9I/ohnInJEys=
|
||||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
@ -93,7 +92,6 @@ golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
|||||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
|
||||||
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
|
golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc=
|
||||||
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
@ -153,6 +153,8 @@ func (c *context) updateFrameImpl(graphicsDriver graphicsdriver.Graphics, update
|
|||||||
if err := ui.error(); err != nil {
|
if err := ui.error(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui.tick.Add(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update window icons during a frame, since an icon might be *ebiten.Image and
|
// Update window icons during a frame, since an icon might be *ebiten.Image and
|
||||||
|
@ -79,6 +79,7 @@ type UserInterface struct {
|
|||||||
graphicsLibrary atomic.Int32
|
graphicsLibrary atomic.Int32
|
||||||
running atomic.Bool
|
running atomic.Bool
|
||||||
terminated atomic.Bool
|
terminated atomic.Bool
|
||||||
|
tick atomic.Uint64
|
||||||
|
|
||||||
whiteImage *Image
|
whiteImage *Image
|
||||||
|
|
||||||
@ -230,3 +231,7 @@ func (u *UserInterface) isTerminated() bool {
|
|||||||
func (u *UserInterface) setTerminated() {
|
func (u *UserInterface) setTerminated() {
|
||||||
u.terminated.Store(true)
|
u.terminated.Store(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (u *UserInterface) Tick() uint64 {
|
||||||
|
return u.tick.Load()
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user