def on_hide(self, e): """Hide event handling""" if self.app.load_config('iconize_on_close', True): self.Hide() else: wx.PostEvent( self, wx.MenuEvent(wx.wxEVT_COMMAND_MENU_SELECTED, wx.ID_EXIT))
def ModifySave(self): """Called when document has been modified prompting a message dialog asking if the user would like to save the document before closing. @return: Result value of whether the file was saved or not """ name = self.nb.GetCurrentCtrl().GetFileName() if name == u"": name = self.nb.GetPageText(self.nb.GetSelection()) dlg = wx.MessageDialog(self, _("The file: \"%s\" has been modified since " "the last save point.\n\nWould you like to " "save the changes?") % name, _("Save Changes?"), wx.YES_NO | wx.YES_DEFAULT | wx.CANCEL | \ wx.ICON_INFORMATION) result = dlg.ShowModal() dlg.Destroy() if result == wx.ID_YES: self.OnSave(wx.MenuEvent(wx.wxEVT_COMMAND_MENU_SELECTED, ID_SAVE)) return result
def OnButton(self, evt): """Handles button events **Parameters:** * evt: event that called this handler **Post-Conditions:** * Dialog is closed * If Report Event then email program is opened """ e_id = evt.GetId() if e_id == wx.ID_CLOSE: self.Close() elif e_id == ID_SEND: frame = SendMailWx() msg = self.err_msg msg = msg.replace("'", '') frame.messageTxt.SetValue(msg) mainW = wx.GetApp().GetTopWindow() msg = _('DEVSimPy %s Error Report') % str(mainW.GetVersion()) frame.subjectTxt.SetValue(msg) frame.Show() self.Close() elif e_id == wx.ID_ABORT: ErrorDialog.ABORT = True # Try a nice shutdown first time through wx.CallLater(500, wx.GetApp().Destroy(), wx.MenuEvent(wx.wxEVT_MENU_OPEN, wx.ID_EXIT), True) self.Close() else: evt.Skip()
def __init__(self): super().__init__(parent=None, title='Yummy', size=(500, 100)) self.gameWindows = {} styles.init() iconFile = RESOURCES + "/yummy-icon-28-white.png" icon = wx.Icon(iconFile, wx.BITMAP_TYPE_ICO) self.SetIcon(icon) self.gs = gameserver.Factory() self.gs.subscribe(self, "msg_new_game", self.onMsgNewGame) self.gs.subscribe(self, "msg_game_updated", self.onMsgGameUpdated) self.gs.subscribe(self, "msg_game_loaded", self.onMsgGameLoaded) self.currentGame = None self.focusedGame = None self.sizer = wx.BoxSizer(wx.VERTICAL) self.createMenu() self.createGameList() self.SetAutoLayout(1) self.sizer.Fit(self) self.Centre() self.SetPosition((0, 0)) self.SetSizer(self.sizer) self.Show() self.Bind(event=wx.EVT_CLOSE, handler=self.onUserCloseMainWindow) wx.PostEvent(self, wx.MenuEvent(wx.wxEVT_MENU, ID_NEWGAME))
def OnButton(self, evt): """Handles button events **Parameters:** * evt: event that called this handler **Post-Conditions:** * Dialog is closed * If Report Event then email program is opened """ e_id = evt.GetId() if e_id == wx.ID_CLOSE: self.Close() elif e_id == ID_SEND: msg = "mailto:%s?subject = Error Report&body = %s" addr = "*****@*****.**" msg = msg % (addr, self.err_msg.encode('utf-8')) msg = msg.replace("'", '') webbrowser.open(msg) self.Close() elif e_id == wx.ID_ABORT: ErrorDialog.ABORT = True # Try a nice shutdown first time through wx.CallLater(500, wx.GetApp().Destroy(), wx.MenuEvent(wx.wxEVT_MENU_OPEN, wx.ID_EXIT), True) self.Close() else: evt.Skip()
def ModifySave(self): """Called when document has been modified prompting a message dialog asking if the user would like to save the document before closing. @return: Result value of whether the file was saved or not """ name = self.GetFileName() if name == u"": name = self.GetTabLabel() dlg = wx.MessageDialog(self, _("The file: \"%s\" has been modified since " "the last save point.\n\nWould you like to " "save the changes?") % name, _("Save Changes?"), wx.YES_NO | wx.YES_DEFAULT | wx.CANCEL | \ wx.ICON_INFORMATION) result = dlg.ShowModal() dlg.Destroy() # HACK if result == wx.ID_YES: evt = wx.MenuEvent(wx.wxEVT_COMMAND_MENU_SELECTED, ed_glob.ID_SAVE) tlw = self.GetTopLevelParent() if hasattr(tlw, 'OnSave'): tlw.OnSave(evt) return result
def OnButton(self, evt): """Handles button events @param evt: event that called this handler @postcondition: Dialog is closed @postcondition: If Report Event then email program is opened """ e_id = evt.GetId() if e_id == wx.ID_CLOSE: self.Close() elif e_id == ID_SEND: msg = "mailto:%s?subject=Error Report&body=%s" addr = "bugs@%s" % (ed_glob.HOME_PAGE.replace("http://", '', 1)) if wx.Platform != '__WXMAC__': msg = urllib2.quote(self.err_msg) else: msg = self.err_msg msg = msg % (addr, msg) msg = msg.replace("'", '') webbrowser.open(msg) self.Close() elif e_id == wx.ID_ABORT: ErrorDialog.ABORT = True # Try a nice shutdown first time through wx.CallLater(500, wx.GetApp().OnExit, wx.MenuEvent(wx.wxEVT_MENU_OPEN, ed_glob.ID_EXIT), True) self.Close() else: evt.Skip()
def openMenu(self): ''' Programmatically open the menu. This is mainly for testing purposes. ''' # On Mac OSX, an explicit UpdateWindowUI is needed to ensure that # menu items are updated before the menu is opened. This is not needed # on other platforms, but it doesn't hurt either. self._window.UpdateWindowUI() self._window.ProcessEvent(wx.MenuEvent(wx.wxEVT_MENU_OPEN, menu=self))
def CallMenu(self): 'Click (down then up) handling.' self.Active() if self.active: event = wx.MenuEvent(wx.wxEVT_MENU_OPEN, -1) event.SetEventObject(self.menu) self.Top.ProcessEvent(event) self.ReleaseAllCapture() self.menu.Display(self)
def onPresetSelect(self, idxPreset, newPreset): if CeciliaLib.getPresets().has_key(newPreset): if newPreset != 'init': CeciliaLib.loadPresetFromDict(newPreset) for preset in CeciliaLib.getPresets(): if preset != newPreset: CeciliaLib.getPresets()[preset]['active'] = False CeciliaLib.getPresets()[newPreset]['active'] = True self.currentPreset = newPreset elif newPreset == 'init': CeciliaLib.getCeciliaEditor().onUpdateInterface(wx.MenuEvent())
def on_menu_item(self, e): """Popup menu item selection handling""" if e.Id == ids.RESTORE: wx.PostEvent(self.app.roster, ev.ShowRoster()) elif e.Id == ids.HIDE: wx.PostEvent(self.app.roster, ev.HideRoster()) elif e.Id == ids.EXIT: wx.PostEvent( self.app.roster, wx.MenuEvent(wx.wxEVT_COMMAND_MENU_SELECTED, wx.ID_EXIT)) elif e.Id == ids.PREFERENCES: wx.PostEvent( self.app.roster, wx.MenuEvent(wx.wxEVT_COMMAND_MENU_SELECTED, ids.PREFERENCES)) elif e.Id == ids.OFFLINE: wx.PostEvent(self.app, ev.ChangePresence(status='offline')) elif e.Id == ids.AWAY: wx.PostEvent(self.app, ev.ChangePresence(status='away')) elif e.Id == ids.ONLINE: wx.PostEvent(self.app, ev.ChangePresence(status='online'))
def trigger_open_replace_window(self): if not os.path.exists(os.path.abspath(replace_project_dir)): os.mkdir(os.path.abspath(replace_project_dir)) if len(os.listdir(replace_project_dir)) > 0: project_name = os.listdir(replace_project_dir)[0] if time.time() - os.path.getctime(os.path.join(replace_project_dir, project_name)) < 15*60: trigger_menu = self.replace_menu_dic.get(project_name) if trigger_menu: # evt = wx.PyCommandEvent(wx.EVT_MENU.typeId, trigger_menu.GetId()) evt = wx.MenuEvent(wx.wxEVT_MENU, trigger_menu.GetId(), self.menu2) wx.PostEvent(self, evt)
def ExecuteCommand(self, cmd_str): """Interprets and executes a command then hides the control @param cmd_str: Command string to execute """ frame = self.GetTopLevelParent() cmd = cmd_str.strip().lstrip(':') if cmd in ['x', 'ZZ']: cmd = 'wq' if cmd.startswith(u'w'): frame.OnSave( wx.MenuEvent(wx.wxEVT_COMMAND_MENU_SELECTED, ed_glob.ID_SAVE)) if self.RE_WGO_BUFFER.match(cmd): self.GoBuffer(cmd[1:]) elif cmd == 'wq': self.Quit() elif cmd.startswith(u'e '): self.EditCommand(cmd) elif cmd.rstrip() == u'e!': ctrl = frame.nb.GetCurrentCtrl() ctrl.RevertToSaved() elif self.RE_GO_WIN.match(cmd): self.GoWindow(cmd) elif re.match(self.RE_GO_BUFFER, cmd): self.GoBuffer(cmd) elif cmd.isdigit() or self.RE_NGO_LINE.match(cmd): ctrl = frame.nb.GetCurrentCtrl() cline = ctrl.GetCurrentLine() if cmd[0] in '+-': line = eval("%s %s %s" % (str(cline), cmd[0], cmd[1:])) else: line = int(cmd) - 1 ctrl.GotoLine(line) elif cmd.startswith('cd '): self.ChangeDir(cmd) elif cmd == 'q': self.Quit() else: wx.Bell() return self.CommandPush(cmd_str) self.GetParent().Hide()
def OpenContextMenu(self, event): RegisterMenuCommand = globalVars.app.hMainView.menu.RegisterMenuCommand if event: targetPath = self.listObject.GetElement( self.hListCtrl.HitTest(event.GetPoint())[0]).fullpath else: targetPath = self.GetFocusedElement().fullpath #end イベントあるか misc.GetContextMenu() misc.AddCustomContextMenuItem("テスト", 5001) can_show_menu = misc.AddContextMenuItemsFromWindows(targetPath) if not can_show_menu: misc.DestroyContextMenu() return #コンテキストメニュー生成できなかった #end メニュー生成できない x, y = wx.GetMousePosition() cmd = misc.ShowContextMenu(x, y) evt = wx.MenuEvent(id=cmd) self.CloseContextMenu(evt)
def OnClose(self, event): """ Handels hiding of submenus and deactivating caller if aplicable when the menu is closed """ if not self.IsShown(): do( item.menu.Show(False) for item in self.spine.items if item.menu and item.menu.IsShown()) while self.spine.HasCapture(): self.spine.ReleaseMouse() if self.caller: # and hasattr(self.caller,'Active'): event = wx.MenuEvent(wx.wxEVT_MENU_CLOSE, self.Id) self.caller.AddPendingEvent(event) self.caller = None if self.connected: window, id = self.connected window.Disconnect(id, id, wx.wxEVT_ACTIVATE) self.connected = None
def OpenContextMenu(self, event): if event: # マウス操作 x, y = wx.GetMousePosition() else: rect = self.hListCtrl.GetItemRect(self.GetFocusedItem(), wx.LIST_RECT_LABEL) x, y = self.hListCtrl.ClientToScreen(rect.GetBottomRight()) # end 表示位置判定 RegisterMenuCommand = globalVars.app.hMainView.menu.RegisterMenuCommand targetPaths = self.GetSelectedItems().GetItemPaths() misc.GetContextMenu() misc.AddCustomContextMenuItem("テスト", 5001) can_show_menu = misc.AddContextMenuItemsFromWindows(targetPaths) if not can_show_menu: misc.DestroyContextMenu() return # コンテキストメニュー生成できなかった # end メニュー生成できない cmd = misc.ShowContextMenu(x, y) evt = wx.MenuEvent(id=cmd) self.CloseContextMenu(evt)
def __init__(self, parent, id=-1, label='', skin=None, icon=None, pos=wx.DefaultPosition, size=None, style=HORIZONTAL, type=None, menu=None, menubarmode=False, onclick=None): """ Usage: UberButton(parent,id,label,skin,icon,pos,size,style,type,menu) -skin - instead of detecting skins presence lke most UberGUI this takes the skin as an argument from the parent this allows different skins to be set to different buttons at the same time if not assigned will look OS native -icon - The icon to show up on the button Note: the button resizes to fit the icon, not vice versa -pos - position of the button -size - size of the button, this is actualy ignored and will likely be adjusted to affect restraint size later -style - wx.HORIZONTAL - Icon centered over label centered on button wx.VERTICAL - Icon spaced from left with label to the right -type - None - normal button combo - no behavior changes, only changes the drawing code on native butons toggle - button toggles True and False, needs visual notification in native mode menu - does not return an event, adds a dropdown icon to the rightside of the button, when toggled on displays the menu associated to it -menu - the menu to drop down when the button is clicked if type is menu """ wx.PyControl.__init__(self, parent, id=id, pos=pos, style=wx.NO_BORDER | wx.FULL_REPAINT_ON_RESIZE) if type == "combo": UberWidget.__init__(self, 'COMBOBOX') else: UberWidget.__init__(self, "button") self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.label = label if label: self.RegAccel(label) self.notified = False self.active = False self.isdown = False self.hovered = False self.state = 1 self.menu = menu if type == 'menu' else None if menu is not None and hasattr(menu, 'OnDismiss'): menu.OnDismiss += lambda: self.AddPendingEvent( wx.MenuEvent(wx.wxEVT_MENU_CLOSE, menu.Id)) if icon: self.icon = icon self.MakeDicon() else: self.icon = None self.style = style self.type = type self.menubarmode = menubarmode self.ssize = wx.Size(0, 0) self.staticwidth = None if size: self.autoscale = False else: self.autoscale = True self.native = None self.Sizer = wx.BoxSizer(HORIZONTAL) self.SetSkinKey(skin, True) Bind = self.Bind Bind(wx.EVT_MOVE, lambda e: self.Refresh()), Bind(wx.EVT_PAINT, self.OnPaint), Bind(wx.EVT_SET_FOCUS, lambda e: self.Refresh()), Bind(wx.EVT_KEY_DOWN, self.OnKeyDown), Bind(wx.EVT_KEY_UP, self.OnKeyUp), Bind(wx.EVT_KILL_FOCUS, self.OnKillFocus), Bind(wx.EVT_LEFT_DOWN, self.OnLeftDown), Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDown), Bind(wx.EVT_LEFT_UP, self.OnLeftUp), Bind(wx.EVT_ENTER_WINDOW, self.OnMouseIn), Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseOut), Bind(wx.EVT_MOTION, self.OnMotion), Bind(wx.EVT_MENU_CLOSE, lambda e: (self.Active(False), self.OnMouseOut())) Bind(wx.EVT_SHOW, self.OnShow) if onclick is not None: if not hasattr(onclick, '__call__'): raise TypeError('onclick must be callable') self.Bind(wx.EVT_BUTTON, lambda e: (e.Skip(), onclick()))
def test_MenuEvent_ctor(self): evt = wx.MenuEvent()
def Abort(self): """Abort the application""" # Try a nice shutdown first time through wx.CallLater(500, wx.GetApp().OnExit, wx.MenuEvent(wx.wxEVT_MENU_OPEN, ed_glob.ID_EXIT), True)
def ProcessKey(self, key_code): """Processes vi commands @todo: complete rewrite, this was initially intended as a quick hack put together for testing but now has implemented everything. """ if self.mode == ViKeyHandler.INSERT: return False self.cmdcache = self.cmdcache + unichr(key_code) if not len(self.cmdcache): return False if self.cmdcache != u'.': cmd = self.cmdcache else: cmd = self.last cpos = self.stc.GetCurrentPos() cline = self.stc.LineFromPosition(cpos) mw = self.stc.GetTopLevelParent() if u':' in cmd: self.cmdcache = u'' mw.ShowCommandCtrl() # Single key commands if len(cmd) == 1 and (cmd in 'AHILmM0^$nia/?:'): if cmd in u'A$': # Insert at EOL self.stc.GotoPos(self.stc.GetLineEndPosition(cline)) elif cmd == u'H': # Go first visible line # todo allow num self.stc.GotoIndentPos(self.stc.GetFirstVisibleLine()) elif cmd in u'I^': # Insert at line start / Jump line start self.stc.GotoIndentPos(cline) elif cmd == u'0': # Jump to line start column 0 self.stc.GotoPos(self.stc.PositionFromLine(cline)) elif cmd == u'L': # Goto start of last visible line # todo allow num self.stc.GotoIndentPos(self.stc.GetLastVisibleLine()) elif cmd == u'M': # Goto middle line of display self.stc.GotoIndentPos(self.stc.GetMiddleVisibleLine()) elif cmd == u'm': # Mark line if self.stc.MarkerGet(cline): self.stc.Bookmark(ed_glob.ID_DEL_BM) else: self.stc.Bookmark(ed_glob.ID_ADD_BM) elif cmd == u'a': # insert mode after current pos self.stc.GotoPos(cpos + 1) elif cmd in u'/?': if mw is not None: evt = wx.MenuEvent(wx.wxEVT_COMMAND_MENU_SELECTED, ed_glob.ID_QUICK_FIND) wx.PostEvent(mw, evt) if cmd in u'aAiI': self.SetMode(ViKeyHandler.INSERT) self.last = cmd self.cmdcache = u'' # Repeatable 1 key commands elif re.match(VI_SINGLE_REPEAT, cmd): rcmd = cmd[-1] repeat = cmd[0:-1] if repeat == u'': repeat = 1 else: repeat = int(repeat) args = list() kargs = dict() cmd_map = { u'b': self.stc.WordPartLeft, u'B': self.stc.WordLeft, u'e': self.stc.WordPartRightEnd, u'E': self.stc.WordRightEnd, u'h': self.stc.CharLeft, u'j': self.stc.LineDown, u'k': self.stc.LineUp, u'l': self.stc.CharRight, u'o': self.stc.AddLine, u'O': self.stc.AddLine, u'p': self.stc.Paste, u'P': self.stc.Paste, u's': self.stc.Cut, u'u': self.stc.Undo, u'w': self.stc.WordPartRight, u'W': self.stc.WordRight, u'x': self.stc.Cut, u'X': self.stc.Cut, u'{': self.stc.ParaUp, u'}': self.stc.ParaDown, u'~': self.stc.InvertCase } if rcmd in u'pP': success = False newline = False if wx.TheClipboard.Open(): td = wx.TextDataObject() success = wx.TheClipboard.GetData(td) wx.TheClipboard.Close() if success: text = td.GetText() if text[-1] == '\n': if cline == self.stc.GetLineCount( ) - 1 and rcmd == u'p': self.stc.NewLine() else: if rcmd == u'P': self.stc.GotoLine(cline) else: self.stc.GotoLine(cline + 1) newline = True elif rcmd == u'p' and \ self.stc.LineFromPosition(cpos + 1) == cline: self.stc.CharRight() elif rcmd in u'sxX~': if rcmd in u'sx~': tmp = self.stc.GetTextRange(cpos, cpos + repeat) tmp = tmp.split(self.stc.GetEOLChar()) end = cpos + len(tmp[0]) else: tmp = self.stc.GetTextRange(cpos - repeat, cpos) tmp = tmp.split(self.stc.GetEOLChar()) end = cpos - len(tmp[-1]) tmp = end end = cpos cpos = tmp if cpos == self.stc.GetLineEndPosition(cline): self.stc.SetSelection(cpos - 1, cpos) else: self.stc.SetSelection(cpos, end) repeat = 1 elif rcmd == u'O': kargs['before'] = True self.stc.BeginUndoAction() if rcmd in u'CD': # Cut line right self.stc.SetSelection( cpos, self.stc.GetLineEndPosition(cline + (repeat - 1))) self.stc.Cut() elif rcmd == u'J': self.stc.SetTargetStart(cpos) if repeat == 1: repeat = 2 self.stc.SetTargetEnd( self.stc.PositionFromLine(cline + repeat - 1)) self.stc.LinesJoin() elif rcmd == u'G': if repeat == 1 and '1' not in cmd: repeat = self.stc.GetLineCount() self.stc.GotoLine(repeat - 1) elif rcmd == u'+': self.stc.GotoIndentPos(cline + repeat) elif rcmd == u'-': self.stc.GotoIndentPos(cline - repeat) elif rcmd == u'|': self.stc.GotoColumn(repeat - 1) else: if not cmd_map.has_key(rcmd): return True run = cmd_map[rcmd] for count in xrange(repeat): run(*args, **kargs) if rcmd == u'p': if newline: self.stc.GotoIndentPos(cline + repeat) else: self.stc.GotoPos(cpos + 1) elif rcmd == u'P': if newline: self.stc.GotoIndentPos(cline) else: self.stc.GotoPos(cpos) # elif rcmd == u'u': # self.GotoPos(cpos) elif rcmd in u'CoOs': self.SetMode(ViKeyHandler.INSERT) self.stc.EndUndoAction() self.last = cmd self.cmdcache = u'' # 2 key commands elif re.match(VI_DOUBLE_P1, cmd) or \ re.match(VI_DOUBLE_P2, cmd) or \ re.match(re.compile('[cdy]0'), cmd): if re.match(re.compile('[cdy]0'), cmd): rcmd = cmd else: rcmd = re.sub(NUM_PAT, u'', cmd) repeat = re.subn(re.compile(VI_DCMD_RIGHT), u'', cmd, 2)[0] if repeat == u'': repeat = 1 else: repeat = int(repeat) if rcmd[-1] not in u'bBeEGhHlLMwW$|{}0': self.stc.GotoLine(cline) if repeat != 1 or rcmd not in u'>><<': self.stc.SetSelectionStart(self.stc.GetCurrentPos()) self.stc.SetSelectionEnd( self.stc.PositionFromLine(cline + repeat)) else: self.stc.SetAnchor(self.stc.GetCurrentPos()) mcmd = { u'b': self.stc.WordPartLeftExtend, u'B': self.stc.WordLeftExtend, u'e': self.stc.WordPartRightEndExtend, u'E': self.stc.WordRightEndExtend, u'h': self.stc.CharLeftExtend, u'l': self.stc.CharRightExtend, u'w': self.stc.WordPartRightExtend, u'W': self.stc.WordRightExtend, u'{': self.stc.ParaUpExtend, u'}': self.stc.ParaDownExtend } if u'$' in rcmd: pos = self.stc.GetLineEndPosition(cline + repeat - \ len(self.stc.GetEOLChar())) self.stc.SetCurrentPos(pos) elif u'G' in rcmd: if repeat == 0: # invalid cmd self.cmdcache = u'' return True if repeat == 1 and u'1' not in cmd: # Default eof self.stc.SetAnchor( self.stc.GetLineEndPosition(cline - 1)) repeat = self.stc.GetLength() elif repeat < cline + 1: self.stc.SetAnchor(self.stc.PositionFromLine(cline + 1)) repeat = self.stc.PositionFromLine(repeat - 1) cline = self.stc.LineFromPosition(repeat) - 1 elif repeat > cline: self.stc.SetAnchor( self.stc.GetLineEndPosition(cline - 1)) if cline == 0: repeat = self.stc.PositionFromLine(repeat) else: repeat = self.stc.GetLineEndPosition(repeat - 1) else: self.stc.SetAnchor(self.stc.PositionFromLine(cline)) repeat = self.stc.PositionFromLine(cline + 1) self.stc.SetCurrentPos(repeat) elif rcmd[-1] in u'HM': fline = self.stc.GetFirstVisibleLine() lline = self.stc.GetLastVisibleLine() if u'M' in rcmd: repeat = self.stc.GetMiddleVisibleLine() + 1 elif fline + repeat > lline: repeat = lline else: repeat = fline + repeat if repeat > cline: self.stc.SetAnchor(self.stc.PositionFromLine(cline)) self.stc.SetCurrentPos( self.stc.PositionFromLine(repeat)) else: self.stc.SetAnchor( self.stc.PositionFromLine(repeat - 1)) self.stc.SetCurrentPos( self.stc.PositionFromLine(cline + 1)) elif u'L' in rcmd: fline = self.stc.GetFirstVisibleLine() lline = self.stc.GetLastVisibleLine() if lline - repeat < fline: repeat = fline else: repeat = lline - repeat if repeat < cline: self.stc.SetAnchor(self.stc.PositionFromLine(cline)) self.stc.SetCurrentPos( self.stc.PositionFromLine(repeat)) else: self.stc.SetAnchor(self.stc.PositionFromLine(cline)) self.stc.SetCurrentPos( self.stc.PositionFromLine(repeat + 2)) elif u'|' in rcmd: if repeat == 1 and u'1' not in cmd: repeat = 0 self.stc.SetCurrentCol(repeat) elif rcmd[-1] == u'0': self.stc.SetCurrentCol(0) else: doit = mcmd[rcmd[-1]] for x in xrange(repeat): doit() self.stc.BeginUndoAction() if re.match(re.compile('c|c' + VI_DCMD_RIGHT), rcmd): if rcmd == u'cc': self.stc.SetSelectionEnd(self.stc.GetSelectionEnd() - \ len(self.stc.GetEOLChar())) self.stc.Cut() self.SetMode(ViKeyHandler.INSERT) elif re.match(re.compile('d|d' + VI_DCMD_RIGHT), rcmd): self.stc.Cut() elif re.match(re.compile('y|y' + VI_DCMD_RIGHT), rcmd): self.stc.Copy() self.stc.GotoPos(cpos) elif rcmd == u'<<': self.stc.BackTab() elif rcmd == u'>>': self.stc.Tab() else: pass self.stc.EndUndoAction() if rcmd in '<<>>' or rcmd[-1] == u'G': self.stc.GotoIndentPos(cline) self.last = cmd self.cmdcache = u'' elif re.match(VI_GCMDS, cmd): rcmd = cmd[-1] if rcmd == u'g': self.stc.GotoLine(0) elif rcmd == u'f': pass # TODO: gf (Goto file at cursor) self.last = cmd self.cmdcache = u'' else: pass # Update status bar if mw and self.mode == ViKeyHandler.NORMAL: evt = ed_event.StatusEvent(ed_event.edEVT_STATUS, self.stc.GetId(), 'NORMAL %s' % self.cmdcache, ed_glob.SB_BUFF) wx.PostEvent(self.stc.GetTopLevelParent(), evt) return True
def openMenu(self): self.menu.onOpenMenu(wx.MenuEvent(menu=self.menu))