Alloy is a language for describing structures and a tool for exploring them. It has been used in a wide range of applications from finding holes in security mechanisms to designing telephone switching networks. This repository contains the code for the tool.
Add line numbers to the editor display, configured with a preference,
issue AlloyTools#79 "Feature Request: Line Numbers."
The OurLineNumberWidget class is added, providing a rowHeader to the
JScrollPane component of OurSyntaxWidget, based on data and events
from the JTextPane pane also of OurSyntaxWidget. OurLineNumberWidget
receives updates to the line-numbers preference, and also to the
font-name and font-size preference, because we draw the line-number
display in the same font as the main document. OurLineNumberWidget
follows the anti-aliasing strategy expressed by the OurAntiAlias
class, by anti-aliasing when we believe we are on a Mac or on
Windows. The view of the line numbers scrolls with the contents of the
text pane. The line of text where the caret is will have it's line
number in yellow on a black background. The OurLineNumberWidget sets
itself to 0 width, or a calculated width, depending on whether
OurSyntaxWidget constructed or informs it later whether to display.
The code itself does not place a restriction on how many lines there
are in the file or displaying the current line number. The width of
OurLineNumberWidget grows or shrinks depending on the current number
to display with the most digits. This author has tested up to seven
digits.
The highlighting of the line of the caret could certainly be changed
if there is need or preference. Size of the line number area, the exact
font used, color and background, these are all on the table.
The preference for displaying line-numbers is in the Alloy
Preferences window, in the Editor tab, at the end of the list of
preferences there. The current value appears in the Options menu
at the end of the third section, in the same section with the
preferences from the Editor tab.
Testing of this feature has involved a Windows 11 machine with Java 8,
and a Macos 11 with Java 8. Testing has involved combinations of:
launching with the preference unset, or set
opening previous documents or new documents and entering text
setting and unsetting the preference
moving the caret about with arrows, further typing, selections with mouse and keyboard
adding over 1 million lines to an editor through a lot of pasting, scrolling top to bottom, then removing all the lines
changing the window size with line numbers on or off
Hello @pkriens, herewith a PR for the line-numbers. There is absolutely no rush. If I should request review of other parties, do please advise.
Cheers,
Add line numbers to the editor display, configured with a preference, issue AlloyTools#79 "Feature Request: Line Numbers."
The OurLineNumberWidget class is added, providing a rowHeader to the JScrollPane component of OurSyntaxWidget, based on data and events from the JTextPane pane also of OurSyntaxWidget. OurLineNumberWidget receives updates to the line-numbers preference, and also to the font-name and font-size preference, because we draw the line-number display in the same font as the main document. OurLineNumberWidget follows the anti-aliasing strategy expressed by the OurAntiAlias class, by anti-aliasing when we believe we are on a Mac or on Windows. The view of the line numbers scrolls with the contents of the text pane. The line of text where the caret is will have it's line number in yellow on a black background. The OurLineNumberWidget sets itself to 0 width, or a calculated width, depending on whether OurSyntaxWidget constructed or informs it later whether to display.
The code itself does not place a restriction on how many lines there are in the file or displaying the current line number. The width of OurLineNumberWidget grows or shrinks depending on the current number to display with the most digits. This author has tested up to seven digits.
The highlighting of the line of the caret could certainly be changed if there is need or preference. Size of the line number area, the exact font used, color and background, these are all on the table.
The preference for displaying line-numbers is in the Alloy Preferences window, in the Editor tab, at the end of the list of preferences there. The current value appears in the Options menu at the end of the third section, in the same section with the preferences from the Editor tab.
Testing of this feature has involved a Windows 11 machine with Java 8, and a Macos 11 with Java 8. Testing has involved combinations of:
I'd welcome further tests or requests.