Merge branch 'Carpetsmoker-issue-940'
This commit is contained in:
commit
54ff8d2c0e
@ -1269,6 +1269,17 @@ class CommandDispatcher:
|
|||||||
except webelem.IsNullError:
|
except webelem.IsNullError:
|
||||||
raise cmdexc.CommandError("Element vanished while editing!")
|
raise cmdexc.CommandError("Element vanished while editing!")
|
||||||
|
|
||||||
|
def _clear_search(self, view, text):
|
||||||
|
"""Clear search string/highlights for the given view.
|
||||||
|
|
||||||
|
This does nothing if the view's search text is the same as the given
|
||||||
|
text.
|
||||||
|
"""
|
||||||
|
if view.search_text is not None and view.search_text != text:
|
||||||
|
# We first clear the marked text, then the highlights
|
||||||
|
view.search('', 0)
|
||||||
|
view.search('', QWebPage.HighlightAllOccurrences)
|
||||||
|
|
||||||
@cmdutils.register(instance='command-dispatcher', scope='window',
|
@cmdutils.register(instance='command-dispatcher', scope='window',
|
||||||
maxsplit=0)
|
maxsplit=0)
|
||||||
def search(self, text="", reverse=False):
|
def search(self, text="", reverse=False):
|
||||||
@ -1279,11 +1290,7 @@ class CommandDispatcher:
|
|||||||
reverse: Reverse search direction.
|
reverse: Reverse search direction.
|
||||||
"""
|
"""
|
||||||
view = self._current_widget()
|
view = self._current_widget()
|
||||||
if view.search_text is not None and view.search_text != text:
|
self._clear_search(view, text)
|
||||||
# We first clear the marked text, then the highlights
|
|
||||||
view.search('', 0)
|
|
||||||
view.search('', QWebPage.HighlightAllOccurrences)
|
|
||||||
|
|
||||||
flags = 0
|
flags = 0
|
||||||
ignore_case = config.get('general', 'ignore-case')
|
ignore_case = config.get('general', 'ignore-case')
|
||||||
if ignore_case == 'smart':
|
if ignore_case == 'smart':
|
||||||
@ -1301,6 +1308,8 @@ class CommandDispatcher:
|
|||||||
view.search(text, flags | QWebPage.HighlightAllOccurrences)
|
view.search(text, flags | QWebPage.HighlightAllOccurrences)
|
||||||
view.search_text = text
|
view.search_text = text
|
||||||
view.search_flags = flags
|
view.search_flags = flags
|
||||||
|
self._tabbed_browser.search_text = text
|
||||||
|
self._tabbed_browser.search_flags = flags
|
||||||
|
|
||||||
@cmdutils.register(instance='command-dispatcher', hide=True,
|
@cmdutils.register(instance='command-dispatcher', hide=True,
|
||||||
scope='window', count='count')
|
scope='window', count='count')
|
||||||
@ -1311,7 +1320,14 @@ class CommandDispatcher:
|
|||||||
count: How many elements to ignore.
|
count: How many elements to ignore.
|
||||||
"""
|
"""
|
||||||
view = self._current_widget()
|
view = self._current_widget()
|
||||||
if view.search_text is not None:
|
|
||||||
|
self._clear_search(view, self._tabbed_browser.search_text)
|
||||||
|
|
||||||
|
if self._tabbed_browser.search_text is not None:
|
||||||
|
view.search_text = self._tabbed_browser.search_text
|
||||||
|
view.search_flags = self._tabbed_browser.search_flags
|
||||||
|
view.search(view.search_text,
|
||||||
|
view.search_flags | QWebPage.HighlightAllOccurrences)
|
||||||
for _ in range(count):
|
for _ in range(count):
|
||||||
view.search(view.search_text, view.search_flags)
|
view.search(view.search_text, view.search_flags)
|
||||||
|
|
||||||
@ -1324,8 +1340,13 @@ class CommandDispatcher:
|
|||||||
count: How many elements to ignore.
|
count: How many elements to ignore.
|
||||||
"""
|
"""
|
||||||
view = self._current_widget()
|
view = self._current_widget()
|
||||||
if view.search_text is None:
|
self._clear_search(view, self._tabbed_browser.search_text)
|
||||||
return
|
|
||||||
|
if self._tabbed_browser.search_text is not None:
|
||||||
|
view.search_text = self._tabbed_browser.search_text
|
||||||
|
view.search_flags = self._tabbed_browser.search_flags
|
||||||
|
view.search(view.search_text,
|
||||||
|
view.search_flags | QWebPage.HighlightAllOccurrences)
|
||||||
# The int() here serves as a QFlags constructor to create a copy of the
|
# The int() here serves as a QFlags constructor to create a copy of the
|
||||||
# QFlags instance rather as a reference. I don't know why it works this
|
# QFlags instance rather as a reference. I don't know why it works this
|
||||||
# way, but it does.
|
# way, but it does.
|
||||||
|
@ -54,6 +54,8 @@ class TabbedBrowser(tabwidget.TabWidget):
|
|||||||
emitted if the signal occurred in the current tab.
|
emitted if the signal occurred in the current tab.
|
||||||
|
|
||||||
Attributes:
|
Attributes:
|
||||||
|
search_text/search_flags: Search parameters which are shared between
|
||||||
|
all tabs.
|
||||||
_win_id: The window ID this tabbedbrowser is associated with.
|
_win_id: The window ID this tabbedbrowser is associated with.
|
||||||
_filter: A SignalFilter instance.
|
_filter: A SignalFilter instance.
|
||||||
_now_focused: The tab which is focused now.
|
_now_focused: The tab which is focused now.
|
||||||
@ -108,6 +110,8 @@ class TabbedBrowser(tabwidget.TabWidget):
|
|||||||
self._undo_stack = []
|
self._undo_stack = []
|
||||||
self._filter = signalfilter.SignalFilter(win_id, self)
|
self._filter = signalfilter.SignalFilter(win_id, self)
|
||||||
self._now_focused = None
|
self._now_focused = None
|
||||||
|
self.search_text = None
|
||||||
|
self.search_flags = 0
|
||||||
objreg.get('config').changed.connect(self.update_favicons)
|
objreg.get('config').changed.connect(self.update_favicons)
|
||||||
objreg.get('config').changed.connect(self.update_window_title)
|
objreg.get('config').changed.connect(self.update_window_title)
|
||||||
objreg.get('config').changed.connect(self.update_tab_titles)
|
objreg.get('config').changed.connect(self.update_tab_titles)
|
||||||
|
Loading…
Reference in New Issue
Block a user