public
Description: Clone of SVN of PyObjC (not affiliated)
Homepage: http://pyobjc.sourceforge.net/
Clone URL: git://github.com/orestis/pyobjc.git
reindent


git-svn-id: http://svn.red-bean.com/pyobjc/trunk@1053 
f55f28a5-9edb-0310-a011-a803cfcd5d25
ronaldoussoren (author)
Wed Jul 28 10:53:00 -0700 2004
commit  278af1c9d0086dc46e9894d30d12a5ab7f55ed0b
tree    f0462af096930eb31c69c14457d8d105ac5e8f52
parent  2fb37c3417f2dbf8f74d45c827b4b134cb921eee
...
63
64
65
66
 
67
68
69
...
63
64
65
 
66
67
68
69
0
@@ -63,7 +63,7 @@ class PyDETextView(NSTextView):
0
         self.superview().superview().setHasHorizontalScroller_(True)
0
 
0
         # And to make that useable we make our textContainer a fixed, large
0
- # width.
0
+ # width.
0
         self.textContainer().setWidthTracksTextView_(False)
0
         self.textContainer().setContainerSize_((1000000, 1000000))
0
 
...
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
...
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
...
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
130
131
132
133
134
135
136
 
 
 
 
 
137
138
139
140
141
 
 
...
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
...
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
...
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
 
 
 
 
 
132
133
134
135
136
137
138
139
 
 
140
141
0
@@ -1,30 +1,30 @@
0
 """Module to analyze Python source code; for syntax coloring tools.
0
 
0
 Interface:
0
- for tag, start, end, sublist in fontify(pytext, searchfrom, searchto):
0
- ...
0
+ for tag, start, end, sublist in fontify(pytext, searchfrom, searchto):
0
+ ...
0
 
0
 The 'pytext' argument is a string containing Python source code.
0
-The (optional) arguments 'searchfrom' and 'searchto' may contain a slice in pytext.
0
+The (optional) arguments 'searchfrom' and 'searchto' may contain a slice in pytext.
0
 The returned value is a list of tuples, formatted like this:
0
- [('keyword', 0, 6, None), ('keyword', 11, 17, None), ('comment', 23, 53, None), etc. ]
0
+ [('keyword', 0, 6, None), ('keyword', 11, 17, None), ('comment', 23, 53, None), etc. ]
0
 The tuple contents are always like this:
0
- (tag, startindex, endindex, sublist)
0
+ (tag, startindex, endindex, sublist)
0
 tag is one of 'keyword', 'string', 'comment' or 'identifier'
0
-sublist is not used, hence always None.
0
+sublist is not used, hence always None.
0
 """
0
 
0
 # Based on FontText.py by Mitchell S. Chapman,
0
 # which was modified by Zachary Roadhouse,
0
 # then un-Tk'd by Just van Rossum.
0
 # Many thanks for regular expression debugging & authoring are due to:
0
-# Tim (the-incredib-ly y'rs) Peters and Cristian Tismer
0
+# Tim (the-incredib-ly y'rs) Peters and Cristian Tismer
0
 # So, who owns the copyright? ;-) How about this:
0
 # Copyright 1996-2003:
0
-# Mitchell S. Chapman,
0
-# Zachary Roadhouse,
0
-# Tim Peters,
0
-# Just van Rossum
0
+# Mitchell S. Chapman,
0
+# Zachary Roadhouse,
0
+# Tim Peters,
0
+# Just van Rossum
0
 
0
 from __future__ import generators
0
 
0
@@ -45,25 +45,25 @@ quotePat = pat.replace("q", "'") + "|" + pat.replace('q', '"')
0
 
0
 # Way to go, Tim!
0
 pat = r"""
0
- [uU]?[rR]?
0
- qqq
0
- [^\\q]*
0
- (
0
- ( \\[\000-\377]
0
- | q
0
- ( \\[\000-\377]
0
- | [^\q]
0
- | q
0
- ( \\[\000-\377]
0
- | [^\\q]
0
- )
0
- )
0
- )
0
- [^\\q]*
0
- )*
0
- (qqq)?
0
+ [uU]?[rR]?
0
+ qqq
0
+ [^\\q]*
0
+ (
0
+ ( \\[\000-\377]
0
+ | q
0
+ ( \\[\000-\377]
0
+ | [^\q]
0
+ | q
0
+ ( \\[\000-\377]
0
+ | [^\\q]
0
+ )
0
+ )
0
+ )
0
+ [^\\q]*
0
+ )*
0
+ (qqq)?
0
 """
0
-pat = "".join(pat.split()) # get rid of whitespace
0
+pat = "".join(pat.split()) # get rid of whitespace
0
 tripleQuotePat = pat.replace("q", "'") + "|" + pat.replace('q', '"')
0
 
0
 # Build up a regular expression which matches all and only
0
@@ -74,68 +74,68 @@ keyPat = r"\b(" + "|".join(keywordsList) + r")\b"
0
 matchPat = commentPat + "|" + keyPat + "|(" + tripleQuotePat + "|" + quotePat + ")"
0
 matchRE = re.compile(matchPat)
0
 
0
-idKeyPat = "[ \t]*([A-Za-z_][A-Za-z_0-9.]*)" # Ident w. leading whitespace.
0
+idKeyPat = "[ \t]*([A-Za-z_][A-Za-z_0-9.]*)" # Ident w. leading whitespace.
0
 idRE = re.compile(idKeyPat)
0
 asRE = re.compile(r".*?\b(as)\b")
0
 
0
 def fontify(pytext, searchfrom=0, searchto=None):
0
- if searchto is None:
0
- searchto = len(pytext)
0
- # Cache a few attributes for quicker reference.
0
- search = matchRE.search
0
- idMatch = idRE.match
0
- asMatch = asRE.match
0
-
0
- commentTag = 'comment'
0
- stringTag = 'string'
0
- keywordTag = 'keyword'
0
- identifierTag = 'identifier'
0
-
0
- start = 0
0
- end = searchfrom
0
- while 1:
0
- m = search(pytext, end)
0
- if m is None:
0
- break # EXIT LOOP
0
- if start >= searchto:
0
- break # EXIT LOOP
0
- keyword = m.group(1)
0
- if keyword is not None:
0
- # matched a keyword
0
- start, end = m.span(1)
0
- yield keywordTag, start, end, None
0
- if keyword in ["def", "class"]:
0
- # If this was a defining keyword, color the
0
- # following identifier.
0
- m = idMatch(pytext, end)
0
- if m is not None:
0
- start, end = m.span(1)
0
- yield identifierTag, start, end, None
0
- elif keyword == "import":
0
- # color all the "as" words on same line;
0
- # cheap approximation to the truth
0
- while 1:
0
- m = asMatch(pytext, end)
0
- if not m:
0
- break
0
- start, end = m.span(1)
0
- yield keywordTag, start, end, None
0
- elif m.group(0)[0] == "#":
0
- start, end = m.span()
0
- yield commentTag, start, end, None
0
- else:
0
- start, end = m.span()
0
- yield stringTag, start, end, None
0
+ if searchto is None:
0
+ searchto = len(pytext)
0
+ # Cache a few attributes for quicker reference.
0
+ search = matchRE.search
0
+ idMatch = idRE.match
0
+ asMatch = asRE.match
0
+
0
+ commentTag = 'comment'
0
+ stringTag = 'string'
0
+ keywordTag = 'keyword'
0
+ identifierTag = 'identifier'
0
+
0
+ start = 0
0
+ end = searchfrom
0
+ while 1:
0
+ m = search(pytext, end)
0
+ if m is None:
0
+ break # EXIT LOOP
0
+ if start >= searchto:
0
+ break # EXIT LOOP
0
+ keyword = m.group(1)
0
+ if keyword is not None:
0
+ # matched a keyword
0
+ start, end = m.span(1)
0
+ yield keywordTag, start, end, None
0
+ if keyword in ["def", "class"]:
0
+ # If this was a defining keyword, color the
0
+ # following identifier.
0
+ m = idMatch(pytext, end)
0
+ if m is not None:
0
+ start, end = m.span(1)
0
+ yield identifierTag, start, end, None
0
+ elif keyword == "import":
0
+ # color all the "as" words on same line;
0
+ # cheap approximation to the truth
0
+ while 1:
0
+ m = asMatch(pytext, end)
0
+ if not m:
0
+ break
0
+ start, end = m.span(1)
0
+ yield keywordTag, start, end, None
0
+ elif m.group(0)[0] == "#":
0
+ start, end = m.span()
0
+ yield commentTag, start, end, None
0
+ else:
0
+ start, end = m.span()
0
+ yield stringTag, start, end, None
0
 
0
 
0
 def test(path):
0
- f = open(path)
0
- text = f.read()
0
- f.close()
0
- for tag, start, end, sublist in fontify(text):
0
- print tag, repr(text[start:end])
0
+ f = open(path)
0
+ text = f.read()
0
+ f.close()
0
+ for tag, start, end, sublist in fontify(text):
0
+ print tag, repr(text[start:end])
0
 
0
 
0
 if __name__ == "__main__":
0
- import sys
0
- test(sys.argv[1])
0
+ import sys
0
+ test(sys.argv[1])
...
17
18
19
20
21
 
 
22
23
24
...
17
18
19
 
 
20
21
22
23
24
0
@@ -17,8 +17,8 @@ plist = Plist(
0
 buildapp(
0
         name = "PyDE",
0
         mainprogram = "main.py",
0
- resources = [
0
- os.path.join("Resources", x)
0
+ resources = [
0
+ os.path.join("Resources", x)
0
                 for x in os.listdir("Resources")
0
                 if x != 'CVS' ] + [ 'pythonfile.py', 'PyDETextView.py', 'PyFontify.py'],
0
         nibname = "MainMenu.nib",
...
83
84
85
86
 
87
88
89
...
83
84
85
 
86
87
88
89
0
@@ -83,7 +83,7 @@ class PyDEPythonDocument (NibClassBuilder.AutoBaseClass):
0
 
0
     def guessEncoding(self, text):
0
         """
0
- Return the encoding for a python source file
0
+ Return the encoding for a python source file
0
 
0
         The default is ASCII, but that can be changed using a PEP-263 cookie
0
         """

Comments

    No one has commented yet.