Page 1 of 1

trim whitespace in Chat

PostPosted: Wed Dec 14, 2005 3:18 pm
by TurkishMonky
hey, if you think if it's possible, could you add in a little utility to trim all whitespace in the chat to 1 space? if you put in enough spaces and a <username>, it will wrap. i mean, it's fun to do and all, but occasionally it can get annoying...

PostPosted: Wed Dec 14, 2005 3:24 pm
by Slater
hmm... that sounds pretty easy as long as Mithrandir has the source to the .class files. Trimming whitespaces is an easy task in Java.

PostPosted: Sun Dec 18, 2005 10:40 pm
by Mithrandir
Heh. Sure, I *could* do that. It's easier not to, though. I'm pretty much through with the java chat. I'm working on a new and improved one that won't require java, though.

PostPosted: Sun Dec 18, 2005 11:45 pm
by Slater
I could help with the process if you want. One question though... what exactly is the problem with whitespaces? too many in front of a message or at the end of a message?

hmm... in any event, multiple whitespaces aren't really that useful. One can use the Wrapper class to check to see if there are, say, 3 or more whitespaces in a row in a string sent by a user, then trim them out and replace them with a single space...

PostPosted: Mon Dec 19, 2005 12:42 pm
by TurkishMonky
Slater wrote:I could help with the process if you want. One question though... what exactly is the problem with whitespaces? too many in front of a message or at the end of a message?


the "hack" goes as follows (using - for spaces for the puropse of this example)
i type in:

hello--------------------------------------<MyFriend>-hi

becomes

<TurkishMonky> hello
<MyFriend> hi

it's mostly harmless, until people start getting annoying with it, especially in the instances of doing multiple posts, ...

hello----------------------------------------<TurkishMonky>-hi----------------------------------<MyFriend> -hola.
<OriginalPerson> hello
<TurkishMonky> hi
<MyFriend> hola.

but it's not that big a deal, if it's that hard to do.

PostPosted: Thu Dec 22, 2005 10:20 am
by Mithrandir
Heh. What version of Java are you refering to, Slater. I'd find it much simpler to sub in a regex of some type. I don't know if java supports it or not, though. I'm not much of a java programmer. I'm envisioning something like s/\s+/\s/g working quite nicely.

PostPosted: Sat Dec 24, 2005 1:35 pm
by Slater
oooh, I see.
And I've been studying Java 5.0... last time I looked at the chat's source, I didn't notice if it used 1.4 imports versus 5.0 imports.
But what's a regex?