@@ -206,17 +206,19 @@ def __init__(self, parent=None):
206206
207207 self .set_lexer ("g-code" )
208208
209+ self ._marginWidth = '00000'
210+
209211 # Margin 0 is used for line numbers
210- self .set_margin_width ( 1 )
212+ self .setMarginWidth ( 0 , self . _marginWidth )
211213 self .linesChanged .connect (self .on_lines_changed )
212214 self .setMarginLineNumbers (0 , True )
213215
214216 # Clickable margin for showing markers
215217 self .marginClicked .connect (self .on_margin_clicked )
216218 self .setMarginMarkerMask (0 , 0b1111 )
217219 self .setMarginSensitivity (0 , True )
218- # setting marker margin width to zero make the marker highlight line
219- self .setMarginWidth (1 , 5 )
220+ # setting _marker_ margin width
221+ self .setMarginWidth (1 , 0 )
220222
221223 # Gcode highlight current line
222224 self .currentHandle = self .markerDefine (QsciScintilla .Background ,
@@ -286,12 +288,20 @@ def set_font_colors(self):
286288 for i in range (0 , self .lexer_num_styles ):
287289 self .lexer .setColor (self ._styleColor .get (i , self ._styleColor [0 ]), i )
288290
289- def set_margin_width (self , width ):
291+ def set_margin_width (self ):
292+ self .setMarginWidth (0 , self ._marginWidth )
293+
294+ def set_margin_metric (self , width ):
290295 fontmetrics = QFontMetrics (self .getFontMargins ())
291296 self .setMarginWidth (0 , fontmetrics .width ("0" * width ) + 6 )
292297
298+ # reset margin width when number od lines change
293299 def on_lines_changed (self ):
294- self .set_margin_width (len (str (self .lines ())))
300+ if len (str (self .lines ())) < 3 :
301+ self ._marginWidth = '0000'
302+ else :
303+ self ._marginWidth = str (self .lines ())+ '0'
304+ self .setMarginWidth (0 , self ._marginWidth )
295305
296306 def on_margin_clicked (self , nmargin , nline , modifiers ):
297307 # Toggle marker for the line the margin was clicked on
@@ -714,6 +724,16 @@ def jump_line(self, jump):
714724 self .setCursorPosition (line , 0 )
715725 self .highlight_line (None , line )
716726
727+ # overridden functions #
728+ #####################################
729+ def zoomIn (self ):
730+ super ().zoomIn ()
731+ self .set_margin_width ()
732+ def zoomOut (self ):
733+ super ().zoomOut ()
734+ self .set_margin_width ()
735+ #####################################
736+
717737 # designer recognized getter/setters
718738 # auto_show_mdi status
719739 def set_auto_show_mdi (self , data ):
@@ -1065,8 +1085,8 @@ def jump_line(self, jump):
10651085 def get_line (self ):
10661086 return self .editor .getCursorPosition ()[0 ] + 1
10671087
1068- def set_margin_width (self ,width ):
1069- self .editor .set_margin_width (width )
1088+ def set_margin_metric (self ,width ):
1089+ self .editor .set_margin_metric (width )
10701090
10711091 def set_font (self , font ):
10721092 self .editor .setDefaultFont (font )
0 commit comments