Bug: newlines being stripped when pasted to command line

Post Reply
Caled
Posts: 403
Joined: Thu Apr 09, 2009 4:45 am

Bug: newlines being stripped when pasted to command line

Post by Caled »

I noticed this myself, but forgot to report it as it seemed only minor at the time.

If you paste more than one line from a text editor to the command line, the new lines are stripped and the whole thing ends up as a single line.

It was pointed out to me again just now, by a friend that works as a dev, that he pastes code into the command line a lot and likes to do it more than one line at a time.

Could this be either fixed (or if not a bug, then changed)?

Michael
Posts: 9
Joined: Sun Jul 05, 2009 11:19 am

Re: Bug: newlines being stripped when pasted to command line

Post by Michael »

Hi, friend that Caled mentioned here.

If this bug is a problem for anyone else, I came up with a temporary fix in the meantime.

In TCommandLine.cpp: void TCommandLine::enterCommand( QKeyEvent * event )

There should be a line at the very top of this routine that looks like:

Code: Select all

mpHost->send( text() );
Comment this out, and either directly above or below it paste in:

Code: Select all

    QString cmd = text();
    QString delimit("\n");
    QStringList cmdlist = cmd.split(delimit);
    
    for (int i = 0; i < cmdlist.size(); i++ ) {
       mpHost->send(cmdlist[i]);
    }

User avatar
Vadi
Posts: 5042
Joined: Sat Mar 14, 2009 3:13 pm

Re: Bug: newlines being stripped when pasted to command line

Post by Vadi »

This is done intentionally actually; the only bug is that newlines actually get deleted only and not replaced with a space.

For multi-line pastes ("as intended", but usually that's not the common type) mud clients usually either a) provide a separate dialog, or b) provide an button beside the input line to toggle the input mode (multiline or no).

I personally lean towards the button toggle by the input line, as it's a relatively popular option for some and easy access would be worth the space.

User avatar
Heiko
Site Admin
Posts: 1548
Joined: Wed Mar 11, 2009 6:26 pm

Re: Bug: newlines being stripped when pasted to command line

Post by Heiko »

Michael wrote:Hi, friend that Caled mentioned here.

If this bug is a problem for anyone else, I came up with a temporary fix in the meantime.

In TCommandLine.cpp: void TCommandLine::enterCommand( QKeyEvent * event )

There should be a line at the very top of this routine that looks like:

Code: Select all

mpHost->send( text() );
Comment this out, and either directly above or below it paste in:

Code: Select all

    QString cmd = text();
    QString delimit("\n");
    QStringList cmdlist = cmd.split(delimit);
    
    for (int i = 0; i < cmdlist.size(); i++ ) {
       mpHost->send(cmdlist[i]);
    }
As Vadi has said, the behaviour is indeed intentional, but this doesn't mean that it shouldn't be changed. I think that Micheal is right that we should at least offer a multiline enabled command line for those who need such a feature. I'll look into Michael's patch tonight.

Michael
Posts: 9
Joined: Sun Jul 05, 2009 11:19 am

Re: Bug: newlines being stripped when pasted to command line

Post by Michael »

That's awesome, thanks. (P.S. does this "post needs approval before it's viewable" thing ever go away?)

Edit: Apparently it does! :D

Post Reply