diff options
author | 2019-03-27 21:27:55 -0400 | |
---|---|---|
committer | 2019-03-27 21:27:55 -0400 | |
commit | 6dcdb25098fc8c3bcfe01342c27b96d627c5c42a (patch) | |
tree | 7d368d6f2216845710653abbdf03c11c1b9fb981 /init.lua | |
parent | 082df4a067e9757e5cfd2ff32c0a0d7e3d546ce3 (diff) | |
download | textadept-6dcdb25098fc8c3bcfe01342c27b96d627c5c42a.tar.gz textadept-6dcdb25098fc8c3bcfe01342c27b96d627c5c42a.zip |
Line number margin grows for large files as needed.
Diffstat (limited to 'init.lua')
-rw-r--r-- | init.lua | 12 |
1 files changed, 10 insertions, 2 deletions
@@ -131,8 +131,16 @@ buffer.caret_line_visible = not CURSES --buffer.margin_right = -- Line Number Margin. buffer.margin_type_n[0] = buffer.MARGIN_NUMBER -local width = 4 * buffer:text_width(buffer.STYLE_LINENUMBER, '9') -buffer.margin_width_n[0] = width + (not CURSES and 4 or 0) +local function resize_line_number_margin() + -- This needs to be evaluated dynamically since themes/styles can change. + local buffer = _G.buffer + local width = math.max(4, #tostring(buffer.line_count)) * + buffer:text_width(buffer.STYLE_LINENUMBER, '9') + + (not CURSES and 4 or 0) + buffer.margin_width_n[0] = math.max(buffer.margin_width_n[0], width) +end +events.connect(events.BUFFER_NEW, resize_line_number_margin) +events.connect(events.FILE_OPENED, resize_line_number_margin) -- Marker Margin. buffer.margin_width_n[1] = not CURSES and 4 or 1 -- Fold Margin. |