Esempio n. 1
0
 def __init__(self, debug, *args):
     QtGui.QTextEdit.__init__(*(self,) + args)
     self.debug = debug
     self.readOnly = True
     self.setFocusPolicy(QtCore.Qt.NoFocus)
     self.setFontFamily('monospace')
     self._textcolor = self.textColor()
     self._bgcolor = QtGui.QColor('#FFFFFF')
     self._setcolorcode = {
         'F': (self.setTextColor, self._textcolor),
         'B': (self.setTextBackgroundColor, self._bgcolor)
     }
     self._setfont = {
         '*': self.setFontWeight,
         '_': self.setFontUnderline,
         '/': self.setFontItalic
     }
     self._fontvalues = {
         False: {
             '*': QtGui.QFont.Normal,
             '_': False,
             '/': False
         },
         True: {
             '*': QtGui.QFont.Bold,
             '_': True,
             '/': True
         }
     }
     self._color = color.Color(config.color_options(), self.debug)
Esempio n. 2
0
    def __init__(self, config, layout=None):
        Gtk.TextBuffer.__init__(self)
        self.config = config
        self.layout = layout
        self.last_prefix = None
        self.last_message_type = None
        self.longest_prefix = 0
        self.indent_tag_list = []
        self.d_previous = datetime.datetime.fromtimestamp(0)

        # We need the color class that convert formatting codes in network
        # data to codes that the parser functions in this class can handle
        self._color = color.Color(config_module.color_options(), False)

        # Text tags used for formatting
        self.time_tag = self.create_tag(justification=Gtk.Justification.RIGHT,
                                        weight=Pango.Weight.BOLD)
        bold_tag = self.create_tag(weight=Pango.Weight.BOLD)
        underline_tag = self.create_tag(underline=Pango.Underline.SINGLE)
        italic_tag = self.create_tag(style=Pango.Style.ITALIC)
        reverse_tag = self.create_tag()  # reverse video is not implemented
        self.attr_tag = {
            "*": bold_tag,
            "_": underline_tag,
            "/": italic_tag,
            "!": reverse_tag
        }
        self.url_tag = self.create_tag(underline=Pango.Underline.SINGLE)
Esempio n. 3
0
    def __init__(self, debug, *args):
        QtGui.QTextBrowser.__init__(*(self,) + args)
        self.debug = debug

        # Special config options:
        self._color = color.Color(config.color_options(), self.debug)
        self.time_format = '%H:%M'
        self.indent = False
        self._prefix_set = set()
        self.prefix_colors = dict()

        self.readOnly = True
        self.setTextInteractionFlags(QtCore.Qt.LinksAccessibleByMouse |
                                     QtCore.Qt.TextSelectableByMouse |
                                     QtCore.Qt.TextSelectableByKeyboard)
        self.setOpenExternalLinks(True)
        self.setFocusPolicy(QtCore.Qt.NoFocus)
        self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self._context)
        # Avoid setting the font family here so it can be changed elsewhere.
        self._textcolor = self.textColor()
        self._bgcolor = QtGui.QColor('#FFFFFF')
        self._setcolorcode = {
            'F': (self.setTextColor, self._textcolor),
            'B': (self.setTextBackgroundColor, self._bgcolor)
        }
        self._setfont = {
            '*': self.setFontWeight,
            '_': self.setFontUnderline,
            '/': self.setFontItalic
        }
        self._fontvalues = {
            False: {
                '*': QtGui.QFont.Normal,
                '_': False,
                '/': False
            },
            True: {
                '*': QtGui.QFont.Bold,
                '_': True,
                '/': True
            }
        }
        self._timestamp_color = QtGui.QColor('#999999')
        # Table format for indent mode:
        self._table_format = QtGui.QTextTableFormat()
        self._table_format.setBorderStyle(
            QtGui.QTextFrameFormat.BorderStyle_None)
        self._table_format.setBorder(0)
        self._table_format.setCellPadding(0)
        self._table_format.setCellSpacing(0)
        self._table_format.setCellSpacing(0)
        self._align_right = QtGui.QTextBlockFormat()
        self._align_right.setAlignment(QtCore.Qt.AlignRight)

        self.clear()
Esempio n. 4
0
    def __init__(self, debug, *args):
        QtGui.QTextEdit.__init__(*(self,) + args)
        self.debug = debug

        self._textcolor = self.textColor()
        self._bgcolor = QtGui.QColor('#FFFFFF')
        self._setcolorcode = {
            'F': (self.setTextColor, self._textcolor),
            'B': (self.setTextBackgroundColor, self._bgcolor)
        }
        self._setfont = {
            '*': self.setFontWeight,
            '_': self.setFontUnderline,
            '/': self.setFontItalic
        }
        self._fontvalues = {
            False: {
                '*': QtGui.QFont.Normal,
                '_': False,
                '/': False
            },
            True: {
                '*': QtGui.QFont.Bold,
                '_': True,
                '/': True
            }
        }
        self._color = color.Color(config.color_options(), self.debug)
        self.initDict()
        # Set height to one line:
        font_metric = QtGui.QFontMetrics(self.currentFont())
        self.setMinimumHeight(font_metric.height() + 8)
        size_policy = self.sizePolicy()
        size_policy.setHeightForWidth(True)
        size_policy.setVerticalPolicy(QtGui.QSizePolicy.Preferred)
        self.setSizePolicy(size_policy)
        self.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)
        self.textChanged.connect(lambda: self.updateGeometry())