Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

annotate: mouse-wheel events in regexp lineedit walks matches

this will be a pleasant surprise when people discover it

Changeset ed5208684d51

Parent d24ca6564472

by Steve Borho

Changes to one file · Browse files at ed5208684d51 Showing diff from parent d24ca6564472 Diff from another changeset...

 
85
86
87
 
88
89
90
 
148
149
150
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
152
 
153
154
155
 
160
161
162
163
 
164
165
 
 
 
 
 
166
167
168
 
234
235
236
 
 
 
 
 
 
 
 
 
237
238
239
 
85
86
87
88
89
90
91
 
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
 
167
168
169
170
 
175
176
177
 
178
179
 
180
181
182
183
184
185
186
187
 
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
@@ -85,6 +85,7 @@
  hbox.addWidget(self.edit)     self.thread = None + self.matches = []     def annotateFileAtRev(self, repo, ctx, wfile):   if self.thread is not None: @@ -148,8 +149,22 @@
  self.edit.setExtraSelections(self.colorsels)   self.edit.verticalScrollBar().setValue(0)   + def nextMatch(self): + if not self.matches: + return + if self.curmatch < len(self.matches)-1: + self.curmatch += 1 + self.edit.setTextCursor(self.matches[self.curmatch].cursor) + + def prevMatch(self): + if not self.matches: + return + if self.curmatch > 0: + self.curmatch -= 1 + self.edit.setTextCursor(self.matches[self.curmatch].cursor) +   def searchText(self, regexp, icase): - extraSelections = self.colorsels[:] + matches = []   color = QColor(Qt.yellow)   flags = QTextDocument.FindFlags()   if not icase: @@ -160,9 +175,13 @@
  selection = QTextEdit.ExtraSelection()   selection.format.setBackground(color)   selection.cursor = cursor - extraSelections.append(selection) + matches.append(selection)   cursor = doc.find(regexp, cursor) - self.edit.setExtraSelections(extraSelections) + self.matches = matches + self.curmatch = 0 + if matches: + self.edit.setTextCursor(matches[0].cursor) + self.edit.setExtraSelections(self.colorsels + self.matches)    class AnnotateThread(QThread):   'Background thread for annotating a file at a revision' @@ -234,6 +253,15 @@
  self.status.setText(hglib.tounicode(msg))   self.av.searchText(QRegExp(pattern), icase)   + def wheelEvent(self, event): + if self.childAt(event.pos()) != self.le: + event.ignore() + return + if event.delta() > 0: + self.av.prevMatch() + elif event.delta() < 0: + self.av.nextMatch() +   def accept(self):   s = QSettings()   s.setValue('annotate/geom', self.saveGeometry())