Esempio n. 1
0
    def find(self, checked):
        print(checked)

        # Grab the parent's text
        text = self.parent.text_doc.toPlainText()

        # And the text to find
        query = self.findField.toPlainText()

        # By default regexes are case sensitive but usually a search isn't
        # case sensitive by default, so we need to switch this around here
        flags = 0 if self.caseSens.isChecked() else re.I

        # Compile the pattern
        pattern = re.compile(query, flags)

        # If the last match was successful, start at position after the last
        # match's start, else at 0
        start = self.lastMatch.start() + 1 if self.lastMatch else 0

        # The actual search
        self.lastMatch = pattern.search(text, start)

        if self.lastMatch:
            start = self.lastMatch.start()
            end = self.lastMatch.end()

            lineColor = QtGui.QColor(QtCore.Qt.green).lighter(160)
            Highlighter.highlightText(self.parent.text_doc, start, end,
                                      lineColor)

        else:
            # if the search was unsuccessful
            print("Nothing was found")
Esempio n. 2
0
    def load_cursorPos(self, checked):
        print(checked)
        elements = self.data
        check = self.item_data[2]

        index = self.j_tree.currentIndex()
        item = self.model.itemFromIndex(index)
        item_data = QtGui.QStandardItem.data(item)
        self.item_text = QtGui.QStandardItem.text(item)

        for text in elements["Benchmarks"]:
            if item_data[0] == 2:
                for el in text["group_ids"]:
                    if el["id_dupl"] == check:
                        pos = el["position"]
                        start = pos[0]
                        end = pos[1]
                        # length = end - start

                        lineColor = QtGui.QColor(QtCore.Qt.red).lighter(160)
                        Highlighter.highlightText(self.text_doc, start, end,
                                                  lineColor)
Esempio n. 3
0
 def load_cursorPos(self, checked):
     print(checked)
     if self.item_data[0] == 2:
         lineColor = QtGui.QColor(QtCore.Qt.red).lighter(160)
         Highlighter.highlightText(self.text_doc, self.item_data[2],
                                   self.item_data[3], lineColor)