def saveAnsiFile(self, filename, lastLineNum=False, lastColNum=False, firstColNum=False, firstLineNum=None, ircColors=False, encoding="default"):
        """ Saves current frame of current movie to ansi file """
        try:
            if encoding == "default":
                f = open(filename, 'w')
            elif encoding == "cp437":
                f = open(filename, 'w', encoding="cp437")
            elif encoding == "utf-8":
                f = open(filename, 'w', encoding="utf-8")
        except:
            self.notify("Could not open file for writing. (Press any key to continue)", pause=True)
            return False
        string = []
        if not lastLineNum: # if we weren't told what lastLineNum is...
            # find it (last line we should save)
            lastLineNum = self.findFrameLastLine(self.mov.currentFrame)
        if not lastColNum:
            lastColNum = self.findFrameLastCol(self.mov.currentFrame)
        if not firstColNum:
            firstColNum = 0 # Don't crop leftmost blank columns
        if not firstLineNum:
            #firstLineNum = self.findFrameFirstLine(self.mov.currentFrame)
            firstLineNum = 0    # also don't crop leading blank lines. rude
        error_encoding = False
        for lineNum in range(firstLineNum, lastLineNum):  # y == lines
            if lineNum % 1000 == 0 or lineNum == lastLineNum-1:
                self.log.debug(
                    'writing ansi',
                    {'lineNum': lineNum+1, 'total': lastLineNum, 'pct': round(((lineNum+1)/lastLineNum)*100, 2), 'colorMode': self.appState.colorMode}
                )
            for colNum in range(firstColNum, lastColNum):
                char = self.mov.currentFrame.content[lineNum][colNum]
                color = self.mov.currentFrame.newColorMap[lineNum][colNum]
                colorFg = color[0]
                colorBg = color[1]
                if self.appState.colorMode == "256":
                    if self.appState.showBgColorPicker == False:
                        colorBg = 0 # black, I hope
                try:
                    if ircColors:
                        colorCode = self.ansi.getColorCodeIrc(colorFg,colorBg)
                    else:
                        if self.appState.colorMode == "256":
                            colorCode = self.ansi.getColorCode256(colorFg,colorBg)
                        else:
                            colorCode = self.ansi.getColorCode(colorFg,colorBg)
                except KeyError:
                    if ircColors:   # problem? set a default color
                        colorCode = self.ansi.getColorCodeIrc(1,0)
                    else:
                        colorCode = self.ansi.getColorCode(1,0)
                # Make sure encoding this character encodes correctly
                try:
                    #char.encode('cp437')
                    char.encode(encoding)
                except UnicodeEncodeError as encodeError:
                    self.notify("Error: Some characters were not compatible with this encoding. File not saved.", pause=True)
                    self.notify(f"line: {lineNum}, col: {colNum} ", pause=True)
                    saved = False
                    error_encoding = True
                    break
                # If we don't have extended ncurses 6 color pairs,
                # we don't have background colors.. so write the background as black/0
                string.append(colorCode + char)
            if ircColors:
                string.append('\n')
            else:
                string.append('\n')
        if not error_encoding:
            try:
                f.write(''.join(string))
                saved = True
            except UnicodeEncodeError as encodeError:
                self.notify("Error: Some characters were not compatible with this encoding. File not saved.", pause=True)
                self.notify(f"{encodeError}", pause=True)
                saved = False
                #f.close()
                #return False
        f.write('\033[0m') # color attributes off
        f.close()
        #return True
        return saved
 Saves current frame of current movie to ansi file 
durdraw/durdraw_ui_curses.py