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

Add proper long line wrapping. #268

Merged
3 commits merged into from Jan 7, 2015
Merged

Add proper long line wrapping. #268

3 commits merged into from Jan 7, 2015

Conversation

ghost
Copy link

@ghost ghost commented Jan 2, 2015

When sending a message to IRC, the message is relayed to other
servers and other clients by the server and needs to fit within
the max line length for server messages (512). What this means
is that the actual content of the message needs to be truncated
based on the length of the user's nick, hostname, and the kind
of message being sent (PRIVMSG, NOTICE). The current code,
in addition to hardcoding the wrap length at the absolute
max line length (not taking any of this into consideration),
is rather ugly and hard to follow. I've abstracted the logic
into something easier to follow, correct, and reuseable. It'll
be easy to expand it to ACTION.

TODO: maintain colors and other formatting across wrapped
messages. Textual does this for PRIVMSGs, at least, so we can try
looking there for inspiration.

@ghost
Copy link
Author

ghost commented Jan 2, 2015

I will note that this is similar to #142, but the line wrapping implementation itself is a lot cleaner. I don't see where that code actually sets self.messageLength, though it makes reference to doing so if the server specifies it. So, really, there's no difference between my pull and that one besides the fact that (IMO) my code is a lot eaier to follow. Oh, and it applies cleanly.

@jirwin
Copy link
Collaborator

jirwin commented Jan 6, 2015

+1

Chris Nehren added 3 commits January 6, 2015 23:05
When sending a message to IRC, the message is relayed to other
servers and other clients by the server and needs to fit within
the max line length for server messages (512). What this means
is that the actual content of the message needs to be truncated
based on the length of the user's nick, hostname, and the kind
of message being sent (PRIVMSG, NOTICE). The current code,
in addition to hardcoding the wrap length at the absolute
max line length (not taking any of this into consideration),
is rather ugly and hard to follow. I've abstracted the logic
into something easier to follow, correct, and reuseable. It'll
be easy to expand it to ACTION.

TODO: maintain colors and other formatting across wrapped
messages. Textual does this for PRIVMSGs, at least, so we can try
looking there for inspiration.
This fixes the style to be more consistent with the existing code
and makes the line length calculation actually take the target
into consideration. It also makes some methods private according
to whether they are called by the end user or not.
ghost pushed a commit that referenced this pull request Jan 7, 2015
Add proper long line wrapping.
@ghost ghost merged commit 377ce46 into martynsmith:0.3.x Jan 7, 2015
This pull request was closed.
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

Successfully merging this pull request may close these issues.

1 participant