Fix grid numbers not displayed for down solves; Add regressPointer - crossword.koplugin - Unnamed repository; edit this file 'description' to name the repository.
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Submodules
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 9e705bde86fcb1ee4442cb39ac0df00455e00ed2
 (DIR) parent 64bc58be16d8bb0a6544e61447a016d20c59e187
 (HTM) Author: Scarlett <social@scarlettmcallister.com>
       Date:   Wed,  5 Jan 2022 16:37:09 -0400
       
       Fix grid numbers not displayed for down solves; Add regressPointer
       
       Diffstat:
         M gameview.lua                        |      25 ++++++++++++++++++++++++-
         M puzzle.lua                          |      16 ++++++++++++++--
       
       2 files changed, 38 insertions(+), 3 deletions(-)
       ---
 (DIR) diff --git a/gameview.lua b/gameview.lua
       @@ -161,8 +161,31 @@ function GameView:advancePointer()
            -- end
        end
        
       +function GameView:regressPointer()
       +    if self.active_direction == Solve.DOWN then
       +        self.active_row_num = self.active_row_num -1
       +    elseif self.active_direction == Solve.ACROSS then
       +        if (self.active_col_num) >= self.puzzle.size.cols then
       +            self.active_col_num = 1
       +            self.active_row_num = self.active_row_num - 1
       +        else
       +            self.active_col_num = self.active_col_num - 1
       +        end
       +    end
       +    -- Check to see if advancement landed on a non-active grid square.
       +    -- if not self.puzzle:getClueByPos(self,active_row_num, self.active_col_num) then
       +    --     self:advancePointer()
       +    -- end
       +end
       +
       +-- This method should 1) delete the character in the active square, 2) move to the previous
       +-- square in the row or column.
        function GameView:delChar()
       -    self.puzzle:setLetterForGuess("", self.puzzle:getActiveSquare())
       +    if self.puzzle:getLetterForSquare(self.puzzle:getActiveSquare()) ~= "" then
       +        self.puzzle:setLetterForGuess("", self.puzzle:getActiveSquare())
       +    else
       +        self:regressPointer()
       +    end
            self:refreshGameView()
        end
        
 (DIR) diff --git a/puzzle.lua b/puzzle.lua
       @@ -95,6 +95,7 @@ function Puzzle:getGrid()
                        -- set once (like the letter).
                        local grid_square = {
                            solve_indices = { solve_index },
       +                    number = number,
                            letter = letter,
                        }
                        grid[grid_index] = grid_square
       @@ -102,8 +103,11 @@ function Puzzle:getGrid()
                        -- Since the square has been initialized, update the existing element.
                        table.insert(grid[grid_index].solve_indices, solve_index)
                    end
       -            -- Update the other attributes.
       -            grid[grid_index].number = number
       +            -- Update the number, but only if it is not an empty value. Otherwise the down number will
       +            -- overwrite the across numbers.
       +            if number ~= "" then
       +                grid[grid_index].number = number
       +            end
                    -- Updating state like this could overwrite a state value that was set by the
                    -- other direction of squares. So there needs to be a kind of conditional statement
                    -- that checks to see if state has a value.
       @@ -201,6 +205,14 @@ function Puzzle:setLetterForGuess(letter, active_square)
            self.guesses[active_square] = letter
        end
        
       +function Puzzle:getLetterForSquare(active_square)
       +    if not self.guesses[active_square] then
       +        return ""
       +    else
       +        return self.guesses[active_square]
       +    end
       +end
       +
        function Puzzle:setActiveDirection(direction)
            self.active_direction = direction
        end