JCL Help:TJclTabSet

From Project JEDI Wiki
Jump to navigationJump to search

Class Hierarchy

IToString
|
TJclTabSet


Summary

Represents a tab set that can be used to expand tabs to spaces, or vice versa.


Pascal

 public TJclTabSet = class(TInterfacedObject, IToString);


Description

The TJclTabSet class represents tabulation information. Each instance can specify:

The class then provides functionality to:

  • Determine the next tabulation position from a given starting column
  • Determine the optimal tab and space characters needed to get from one column to another
  • Expand tab characters into a sequence of spaces, optionally starting at an arbitrary column
  • Collapse a sequence of space and tab characters into an optimized sequence of tab and space characters, optionally starting at an arbitrary column

The class contains logic to allow automatic tab width determination by setting the tabulation width to zero or a negative value; in this case the tab width is determined by the provided tabulation positions in the following manner:

Situation ActualTabWidth
No tabulation positions defined 2
One tabulation position defined the defined tabulation position
Two or more tabulation positions defined the distance between the last two tabulation positions


nil - safetyThe public methods and properties that do not modify the tab set are nil-safe, meaning they will work when used on a nil reference. A nil tab set will behave as if explicitly set to:

Note that reading any of the public properties on a nil instance will work properly.


Examples

  // initiate a tab set with (zero-based) stops at 15, 20 and 30, and a tab width of 2 for
// tabs beyond the column 30
tabs := TJclTabSet.Create([15, 20, 30], True, 2);
try
x := tabs.Expand('MyLabel:'#9'LD'#9'A,(HL)'#9'; Initialize A register');
finally
tabs.Free;
end;
The above snippet will result in x containing the string (· represents a space character): MyLabel:·······LD···A,(HL)····;·Initialize·A·register. In this case the first tab character (ASCII code 9) was transformed into seven spaces, the second tab character into three spaces and the third tab character into four spaces.


About

Unit

JclStrings


Navigation

Donator

Marcel Bestebroer


Contribute to this help topic

This documentation wiki is based on the collaborative effort of Project JEDI users. Your edits are welcome in order to improve documentation quality: edit this page