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
+31
-16
No files matched your search
@@ -1,9 +1,8 @@
|
|||||||
todo
|
todo
|
||||||
|
|
||||||
- fix bug with that one 6x6 puzzle
|
|
||||||
- correctly calculate uiHeight with multi-line clues
|
- correctly calculate uiHeight with multi-line clues
|
||||||
- timer
|
- timer
|
||||||
- reveal grid/word
|
- reveal grid/word
|
||||||
- .puz checksums
|
- .puz checksums
|
||||||
- fix shift+enter / short+tab in other terminals
|
- fix shift+enter / shift+tab in other terminals
|
||||||
- clear grid
|
- clear grid
|
||||||
+30
-14
@@ -348,6 +348,23 @@ func (state *State) LoadSaveFile(f []byte) error {
|
|||||||
return nil
|
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) {
|
func (state *State) HandleInput(buffer []byte) (exited bool) {
|
||||||
if len(buffer) == 0 {
|
if len(buffer) == 0 {
|
||||||
return false
|
return false
|
||||||
@@ -360,16 +377,7 @@ func (state *State) HandleInput(buffer []byte) (exited bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if buffer[0] == ' ' {
|
if buffer[0] == ' ' {
|
||||||
switch state.SelectedClue.Direction {
|
state.SwitchDirections()
|
||||||
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]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if buffer[0] >= 0x61 && buffer[0] <= 0x7a {
|
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 string(buffer[0:2]) == "\x1b[" {
|
||||||
if (buffer[2] == 68 || buffer[2] == 67) && state.SelectedClue != nil && state.SelectedClue.Direction == puz.DirectionDown {
|
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 {
|
} 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 {
|
} else {
|
||||||
switch buffer[2] {
|
switch buffer[2] {
|
||||||
case 68: // left
|
case 68: // left
|
||||||
@@ -444,9 +452,17 @@ func (state *State) HandleInput(buffer []byte) (exited bool) {
|
|||||||
|
|
||||||
switch state.SelectedClue.Direction {
|
switch state.SelectedClue.Direction {
|
||||||
case puz.DirectionAcross:
|
case puz.DirectionAcross:
|
||||||
state.SelectedClue = state.Puzzle.Cells[state.SelectedCell][0]
|
if state.Puzzle.Cells[state.SelectedCell][0] != nil {
|
||||||
|
state.SelectedClue = state.Puzzle.Cells[state.SelectedCell][0]
|
||||||
|
} else {
|
||||||
|
state.SelectedClue = state.Puzzle.Cells[state.SelectedCell][1]
|
||||||
|
}
|
||||||
case puz.DirectionDown:
|
case puz.DirectionDown:
|
||||||
state.SelectedClue = state.Puzzle.Cells[state.SelectedCell][1]
|
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]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user