mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 19:28:09 -06:00
Merge pull request #52 from codeofdusk/bluebuffersearch
find a string in the currently focused buffer
This commit is contained in:
commit
81d3817b4c
@ -127,6 +127,7 @@ class Controller(object):
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.search, menuitem=self.view.menuitem_search)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.list_manager, menuitem=self.view.lists)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.get_trending_topics, menuitem=self.view.trends)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.find, menuitem=self.view.find)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.accountConfiguration, menuitem=self.view.account_settings)
|
||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.configuration, menuitem=self.view.prefs)
|
||||
|
||||
@ -417,6 +418,33 @@ class Controller(object):
|
||||
search.timer.start()
|
||||
dlg.Destroy()
|
||||
|
||||
def find(self, *args, **kwargs):
|
||||
if 'string' in kwargs:
|
||||
string=kwargs['string']
|
||||
else:
|
||||
string=''
|
||||
dlg = dialogs.find.findDialog(string)
|
||||
if dlg.get_response() == widgetUtils.OK and dlg.get("string") != "":
|
||||
string = dlg.get("string")
|
||||
#If we still have an empty string for some reason (I.E. user clicked cancel, etc), return here.
|
||||
if string == '':
|
||||
log.debug("Find canceled.")
|
||||
return
|
||||
page = self.get_current_buffer()
|
||||
if not hasattr(page.buffer, "list"):
|
||||
output.speak(_(u"No session is currently in focus. Focus a session with the next or previous session shortcut."), True)
|
||||
return
|
||||
count = page.buffer.list.get_count()
|
||||
if count < 1:
|
||||
output.speak(_(u"Empty buffer."), True)
|
||||
return
|
||||
start = page.buffer.list.get_selected()
|
||||
for i in xrange(start,count):
|
||||
page.buffer.list.select_item(i)
|
||||
if string.lower() in page.get_message().lower():
|
||||
return output.speak(page.get_message(), True)
|
||||
output.speak(unicode(string)+unicode(" ")+_(u"not found."), True)
|
||||
page.buffer.list.select_item(start)
|
||||
def edit_keystrokes(self, *args, **kwargs):
|
||||
editor = keystrokeEditor.KeystrokeEditor()
|
||||
if editor.changed == True:
|
||||
|
@ -27,3 +27,4 @@ clear_buffer = control+win+shift+delete
|
||||
repeat_item = control+win+space
|
||||
copy_to_clipboard = control+win+shift+c
|
||||
search = control+win+/
|
||||
find = control+win+shift+/
|
||||
|
@ -40,6 +40,7 @@ remove_from_list = control+win+alt+shift+l
|
||||
toggle_buffer_mute = control+win+alt+m
|
||||
toggle_session_mute = control+win+m
|
||||
search = control+win+/
|
||||
find = control+win+shift+/
|
||||
edit_keystrokes = control+win+k
|
||||
view_user_lists = win+alt+shift+l
|
||||
reverse_geocode = control+win+g
|
||||
|
@ -43,6 +43,7 @@ toggle_buffer_mute = string(default="control+win+shift+m")
|
||||
toggle_session_mute = string(default="alt+win+m")
|
||||
toggle_autoread = string(default="control+win+e")
|
||||
search = string(default="control+win+-")
|
||||
find = string(default="control+win+/")
|
||||
edit_keystrokes = string(default="control+win+k")
|
||||
view_user_lists = string(default="control+win+l")
|
||||
get_more_items = string(default="alt+win+pageup")
|
||||
|
@ -38,6 +38,7 @@ actions = {
|
||||
"toggle_session_mute": _(u"Mute/unmute the current session"),
|
||||
"toggle_autoread": _(u"toggle the automatic reading of incoming tweets in the active buffer"),
|
||||
"search": _(u"Search on twitter"),
|
||||
"find": _(u"Find a string in the currently focused buffer"),
|
||||
"edit_keystrokes": _(u"Show the keystroke editor"),
|
||||
"view_user_lists": _(u"Show lists for a specified user"),
|
||||
"get_more_items": _(u"load previous items"),
|
||||
|
@ -1 +1 @@
|
||||
import baseDialog, trends, configuration, lists, message, search, show_user, update_profile, urlList, userSelection, utils
|
||||
import baseDialog, trends, configuration, lists, message, search, find, show_user, update_profile, urlList, userSelection, utils
|
||||
|
26
src/wxUI/dialogs/find.py
Normal file
26
src/wxUI/dialogs/find.py
Normal file
@ -0,0 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import baseDialog
|
||||
import wx
|
||||
|
||||
class findDialog(baseDialog.BaseWXDialog):
|
||||
def __init__(self, value=""):
|
||||
super(findDialog, self).__init__(None, -1)
|
||||
panel = wx.Panel(self)
|
||||
sizer = wx.BoxSizer(wx.VERTICAL)
|
||||
self.SetTitle(_(u"Find in current buffer"))
|
||||
label = wx.StaticText(panel, -1, _(u"String"))
|
||||
self.string = wx.TextCtrl(panel, -1, value)
|
||||
dc = wx.WindowDC(self.string)
|
||||
dc.SetFont(self.string.GetFont())
|
||||
self.string.SetSize(dc.GetTextExtent("0"*40))
|
||||
sizer.Add(label, 0, wx.ALL, 5)
|
||||
sizer.Add(self.string, 0, wx.ALL, 5)
|
||||
ok = wx.Button(panel, wx.ID_OK, _(u"OK"))
|
||||
ok.SetDefault()
|
||||
cancel = wx.Button(panel, wx.ID_CANCEL, _(u"Cancel"))
|
||||
btnsizer = wx.BoxSizer()
|
||||
btnsizer.Add(ok, 0, wx.ALL, 5)
|
||||
btnsizer.Add(cancel, 0, wx.ALL, 5)
|
||||
sizer.Add(btnsizer, 0, wx.ALL, 5)
|
||||
panel.SetSizer(sizer)
|
||||
self.SetClientSize(sizer.CalcMin())
|
@ -50,6 +50,7 @@ class mainFrame(wx.Frame):
|
||||
# buffer menu
|
||||
buffer = wx.Menu()
|
||||
self.trends = buffer.Append(wx.NewId(), _(u"New &trending topics buffer..."))
|
||||
self.find = buffer.Append(wx.NewId(), _(u"Find a string in the currently focused buffer..."))
|
||||
self.load_previous_items = buffer.Append(wx.NewId(), _(u"&Load previous items"))
|
||||
buffer.AppendSeparator()
|
||||
self.mute_buffer = buffer.AppendCheckItem(wx.NewId(), _(u"&Mute"))
|
||||
|
Loading…
Reference in New Issue
Block a user