mirror of
https://github.com/cjdenio/crossword.git
synced 2026-10-03 11:06:19 +00:00
fix bug
This commit is contained in:
2 files changed
+30
-15
No files matched your search
@@ -1,9 +1,8 @@
|
||||
todo
|
||||
|
||||
- fix bug with that one 6x6 puzzle
|
||||
- correctly calculate uiHeight with multi-line clues
|
||||
- timer
|
||||
- reveal grid/word
|
||||
- .puz checksums
|
||||
- fix shift+enter / short+tab in other terminals
|
||||
- fix shift+enter / shift+tab in other terminals
|
||||
- clear grid
|
||||
+29
-13
@@ -348,6 +348,23 @@ func (state *State) LoadSaveFile(f []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (state *State) SwitchDirections() bool {
|
||||
switch state.SelectedClue.Direction {
|
||||
case puz.DirectionAcross:
|
||||
if state.Puzzle.Cells[state.SelectedCell][1] != nil {
|
||||
state.SelectedClue = state.Puzzle.Cells[state.SelectedCell][1]
|
||||
}
|
||||
return true
|
||||
case puz.DirectionDown:
|
||||
if state.Puzzle.Cells[state.SelectedCell][0] != nil {
|
||||
state.SelectedClue = state.Puzzle.Cells[state.SelectedCell][0]
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
func (state *State) HandleInput(buffer []byte) (exited bool) {
|
||||
if len(buffer) == 0 {
|
||||
return false
|
||||
@@ -360,16 +377,7 @@ func (state *State) HandleInput(buffer []byte) (exited bool) {
|
||||
}
|
||||
|
||||
if buffer[0] == ' ' {
|
||||
switch state.SelectedClue.Direction {
|
||||
case puz.DirectionAcross:
|
||||
if state.Puzzle.Cells[state.SelectedCell][1] != nil {
|
||||
state.SelectedClue = state.Puzzle.Cells[state.SelectedCell][1]
|
||||
}
|
||||
case puz.DirectionDown:
|
||||
if state.Puzzle.Cells[state.SelectedCell][0] != nil {
|
||||
state.SelectedClue = state.Puzzle.Cells[state.SelectedCell][0]
|
||||
}
|
||||
}
|
||||
state.SwitchDirections()
|
||||
}
|
||||
|
||||
if buffer[0] >= 0x61 && buffer[0] <= 0x7a {
|
||||
@@ -427,9 +435,9 @@ func (state *State) HandleInput(buffer []byte) (exited bool) {
|
||||
|
||||
if string(buffer[0:2]) == "\x1b[" {
|
||||
if (buffer[2] == 68 || buffer[2] == 67) && state.SelectedClue != nil && state.SelectedClue.Direction == puz.DirectionDown {
|
||||
state.SelectedClue = state.Puzzle.Cells[state.SelectedCell][0]
|
||||
state.SwitchDirections()
|
||||
} else if (buffer[2] == 65 || buffer[2] == 66) && state.SelectedClue != nil && state.SelectedClue.Direction == puz.DirectionAcross {
|
||||
state.SelectedClue = state.Puzzle.Cells[state.SelectedCell][1]
|
||||
state.SwitchDirections()
|
||||
} else {
|
||||
switch buffer[2] {
|
||||
case 68: // left
|
||||
@@ -444,10 +452,18 @@ func (state *State) HandleInput(buffer []byte) (exited bool) {
|
||||
|
||||
switch state.SelectedClue.Direction {
|
||||
case puz.DirectionAcross:
|
||||
if state.Puzzle.Cells[state.SelectedCell][0] != nil {
|
||||
state.SelectedClue = state.Puzzle.Cells[state.SelectedCell][0]
|
||||
case puz.DirectionDown:
|
||||
} else {
|
||||
state.SelectedClue = state.Puzzle.Cells[state.SelectedCell][1]
|
||||
}
|
||||
case puz.DirectionDown:
|
||||
if state.Puzzle.Cells[state.SelectedCell][1] != nil {
|
||||
state.SelectedClue = state.Puzzle.Cells[state.SelectedCell][1]
|
||||
} else {
|
||||
state.SelectedClue = state.Puzzle.Cells[state.SelectedCell][0]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false
|
||||
|
||||
Reference in new issue
Block a user