Types - skalogryz/editorConfig GitHub Wiki

Table of Contents

TTriBool

  TTriBool = (
    tbUnset, 
    tbFalse, 
    tbTrue 
  ); 
It's necessary to know, if a boolean flag was NOT specified a file. Pascal doesn't have a native Null-able types, thus 3-sate "boolean" type is introduced.
  • tbUnset - unspecified (an editor default should be used)
  • tbFalse - false (specified)
  • tbTrue - true (specified)

TEditorConfigEntry

  TEditorConfigEntry = class(TObject)
  public
    indent_style : string;  
    indent_size  : integer; 
    tab_width    : integer; 
    end_of_line  : string;  
    charset      : string;  
    trim_trailing_whitespace : TTriBool; 
    insert_final_newline     : TTriBool; 
    constructor Create(const aname: string);
    property name: string read fname;
  end;  
  • indent_style - set to tab or space to use hard tabs or soft tabs respectively.
  • indent_size a whole number defining the number of columns used for each indentation level and the width of soft tabs (when supported). When set to tab, the value of tab_width (if specified) will be used.
  • tab_width - a whole number defining the number of columns used to represent a tab character. This defaults to the value of indent_size and doesn't usually need to be specified.
  • end_of_line - set to lf, cr, or crlf to control how line breaks are represented.
  • charset - set to latin1, utf-8, utf-8-bom, utf-16be or utf-16le to control the character set.
  • trim_trailing_whitespace - set to tbTrue to remove any whitespace characters preceding newline characters and tbFalse to ensure it doesn't.
  • insert_final_newline - set to tbTrue to ensure file ends with a newline when saving and tbFalse to ensure it doesn't.

TEditorConfigEntry

 TEditorConfigFile = class(TObject)
  public
    root : Boolean; 
    filepath : String;
    function AddEntry(const aname: string): TEditorConfigEntry;
    property Entry[i: integer]: TEditorConfigEntry read GetEntry; default;
    property Count: Integer read GetCount;
  end; 
  • root - the boolean flag indicating if the file is .editorconfig root file
  • filepath - optional file path of the .editorconfig stores. Can be empty.
  • Count - number of entries in the file
  • Entry - returns an editorconfig entry
  • AddEntry() - creates a new entry for the pattern specified in aname parameter. The function doesn't check for duplicates.

FileNameMatch()

function FileNameMatch(const pattern, filename: string): Boolean;
Performs unix (glob) file matching pattern (filemask) matching to a filename. Returns true if file name matches the file mask, false otherwise.

ECMatch()

function ECMatch(const pattern, filename: string): Boolean;
Performs EditorConfig pattern matching to a filename. Returns true if file name matches the file mask, false otherwise.

TryStrToTriBool()

function TryStrToTriBool(const S: string; out Value: TTriBool): Boolean;
if S is a blank string value is set to tbUnset.

If s is 0 or false the value is set to tbFalse, otherwise tbTrue.

The function always true.

⚠️ **GitHub.com Fallback** ⚠️