mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2026-04-22 15:57:15 +08:00
exp/textinput: add Field.HasText
Closes #3419 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -281,6 +281,11 @@ func (f *Field) TextForRendering() string {
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// HasText reports whether the field has any text.
|
||||
func (f *Field) HasText() bool {
|
||||
return f.pieceTable.hasText()
|
||||
}
|
||||
|
||||
// TextLengthInBytes returns the length of the current text in bytes.
|
||||
func (f *Field) TextLengthInBytes() int {
|
||||
return f.pieceTable.Len()
|
||||
|
||||
@@ -139,6 +139,15 @@ func (p *pieceTable) writeToWithInsertion(w io.Writer, text string, start, end i
|
||||
return n, nil
|
||||
}
|
||||
|
||||
func (p *pieceTable) hasText() bool {
|
||||
for _, item := range p.items() {
|
||||
if item.start < item.end {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (p *pieceTable) Len() int {
|
||||
var n int
|
||||
items := p.items()
|
||||
|
||||
Reference in New Issue
Block a user