Package peppy :: Module stcbase :: Class PeppyBaseSTC
[frames] | no frames]

Class PeppyBaseSTC

     object --+                    
              |                    
wx._core.Object --+                
                  |                
wx._core.EvtHandler --+            
                      |            
        wx._core.Window --+        
                          |        
           wx._core.Control --+    
                              |    
          wx.stc.StyledTextCtrl --+
                                  |
                     object --+   |
                              |   |
      stcinterface.STCInterface --+
                                  |
                     object --+   |
                              |   |
               debug.debugmixin --+
                                  |
                                 PeppyBaseSTC
Known Subclasses:

The base class used as backend storage for files that fit in memory.

Peppy uses the wx.stc.StyledTextCtrl (abbreviated STC in the peppy documentation) to store its files in memory. Because the STC allows multiple views of the same file, we take advantage of this to prevent keeping multiple copies of the file for different views. As described in MajorMode, multiple STCs will keep themselves updated when the user makes change in another STC.

Note that there is a difference in the STC stored in the Buffer and any STCs that are used by the FundamentalMode class. There will always be at least two instances of STCs: one in the buffer that is the main backend storage, and the other in the major mode that provides the view. They both point to the same data, but they are kept separate in order that major modes (i.e. the views of the data) can change at will.

This class performs the bookkeeping to keep the STC document pointers up to date when a new view is added.

Instance Methods
EvtHandler
__init__(self, parent, refstc=None, copy=None, **kwargs)
__init__(self, Window parent, int id=ID_ANY, Point pos=DefaultPosition, ...
 
updateSubordinateClasses(self)
Update the list of classes viewing this buffer.
 
getSharedClassInfo(self, cls)
Get the dict that can be used to store data common to viewers of the specified class.
 
addSubordinate(self, otherstc)
 
removeDocumentView(self)
Remove the reference of this view from its parent document
 
open(self, buffer, message=None)
Open the file from the buffer and read in its contents.
 
readThreaded(self, fh, buffer, message=None)
 
openSuccess(self, buffer, headersize=1024, encoding=None)
Called after a file has been successfully opened.
 
readFrom(self, fh, amount=None, chunk=65536, length=0, message=None)
Read a chunk of the file from the file-like object.
 
decodeText(self, bytes)
Check for the file encoding and convert in place.
 
prepareEncoding(self)
Prepare the file for encoding.
 
writeTo(self, fh)
Writes a copy of the document to the provided file-like object.
 
checkUndoEOL(self)
Check to see if the last change was converting all EOL characters.
 
Undo(self)
Override of base Undo command to add our additional checks.
 
Redo(self)
Override of base Redo command to add our additional checks.
 
CanEdit(self)
PyPE compat
 
CanCopy(self)
 
CanCut(self)
 
SelectAll(self)
Select all the text in the document.
 
GetBinaryData(self, start=0, end=-1)
Convenience function to get binary data out of the STC.
boolean
GuessBinary(self, amount, percentage)
Guess if the text in this file is binary or text by scanning through the first amount characters in the file and checking if some percentage is out of the printable ascii range.
 
GetSelection2(self)
Get the current region, but don't return an empty last line if the cursor is at column zero of the last line.
 
GetLineRegion(self)
Get current region, extending to current line if no region selected.
 
PasteAtColumn(self, paste=None)
Paste a rectangular selection at a particular column.
 
detectLineEndings(self, header)
Guess which type of line ending is used by the file.
 
ConvertEOLs(self, mode)
ConvertEOLs(self, int eolMode)
 
getLinesep(self)
Get the current line separator character.
 
convertStringEOL(self, text)
Convert a string to the target EOL format of this STC
 
isStyleString(self, style)
Is the style a string?
 
isStyleComment(self, style)
Is the style a comment?
 
showStyle(self, linenum=None)
Debugging routine to show the styling information on a line.
 
showLine(self, line)
 
GetFoldColumn(self, linenum)
Return column number of folding.
 
GetPrevLineIndentation(self, linenum)
Get the indentation of the line before the specified line.
 
GetIndentString(self, ind)
 
addLinePrefixAndSuffix(self, start, end, prefix='', suffix='')
Add a prefix and/or suffix to the line specified by start and end.
 
removeLinePrefixAndSuffix(self, start, end, prefix='', suffix='')
Remove the specified prefix and suffix of the line.
 
setCommentDelimiters(self, start='', end='')
Set instance-specific comment characters and comment regex
 
commentRegion(self, add=True)
Default implementation of block commenting and uncommenting
 
splitCommentLine(self, line)
Split the line into the whitespace leader and body of the line.
 
getWordFromPosition(self, pos)

Inherited from wx.stc.StyledTextCtrl: AddRefDocument, AddStyledText, AddText, AddTextRaw, AddTextUTF8, Allocate, AppendText, AppendTextRaw, AppendTextUTF8, AutoCompActive, AutoCompCancel, AutoCompComplete, AutoCompGetAutoHide, AutoCompGetCancelAtStart, AutoCompGetChooseSingle, AutoCompGetCurrent, AutoCompGetDropRestOfWord, AutoCompGetIgnoreCase, AutoCompGetMaxHeight, AutoCompGetMaxWidth, AutoCompGetSeparator, AutoCompGetTypeSeparator, AutoCompPosStart, AutoCompSelect, AutoCompSetAutoHide, AutoCompSetCancelAtStart, AutoCompSetChooseSingle, AutoCompSetDropRestOfWord, AutoCompSetFillUps, AutoCompSetIgnoreCase, AutoCompSetMaxHeight, AutoCompSetMaxWidth, AutoCompSetSeparator, AutoCompSetTypeSeparator, AutoCompShow, AutoCompStops, BackTab, BeginUndoAction, BraceBadLight, BraceHighlight, BraceMatch, CallTipActive, CallTipCancel, CallTipPosAtStart, CallTipSetBackground, CallTipSetForeground, CallTipSetForegroundHighlight, CallTipSetHighlight, CallTipShow, CallTipUseStyle, CanPaste, CanRedo, CanUndo, Cancel, CharLeft, CharLeftExtend, CharLeftRectExtend, CharRight, CharRightExtend, CharRightRectExtend, ChooseCaretX, Clear, ClearAll, ClearDocumentStyle, ClearRegisteredImages, CmdKeyAssign, CmdKeyClear, CmdKeyClearAll, CmdKeyExecute, Colourise, Copy, CopyRange, CopyText, Create, CreateDocument, Cut, DelLineLeft, DelLineRight, DelWordLeft, DelWordRight, DeleteBack, DeleteBackNotLine, DoDragOver, DoDropText, DocLineFromVisible, DocumentEnd, DocumentEndExtend, DocumentStart, DocumentStartExtend, EditToggleOvertype, EmptyUndoBuffer, EndUndoAction, EnsureCaretVisible, EnsureVisible, EnsureVisibleEnforcePolicy, FindColumn, FindText, FormFeed, FormatRange, GetAnchor, GetBackSpaceUnIndents, GetBufferedDraw, GetCaretForeground, GetCaretLineBack, GetCaretLineBackAlpha, GetCaretLineBackground, GetCaretLineVisible, GetCaretPeriod, GetCaretSticky, GetCaretWidth, GetCharAt, GetCodePage, GetColumn, GetControlCharSymbol, GetCurLine, GetCurLineRaw, GetCurLineUTF8, GetCurrentLine, GetCurrentPos, GetDocPointer, GetEOLMode, GetEdgeColour, GetEdgeColumn, GetEdgeMode, GetEndAtLastLine, GetEndStyled, GetFirstVisibleLine, GetFoldExpanded, GetFoldLevel, GetFoldParent, GetHighlightGuide, GetIndent, GetIndentationGuides, GetLastChild, GetLastKeydownProcessed, GetLayoutCache, GetLength, GetLexer, GetLine, GetLineCount, GetLineEndPosition, GetLineIndentPosition, GetLineIndentation, GetLineRaw, GetLineSelEndPosition, GetLineSelStartPosition, GetLineState, GetLineUTF8, GetLineVisible, GetMarginLeft, GetMarginMask, GetMarginRight, GetMarginSensitive, GetMarginType, GetMarginWidth, GetMaxLineState, GetModEventMask, GetModify, GetMouseDownCaptures, GetMouseDwellTime, GetOvertype, GetPasteConvertEndings, GetPrintColourMode, GetPrintMagnification, GetPrintWrapMode, GetProperty, GetPropertyExpanded, GetPropertyInt, GetReadOnly, GetSTCCursor, GetSTCFocus, GetScrollWidth, GetSearchFlags, GetSelAlpha, GetSelectedText, GetSelectedTextRaw, GetSelectedTextUTF8, GetSelection, GetSelectionEnd, GetSelectionMode, GetSelectionStart, GetStatus, GetStyleAt, GetStyleBits, GetStyleBitsNeeded, GetStyledText, GetTabIndents, GetTabWidth, GetTargetEnd, GetTargetStart, GetText, GetTextLength, GetTextRange, GetTextRangeRaw, GetTextRangeUTF8, GetTextRaw, GetTextUTF8, GetTwoPhaseDraw, GetUndoCollection, GetUseAntiAliasing, GetUseHorizontalScrollBar, GetUseTabs, GetUseVerticalScrollBar, GetViewEOL, GetViewWhiteSpace, GetWrapMode, GetWrapStartIndent, GetWrapVisualFlags, GetWrapVisualFlagsLocation, GetXOffset, GetZoom, GotoLine, GotoPos, HideLines, HideSelection, Home, HomeDisplay, HomeDisplayExtend, HomeExtend, HomeRectExtend, HomeWrap, HomeWrapExtend, IndicatorGetForeground, IndicatorGetStyle, IndicatorSetForeground, IndicatorSetStyle, InsertText, InsertTextRaw, InsertTextUTF8, LineCopy, LineCut, LineDelete, LineDown, LineDownExtend, LineDownRectExtend, LineDuplicate, LineEnd, LineEndDisplay, LineEndDisplayExtend, LineEndExtend, LineEndRectExtend, LineEndWrap, LineEndWrapExtend, LineFromPosition, LineLength, LineScroll, LineScrollDown, LineScrollUp, LineTranspose, LineUp, LineUpExtend, LineUpRectExtend, LinesJoin, LinesOnScreen, LinesSplit, LoadFile, LowerCase, MarkerAdd, MarkerAddSet, MarkerDefine, MarkerDefineBitmap, MarkerDelete, MarkerDeleteAll, MarkerDeleteHandle, MarkerGet, MarkerLineFromHandle, MarkerNext, MarkerPrevious, MarkerSetAlpha, MarkerSetBackground, MarkerSetForeground, MoveCaretInsideView, NewLine, PageDown, PageDownExtend, PageDownRectExtend, PageUp, PageUpExtend, PageUpRectExtend, ParaDown, ParaDownExtend, ParaUp, ParaUpExtend, Paste, PointFromPosition, PositionAfter, PositionBefore, PositionFromLine, PositionFromPoint, PositionFromPointClose, RegisterImage, ReleaseDocument, ReplaceSelection, ReplaceTarget, ReplaceTargetRE, SaveFile, ScrollToColumn, ScrollToLine, SearchAnchor, SearchInTarget, SearchNext, SearchPrev, SelectionDuplicate, SelectionIsRectangle, SendMsg, SetAnchor, SetBackSpaceUnIndents, SetBufferedDraw, SetCaretForeground, SetCaretLineBack, SetCaretLineBackAlpha, SetCaretLineBackground, SetCaretLineVisible, SetCaretPeriod, SetCaretSticky, SetCaretWidth, SetCharsDefault, SetCodePage, SetControlCharSymbol, SetCurrentPos, SetDocPointer, SetEOLMode, SetEdgeColour, SetEdgeColumn, SetEdgeMode, SetEndAtLastLine, SetFoldExpanded, SetFoldFlags, SetFoldLevel, SetFoldMarginColour, SetFoldMarginHiColour, SetHScrollBar, SetHighlightGuide, SetHotspotActiveBackground, SetHotspotActiveForeground, SetHotspotActiveUnderline, SetHotspotSingleLine, SetIndent, SetIndentationGuides, SetKeyWords, SetLastKeydownProcessed, SetLayoutCache, SetLexer, SetLexerLanguage, SetLineIndentation, SetLineState, SetMarginLeft, SetMarginMask, SetMarginRight, SetMarginSensitive, SetMarginType, SetMarginWidth, SetMargins, SetModEventMask, SetMouseDownCaptures, SetMouseDwellTime, SetOvertype, SetPasteConvertEndings, SetPrintColourMode, SetPrintMagnification, SetPrintWrapMode, SetProperty, SetReadOnly, SetSTCCursor, SetSTCFocus, SetSavePoint, SetScrollWidth, SetSearchFlags, SetSelAlpha, SetSelBackground, SetSelForeground, SetSelection, SetSelectionEnd, SetSelectionMode, SetSelectionStart, SetStatus, SetStyleBits, SetStyleBytes, SetStyling, SetTabIndents, SetTabWidth, SetTargetEnd, SetTargetStart, SetText, SetTextRaw, SetTextUTF8, SetTwoPhaseDraw, SetUndoCollection, SetUseAntiAliasing, SetUseHorizontalScrollBar, SetUseTabs, SetUseVerticalScrollBar, SetVScrollBar, SetViewEOL, SetViewWhiteSpace, SetVisiblePolicy, SetWhitespaceBackground, SetWhitespaceChars, SetWhitespaceForeground, SetWordChars, SetWrapMode, SetWrapStartIndent, SetWrapVisualFlags, SetWrapVisualFlagsLocation, SetXCaretPolicy, SetXOffset, SetYCaretPolicy, SetZoom, ShowLines, StartRecord, StartStyling, StopRecord, StutteredPageDown, StutteredPageDownExtend, StutteredPageUp, StutteredPageUpExtend, StyleClearAll, StyleResetDefault, StyleSetBackground, StyleSetBold, StyleSetCase, StyleSetChangeable, StyleSetCharacterSet, StyleSetEOLFilled, StyleSetFaceName, StyleSetFont, StyleSetFontAttr, StyleSetFontEncoding, StyleSetForeground, StyleSetHotSpot, StyleSetItalic, StyleSetSize, StyleSetSpec, StyleSetUnderline, StyleSetVisible, Tab, TargetFromSelection, TextHeight, TextWidth, ToggleCaretSticky, ToggleFold, UpperCase, UsePopUp, UserListShow, VCHome, VCHomeExtend, VCHomeRectExtend, VCHomeWrap, VCHomeWrapExtend, VisibleFromDocLine, WordEndPosition, WordLeft, WordLeftEnd, WordLeftEndExtend, WordLeftExtend, WordPartLeft, WordPartLeftExtend, WordPartRight, WordPartRightExtend, WordRight, WordRightEnd, WordRightEndExtend, WordRightExtend, WordStartPosition, WrapCount, ZoomIn, ZoomOut, __repr__

Inherited from wx._core.Control: Command, GetAlignment, GetLabelText

Inherited from wx._core.Window: AcceptsFocus, AcceptsFocusFromKeyboard, AddChild, AdjustForLayoutDirection, AssociateHandle, CacheBestSize, CanSetTransparent, CaptureMouse, Center, CenterOnParent, Centre, CentreOnParent, ClearBackground, ClientToScreen, ClientToScreenXY, Close, ConvertDialogPointToPixels, ConvertDialogSizeToPixels, ConvertPixelPointToDialog, ConvertPixelSizeToDialog, DLG_PNT, DLG_SZE, Destroy, DestroyChildren, Disable, DissociateHandle, DragAcceptFiles, Enable, FindWindowById, FindWindowByName, Fit, FitInside, Freeze, GetAcceleratorTable, GetAdjustedBestSize, GetAutoLayout, GetBackgroundColour, GetBackgroundStyle, GetBestFittingSize, GetBestSize, GetBestSizeTuple, GetBestVirtualSize, GetBorder, GetCaret, GetCharHeight, GetCharWidth, GetChildren, GetClientAreaOrigin, GetClientRect, GetClientSize, GetClientSizeTuple, GetConstraints, GetContainingSizer, GetCursor, GetDefaultAttributes, GetDropTarget, GetEffectiveMinSize, GetEventHandler, GetExtraStyle, GetFont, GetForegroundColour, GetFullTextExtent, GetGrandParent, GetGtkWidget, GetHandle, GetHelpText, GetHelpTextAtPoint, GetId, GetLabel, GetLayoutDirection, GetMaxHeight, GetMaxSize, GetMaxWidth, GetMinHeight, GetMinSize, GetMinWidth, GetName, GetParent, GetPosition, GetPositionTuple, GetRect, GetScreenPosition, GetScreenPositionTuple, GetScreenRect, GetScrollPos, GetScrollRange, GetScrollThumb, GetSize, GetSizeTuple, GetSizer, GetTextExtent, GetThemeEnabled, GetToolTip, GetTopLevelParent, GetUpdateClientRect, GetUpdateRegion, GetValidator, GetVirtualSize, GetVirtualSizeTuple, GetWindowBorderSize, GetWindowStyle, GetWindowStyleFlag, GetWindowVariant, HasCapture, HasFlag, HasMultiplePages, HasScrollbar, HasTransparentBackground, Hide, HitTest, HitTestXY, InheritAttributes, InheritsBackgroundColour, InitDialog, InvalidateBestSize, IsBeingDeleted, IsDoubleBuffered, IsEnabled, IsExposed, IsExposedPoint, IsExposedRect, IsFrozen, IsRetained, IsShown, IsShownOnScreen, IsTopLevel, Layout, Lower, MakeModal, Move, MoveAfterInTabOrder, MoveBeforeInTabOrder, MoveXY, Navigate, PopEventHandler, PopupMenu, PopupMenuXY, PostCreate, PrepareDC, PushEventHandler, Raise, Refresh, RefreshRect, RegisterHotKey, ReleaseMouse, RemoveChild, RemoveEventHandler, Reparent, ScreenToClient, ScreenToClientXY, ScrollLines, ScrollPages, ScrollWindow, SendSizeEvent, SetAcceleratorTable, SetAutoLayout, SetBackgroundColour, SetBackgroundStyle, SetBestFittingSize, SetCaret, SetClientRect, SetClientSize, SetClientSizeWH, SetConstraints, SetContainingSizer, SetCursor, SetDimensions, SetDoubleBuffered, SetDropTarget, SetEventHandler, SetExtraStyle, SetFocus, SetFocusFromKbd, SetFont, SetForegroundColour, SetHelpText, SetHelpTextForId, SetId, SetInitialSize, SetLabel, SetLayoutDirection, SetMaxSize, SetMinSize, SetName, SetOwnBackgroundColour, SetOwnFont, SetOwnForegroundColour, SetPosition, SetRect, SetScrollPos, SetScrollbar, SetSize, SetSizeHints, SetSizeHintsSz, SetSizeWH, SetSizer, SetSizerAndFit, SetThemeEnabled, SetToolTip, SetToolTipString, SetTransparent, SetValidator, SetVirtualSize, SetVirtualSizeHints, SetVirtualSizeHintsSz, SetVirtualSizeWH, SetWindowStyle, SetWindowStyleFlag, SetWindowVariant, ShouldInheritColours, Show, Thaw, ToggleWindowStyle, TransferDataFromWindow, TransferDataToWindow, UnregisterHotKey, Update, UpdateWindowUI, UseBgCol, Validate, WarpPointer

Inherited from wx._core.EvtHandler: AddPendingEvent, Bind, Connect, Disconnect, GetEvtHandlerEnabled, GetNextHandler, GetPreviousHandler, ProcessEvent, ProcessPendingEvents, SetEvtHandlerEnabled, SetNextHandler, SetPreviousHandler, Unbind

Inherited from wx._core.Object: GetClassName, IsSameAs

Inherited from stcinterface.STCInterface: CanSave, getShortDisplayName

Inherited from object: __delattr__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __setattr__, __str__

Class Methods

Inherited from debug.debugmixin: dprint

Static Methods

Inherited from wx._core.Control: GetClassDefaultAttributes

Inherited from wx._core.Window: FindFocus, GetCapture, NewControlId, NextControlId, PrevControlId

Class Variables
  eol2int = {'\n': 2, '\r': 1, '\r\n': 0}
  int2eol = {0: '\r\n', 1: '\r', 2: '\n'}

Inherited from debug.debugmixin: debuglevel

Properties

Inherited from wx.stc.StyledTextCtrl: Anchor, BackSpaceUnIndents, BufferedDraw, CaretForeground, CaretLineBack, CaretLineBackAlpha, CaretLineBackground, CaretLineVisible, CaretPeriod, CaretSticky, CaretWidth, CodePage, ControlCharSymbol, CurLine, CurLineRaw, CurLineUTF8, CurrentLine, CurrentPos, DocPointer, EOLMode, EdgeColour, EdgeColumn, EdgeMode, EndAtLastLine, EndStyled, FirstVisibleLine, HighlightGuide, Indent, IndentationGuides, LastKeydownProcessed, LayoutCache, Length, Lexer, LineCount, MarginLeft, MarginRight, MaxLineState, ModEventMask, Modify, MouseDownCaptures, MouseDwellTime, Overtype, PasteConvertEndings, PrintColourMode, PrintMagnification, PrintWrapMode, ReadOnly, STCCursor, STCFocus, ScrollWidth, SearchFlags, SelAlpha, SelectedText, SelectedTextRaw, SelectedTextUTF8, Selection, SelectionEnd, SelectionMode, SelectionStart, Status, StyleBits, StyleBitsNeeded, TabIndents, TabWidth, TargetEnd, TargetStart, Text, TextLength, TextRaw, TextUTF8, TwoPhaseDraw, UndoCollection, UseAntiAliasing, UseHorizontalScrollBar, UseTabs, UseVerticalScrollBar, ViewEOL, ViewWhiteSpace, WrapMode, WrapStartIndent, WrapVisualFlags, WrapVisualFlagsLocation, XOffset, Zoom, thisown

Inherited from wx._core.Control: Alignment, LabelText

Inherited from wx._core.Window: AcceleratorTable, AutoLayout, BackgroundColour, BackgroundStyle, BestSize, BestVirtualSize, Border, Caret, CharHeight, CharWidth, Children, ClientAreaOrigin, ClientRect, ClientSize, Constraints, ContainingSizer, Cursor, DefaultAttributes, DropTarget, EffectiveMinSize, Enabled, EventHandler, ExtraStyle, Font, ForegroundColour, GrandParent, GtkWidget, Handle, HelpText, Id, Label, LayoutDirection, MaxHeight, MaxSize, MaxWidth, MinHeight, MinSize, MinWidth, Name, Parent, Position, Rect, ScreenPosition, ScreenRect, Shown, Size, Sizer, ThemeEnabled, ToolTip, TopLevel, TopLevelParent, UpdateClientRect, UpdateRegion, Validator, VirtualSize, WindowStyle, WindowStyleFlag, WindowVariant

Inherited from wx._core.EvtHandler: EvtHandlerEnabled, NextHandler, PreviousHandler

Inherited from wx._core.Object: ClassName

Inherited from object: __class__

Method Details

__init__(self, parent, refstc=None, copy=None, **kwargs)
(Constructor)

 

__init__(self, Window parent, int id=ID_ANY, Point pos=DefaultPosition, 
    Size size=DefaultSize, long style=0, String name=STCNameStr) -> StyledTextCtrl

Returns: EvtHandler
Overrides: object.__init__
(inherited documentation)

open(self, buffer, message=None)

 

Open the file from the buffer and read in its contents.

The open method is provided here in the STC and not in the buffer so that specialized STCs can provide their own load methods. So far, this is only used in the NonResidentSTC for files that are too large to fit in memory.

Overrides: stcinterface.STCInterface.open

openSuccess(self, buffer, headersize=1024, encoding=None)

 

Called after a file has been successfully opened.

This is called by the GUI thread, so can update any GUI elements here.

Overrides: stcinterface.STCInterface.openSuccess
(inherited documentation)

readFrom(self, fh, amount=None, chunk=65536, length=0, message=None)

 

Read a chunk of the file from the file-like object.

Rather than reading the file in with a single call to fh.read(), it is broken up into segments. It may take a significant amount of time to read a file, either if the file is really big or the file is loaded over a slow URI scheme. The threaded load capability of peppy is used to display a progress bar that is updated after each segment is loaded, and also keeps the user interface responsive during a file load.

Parameters:
  • fh - file-like object used to load the file
Overrides: stcinterface.STCInterface.readFrom

decodeText(self, bytes)

 

Check for the file encoding and convert in place.

If the encoding is embedded in the file (through emacs "magic comments"), change the text from the binary representation into the specified encoding.

prepareEncoding(self)

 

Prepare the file for encoding.

This method provides a short-circuit of the writing process in case the encoding is bad. This is a poor man's way of preventing a zero-length file due to a bad encoding, because should this method generate an exception, the file will never be opened for writing and therefore won't be truncated.

Overrides: stcinterface.STCInterface.prepareEncoding

writeTo(self, fh)

 

Writes a copy of the document to the provided file-like object.

Note that peppy is not currently thread-enabled during file writing.

Parameters:
  • fh - file-like object used to write the file
Overrides: stcinterface.STCInterface.writeTo

checkUndoEOL(self)

 

Check to see if the last change was converting all EOL characters.

The wx.stc.StyledTextCtrl doesn't directly store if the last undo/redo was the change in all of the end of line characters, so we have to check ourselves.

Undo(self)

 

Override of base Undo command to add our additional checks.

Overrides: stcinterface.STCInterface.Undo

Redo(self)

 

Override of base Redo command to add our additional checks.

Overrides: stcinterface.STCInterface.Redo

CanEdit(self)

 

PyPE compat

Overrides: stcinterface.STCInterface.CanEdit

CanCopy(self)

 
Overrides: stcinterface.STCInterface.CanCopy

CanCut(self)

 
Overrides: stcinterface.STCInterface.CanCut

SelectAll(self)

 

Select all the text in the document.

Overrides: wx.stc.StyledTextCtrl.SelectAll
(inherited documentation)

GetBinaryData(self, start=0, end=-1)

 

Convenience function to get binary data out of the STC.

The only way to get binary data out of the STC is to use the GetStyledText method and chop out every other byte. Using the regular GetText method will stop at the first nul character.

Parameters:
  • start - first text position
  • end - last text position
Returns:
binary data between start and end-1, inclusive (just like standard python array slicing)
Overrides: stcinterface.STCInterface.GetBinaryData

GuessBinary(self, amount, percentage)

 

Guess if the text in this file is binary or text by scanning through the first amount characters in the file and checking if some percentage is out of the printable ascii range.

Obviously this is a poor check for unicode files, so this is just a bit of a hack.

Parameters:
  • amount (int) - number of characters to check at the beginning of the file
  • percentage (number) - percentage of characters that must be in the printable ASCII range
Returns: boolean
Overrides: stcinterface.STCInterface.GuessBinary

GetSelection2(self)

 

Get the current region, but don't return an empty last line if the cursor is at column zero of the last line.

The STC seems to make entire line selections by placing the cursor on the left margin of the next line, rather than the end of the last highlighted line. This causes any use of GetLineEndPosition to use this line with only the cursor to mean a real part of the selection, which is never what I indend, at least. So, this version of GetSelection handles this case.

GetLineRegion(self)

 

Get current region, extending to current line if no region selected.

If there's a region selected, extend it if necessary to encompass full lines. If no region is selected, create one from the current line.

PasteAtColumn(self, paste=None)

 

Paste a rectangular selection at a particular column.

This method inserts a previously cut or copied rectangular selection at a column. If some lines in the STC are too short and end before the column, leading spaces are inserted so that the column is pasted correctly.

ConvertEOLs(self, mode)

 

ConvertEOLs(self, int eolMode)

Convert all line endings in the document to one mode.

Overrides: wx.stc.StyledTextCtrl.ConvertEOLs
(inherited documentation)

isStyleString(self, style)

 

Is the style a string?

Designed to be overridded by subclasses to map styling info to useful status checks.

isStyleComment(self, style)

 

Is the style a comment?

Designed to be overridded by subclasses to map styling info to useful status checks.

showStyle(self, linenum=None)

 

Debugging routine to show the styling information on a line.

Print styling information to stdout to aid in debugging.

Overrides: stcinterface.STCInterface.showStyle
(inherited documentation)

GetFoldColumn(self, linenum)

 

Return column number of folding.

Return column number of the current fold level.

Overrides: stcinterface.STCInterface.GetFoldColumn
(inherited documentation)

GetPrevLineIndentation(self, linenum)

 

Get the indentation of the line before the specified line.

Return a tuple containing the number of columns of indentation of the first non-blank line before the specified line, and the line number of the line that it found.

Overrides: stcinterface.STCInterface.GetPrevLineIndentation
(inherited documentation)

addLinePrefixAndSuffix(self, start, end, prefix='', suffix='')

 

Add a prefix and/or suffix to the line specified by start and end.

Method to add characters to the start and end of the line. This is typically called within a loop that adds comment characters to the line. start and end are assumed to be the endpoints of the current line, so no further checking of the line is necessary.

Parameters:
  • start - first character in line
  • end - last character in line before line ending
  • prefix - optional prefix for the line
  • suffix - optional suffix for the line
Returns:
new position of last character before line ending

removeLinePrefixAndSuffix(self, start, end, prefix='', suffix='')

 

Remove the specified prefix and suffix of the line.

Method to remove the specified prefix and suffix characters from the line specified by start and end. If the prefix or suffix doesn't match the characters in the line, nothing is removed. This is typically called within a loop that adds comment characters to the line. start and end are assumed to be the endpoints of the current line, so no further checking of the line is necessary.

Parameters:
  • start - first character in line
  • end - last character in line before line ending
  • prefix - optional prefix for the line
  • suffix - optional suffix for the line
Returns:
new position of last character before line ending

setCommentDelimiters(self, start='', end='')

 

Set instance-specific comment characters and comment regex

If the instance uses different comment characters that the class attributes, set the instance attributes here which will override the class attributes.

A regex is created that will match a line with the comment characters. The regex returns a 3-tuple of whitespace followed by the opening comment character, the body of the line, and then the closing comment including any trailing whitespace. If the language doesn't have a closing comment character, the final tuple element will always be an empty string.

This is typically called by the Editra stc mixin to set the comment characters encoded by the Editra style manager.

commentRegion(self, add=True)

 

Default implementation of block commenting and uncommenting

This class provides the default implementation of block commenting. Blocks are commented by adding a comment string at the beginning of the line, and an optional comment string at the end of each line in the block.

Typically the comment characters are known to the Editra styling system and are therefore automatically added to the FundamentalMode subclass by a call to setCommentDelimiters.

Parameters:
  • add - True to add comments, False to remove them

splitCommentLine(self, line)

 

Split the line into the whitespace leader and body of the line.

Return a tuple containing the leading whitespace and comment character(s), the body of the line, and any trailing comment character(s)