@@ -2394,12 +2394,11 @@ def mark_file_dirty(self, dirty=True):
2394
2394
self ._data .mark_data_pristine ()
2395
2395
2396
2396
2397
- class RobotDataEditor (PythonSTC , stc . StyledTextCtrl ):
2397
+ class RobotDataEditor (PythonSTC ):
2398
2398
margin = 1
2399
2399
2400
2400
def __init__ (self , parent , readonly = False , language = None , style = wx .BORDER_NONE ):
2401
2401
PythonSTC .__init__ (self , parent , - 1 , style = style )
2402
- self .SetUpEditor ()
2403
2402
# stc.StyledTextCtrl.__init__(self, parent)
2404
2403
self .parent = parent
2405
2404
self .language = language
@@ -2408,7 +2407,7 @@ def __init__(self, parent, readonly=False, language=None, style=wx.BORDER_NONE):
2408
2407
self ._information_popup = None
2409
2408
self ._old_details = None
2410
2409
self .readonly = readonly
2411
- self .SetMarginType (self .margin , stc .STC_MARGIN_NUMBER )
2410
+ # self.SetMarginType(self.margin, stc.STC_MARGIN_NUMBER)
2412
2411
self .SetLexer (stc .STC_LEX_CONTAINER )
2413
2412
self .SetReadOnly (True )
2414
2413
self .SetUseTabs (False )
@@ -2420,9 +2419,13 @@ def __init__(self, parent, readonly=False, language=None, style=wx.BORDER_NONE):
2420
2419
caret_style = stc .STC_CARETSTYLE_BLOCK if caret_style .lower () == 'block' else stc .STC_CARETSTYLE_LINE
2421
2420
self .SetCaretStyle (caret_style )
2422
2421
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 )
2424
2425
self .Bind (stc .EVT_STC_STYLENEEDED , self .on_style )
2425
2426
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 )
2426
2429
# DEBUG:
2427
2430
self .Bind (wx .EVT_KEY_DOWN , self .on_key_pressed )
2428
2431
# Only set, after language: self.stylizer = RobotStylizer(self, self._settings, self.readonly)
@@ -2487,6 +2490,7 @@ def set_text(self, text):
2487
2490
self .stylizer .stylize ()
2488
2491
self .EmptyUndoBuffer ()
2489
2492
self .SetMarginWidth (self .margin , self .calc_margin_width ())
2493
+ self .SetMarginWidth (2 , self .TextWidth (stc .STC_STYLE_DEFAULT , "MM" ))
2490
2494
self .Update ()
2491
2495
2492
2496
def set_language (self , dlanguage ):
@@ -2513,6 +2517,7 @@ def on_style(self, event):
2513
2517
def on_zoom (self , event ):
2514
2518
__ = event
2515
2519
self .SetMarginWidth (self .margin , self .calc_margin_width ())
2520
+ self .SetMarginWidth (2 , self .TextWidth (stc .STC_STYLE_FOLDDISPLAYTEXT , "MM" ))
2516
2521
self ._set_zoom ()
2517
2522
2518
2523
def _set_zoom (self ):
@@ -2669,6 +2674,7 @@ def on_update_ui(self, evt):
2669
2674
self .BraceBadLight (brace_at_caret )
2670
2675
else :
2671
2676
self .BraceHighlight (brace_at_caret , brace_opposite )
2677
+ self .stylizer .stylize ()
2672
2678
2673
2679
def _show_keyword_details (self , value , coords = None ):
2674
2680
"""
@@ -2699,7 +2705,7 @@ def get_visible_color(self, colour):
2699
2705
return Colour (colour )
2700
2706
return Colour ('black' )
2701
2707
2702
- def SetUpEditor (self ):
2708
+ def SetUpEditor (self , tab_size = 4 , m_bg = '' , m_fg = '' ):
2703
2709
"""
2704
2710
This method carries out the work of setting up the Code editor.
2705
2711
It's seperate so as not to clutter up the init code.
@@ -2718,17 +2724,18 @@ def SetUpEditor(self):
2718
2724
# Set left and right margins
2719
2725
self .SetMargins (2 , 2 )
2720
2726
2727
+ self .SetMarginBackground (1 , m_bg )
2721
2728
# Set up the numbers in the margin for margin #1
2722
2729
self .SetMarginType (1 , wx .stc .STC_MARGIN_NUMBER )
2723
2730
# Reasonable value for, say, 4-5 digits using a mono font (40 pix)
2724
- self .SetMarginWidth (1 , 40 )
2731
+ # self.SetMarginWidth(1, 40)
2725
2732
2726
2733
# Indentation and tab stuff
2727
- self .SetIndent (4 ) # Proscribed indent size for wx
2734
+ self .SetIndent (tab_size ) # Proscribed indent size for wx
2728
2735
self .SetIndentationGuides (True ) # Show indent guides
2729
2736
self .SetBackSpaceUnIndents (True ) # Backspace unindents rather than delete 1 space
2730
2737
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
2732
2739
self .SetUseTabs (False ) # Use spaces rather than tabs, or TabTimmy will complain!
2733
2740
# White space
2734
2741
self .SetViewWhiteSpace (False ) # Don't view white space
@@ -2746,7 +2753,10 @@ def SetUpEditor(self):
2746
2753
self .SetMarginType (2 , stc .STC_MARGIN_SYMBOL )
2747
2754
self .SetMarginMask (2 , stc .STC_MASK_FOLDERS )
2748
2755
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" ))
2750
2760
2751
2761
# Global default style
2752
2762
if wx .Platform == '__WXMSW__' :
0 commit comments