Beispiel #1
0
 def goToLine(self):
     tc = self.document().find(QString(u'{'), self.textCursor(),
                               QTextDocument.FindBackward)
     if not tc.isNull():  # found it, or one. tc now selects the {
         re = QRegExp(QString(u'\{\d+\}'))
         tc.setPosition(tc.selectionStart())  # start looking left of {
         tc = self.document().find(re, tc)
         if not tc.isNull():  # found that.
             self.setTextCursor(tc)  # highlight the found string
             qs = tc.selectedText()  # "{nnn}"
             qs.remove(0, 1)  # "nnn}"
             qs.chop(1)  # "nnn"
             # toInt returns a tuple, (int, flag) where flag is false
             # if the conversion fails. In this case it cannot fail
             # since we found \d+ in the first place. However, the
             # number might be invalid as a line number.
             (bn, flg) = qs.toInt()  # line number as int
             doc = IMC.editWidget.document()  # main document
             tb = doc.findBlockByNumber(bn)  # text block number bn
             if tb.isValid():  # if it exists,
                 tc = IMC.editWidget.textCursor()  # cursor on main doc
                 tc.setPosition(tb.position())  # set it on block
                 IMC.editWidget.setTextCursor(tc)  # make it visible
                 IMC.editWidget.setFocus(Qt.TabFocusReason)
         else:  # no {ddd} seen
             pqMsgs.beep()
     else:  # no { preceding the cursor on same line
         pqMsgs.beep()
Beispiel #2
0
 def goToLine(self):
     tc = self.document().find(QString(u'{'),
                               self.textCursor(), QTextDocument.FindBackward)
     if not tc.isNull(): # found it, or one. tc now selects the {
         re = QRegExp(QString(u'\{\d+\}'))
         tc.setPosition(tc.selectionStart()) # start looking left of {
         tc = self.document().find(re,tc)
         if not tc.isNull(): # found that.
             self.setTextCursor(tc) # highlight the found string
             qs = tc.selectedText() # "{nnn}"
             qs.remove(0,1) # "nnn}"
             qs.chop(1) # "nnn"
             # toInt returns a tuple, (int, flag) where flag is false
             # if the conversion fails. In this case it cannot fail
             # since we found \d+ in the first place. However, the
             # number might be invalid as a line number.
             (bn,flg) = qs.toInt() # line number as int
             doc = IMC.editWidget.document() # main document
             tb = doc.findBlockByNumber(bn) # text block number bn
             if tb.isValid(): # if it exists,
                 tc = IMC.editWidget.textCursor() # cursor on main doc
                 tc.setPosition(tb.position()) # set it on block
                 IMC.editWidget.setTextCursor(tc) # make it visible
                 IMC.editWidget.setFocus(Qt.TabFocusReason)
         else: # no {ddd} seen
             pqMsgs.beep()
     else: # no { preceding the cursor on same line
         pqMsgs.beep()
Beispiel #3
0
 def doFind(self, kkey):
     if (kkey == IMC.ctl_F) or (self.findText.isEmpty()):
         # ctl+F, or ctl+G but no previous find done, show the find dialog
         # with a COPY of current selection as pqMsgs might truncate it
         prepText = QString(self.webPage.selectedText())
         (ok, self.findText) = pqMsgs.getFindMsg(self, prepText)
     # dialog or no dialog, we should have some findText now
     if not self.findText.isEmpty():
         if not self.webPage.findText(self.findText,
                                      QWebPage.FindWrapsAroundDocument):
             pqMsgs.beep()
Beispiel #4
0
 def doFind(self,kkey):
     if (kkey == IMC.ctl_F) or (self.findText.isEmpty()) :
         # ctl+F, or ctl+G but no previous find done, show the find dialog
         # with a COPY of current selection as pqMsgs might truncate it
         prepText = QString(self.textCursor().selectedText())
         (ok, self.findText) = pqMsgs.getFindMsg(self,prepText)
     # dialog or no dialog, we should have some findText now
     if not self.findText.isEmpty() :
         if not self.find(self.findText): # no hits going down
             self.moveCursor(QTextCursor.Start) # go to top
             if not self.find(self.findText): # still no hit
                 pqMsgs.beep()
Beispiel #5
0
 def doFind(self, kkey):
     if (kkey == IMC.ctl_F) or (self.userFindText.isEmpty()):
         # ctl+F, or ctl+G but no previous find done, show the find dialog
         # with a COPY of current selection as pqMsgs might truncate it
         prepText = QString(self.page().selectedText())
         (ok, self.userFindText) = pqMsgs.getFindMsg(self, prepText)
     # We should have some findText now, either left from previous find
     # on a ctl-G, or entered by user. If none, then user cleared dialog.
     if not self.userFindText.isEmpty():
         if not self.page().findText(self.userFindText,
                                     QWebPage.FindWrapsAroundDocument):
             pqMsgs.beep()
Beispiel #6
0
 def doFind(self, kkey):
     if (kkey == IMC.ctl_F) or (self.findText.isEmpty()):
         # ctl+F, or ctl+G but no previous find done, show the find dialog
         # with a COPY of current selection as pqMsgs might truncate it
         prepText = QString(self.textCursor().selectedText())
         (ok, self.findText) = pqMsgs.getFindMsg(self, prepText)
     # dialog or no dialog, we should have some findText now
     if not self.findText.isEmpty():
         if not self.find(self.findText):  # no hits going down
             self.moveCursor(QTextCursor.Start)  # go to top
             if not self.find(self.findText):  # still no hit
                 pqMsgs.beep()
Beispiel #7
0
 def doFind(self,kkey):
     if (kkey == IMC.ctl_F) or (self.findText.isEmpty()) :
         # ctl+F, or ctl+G but no previous find done, show the find dialog
         # with a COPY of current selection as pqMsgs might truncate it
         prepText = QString(self.webPage.selectedText())
         (ok, self.findText) = pqMsgs.getFindMsg(self,prepText)
     # dialog or no dialog, we should have some findText now
     if not self.findText.isEmpty() :
         if not self.webPage.findText(
             self.findText, QWebPage.FindWrapsAroundDocument
             ) :
             pqMsgs.beep()
Beispiel #8
0
 def doFind(self,kkey):
     if (kkey == IMC.ctl_F) or (self.userFindText.isEmpty()) :
         # ctl+F, or ctl+G but no previous find done, show the find dialog
         # with a COPY of current selection as pqMsgs might truncate it
         prepText = QString(self.page().selectedText())
         (ok, self.userFindText) = pqMsgs.getFindMsg(self,prepText)
     # We should have some findText now, either left from previous find
     # on a ctl-G, or entered by user. If none, then user cleared dialog.
     if not self.userFindText.isEmpty() :
         if not self.page().findText(
             self.userFindText, QWebPage.FindWrapsAroundDocument
             ) :
             pqMsgs.beep()
Beispiel #9
0
 def goToPage(self):
     tc = self.document().find(QString(u'['),
                               self.textCursor(), QTextDocument.FindBackward)
     if not tc.isNull(): # found it, or one. tc now selects the [
         re = QRegExp(QString(u'\[\d+\]'))
         tc.setPosition(tc.selectionStart()) # start looking left of [
         tc = self.document().find(re,tc)
         if not tc.isNull(): # found that.
             self.setTextCursor(tc) # highlight the found string
             qs = tc.selectedText() # "[nnn]"
             qs.remove(0,1) # "nnn]"
             qs.chop(1) # "nnn"
             (pn,flg) = qs.toInt() # page number as int
             pn -= 1 # index to that page in the page table
             if (pn >= 0) and (pn < IMC.pageTable.size()) :
                 etc = IMC.pageTable.getCursor(pn) # cursor for that page
                 doc = IMC.editWidget.document() # main document
                 IMC.editWidget.setTextCursor(etc) # make it visible
                 IMC.editWidget.setFocus(Qt.TabFocusReason)
             else: # should not occur
                 pqMsgs.beep()
         else: # no [ppp] seen
             pqMsgs.beep()
     else: # no [ preceding the cursor on same line
         pqMsgs.beep()
Beispiel #10
0
 def goToPage(self):
     tc = self.document().find(QString(u'['), self.textCursor(),
                               QTextDocument.FindBackward)
     if not tc.isNull():  # found it, or one. tc now selects the [
         re = QRegExp(QString(u'\[\d+\]'))
         tc.setPosition(tc.selectionStart())  # start looking left of [
         tc = self.document().find(re, tc)
         if not tc.isNull():  # found that.
             self.setTextCursor(tc)  # highlight the found string
             qs = tc.selectedText()  # "[nnn]"
             qs.remove(0, 1)  # "nnn]"
             qs.chop(1)  # "nnn"
             (pn, flg) = qs.toInt()  # page number as int
             pn -= 1  # index to that page in the page table
             if (pn >= 0) and (pn < IMC.pageTable.size()):
                 etc = IMC.pageTable.getCursor(pn)  # cursor for that page
                 doc = IMC.editWidget.document()  # main document
                 IMC.editWidget.setTextCursor(etc)  # make it visible
                 IMC.editWidget.setFocus(Qt.TabFocusReason)
             else:  # should not occur
                 pqMsgs.beep()
         else:  # no [ppp] seen
             pqMsgs.beep()
     else:  # no [ preceding the cursor on same line
         pqMsgs.beep()