You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 24, 2021. It is now read-only.
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 lineif"|"indesc:
newdesc=desc.replace("|", "\n")
# Print the updated textprint(newdesc)
# Display iin a list to show a diagram of the new textprint([newdesc])
# Now, let's write the descriptionwithopen("MyPatch.txt", "wt") asf:
f.write(desc)
# ...And read it backwithopen("MyPatch.txt", "rt") asf:
lines=f.read()
# And display the reading print(lines)
# Again, display in a list so we can see the diagram of the textprint([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!"']
The text was updated successfully, but these errors were encountered:
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-inreplace
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.
And the code, when run
The text was updated successfully, but these errors were encountered: