SearchBinding.py :  » Mobile » Python-for-PalmOS » Python-1.5.2+reduced-1.0 » Tools » idle » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Mobile » Python for PalmOS 
Python for PalmOS » Python 1.5.2 reduced 1.0 » Tools » idle » SearchBinding.py
import tkSimpleDialog

###$ event <<find>>
###$ win <Control-f>
###$ unix <Control-u><Control-u><Control-s>

###$ event <<find-again>>
###$ win <Control-g>
###$ win <F3>
###$ unix <Control-u><Control-s>

###$ event <<find-selection>>
###$ win <Control-F3>
###$ unix <Control-s>

###$ event <<find-in-files>>
###$ win <Alt-F3>

###$ event <<replace>>
###$ win <Control-h>

###$ event <<goto-line>>
###$ win <Alt-g>
###$ unix <Alt-g>

class SearchBinding:

    windows_keydefs = {
        '<<find-again>>': ['<Control-g>', '<F3>'],
        '<<find-in-files>>': ['<Alt-F3>'],
        '<<find-selection>>': ['<Control-F3>'],
        '<<find>>': ['<Control-f>'],
        '<<replace>>': ['<Control-h>'],
        '<<goto-line>>': ['<Alt-g>'],
    }

    unix_keydefs = {
        '<<find-again>>': ['<Control-u><Control-s>'],
        '<<find-in-files>>': ['<Alt-s>', '<Meta-s>'],
        '<<find-selection>>': ['<Control-s>'],
        '<<find>>': ['<Control-u><Control-u><Control-s>'],
        '<<replace>>': ['<Control-r>'],
        '<<goto-line>>': ['<Alt-g>', '<Meta-g>'],
    }

    menudefs = [
        ('edit', [
            None,
            ('_Find...', '<<find>>'),
            ('Find a_gain', '<<find-again>>'),
            ('Find _selection', '<<find-selection>>'),
            ('Find in Files...', '<<find-in-files>>'),
            ('R_eplace...', '<<replace>>'),
            ('Go to _line', '<<goto-line>>'),
         ]),
    ]

    def __init__(self, editwin):
        self.editwin = editwin

    def find_event(self, event):
        import SearchDialog
        SearchDialog.find(self.editwin.text)
        return "break"

    def find_again_event(self, event):
        import SearchDialog
        SearchDialog.find_again(self.editwin.text)
        return "break"

    def find_selection_event(self, event):
        import SearchDialog
        SearchDialog.find_selection(self.editwin.text)
        return "break"

    def find_in_files_event(self, event):
        import GrepDialog
        GrepDialog.grep(self.editwin.text, self.editwin.io, self.editwin.flist)
        return "break"

    def replace_event(self, event):
        import ReplaceDialog
        ReplaceDialog.replace(self.editwin.text)
        return "break"

    def goto_line_event(self, event):
        text = self.editwin.text
        lineno = tkSimpleDialog.askinteger("Goto",
                                           "Go to line number:",
                                           parent=text)
        if lineno is None:
            return "break"
        if lineno <= 0:
            text.bell()
            return "break"
        text.mark_set("insert", "%d.0" % lineno)
        text.see("insert")
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.