@@ -2394,12 +2394,11 @@ def mark_file_dirty(self, dirty=True):
23942394 self ._data .mark_data_pristine ()
23952395
23962396
2397- class RobotDataEditor (PythonSTC , stc . StyledTextCtrl ):
2397+ class RobotDataEditor (PythonSTC ):
23982398 margin = 1
23992399
24002400 def __init__ (self , parent , readonly = False , language = None , style = wx .BORDER_NONE ):
24012401 PythonSTC .__init__ (self , parent , - 1 , style = style )
2402- self .SetUpEditor ()
24032402 # stc.StyledTextCtrl.__init__(self, parent)
24042403 self .parent = parent
24052404 self .language = language
@@ -2408,7 +2407,7 @@ def __init__(self, parent, readonly=False, language=None, style=wx.BORDER_NONE):
24082407 self ._information_popup = None
24092408 self ._old_details = None
24102409 self .readonly = readonly
2411- self .SetMarginType (self .margin , stc .STC_MARGIN_NUMBER )
2410+ # self.SetMarginType(self.margin, stc.STC_MARGIN_NUMBER)
24122411 self .SetLexer (stc .STC_LEX_CONTAINER )
24132412 self .SetReadOnly (True )
24142413 self .SetUseTabs (False )
@@ -2420,9 +2419,13 @@ def __init__(self, parent, readonly=False, language=None, style=wx.BORDER_NONE):
24202419 caret_style = stc .STC_CARETSTYLE_BLOCK if caret_style .lower () == 'block' else stc .STC_CARETSTYLE_LINE
24212420 self .SetCaretStyle (caret_style )
24222421 self .SetTabWidth (parent .tab_size )
2423- self .Bind (stc .EVT_STC_UPDATEUI , self .on_update_ui )
2422+ margin_background = self ._settings ['General' ].get ('secondary background' , '' )
2423+ margin_foreground = self ._settings ['General' ].get ('secondary foreground' , '' )
2424+ self .SetUpEditor (tab_size = parent .tab_size , m_bg = margin_background , m_fg = margin_foreground )
24242425 self .Bind (stc .EVT_STC_STYLENEEDED , self .on_style )
24252426 self .Bind (stc .EVT_STC_ZOOM , self .on_zoom )
2427+ self .Bind (stc .EVT_STC_UPDATEUI , self .on_update_ui )
2428+ self .Bind (stc .EVT_STC_MARGINCLICK , self .on_margin_click )
24262429 # DEBUG:
24272430 self .Bind (wx .EVT_KEY_DOWN , self .on_key_pressed )
24282431 # Only set, after language: self.stylizer = RobotStylizer(self, self._settings, self.readonly)
@@ -2487,6 +2490,7 @@ def set_text(self, text):
24872490 self .stylizer .stylize ()
24882491 self .EmptyUndoBuffer ()
24892492 self .SetMarginWidth (self .margin , self .calc_margin_width ())
2493+ self .SetMarginWidth (2 , self .TextWidth (stc .STC_STYLE_DEFAULT , "MM" ))
24902494 self .Update ()
24912495
24922496 def set_language (self , dlanguage ):
@@ -2513,6 +2517,7 @@ def on_style(self, event):
25132517 def on_zoom (self , event ):
25142518 __ = event
25152519 self .SetMarginWidth (self .margin , self .calc_margin_width ())
2520+ self .SetMarginWidth (2 , self .TextWidth (stc .STC_STYLE_FOLDDISPLAYTEXT , "MM" ))
25162521 self ._set_zoom ()
25172522
25182523 def _set_zoom (self ):
@@ -2669,6 +2674,7 @@ def on_update_ui(self, evt):
26692674 self .BraceBadLight (brace_at_caret )
26702675 else :
26712676 self .BraceHighlight (brace_at_caret , brace_opposite )
2677+ self .stylizer .stylize ()
26722678
26732679 def _show_keyword_details (self , value , coords = None ):
26742680 """
@@ -2699,7 +2705,7 @@ def get_visible_color(self, colour):
26992705 return Colour (colour )
27002706 return Colour ('black' )
27012707
2702- def SetUpEditor (self ):
2708+ def SetUpEditor (self , tab_size = 4 , m_bg = '' , m_fg = '' ):
27032709 """
27042710 This method carries out the work of setting up the Code editor.
27052711 It's seperate so as not to clutter up the init code.
@@ -2718,17 +2724,18 @@ def SetUpEditor(self):
27182724 # Set left and right margins
27192725 self .SetMargins (2 , 2 )
27202726
2727+ self .SetMarginBackground (1 , m_bg )
27212728 # Set up the numbers in the margin for margin #1
27222729 self .SetMarginType (1 , wx .stc .STC_MARGIN_NUMBER )
27232730 # Reasonable value for, say, 4-5 digits using a mono font (40 pix)
2724- self .SetMarginWidth (1 , 40 )
2731+ # self.SetMarginWidth(1, 40)
27252732
27262733 # Indentation and tab stuff
2727- self .SetIndent (4 ) # Proscribed indent size for wx
2734+ self .SetIndent (tab_size ) # Proscribed indent size for wx
27282735 self .SetIndentationGuides (True ) # Show indent guides
27292736 self .SetBackSpaceUnIndents (True ) # Backspace unindents rather than delete 1 space
27302737 self .SetTabIndents (True ) # Tab key indents
2731- self .SetTabWidth (4 ) # Proscribed tab size for wx
2738+ self .SetTabWidth (tab_size ) # Proscribed tab size for wx
27322739 self .SetUseTabs (False ) # Use spaces rather than tabs, or TabTimmy will complain!
27332740 # White space
27342741 self .SetViewWhiteSpace (False ) # Don't view white space
@@ -2746,7 +2753,10 @@ def SetUpEditor(self):
27462753 self .SetMarginType (2 , stc .STC_MARGIN_SYMBOL )
27472754 self .SetMarginMask (2 , stc .STC_MASK_FOLDERS )
27482755 self .SetMarginSensitive (2 , True )
2749- self .SetMarginWidth (2 , 12 )
2756+ self .SetMarginBackground (2 , m_bg )
2757+ self .SetFoldMarginColour (True , m_bg )
2758+ self .SetFoldMarginHiColour (True , m_bg )
2759+ self .SetMarginWidth (2 , self .TextWidth (stc .STC_STYLE_FOLDDISPLAYTEXT , "MM" ))
27502760
27512761 # Global default style
27522762 if wx .Platform == '__WXMSW__' :
0 commit comments