'Is the cursor inside or next to a comment or string?'

def in_comment_or_string(self, cursor=None):

    if self.highlighter:
        if (cursor is None):
            current_color = self.__get_current_color()
        else:
            current_color = self.__get_current_color(cursor=cursor)
        comment_color = self.highlighter.get_color_name('comment')
        string_color = self.highlighter.get_color_name('string')
        if ((current_color == comment_color) or (current_color == string_color)):
            return True
        else:
            return False
    else:
        return False
