Пример #1
0
    def text(self):  # pylint: disable=W0613
        """Displayable text of search result. Shown as line in the search results dock
        """
        beforeMatch = self.wholeLine[:self.column].lstrip()
        afterMatch = self.wholeLine[self.column + len(self.match.group(0)):].rstrip()

        if QApplication.instance().palette().base().color().lightnessF() > 0.5:
            backgroundColor = 'yellow'
            foregroundColor = 'black'
        else:
            backgroundColor = 'maroon'
            foregroundColor = 'white'

        return '<html>' \
            'Line: %d, Column: %d: %s' \
            '<font style=\'background-color: %s; color: %s\'>%s</font>' \
            '%s' \
               '</html>' % \
            (self.line + 1,
             self.column,
             htmlEscape(beforeMatch),
             backgroundColor,
             foregroundColor,
             htmlEscape(self.match.group(0)),
             htmlEscape(afterMatch))
Пример #2
0
    def _formatPath(self, path, isDir):
        """Format file or directory for show it in the list of completions
        """
        path = os.path.basename(path)
        if isDir:
            path += '/'

        typedLen = self._lastTypedSegmentLength()
        typedLenPlusInline = typedLen + len(self.inline())
        return '<b>%s</b><font color="red">%s</font>%s' % \
            (htmlEscape(path[:typedLen]),
             htmlEscape(path[typedLen:typedLenPlusInline]),
             htmlEscape(path[typedLenPlusInline:]))
Пример #3
0
    def _formatPath(self, path, isDir):
        """Format file or directory for show it in the list of completions
        """
        path = os.path.basename(path)
        if isDir:
            path += '/'

        typedLen = self._lastTypedSegmentLength()
        typedLenPlusInline = typedLen + len(self.inline())
        return '<b>%s</b><font color="red">%s</font>%s' % \
            (htmlEscape(path[:typedLen]),
             htmlEscape(path[typedLen:typedLenPlusInline]),
             htmlEscape(path[typedLenPlusInline:]))
Пример #4
0
 def text(self, row, column):
     """Item text in the list of completions
     """
     rowType, index = self._classifyRowIndex(row)
     if rowType == self._ERROR:
         return '<font color=red>%s</font>' % htmlEscape(self._error)
     elif rowType == self._HEADER:
         return self._formatHeader(self._headerText())
     elif rowType == self._STATUS:
         return '<i>%s</i>' % htmlEscape(self._status)
     elif rowType == self._DIRECTORY:
         return self._formatPath(self._dirs[index], True)
     elif rowType == self._FILE:
         return self._formatPath(self._files[index], False)
Пример #5
0
 def text(self, row, column):
     """Item text in the list of completions
     """
     rowType, index = self._classifyRowIndex(row)
     if rowType == self._ERROR:
         return '<font color=red>%s</font>' % htmlEscape(self._error)
     elif rowType == self._HEADER:
         return self._formatHeader(self._headerText())
     elif rowType == self._STATUS:
         return '<i>%s</i>' % htmlEscape(self._status)
     elif rowType == self._DIRECTORY:
         return self._formatPath(self._dirs[index], True)
     elif rowType == self._FILE:
         return self._formatPath(self._files[index], False)
Пример #6
0
 def _formatHeader(self, text):
     """Format current directory for show it in the list of completions
     """
     return '<font style="background-color: %s; color: %s">%s</font>' % \
         (QApplication.instance().palette().color(QPalette.Window).name(),
          QApplication.instance().palette().color(QPalette.WindowText).name(),
          htmlEscape(text))
Пример #7
0
 def _formatHeader(self, text):
     """Format current directory for show it in the list of completions
     """
     return '<font style="background-color: %s; color: %s">%s</font>' % \
         (QApplication.instance().palette().color(QPalette.Window).name(),
          QApplication.instance().palette().color(QPalette.WindowText).name(),
          htmlEscape(text))