mirror of
https://github.com/cjdenio/crossword.git
synced 2026-10-03 11:06:19 +00:00
better behavior
This commit is contained in:
1 file changed
+11
-1
@@ -282,15 +282,25 @@ func main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if buffer[0] >= 0x61 && buffer[0] <= 0x7a {
|
if buffer[0] >= 0x61 && buffer[0] <= 0x7a {
|
||||||
|
cellWasFilled := state.PuzzleState[state.SelectedCell] != '-'
|
||||||
state.PuzzleState[state.SelectedCell] = unicode.ToUpper(rune(buffer[0]))
|
state.PuzzleState[state.SelectedCell] = unicode.ToUpper(rune(buffer[0]))
|
||||||
// jump to next unfilled cell in clue
|
|
||||||
i := slices.Index(state.SelectedClue.Cells, state.SelectedCell)
|
i := slices.Index(state.SelectedClue.Cells, state.SelectedCell)
|
||||||
|
|
||||||
|
if !cellWasFilled {
|
||||||
|
// jump to next unfilled cell in clue
|
||||||
for x := i + 1; x < len(state.SelectedClue.Cells); x++ {
|
for x := i + 1; x < len(state.SelectedClue.Cells); x++ {
|
||||||
if state.PuzzleState[state.SelectedClue.Cells[x]] == '-' {
|
if state.PuzzleState[state.SelectedClue.Cells[x]] == '-' {
|
||||||
state.SelectedCell = state.SelectedClue.Cells[x]
|
state.SelectedCell = state.SelectedClue.Cells[x]
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// jump to next cell
|
||||||
|
if i < len(state.SelectedClue.Cells)-1 {
|
||||||
|
state.SelectedCell = state.SelectedClue.Cells[i+1]
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if buffer[0] == 0x7f {
|
if buffer[0] == 0x7f {
|
||||||
|
|||||||
Reference in new issue
Block a user