Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code format uglifies code #71

Open
EmilyGraceSeville7cf opened this issue Apr 19, 2024 · 0 comments
Open

Code format uglifies code #71

EmilyGraceSeville7cf opened this issue Apr 19, 2024 · 0 comments

Comments

@EmilyGraceSeville7cf
Copy link

EmilyGraceSeville7cf commented Apr 19, 2024

Initial code:

program Test; 

uses
  Crt;


type
  TColor = record
    foreground, background: integer;
  end;
  // Create a new color from 3 color components

  
function clARGB(a, r, g, b: integer) : integer;
var
  generator: android_graphics_Color;


begin
  clARGB := generator.argb(a, r, g, b);
end;
 
// Create a new color from 3 color components
function clRGB(r, g, b: integer) : integer;
begin
  clRGB := clARGB(0, r, g, b);
end; 

// Create a pair of colors
function clNew(foreground, background: integer) : TColor;
var
  color: TColor;


begin
  color.foreground := foreground;
  color.background := background;
  clNew := color;
end; 

// Set text and its background color based on the color pair
procedure clSet(cl: TColor);
begin
  textColor(cl.foreground);
  textBackground(cl.background);
end;

// Write a colored text
procedure clWrite(cl: TColor;
value: string); 
begin
  clSet(cl);
  Write(value);
end; 

var
  cl: TColor;

begin
  cl := clNew(clRGB(255, 0, 0), clRGB(255, 255, 0));
  clWrite(cl, 'I love u, Lana');
end.

Formatted code:

program Test; 

uses
  Crt;


type
  TColor = record
    foreground, background: integer;
  end;
  // Create a new color from 3 color components

  
function clARGB(a, r, g, b: integer) : integer;

var
  generator: android_graphics_Color;


begin
  clARGB := generator.argb(a, r, g, b);
end; 
// Create a new color from 3 color components

function clRGB(r, g, b: integer) : integer;

begin
  clRGB := clARGB(0, r, g, b);
end; 
// Create a pair of colors

function clNew(foreground, background: integer) : TColor;

var
  color: TColor;


begin
  color.foreground := foreground;
  color.background := background;
  clNew := color;
end; 
// Set text and its background color based on the color pair

procedure clSet(cl: TColor);

begin
  textColor(cl.foreground);
  textBackground(cl.background);
end; 
// Write a colored text

procedure clWrite(cl: TColor;
value: string); 

begin
  clSet(cl);
  Write(value);
end; 

var
  cl: TColor;


begin
  cl := clNew(clRGB(255, 0, 0), clRGB(255, 255, 0));
  clWrite(cl, 'I love u, Lana');
end.

Issues found:

  • functions are joined, empty lines between them are removed
  • function comments became separated from functions by one empty line
  • empty one line is added before function's begin even there is no var section before begin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant