def delete(self, x, y): """ update deletion from the grid in the coordibate (x,y) delete content from coordinate from the queue in order to recreate the actions that led to the solution. """ if (x, y) in self.read_only_tiles: print("READ ONLY TILE ON ( ", x, y, ") CAN'T DELETE") sys.exit() self.grid[y][x] = EMPTY_VALUE self.full_tiles.remove((x, y)) self.actions_queue.append(Action(x, y))
def insert(self, x, y, value): """ update insetrion to the grid with the value in coordibate (x,y) insert coordinate and value to the queue in order to recreate the actions that led to the solution. """ if (x, y) in self.read_only_tiles: print("READ ONLY TILE ON ( ", x, y, ") CAN'T INSERT VALUE", value) sys.exit() self.grid[y][x] = value self.full_tiles += [(x, y)] self.actions_queue.append((Action(x, y, value)))
def selectTodoItem(stdscr, todoList): """ Opens a display of the *todoList* for the user to select an item and choose an action to take. """ selectionList = displayTodoList(stdscr, todoList) currentSelection = selectionList.current() highlightSelection(stdscr, currentSelection) while True: lastSelection = currentSelection k = stdscr.get_wch() if k in ['k', curses.KEY_UP]: currentSelection = selectionList.prev() elif k in ['j', curses.KEY_DOWN]: currentSelection = selectionList.next() elif k in ['d']: return Action(Action.REMOVE, currentSelection.todoItem) elif k == 'q': return None switchSelection(stdscr, lastSelection, currentSelection) stdscr.refresh()