Changeset 351
- Timestamp:
- 07/02/12 11:37:23 (12 months ago)
- Location:
- branches/mbutscher/work/lib/pwiki
- Files:
-
- 2 modified
-
ViHelper.py (modified) (13 diffs)
-
WikiTxtCtrl.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/mbutscher/work/lib/pwiki/ViHelper.py
r343 r351 232 232 continue 233 233 234 def ReloadPlugins(self, name): 235 self.RegisterPlugins() 236 self.LoadPlugins(name) 234 237 235 238 def LoadSettings(self): … … 495 498 selected_text = None 496 499 if self.mode == ViHelper.VISUAL: 500 # TODO: fix line selection mode 497 501 selected_text = self.GetSelectionDetails(selection_type) 498 502 … … 1083 1087 searchString = self.tfInput.GetValue() 1084 1088 1085 foundPos = -2 1089 foundPos = -26 1086 1090 if accP in ((wx.ACCEL_NORMAL, wx.WXK_NUMPAD_ENTER), 1087 1091 (wx.ACCEL_NORMAL, wx.WXK_RETURN)): … … 1300 1304 "tabparents" : (self.GetParentPages, self.OpenWikiPageNewTab), 1301 1305 "bgparents" : (self.GetParentPages, self.OpenWikiPageBackgroundTab), 1306 "w" : (self.Pass, self.SaveCurrentPage), 1302 1307 "write" : (self.Pass, self.SaveCurrentPage), 1303 1308 "open" : (self.GetWikiPages, self.OpenWikiPageCurrentTab), … … 1314 1319 # TODO: rewrite with vi like confirmation 1315 1320 "deletepage" : (self.GetDefinedWikiPages, self.ctrl.presenter.getMainControl().showWikiWordDeleteDialog), 1316 "d lpage" : (self.GetDefinedWikiPages, self.ctrl.presenter.getMainControl().showWikiWordDeleteDialog),1317 1318 "renamepage" : (self.GetDefinedWikiPages, self.Pass),1321 "delpage" : (self.GetDefinedWikiPages, self.ctrl.presenter.getMainControl().showWikiWordDeleteDialog), 1322 1323 #"renamepage" : (self.GetDefinedWikiPages, self.Pass), 1319 1324 1320 1325 # Currently bdelete and bwipeout are currently synonymous … … 1325 1330 "tabonly" : (self.GetTabs, self.CloseOtherTabs), 1326 1331 "exit" : (self.Pass, self.CloseWiki), 1332 1333 "reloadplugins" : (self.Pass, self.ReloadPlugins), 1327 1334 } 1328 1335 … … 1591 1598 self.data = [] 1592 1599 1600 def ReloadPlugins(self, args=None): 1601 """ 1602 Reload plugins globally using reloadMenuPlugins() and then 1603 on a per tab basis 1604 """ 1605 self.ctrl.presenter.getMainControl().reloadMenuPlugins() 1606 1607 # NOTE: should probably unify names 1608 for scName, name in (("textedit", "editor"), ("preview", "preview")): 1609 for tab in self.ctrl.presenter.getMainControl().getMainAreaPanel().getPresenters(): 1610 # Try and reload key bindings for each presenter on each tab 1611 # (if they exist) 1612 try: 1613 tab.getSubControl(scName).vi.ReloadPlugins(name) 1614 except AttributeError: 1615 pass 1616 1617 1618 1593 1619 def OpenPageInGoogle(self, text_input=None): 1594 1620 if type(text_input) == tuple: … … 1840 1866 self.selection_range = None 1841 1867 1868 self.block_kill_focus = False 1842 1869 wx.EVT_KILL_FOCUS(self.ctrls.viInputTextField, self.OnKillFocus) 1843 1870 … … 1911 1938 Called if a user clicks outside of the viInputPanel 1912 1939 """ 1913 if self.search :1940 if self.search and not self.block_kill_focus: 1914 1941 self.Close() 1915 1942 … … 1924 1951 return self.ctrls.viInputTextField.GetValue() 1925 1952 1926 def SetInput(self, text ):1953 def SetInput(self, text, clear=False): 1927 1954 # Check if we just want to change the cmd argument 1928 current_text = self.GetInput().split(" ") 1929 if len(current_text) > 1: 1930 text = "{0} {1}".format(current_text[0], text) 1955 if not clear: 1956 current_text = self.GetInput().split(" ") 1957 if len(current_text) > 1: 1958 text = "{0} {1}".format(current_text[0], text) 1931 1959 1932 1960 if text: … … 1958 1986 """ 1959 1987 if self.search: 1960 text = self.GetInput() 1961 1962 if len(text) < 1: 1963 return 1964 1965 self.search_args[u"text"] = text 1966 1967 # would .copy() be better? 1968 temp_search_args = dict(self.search_args) 1969 1970 temp_search_args[u"select_text"] = True 1971 1972 # TODO: set flags from config? 1973 result = self.ctrl.vi._SearchText(**temp_search_args) 1974 1975 if not result: 1976 self.ctrl.vi.visualBell("RED") 1977 self.ctrls.viInputTextField.SetBackgroundColour(ViInputDialog.COLOR_YELLOW) 1978 else: 1979 self.ctrls.viInputTextField.SetBackgroundColour(ViInputDialog.COLOR_GREEN) 1988 self.RunSearch() 1980 1989 1981 1990 # cmd … … 1996 2005 else: 1997 2006 self.ctrls.viInputTextField.SetBackgroundColour(ViInputDialog.COLOR_RED) 2007 2008 def RunSearch(self): 2009 text = self.GetInput() 2010 2011 if len(text) < 1: 2012 return 2013 2014 self.search_args[u"text"] = text 2015 2016 # would .copy() be better? 2017 temp_search_args = dict(self.search_args) 2018 2019 temp_search_args[u"select_text"] = True 2020 2021 self.block_kill_focus = True 2022 # TODO: set flags from config? 2023 result = self.ctrl.vi._SearchText(**temp_search_args) 2024 self.FocusInputField() 2025 self.block_kill_focus = False 2026 2027 if not result: 2028 self.ctrl.vi.visualBell("RED") 2029 self.ctrls.viInputTextField.SetBackgroundColour(ViInputDialog.COLOR_YELLOW) 2030 else: 2031 self.ctrls.viInputTextField.SetBackgroundColour(ViInputDialog.COLOR_GREEN) 1998 2032 1999 2033 def ExecuteCmd(self, text_input): … … 2120 2154 # Arrow keys can be used to navigate the cmd_lie history 2121 2155 elif accP == (wx.ACCEL_NORMAL, wx.WXK_UP): 2122 self.SetInput(self.cmd_history.GoBackwardsInHistory() )2156 self.SetInput(self.cmd_history.GoBackwardsInHistory(), clear=True) 2123 2157 2124 2158 elif accP == (wx.ACCEL_NORMAL, wx.WXK_DOWN): 2125 self.SetInput(self.cmd_history.GoForwardInHistory() )2159 self.SetInput(self.cmd_history.GoForwardInHistory(), clear=True) 2126 2160 2127 2161 elif accP == (wx.ACCEL_NORMAL, wx.WXK_TAB): -
branches/mbutscher/work/lib/pwiki/WikiTxtCtrl.py
r344 r351 3932 3932 } 3933 3933 3934 self.LoadKeybindings() 3935 self.LoadPlugins(u"editor") 3936 self.GenerateKeyBindings() 3937 3938 self.SINGLE_LINE_WHITESPACE = [9, 11, 12, 32] 3939 self.WORD_BREAK = '!"#$%&\'()*+,-./:;<=>?@[\\]^`{|}~' 3940 self.WORD_BREAK_INCLUDING_WHITESPACE = \ 3941 '!"#$%&\'()*+,-./:;<=>?@[\\]^`{|}~ \n\r' 3942 self.SENTENCE_ENDINGS = (".", "!", "?", "\n\n") 3943 self.SENTENCE_ENDINGS_SUFFIXS = '\'")]' 3944 3945 self.BRACES = { 3946 u"(" : u")", 3947 u"[" : u"]", 3948 u"{" : u"}", 3949 u"<" : u">", 3950 u"<<" : u">>", 3951 } 3952 self.REVERSE_BRACES = dict((v,k) for k, v in self.BRACES.iteritems()) 3953 3954 3955 self.SURROUND_REPLACEMENTS = { 3956 ")" : ("(", ")"), 3957 "b" : ("(", ")"), 3958 "}" : ("{", "}"), 3959 "B" : ("{", "}"), 3960 "]" : ("[", "]"), 3961 "r" : ("[", "]"), 3962 ">" : ("<", ">"), 3963 "a" : ("<", ">"), 3964 3965 "(" : ("( ", " )"), 3966 "{" : ("{ ", " }"), 3967 "[" : ("[ ", " ]"), 3968 3969 # TODO 3970 #"t" : ("<{0}>", "</{0}>"), 3971 #"<" : ("<{0}>", "</{0}>"), 3972 3973 "'" : ("'", "'"), 3974 '"' : ('"', '"'), 3975 "`" : ("`", "`"), 3976 3977 } 3978 3979 3980 3981 3982 self._undo_state = 0 3983 self._undo_pos = -1 3984 self._undo_start_position = None 3985 self._undo_positions = [] 3986 3987 self._line_column_pos = 0 3988 3989 self._visual_start_pos = None 3990 3991 self.isLinux = isLinux() 3992 3993 def LoadKeybindings(self): 3994 """ 3995 Function called to load keybindings. 3996 3997 Must call GenerateKeyBindings after this. 3998 """ 3934 3999 # Format 3935 4000 # key code : (command type, (function, arguments), repeatable, selection_type) … … 4262 4327 self.keys[3] = {} 4263 4328 4264 4265 self.LoadPlugins(u"editor") 4266 4329 4330 def GenerateKeyBindings(self): 4267 4331 4268 4332 #self._motion_chains = self.GenerateMotionKeyChains(self.keys) … … 4273 4337 # Used for rewriting menu shortcuts 4274 4338 self.viKeyAccels = self.GenerateKeyAccelerators(self.keys) 4275 4276 4277 self.SINGLE_LINE_WHITESPACE = [9, 11, 12, 32]4278 self.WORD_BREAK = '!"#$%&\'()*+,-./:;<=>?@[\\]^`{|}~'4279 self.WORD_BREAK_INCLUDING_WHITESPACE = \4280 '!"#$%&\'()*+,-./:;<=>?@[\\]^`{|}~ \n\r'4281 self.SENTENCE_ENDINGS = (".", "!", "?", "\n\n")4282 self.SENTENCE_ENDINGS_SUFFIXS = '\'")]'4283 4284 self.BRACES = {4285 u"(" : u")",4286 u"[" : u"]",4287 u"{" : u"}",4288 u"<" : u">",4289 u"<<" : u">>",4290 }4291 self.REVERSE_BRACES = dict((v,k) for k, v in self.BRACES.iteritems())4292 4293 4294 self.SURROUND_REPLACEMENTS = {4295 ")" : ("(", ")"),4296 "b" : ("(", ")"),4297 "}" : ("{", "}"),4298 "B" : ("{", "}"),4299 "]" : ("[", "]"),4300 "r" : ("[", "]"),4301 ">" : ("<", ">"),4302 "a" : ("<", ">"),4303 4304 "(" : ("( ", " )"),4305 "{" : ("{ ", " }"),4306 "[" : ("[ ", " ]"),4307 4308 # TODO4309 #"t" : ("<{0}>", "</{0}>"),4310 #"<" : ("<{0}>", "</{0}>"),4311 4312 "'" : ("'", "'"),4313 '"' : ('"', '"'),4314 "`" : ("`", "`"),4315 4316 }4317 4318 4319 4320 4321 self._undo_state = 04322 self._undo_pos = -14323 self._undo_start_position = None4324 self._undo_positions = []4325 4326 self._line_column_pos = 04327 4328 self._visual_start_pos = None4329 4330 self.isLinux = isLinux()4331 4339 4332 4340
