Changeset 1168
- Timestamp:
- 03/13/08 22:04:55 (6 months ago)
- Location:
- trunk/peppy
- Files:
-
- 3 modified
-
lib/autoindent.py (modified) (2 diffs)
-
plugins/cpp_mode.py (modified) (2 diffs)
-
plugins/c_mode.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/peppy/lib/autoindent.py
r1166 r1168 188 188 189 189 190 class CStyleAutoindent(BasicAutoindent): 191 """Use the STC Folding to reindent a line in a C-like mode. 192 193 This autoindenter uses the built-in Scintilla folding to determine the 194 correct indent level for C-like modes (C, C++, Java, Javascript, etc.) 195 plus a bunch of heuristics to handle things that Scintilla doesn't. 196 """ 197 debuglevel = 1 198 def findIndent(self, stc, linenum=None): 199 """Reindent the specified line to the correct level. 200 201 Given a line, use Scintilla's built-in folding to determine 202 the indention level of the current line. 203 """ 204 if linenum is None: 205 linenum = stc.GetCurrentLine() 206 linestart = stc.PositionFromLine(linenum) 207 208 # actual indention of current line 209 col = stc.GetLineIndentation(linenum) # columns 210 pos = stc.GetLineIndentPosition(linenum) # absolute character position 211 212 # folding says this should be the current indention 213 fold = stc.GetFoldLevel(linenum)&wx.stc.STC_FOLDLEVELNUMBERMASK - wx.stc.STC_FOLDLEVELBASE 214 c = stc.GetCharAt(pos) 215 self.dprint("col=%d (pos=%d), fold=%d char=%s" % (col, pos, fold, c)) 216 if c == ord('}'): 217 # Scintilla doesn't automatically dedent the closing brace, so we 218 # force that here. 219 fold -= 1 220 221 return fold * stc.GetIndent() 222 223 190 224 class RegexAutoindent(BasicAutoindent): 191 225 """Regex based autoindenter … … 199 233 entry<http://www.alweb.dk/blog/anders/autoindentation>} describing his 200 234 thinking that led up to the creation of the code. 235 236 The source code for the autoindenting part of Kate is actually in the 237 L{kpart<http://websvn.kde.org/branches/KDE/3.5/kdelibs/kate/part/kateautoindent.cpp?revision=620408&view=markup>} 238 section of KDE, not with the main Kate application. 201 239 """ 202 240 -
trunk/peppy/plugins/cpp_mode.py
r1166 r1168 12 12 13 13 from peppy.lib.foldexplorer import * 14 from peppy.lib.autoindent import FoldingAutoindent14 from peppy.lib.autoindent import CStyleAutoindent 15 15 from peppy.yapsy.plugins import * 16 16 from peppy.major import * … … 29 29 ) 30 30 31 autoindent = FoldingAutoindent()31 autoindent = CStyleAutoindent() 32 32 33 33 -
trunk/peppy/plugins/c_mode.py
r1166 r1168 13 13 14 14 from peppy.lib.foldexplorer import * 15 from peppy.lib.autoindent import FoldingAutoindent15 from peppy.lib.autoindent import CStyleAutoindent 16 16 from peppy.yapsy.plugins import * 17 17 from peppy.major import * … … 46 46 ) 47 47 48 autoindent = FoldingAutoindent()48 autoindent = CStyleAutoindent() 49 49 50 50
