Window Lines Help
Name:Window Lines
Version:1.6
Last update:2019-08-08 16:05:34






This package adds a new Tools ↣ Window Lines menu. In general, the actions described below will be performed for the active window -- in some cases, the file must exist on a local disk in order for the operation to take place. To turn this package on, select the command Alpha ↣ Global Setup ↣ Features and click on the checkbox that is next to Window Lines.
Click here to display the Features Preferences dialog and activate this package.

Window Lines menu

The commands in the Tools ↣ Window Lines menu will analyze either the entire window or any currently highlighted selection, looking for unique or duplicated lines. In each case, if there are any results they will be displayed in a new window, complete with line number and duplicate count information.
For example, you might want to locate which lines are duplicates, unique, etc. in your currently opened document.
The hyperlinks for each item described below will allow you to perform these actions on this window, even if this package is not yet turned on!

Number Lines

This is a simple utility to add row numbers to the left of each line.
Experiment: click here to number the lines in your current Alpha document.

Count Duplicate Lines

This item will scan the region, and report the number of times that each line appears. The 'count' column is incremental, indicating how many times this line has appeared so far.
Experiment: click here to count the duplicate lines in your current Alpha document.

Find Unique Lines

This item will only report occurences of unique lines, i.e. those that only appear once in the region:
Experiment: click here to find the unique lines in your current Alpha document.

Find Duplicate Lines

This item reports only those lines that appear more than once in the region, with line numbers for each occurence and the number of times each item appears:
Experiment: click here to find the duplicate lines in your current Alpha document.

Find First Duplicate Lines

Similar to Find Duplicate Lines, but only the first occurence of each duplicate line is reported, along with the total number of times that it appears in the region.
Experiment: click here to find the first duplicate in your current Alpha document.

Remove Duplicate Lines

This item will include all unique lines and the first appearance of a duplicate line, but remove any subsequent appearance of duplicates found in the region.
Experiment: click here to remove the duplicate lines in your current Alpha document.

Insert Mode Line ...

This item inserts a line looking like
# -*-Tcl-*-
at the top of the window. This will indicate that the file should be opened in Tcl mode (e.g.) by Alpha, no matter what its file suffix is. If the current mode is 'Text' you will be given the option to first change the mode of this window to something else. See the Smart mode lines section in the Alpha Manual.
Experiment: click here to insert a mode line in your current Alpha document.

Sort Words

This item requires a selection. Each 'word' in the region, separated by a space or carriage return, is turned into a list which is sorted in alphabetical order, and the region is then replaced and the region is selected once again. By default this sort is an 'ascii' sort, i.e.
ABCD...abcd
If you want a 'dictionary' style, i.e.
AaBbCcDd...
then simply use this Tools ↣ Window Lines ↣ Sort Words item once again -- it will recognize the boundaries of the previous sort and decide that you want to try something different. A third Sort Words action will revert the sort back to 'ascii'.
Note that after performing the sort and replace, the lines containing the region are also 'wrapped' by necessity, so this will require two 'undo' actions to revert back to the original text. Also, 'words' that are surrounded by curly braces {} or double quotes are considered to be a single item in the list.
You can experiment with these strings of text:
This is a test of sorting with both Dictionary and Ascii styles
This is another Test of "Window Lines" sorting.
And This is another Test {but with curly braces.}
A dynamic Window Lines ↣ Reverse Sort Words item is also available, press the Option key to display it in the menu. The same rules regarding dictionary sorts also apply here.

Known problems

Please report any problem or bug you encounter to Alpha's Bug Tracker.
If you have additional window/file utilities that you would like to see added to this package, contact its maintainer and describe what you would like to see. Source code is always welcome! See the filewindowLines.tcl file for the current implementation.

License and Disclaimer

Copyright (c) 1996-2019, Vince Darley.
All rights reserved.
The windowLines package is free software and distributed under the terms of the new BSD license:
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL VINCE DARLEY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.