Ejemplo n.º 1
0
    def OnKeyDown( self, event ):
        """ キーダウンイベントハンドラ
        """
        kr = KeyReader( event )
        from keyMapper import KeyMapper_TextCtrl as KMap
        if KMap.isCancel( event ) or KMap.isDecide( event ):
            # ESC押されたらListCtrlにフォーカスを戻す
            self.getFrame().setFocusedPane( self.getFrame().getFocusedPane() )
        else:
            if self.mode==TextCtrl.MODE_SEARCH:
                # インクリメンタルサーチ結果を更新する
                self.EmulateKeyPress( event )
                if len( self.GetLineText(0) ):
                    self.getFrame().getFocusedListCtrl().updateIncSearch( self.GetLineText(0) )
                return
            elif self.mode==TextCtrl.MODE_GREP:
                if KMap.isDecide( event ):
                    # grepを行う
                    curDir = self.getFrame().getFocusedListCtrl().getCurDir()
                    # まず処理するファイル総数を計測
                    totalFileCount = 0
                    for path,dirs,files in os.walk( curDir ):
                        for f in files:
                            totalFileCount += 1

                    # プログレスダイアログを生成
                    pd = wx.ProgressDialog(
                            title="--- GREP ---",
                            message="This is a Grep!",
                            maximum=totalFileCount,
                            parent=self.getFrame(),
                            style=wx.PD_AUTO_HIDE|wx.PD_APP_MODAL|wx.PD_SMOOTH|wx.PD_ESTIMATED_TIME
                            )
                    pd.ShowModal()

                    """ このあたり作りかけ。Grepよりほかの実装項目を優先
                    """
                    # ファイル舞にGrep処理
                    procedFileCount = 0
                    for path,dirs,files in os.walk( curDir ):
                        for f in files:
                            print os.path.join( path, f )
                            procedFileCount += 1
                            pd.Update( procedFileCount )

                    pd.Update( totalFileCount )
                    pd.Destroy()
        event.Skip()