Write same newlines across operating systems for gradient_test.ans

This commit is contained in:
Isaiah Odhner 2024-10-31 20:55:27 -04:00
parent 33650e4dd0
commit ade8d115cf
2 changed files with 3 additions and 2 deletions

View File

@ -95,6 +95,7 @@ def write_ansi_file(file: TextIO) -> None:
write('\u001b[0m')
# Generate and write to a file
# Warning: in text mode, any newlines will be converted to the system's line ending, unless `newline` is passed as an argument to `open()`
file_path = os.path.join(os.path.dirname(__file__), f'../samples/{box_inner_width}x{box_inner_height}_font_template.ans')
file_path = os.path.abspath(file_path)
with open(file_path, 'w', encoding='utf-8') as file:

View File

@ -65,11 +65,11 @@ height = 24
# Generate and write the ANSI art to a file
file_path = os.path.join(os.path.dirname(__file__), '../samples/gradient_test.ans')
file_path = os.path.abspath(file_path)
with open(file_path, 'w', encoding='utf-8') as file:
with open(file_path, 'w', encoding='utf-8', newline='\n') as file:
generate_ansi_art(width, height, file)
# Print the art to the terminal
with open(file_path, 'r', encoding='utf-8') as file:
with open(file_path, 'r', encoding='utf-8', newline='\n') as file:
print(file.read())
# Print the path to the file, and resulting file size