Stash bunch of broken generated test with shitty broken mocking
This commit is contained in:
+10
-8
@@ -25,12 +25,14 @@ type Chat struct {
|
||||
cursorPos int
|
||||
scrollOffset int
|
||||
userData interface{}
|
||||
input InputHandler
|
||||
}
|
||||
|
||||
func NewChat() *Chat {
|
||||
return &Chat{
|
||||
messages: make([]types.ChatMessage, 0, maxMessages),
|
||||
inputBuffer: make([]rune, 0, runeLimit),
|
||||
input: &RaylibInput{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,23 +155,23 @@ func (c *Chat) Update() (string, bool) {
|
||||
c.scrollOffset = clamp(c.scrollOffset-int(wheelMove), 0, maxScroll)
|
||||
}
|
||||
|
||||
if rl.IsKeyPressed(rl.KeyT) {
|
||||
if c.input.IsKeyPressed(rl.KeyT) {
|
||||
c.isTyping = true
|
||||
return "", false
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
key := rl.GetCharPressed()
|
||||
key := c.input.GetCharPressed()
|
||||
for key > 0 {
|
||||
if len(c.inputBuffer) < runeLimit {
|
||||
c.inputBuffer = append(c.inputBuffer[:c.cursorPos], append([]rune{key}, c.inputBuffer[c.cursorPos:]...)...)
|
||||
c.cursorPos++
|
||||
}
|
||||
key = rl.GetCharPressed()
|
||||
key = c.input.GetCharPressed()
|
||||
}
|
||||
|
||||
if rl.IsKeyPressed(rl.KeyEnter) || rl.IsKeyPressed(rl.KeyKpEnter) {
|
||||
if c.input.IsKeyPressed(rl.KeyEnter) || c.input.IsKeyPressed(rl.KeyKpEnter) {
|
||||
if len(c.inputBuffer) > 0 {
|
||||
message := string(c.inputBuffer)
|
||||
c.inputBuffer = c.inputBuffer[:0]
|
||||
@@ -180,21 +182,21 @@ func (c *Chat) Update() (string, bool) {
|
||||
c.isTyping = false
|
||||
}
|
||||
|
||||
if rl.IsKeyPressed(rl.KeyEscape) && c.isTyping {
|
||||
if c.input.IsKeyPressed(rl.KeyEscape) && c.isTyping {
|
||||
c.inputBuffer = c.inputBuffer[:0]
|
||||
c.cursorPos = 0
|
||||
c.isTyping = false
|
||||
}
|
||||
|
||||
if rl.IsKeyPressed(rl.KeyBackspace) && c.cursorPos > 0 {
|
||||
if c.input.IsKeyPressed(rl.KeyBackspace) && c.cursorPos > 0 {
|
||||
c.inputBuffer = append(c.inputBuffer[:c.cursorPos-1], c.inputBuffer[c.cursorPos:]...)
|
||||
c.cursorPos--
|
||||
}
|
||||
|
||||
if rl.IsKeyPressed(rl.KeyLeft) && c.cursorPos > 0 {
|
||||
if c.input.IsKeyPressed(rl.KeyLeft) && c.cursorPos > 0 {
|
||||
c.cursorPos--
|
||||
}
|
||||
if rl.IsKeyPressed(rl.KeyRight) && c.cursorPos < len(c.inputBuffer) {
|
||||
if c.input.IsKeyPressed(rl.KeyRight) && c.cursorPos < len(c.inputBuffer) {
|
||||
c.cursorPos++
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user