Project

General

Profile

Bug #30

Line number margin width should be set automatically on growing/shrinking lines

Added by Wil van Antwerpen about 7 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Normal
Category:
-
Start date:
03/27/2017
Due date:
% Done:

0%


Description

The line number margin width is set automatically.
However it is only determined once. As a result when your required width changes, it does not adapt the width with it.

The way the automatic margin width logic currently works is this:

If you enable line margins when the document is empty it will set a default margin of based on the width of this string “_99999”. This is currently what you will see if you start the hammer2 (maybe also hammer3) as it sets the margin before the document is loaded.

If you enable the margin once you have a document loaded (eg. toggle using the new settings dialog) then it will set the margin width depending on how many lines are stored in your document.
So if you have a file with 200 lines of code it will determine the line count and set the width for “200”.
If your document has 6350 lines then it will set a width for “_6350” lines etc..
If your document has 2226350 lines then it will set a width for “
2226350” lines etc..
Note that the line numbering itself is automatic.. we do not have to do anything for that, the control does this automatically

So we have to add margin width detection logic in the LineChanged event.

History

#1 Updated by Wil van Antwerpen about 7 years ago

  • Status changed from New to Resolved
  • Assignee set to Wil van Antwerpen

The width of the margin for line numbers is now completely automatically determined.

This is done in methods:
- LineCountChanged
- CM_SetLineNumbering
- property piMarginLineNumberDigits
LineCountChanged is a new event that is called when text is added or deleted.
Not completely a one on one relationship, but sufficient.

If you have margins enabled and you delete almost all lines then the logic will keep a minimum margin width of 3 digits (plus a 1 character prefix)

#2 Updated by Wil van Antwerpen about 7 years ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF