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

fileview: remove obsolete use of indicators for search highlight

QsciScintilla has a wonderful search highlighting feature of which we are only
scratching the surface.

Changeset 1d30d49f2f77

Parent b3dcfb9a637b

by Steve Borho

Changes to one file · Browse files at 1d30d49f2f77 Showing diff from parent b3dcfb9a637b Diff from another changeset...

 
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
 
359
360
361
362
363
364
365
366
367
 
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
 
491
492
493
 
123
124
125
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
127
128
 
344
345
346
 
 
 
347
348
349
 
425
426
427
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
428
429
430
431
432
433
@@ -123,21 +123,6 @@
  self.sci.setMarginType(0, qsci.SymbolMargin)   self.sci.setMarginWidth(0, 0)   - if hasattr(self.sci, 'indicatorDefine'): - self.sci.indicatorDefine(qsci.RoundBoxIndicator, 8) - self.sci.setIndicatorDrawUnder(8) - self.sci.setIndicatorForegroundColor(QColor('#BBFFFF'), 8) - self.sci.indicatorDefine(qsci.RoundBoxIndicator, 9) - self.sci.setIndicatorDrawUnder(9) - self.sci.setIndicatorForegroundColor(QColor('#58A8FF'), 9) - else: - self.sci.SendScintilla(qsci.SCI_INDICSETSTYLE, 8, qsci.INDIC_ROUNDBOX) - self.sci.SendScintilla(qsci.SCI_INDICSETUNDER, 8, True) - self.sci.SendScintilla(qsci.SCI_INDICSETFORE, 8, 0xBBFFFF) - self.sci.SendScintilla(qsci.SCI_INDICSETSTYLE, 9, qsci.INDIC_ROUNDBOX) - self.sci.SendScintilla(qsci.SCI_INDICSETUNDER, 9, True) - self.sci.SendScintilla(qsci.SCI_INDICSETFORE, 9, 0x58A8FF) -   self._annotate = annotate.AnnotateView(repo, self)   for name in ('searchRequested', 'editSelected', 'grepRequested'):   getattr(self._annotate, name).connect(getattr(self, name)) @@ -359,9 +344,6 @@
  self.sci.setMarginWidth(1, str(nlines)+'0')   self.sci.setText(fd.contents)   - if self._find_text: - self.highlightSearchString(self._find_text) -   uf = hglib.tounicode(self._filename)   self.fileDisplayed.emit(uf, fd.contents or QString())   @@ -443,51 +425,9 @@
  files = [os.path.join(base, path)]   wctxactions.edit(self, repo.ui, repo, files, line, self._find_text)   - def searchString(self, text): - self._find_text = text - self.clearHighlights() - findpos = self.highlightSearchString(self._find_text) - if findpos: - def finditer(self, findpos): - if self._find_text: - for pos in findpos: - self.highlightCurrentSearchString(pos, self._find_text) - yield self._ctx.rev(), self._filename, pos - return finditer(self, findpos) - - def clearHighlights(self): - n = self.sci.length() - # highlight - self.sci.SendScintilla(qsci.SCI_SETINDICATORCURRENT, 8) - self.sci.SendScintilla(qsci.SCI_INDICATORCLEARRANGE, 0, n) - # current found occurrence - self.sci.SendScintilla(qsci.SCI_SETINDICATORCURRENT, 9) - self.sci.SendScintilla(qsci.SCI_INDICATORCLEARRANGE, 0, n) - - def highlightSearchString(self, text): - data = unicode(self.sci.text()) - self.sci.SendScintilla(qsci.SCI_SETINDICATORCURRENT, 8) - pos = [data.find(text)] - n = len(text) - while pos[-1] > -1: - self.sci.SendScintilla(qsci.SCI_INDICATORFILLRANGE, pos[-1], n) - pos.append(data.find(text, pos[-1]+1)) - pos = [x for x in pos if x > -1] - self.showMessage.emit( - _("Found %d occurrences of '%s' in current file or diff") % ( - len(pos), text)) - return pos - - def highlightCurrentSearchString(self, pos, text): - line = self.sci.SendScintilla(qsci.SCI_LINEFROMPOSITION, pos) - #line, idx = w.lineIndexFromPosition(nextpos) - self.sci.ensureLineVisible(line) - self.sci.SendScintilla(qsci.SCI_SETINDICATORCURRENT, 9) - self.sci.SendScintilla(qsci.SCI_INDICATORCLEARRANGE, 0, pos) - self.sci.SendScintilla(qsci.SCI_INDICATORFILLRANGE, pos, len(text)) -   @pyqtSlot(unicode, bool, bool, bool)   def find(self, exp, icase=True, wrap=False, forward=True): + self._find_text = hglib.fromunicode(exp)   self.sci.find(exp, icase, wrap, forward)     @pyqtSlot(unicode, bool)