def showColorPicker(self, type="fg", message=None):
        #self.colorPicker.caller.notify(f"showColorPicker")
        """ Shows picker, has UI loop for letting user pick color with keyboard or mouse """
        if type == "fg":
            self.updateFgPicker()
        elif type == "bg":
            self.updateBgPicker()
        prompting = False
        #print('\033[?1003l') # disable mouse movement tracking (xterm api)
        #curses.mousemask(1)
        curses_cursorOff()
        # populate window with colors
        self.panel.top()
        #self.move(0,self.x - 6)
        self.panel.show()
        oldFgColor = self.colorPicker.caller.colorfg
        oldBgColor = self.colorPicker.caller.colorbg
        color = self.colorPicker.caller.colorfg
        if self.appState.colorPickerSelected:
            prompting = True
            #self.window.nodelay(0) # wait for input when calling getch
        else:
            prompting = False
        if self.appState.colorPickerSelected:
            if self.appState.sideBarShowing:
                self.drawBorder()
        #self.window.nodelay(1)

        #self.colorPicker.caller.notify(f"showColorPicker() hit. {prompting=}")
        
        mov = self.colorPicker.caller.mov
        appState = self.colorPicker.caller.appState
        # ^ Used to determine if we clicked in the canvas:

        while(prompting):
            time.sleep(0.01)
            #self.colorPicker.caller.drawStatusBar()
            self.update()
            c = self.window.getch()
            if c in [98, curses.KEY_LEFT, ord('h')]:
                if color == 0:
                    color = self.totalColors
                else:
                    color -= 1
                #self.colorPicker.caller.colorfg = color
                self.colorPicker.caller.setFgColor(color)
                self.updateFgPicker()
                self.colorPicker.caller.drawStatusBar()
            elif c in [102, curses.KEY_RIGHT, ord('l')]:
                color += 1
                #if color >= curses.COLORS:
                if color > self.totalColors:
                    color = 0
                #self.colorPicker.caller.colorfg = color
                self.colorPicker.caller.setFgColor(color)
                self.updateFgPicker()
                self.colorPicker.caller.drawStatusBar()
            elif c in [curses.KEY_UP, ord('k')]:
                if self.colorMode == "256":
                    if color < 32:
                        color -= 16
                    elif color > 31 and color < 52:
                        color = 15
                    else:
                        color -= self.width - 2
                elif self.colorMode == "16":
                    self.colorPicker.caller.nextBgColor()
                    #color -= self.width - 2
                if color <= 0:
                    color = 1
                self.colorPicker.caller.setFgColor(color)
                self.updateFgPicker()
                self.colorPicker.caller.drawStatusBar()
            elif c in [curses.KEY_DOWN, ord('j')]:
                if self.colorMode == "256":
                    if color < 16:
                        color += 16
                    else:
                        color += self.width - 2
                    if color >= self.totalColors:
                        color = self.totalColors
                    self.colorPicker.caller.setFgColor(color)
                elif self.colorMode == "16":
                    self.colorPicker.caller.prevBgColor()
                    #color += self.width - 2
                self.updateFgPicker()
                self.colorPicker.caller.drawStatusBar()
            elif c == curses.KEY_HOME:
                color = 1
                self.colorPicker.caller.setFgColor(color)
                self.updateFgPicker()
                self.colorPicker.caller.drawStatusBar()
            elif c == curses.KEY_END:
                #COLOr = 255
                color = self.totalColors
                self.colorPicker.caller.setFgColor(color)
                self.updateFgPicker()
                self.colorPicker.caller.drawStatusBar()
            elif c in [13, curses.KEY_ENTER, 9, 353, 27]:   # Return, Accept color. 9=tab, 353=shift-tab, 27 = esc
                #if not self.appState.stickyColorPicker:
                if not self.appState.sideBarShowing:
                    self.hide()
                prompting = False
                self.appState.colorPickerSelected = False
                self.updateFgPicker()
                self.hideBorder()
                #self.colorPicker.caller.notify(f"{c=}, {prompting=}")
                if not self.colorPicker.caller.playing:    # caller.caller is the main UI thing
                    self.window.nodelay(0)  # wait
                if c == 27: # esc, cancel
                    self.colorPicker.caller.setFgColor(oldFgColor)
                    self.colorPicker.caller.setBgColor(oldBgColor)
                    return False
                c = None
                #return color
            elif c == curses.KEY_MOUSE:
                try:
                    _, mouseX, mouseY, _, mouseState = curses.getmouse()
                except:
                    pass

                if not self.appState.hasMouseScroll:
                    curses.BUTTON5_PRESSED = 0
                    curses.BUTTON4_PRESSED = 0
                if mouseState & curses.BUTTON4_PRESSED: # wheel down?
                    color += 1
                    if color > appState.totalFgColors:
                        if appState.colorMode == "16":
                            color = 1
                        elif appState.colorMode == "256":
                            color = 0
                    self.colorPicker.caller.setFgColor(color)
                    self.updateFgPicker()
                    self.colorPicker.caller.drawStatusBar()
                elif mouseState & curses.BUTTON5_PRESSED:   # wheel up?
                    color -= 1
                    if appState.colorMode == "16":
                        if color <= 0:
                            color = appState.totalFgColors 
                    elif appState.colorMode == "256":
                        if color < 0:
                            color = appState.totalFgColors 
                    self.colorPicker.caller.setFgColor(color)
                    self.updateFgPicker()
                    self.colorPicker.caller.drawStatusBar()
                elif mouseY >= self.origin and mouseX > self.x and mouseX < self.x + len(self.colorGrid[0])-2:   # cpicked in the color picker
                    self.hideBorder()
                    #self.colorPicker.caller.notify(f"DEBUG: self.origin={self.origin}, self.x = {self.x}. mouseX={mouseX}, mouseY={mouseY}", pause=True)
                    self.gotClick(mouseX, mouseY)
                    prompting = False

                elif mouseY < mov.sizeY and mouseX < mov.sizeX \
                        and mouseY + appState.topLine < appState.topLine + self.colorPicker.caller.statusBarLineNum:
                    # we did click in the canvas.
                    self.hideBorder()
                    prompting = False


                if not prompting:
                    if not self.appState.sideBarShowing:
                        self.hide()
                #self.hide()
                #prompting = False
            elif c == 27:  # normal esc, Cancel
                c = self.window.getch()
                if c == curses.ERR: # Just esc was hit, no other escape sequence
                    self.hideBorder()
                    self.colorPicker.caller.setFgColor(oldFgColor)
                    self.colorPicker.caller.setBgColor(oldBgColor)
                    self.updateFgPicker()
                    if not self.appState.sideBarShowing:
                        self.hide()
                    #self.hide()
                    prompting = False

            # Show message, eg: "pick new color"
            #curses_addstr(self.window, self.appState.realmaxX - 2, 0, message, curses.color_pair(self.appState.theme['notificationColor']))

        if not self.appState.colorPickerSelected:
            if self.appState.sideBarShowing:
                self.hideBorder()

        self.appState.colorPickerSelected = False   # done prompting
        self.updateFgPicker()

        if not self.appState.sideBarShowing:
            self.hide()

        #self.hide()
        curses_cursorOn()
        self.window.nodelay(0)
        if self.colorPicker.caller.playing:
            self.window.nodelay(1)
        #curses.mousemask(curses.REPORT_MOUSE_POSITION | curses.ALL_MOUSE_EVENTS)
        #print('\033[?1003h') # enable mouse tracking
        return color
 Shows picker, has UI loop for letting user pick color with keyboard or mouse 
durdraw/durdraw_ui_widgets_curses.py