# Path: pinguino/qtgui/ide/custom_widgets/plain_outputs/python_highlighter.py
# class Highlighter(QtGui.QSyntaxHighlighter):
# 
#     #----------------------------------------------------------------------
#     def __init__(self, parent, extra=[], python=True):
#         super(Highlighter, self).__init__(parent)
#         color = QtGui.QColor
# 
#         self.highlightingRules = []
# 
#         if python:
#             operators = QtGui.QTextCharFormat()
#             operators.setFontWeight(QtGui.QFont.Bold)
#             self.highlightingRules.append(("[()\[\]{}<>=\-\+\*\\%#!~&^,/]", operators))
# 
#             reserved = QtGui.QTextCharFormat()
#             reserved.setForeground(color("#8ae234"))
#             #self.highlightingRules.append(("\\b(None|False|True|def|class|for|while|pass|try|except|print|if)\\b", reserved))
#             self.highlightingRules.append(("\\b({})\\b".format(RESERVED_PYTHON), reserved))
# 
#         if extra:
#             start_command = QtGui.QTextCharFormat()
#             start_command.setForeground(color("#729fcf"))
#             self.highlightingRules.append((extra[0].replace(".", "\."), start_command))
# 
#         sdcc_error_01 = QtGui.QTextCharFormat()
#         sdcc_error_01.setForeground(color("#ef292a"))
#         self.highlightingRules.append(("ERROR: .*", sdcc_error_01))
# 
#         for msg, color_ in MESSAGES:
#             debugger = QtGui.QTextCharFormat()
#             debugger.setForeground(color(color_))
#             self.highlightingRules.append(("\[{}\] .*".format(msg), debugger))
# 
#         for msg, color_ in EXCEPTIONS:
#             debugger = QtGui.QTextCharFormat()
#             debugger.setForeground(color(color_))
#             self.highlightingRules.append(("\\b({})\\b".format(msg), debugger))
# 
# 
#     #----------------------------------------------------------------------
#     def highlightBlock(self, text):
#         for pattern, format_ in self.highlightingRules:
#             expression = QtCore.QRegExp(pattern)
#             index = expression.indexIn(text)
#             while index >= 0:
#                 length = expression.matchedLength()
#                 self.setFormat(index, length, format_)
#                 index = expression.indexIn(text, index + length)
# 
# Path: pinguino/qtgui/ide/custom_widgets/plain_outputs/python_shell.py
# class PythonShell(object):
# 
#     #----------------------------------------------------------------------
#     def __init__(self):
# 
#         self.statement_module = types.ModuleType("__main__")
#         # self.statement_module.__builtins__ = builtins.__builtins__
# 
#         sys.modules['__main__'] = self.statement_module
#         self.statement_module.__name__ = '__main__'
# 
#     #----------------------------------------------------------------------
#     def run(self, command, log=None):
# 
#         if log is None: log = StringIO()
#         sys.stdout = log
#         sys.stderr = log
# 
#         try:
#             compiled = compile(command, '<string>', 'single')
#             exec(compiled, self.statement_module.__dict__)
# 
#         except: log.write(traceback.format_exc())
#         # return log.getvalue()
# 
#     #----------------------------------------------------------------------
#     def restart(self):
# 
#         self.__init__()


import os
import sys
import pickle
from PySide2 import QtCore, QtGui, QtWidgets
from .python_highlighter import Highlighter
from .python_shell import PythonShell
#!/usr/bin/env python
#-*- coding: utf-8 -*-




HEAD = os.getenv("PINGUINO_NAME") + " " + os.getenv("PINGUINO_VERSION") + "\n" + "Python " + sys.version + " on " + sys.platform
HELP = QtWidgets.QApplication.translate("PythonShell", "Commands available:") + ' "clear", "restart"'

START = ">>> "
NEW_LINE = "... "


########################################################################
class PinguinoTextEdit(QtWidgets.QPlainTextEdit):

    #----------------------------------------------------------------------
    def __init__(self, widget=None, shell=True):
        super(PinguinoTextEdit, self).__init__(widget)


# Path: pinguino/qtgui/ide/custom_widgets/plain_outputs/python_highlighter.py
# class Highlighter(QtGui.QSyntaxHighlighter):
# 
#     #----------------------------------------------------------------------
#     def __init__(self, parent, extra=[], python=True):
#         super(Highlighter, self).__init__(parent)
#         color = QtGui.QColor
# 
#         self.highlightingRules = []
# 
#         if python:
#             operators = QtGui.QTextCharFormat()
#             operators.setFontWeight(QtGui.QFont.Bold)
#             self.highlightingRules.append(("[()\[\]{}<>=\-\+\*\\%#!~&^,/]", operators))
# 
#             reserved = QtGui.QTextCharFormat()
#             reserved.setForeground(color("#8ae234"))
#             #self.highlightingRules.append(("\\b(None|False|True|def|class|for|while|pass|try|except|print|if)\\b", reserved))
#             self.highlightingRules.append(("\\b({})\\b".format(RESERVED_PYTHON), reserved))
# 
#         if extra:
#             start_command = QtGui.QTextCharFormat()
#             start_command.setForeground(color("#729fcf"))
#             self.highlightingRules.append((extra[0].replace(".", "\."), start_command))
# 
#         sdcc_error_01 = QtGui.QTextCharFormat()
#         sdcc_error_01.setForeground(color("#ef292a"))
#         self.highlightingRules.append(("ERROR: .*", sdcc_error_01))
# 
#         for msg, color_ in MESSAGES:
#             debugger = QtGui.QTextCharFormat()
#             debugger.setForeground(color(color_))
#             self.highlightingRules.append(("\[{}\] .*".format(msg), debugger))
# 
#         for msg, color_ in EXCEPTIONS:
#             debugger = QtGui.QTextCharFormat()
#             debugger.setForeground(color(color_))
#             self.highlightingRules.append(("\\b({})\\b".format(msg), debugger))
# 
# 
#     #----------------------------------------------------------------------
#     def highlightBlock(self, text):
#         for pattern, format_ in self.highlightingRules:
#             expression = QtCore.QRegExp(pattern)
#             index = expression.indexIn(text)
#             while index >= 0:
#                 length = expression.matchedLength()
#                 self.setFormat(index, length, format_)
#                 index = expression.indexIn(text, index + length)
# 
# Path: pinguino/qtgui/ide/custom_widgets/plain_outputs/python_shell.py
# class PythonShell(object):
# 
#     #----------------------------------------------------------------------
#     def __init__(self):
# 
#         self.statement_module = types.ModuleType("__main__")
#         # self.statement_module.__builtins__ = builtins.__builtins__
# 
#         sys.modules['__main__'] = self.statement_module
#         self.statement_module.__name__ = '__main__'
# 
#     #----------------------------------------------------------------------
#     def run(self, command, log=None):
# 
#         if log is None: log = StringIO()
#         sys.stdout = log
#         sys.stderr = log
# 
#         try:
#             compiled = compile(command, '<string>', 'single')
#             exec(compiled, self.statement_module.__dict__)
# 
#         except: log.write(traceback.format_exc())
#         # return log.getvalue()
# 
#     #----------------------------------------------------------------------
#     def restart(self):
# 
#         self.__init__()


# Path: pinguino/qtgui/ide/custom_widgets/plain_outputs/output_widget.py
import os
import sys
import pickle
from PySide2 import QtCore, QtGui, QtWidgets
from .python_highlighter import Highlighter
from .python_shell import PythonShell

#!/usr/bin/env python
#-*- coding: utf-8 -*-




HEAD = os.getenv("PINGUINO_NAME") + " " + os.getenv("PINGUINO_VERSION") + "\n" + "Python " + sys.version + " on " + sys.platform
HELP = QtWidgets.QApplication.translate("PythonShell", "Commands available:") + ' "clear", "restart"'

START = ">>> "
NEW_LINE = "... "


########################################################################
class PinguinoTextEdit(QtWidgets.QPlainTextEdit):

    #----------------------------------------------------------------------
    def __init__(self, widget=None, shell=True):
        super(PinguinoTextEdit, self).__init__(widget)


        self.shell = PythonShell()