File: EditorHelper.py

package info (click to toggle)
boa-constructor 0.4.4cvs20050714-4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 10,080 kB
  • ctags: 9,175
  • sloc: python: 56,189; sh: 545; makefile: 40
file content (112 lines) | stat: -rw-r--r-- 4,337 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#-----------------------------------------------------------------------------
# Name:        EditorHelper.py
# Purpose:
#
# Author:      Riaan Booysen
#
# Created:     2001
# RCS-ID:      $Id: EditorHelper.py,v 1.11 2005/05/18 12:05:11 riaan Exp $
# Copyright:   (c) 2001 - 2005
# Licence:     GPL
#-----------------------------------------------------------------------------

""" Global namespace for general IDE window ids, image indexes and registries """

import Preferences, Utils

(wxID_EDITOROPEN, wxID_EDITORSAVE, wxID_EDITORSAVEAS, wxID_EDITORCLOSEPAGE,
 wxID_EDITORREFRESH, wxID_EDITORDESIGNER, wxID_EDITORDEBUG, wxID_EDITORHELP,
 wxID_DEFAULTVIEWS, wxID_EDITORSWITCHTO, wxID_EDITORDIFF, wxID_EDITORPATCH,
 wxID_EDITORTOGGLEVIEW, wxID_EDITORSWITCHEXPLORER, wxID_EDITORSWITCHSHELL,
 wxID_EDITORSWITCHPALETTE, wxID_EDITORSWITCHINSPECTOR,
 wxID_EDITORTOGGLERO, wxID_EDITORHELPFIND, wxID_EDITORRELOAD,
 wxID_EDITORHELPABOUT, wxID_EDITORHELPGUIDE, wxID_EDITORHELPTIPS,
 wxID_EDITORHELPOPENEX,
 wxID_EDITORPREVPAGE, wxID_EDITORNEXTPAGE,
 wxID_EDITORBROWSEFWD, wxID_EDITORBROWSEBACK,
 wxID_EDITOREXITBOA, wxID_EDITOROPENRECENT,
 wxID_EDITORHIDEPALETTE, wxID_EDITORWINDIMS, wxID_EDITORWINDIMSLOAD,
 wxID_EDITORWINDIMSSAVE, wxID_EDITORWINDIMSRESDEFS,
 wxID_EDITORSWITCHPREFS,
) = Utils.wxNewIds(36)

imgCounter=0
def imgIdxRange(cnt=0):
    """ Allocates either a range of image indexes or a single one """
    global imgCounter
    if cnt:
        rng = range(imgCounter, imgCounter + cnt)
        imgCounter = imgCounter + cnt
        return rng
    else:
        imgCounter = imgCounter + 1
        return imgCounter - 1

builtinImgs =('Images/Modules/FolderUp.png',
              'Images/Modules/Folder.png',
              'Images/Modules/Folder_green.png',
              'Images/Modules/Folder_cyan.png',
              'Images/Shared/SystemObj.png',
              'Images/Shared/SystemObjOrdered.png',
              'Images/Shared/SystemObjBroken.png',
              'Images/Shared/SystemObjPending.png',
              'Images/Shared/SystemObjDisabled.png',
              'Images/Modules/ZopeConn.png',
              'Images/Shared/BoaLogo.png',
              'Images/Modules/Drive.png',
              'Images/Modules/NetDrive.png',
              'Images/Modules/FolderBookmark.png',
              'Images/Modules/OpenEditorModels.png',
              'Images/Modules/PrefsFolder.png',
              'Images/Shared/PrefsSTCStyles.png',
              'Images/Editor/RecentFiles.png',
              'Images/Editor/Shell.png',
              'Images/Editor/Explorer.png',
              'Images/Modules/HelpBook.png',
            )
# Like builtinImgs, but stores list of tuples, (imgIdx, name)
pluginImgs = []

def addPluginImgs(imgPath):
    imgIdx = imgIdxRange()
    pluginImgs.append( (imgIdx, imgPath) )

    return imgIdx


# Indexes for the imagelist
(imgFolderUp, imgFolder, imgPathFolder, imgCVSFolder, imgSystemObj,
 imgSystemObjOrdered, imgSystemObjBroken, imgSystemObjPending, imgSystemObjDisabled,
 imgZopeConnection, imgBoaLogo, imgFSDrive, imgNetDrive, imgFolderBookmark,
 imgOpenEditorModels, imgPrefsFolder, imgPrefsSTCStyles, imgRecentFiles,
 imgShell, imgExplorer, imgHelpBook,

 imgTextModel, imgBitmapFileModel, imgUnknownFileModel, imgInternalFileModel,
) = imgIdxRange(25)

# List of name, func tuples that will be installed under the Tools menu.
editorToolsReg = []

# Registry of all modules {modelIdentifier : Model} (populated by EditorModels)
# Used for images and header identifier
modelReg = {}
# Mapping of file extension to model (populated by EditorModels)
extMap = {}
# List of image file extensions
imageExtReg = []
# Dict of ext:Model entries. For types where not all files of that ext are images
imageSubTypeExtReg = {}
# List of extensions for internal filetypes created by Boa
internalFilesReg = []
# Dict of ext:Model entries which can be further identified by reading a header from the source
inspectableFilesReg = {}
# List of extensions for additional binary files (will not be searched)
binaryFilesReg = []
def getBinaryFiles():
    return imageExtReg + binaryFilesReg

def initExtMap():
    # All non python files identified by extension
    for mod in modelReg.values():
        if mod.ext not in ['.*', '.intfile', '.pybin'] +inspectableFilesReg.keys():
            extMap[mod.ext] = mod