Skip to content
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.

Add new lines in Patch Description #13

Closed
le717 opened this issue Jul 29, 2013 · 1 comment
Closed

Add new lines in Patch Description #13

le717 opened this issue Jul 29, 2013 · 1 comment
Assignees
Milestone

Comments

@le717
Copy link
Owner

le717 commented Jul 29, 2013

Feature

For a while now, I've wanted to add a way to insert new lines in the Patch Description. Right now, it is an absolute WYSIWYG deal: if a word is not completed by the end of the line, you just have to keep typing, and however the word is cut off is how it is displayed during Installation.

Comments

I would need to use some character to designate a new line, one that would not force character escaping, but is still easy to type. Further more, it should be one that can typed on any keyboard, laptop, desktop, or tablet, full-size or not.

The Implementation

I know exactly how I will implement this feature, and the character I will use. I'll use an horizontal bar (|) to denote a new line, as it can be typed on any keyboard, and many gaming utilities already use it to denote a new line, so it wouldn't be a special-case thing. As for the code, I just have to detect the presence of any bars, replace them with the new line symbol (\n) using the built-in replace function, then write the description to the PiP File. This does not edit the PiP File Format, as it it already designed and coded to exist on however many lines are left in the PiP.
The following code and it's interpretation shows exactly how it works.

desc = input("Description: ")
print(desc)

# Check for the presence of | in the input,
# and replace it with a new line
if "|" in desc:
    newdesc = desc.replace("|", "\n")

# Print the updated text
print(newdesc)

# Display iin a list to show a diagram of the new text
print([newdesc])

# Now, let's write the description
with open("MyPatch.txt", "wt") as f:
    f.write(desc)   

# ...And read it back
with open("MyPatch.txt", "rt") as f:
    lines = f.read()

# And display the reading   
print(lines)

# Again, display in a list so we can see the diagram of the text
print([lines])
# Tada! The new lines are preserved. :)

And the code, when run

Description: MyPatch is an example PatchIt! Patch whose description spans multiple lines.|It uses an horizontal bar to denote a new line. Before it is written, the bar is replaced with the new line|symbol so new lines are written||Hey, look! I am | three lines before the last paragraph!
"MyPatch is an example PatchIt! Patch whose description spans multiple lines.
It uses an horizontal bar to denote a new line. Before it is written, the bar is replaced with the new line
symbol so new lines are written"

Hey, look! I am 
 three lines before the last paragraph!"
['"MyPatch is an example PatchIt! Patch whose description spans multiple lines.\nIt uses an horzintal bar to denote a new line. Before it is written, the bar is replaced with the new line\nsymbol so new lines are written\n\nHey, look! I am \n three lines before the last paragraph!"']
@ghost ghost assigned le717 Jul 29, 2013
le717 pushed a commit that referenced this issue Jul 30, 2013
@le717
Copy link
Owner Author

le717 commented Jul 30, 2013

This feature was added in commit 9d86695. You can now add new lines in a Patch Description! 😀

@le717 le717 closed this as completed Jul 30, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant