New line on command line

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

New line on command line

Rajula Vineet
Hey,

I have been trying to print on the command line as a part of my handler implementation. I have been using `nextPutAll: aString;lf.` Apparently, 'lf' does not seem to work. I tried 'cr' too. I am using the latest 7.0 Pharo-vm and pharo image. I tried 'OSPlatform current lineEnding' as suggested by Clement Mastin. But, when I used the 6.0 version the 'lf' message is working fine. Please find the attached image which demonstrates the same. The left terminal is of version 7.0, right one is of 6.0. Can someone help me out with this?
Reply | Threaded
Open this post in threaded view
|

Re: New line on command line

Guillermo Polito
Hi Rajula

On Sat, Aug 12, 2017 at 12:56 AM, Rajula Vineet <[hidden email]> wrote:
Hey,

I have been trying to print on the command line as a part of my handler
implementation. I have been using `nextPutAll: aString;lf.` Apparently, 'lf'
does not seem to work. I tried 'cr' too. I am using the latest 7.0 Pharo-vm
and pharo image. I tried 'OSPlatform current lineEnding' as suggested by
Clement Mastin. But, when I used the 6.0 version the 'lf' message is working
fine.

We did some changes to remodularize a bit more the kernel some weeks ago. 

The correct way to print a line ending is, as Clement pointed out, 'OSPlatform current lineEnding'. That is because there is no portable character for a new line. Each platform has its own.

That said, maybe you found a bug :). Since the image before automatically transformed cr's in line endings for a platform, I did a stream decorator that replaces that behaviour for Pharo 7, I just did it to make it work, did not test it further actually.

Could you try the following?

 - seeing what happens if you print a new line twice?
      nextPutAll: aString; lf;lf

 - What is the stream you're using to print out? Transcript or Stdout? Could you show the entire expression you're using?
 - Can you print out the stream you're using?
     stream nextPutAll: stream asString; lf.

Guille
 
Please find the attached image which demonstrates the same. The left
terminal is of version 7.0, right one is of 6.0. Can someone help me out
with this?
<http://forum.world.st/file/n4960327/Screenshot_from_2017-08-11_00-04-29.png>



--
View this message in context: http://forum.world.st/New-line-on-command-line-tp4960327.html
Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.




--

   

Guille Polito


Research Engineer

French National Center for Scientific Research - http://www.cnrs.fr



Web: http://guillep.github.io

Phone: +33 06 52 70 66 13

Reply | Threaded
Open this post in threaded view
|

Re: New line on command line

Rajula Vineet


    Hi Rajula

Hey



    On Sat, Aug 12, 2017 at 12:56 AM, Rajula Vineet <[hidden email]> wrote:

        Hey,

        I have been trying to print on the command line as a part of my handler
        implementation. I have been using `nextPutAll: aString;lf.` Apparently, 'lf'
        does not seem to work. I tried 'cr' too. I am using the latest 7.0 Pharo-vm
        and pharo image. I tried 'OSPlatform current lineEnding' as suggested by
        Clement Mastin. But, when I used the 6.0 version the 'lf' message is working
        fine.


    We did some changes to remodularize a bit more the kernel some weeks ago.

    The correct way to print a line ending is, as Clement pointed out, 'OSPlatform current lineEnding'. That is because there is no portable character for a new line. Each platform has its own.

Oh! Cool!

    That said, maybe you found a bug :). Since the image before automatically transformed cr's in line endings for a platform, I did a stream decorator that replaces that behaviour for Pharo 7, I just did it to make it work, did not test it further actually.

Oh! Yeah, it might be a bug.

    Could you try the following?

     - seeing what happens if you print a new line twice?
          nextPutAll: aString; lf;lf

I tried it out, it is not changing anything. No new line.

      - What is the stream you're using to print out? Transcript or Stdout? Could you show the entire expression you're using?

Yeah, I am using stdout. This is the expression
self stdoutnextPutAll: (SystemVersion current highestUpdate) asString;lf.

      - Can you print out the stream you're using?
         stream nextPutAll: stream asString; lf.

Yeah, the stream I am using is a VTermOutputDriver.

    Guille
     
Rajula

        Please find the attached image which demonstrates the same. The left
        terminal is of version 7.0, right one is of 6.0. Can someone help me out
        with this?
        <http://forum.world.st/file/n4960327/Screenshot_from_2017-08-11_00-04-29.png>



        --
        View this message in context: http://forum.world.st/New-line-on-command-line-tp4960327.html
        Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.




    --

      
       

    Guille Polito


    Research Engineer

    French National Center for Scientific Research - http://www.cnrs.fr



    Web: http://guillep.github.io

    Phone: +33 06 52 70 66 13
 

Reply | Threaded
Open this post in threaded view
|

Re: New line on command line

Guillermo Polito
Rajula, you can debug the code in graphical mode also. Would you mind investigating the bug and proposing a fix? It should not be difficult :)

Guille

On Sat, Aug 12, 2017 at 3:39 PM, Rajula Vineet <[hidden email]> wrote:


    Hi Rajula

Hey



    On Sat, Aug 12, 2017 at 12:56 AM, Rajula Vineet <[hidden email]> wrote:

        Hey,

        I have been trying to print on the command line as a part of my handler
        implementation. I have been using `nextPutAll: aString;lf.` Apparently, 'lf'
        does not seem to work. I tried 'cr' too. I am using the latest 7.0 Pharo-vm
        and pharo image. I tried 'OSPlatform current lineEnding' as suggested by
        Clement Mastin. But, when I used the 6.0 version the 'lf' message is working
        fine.


    We did some changes to remodularize a bit more the kernel some weeks ago.

    The correct way to print a line ending is, as Clement pointed out, 'OSPlatform current lineEnding'. That is because there is no portable character for a new line. Each platform has its own.

Oh! Cool!

    That said, maybe you found a bug :). Since the image before automatically transformed cr's in line endings for a platform, I did a stream decorator that replaces that behaviour for Pharo 7, I just did it to make it work, did not test it further actually.

Oh! Yeah, it might be a bug.

    Could you try the following?

     - seeing what happens if you print a new line twice?
          nextPutAll: aString; lf;lf

I tried it out, it is not changing anything. No new line.

      - What is the stream you're using to print out? Transcript or Stdout? Could you show the entire expression you're using?

Yeah, I am using stdout. This is the expression
self stdoutnextPutAll: (SystemVersion current highestUpdate) asString;lf.

      - Can you print out the stream you're using?
         stream nextPutAll: stream asString; lf.

Yeah, the stream I am using is a VTermOutputDriver.

    Guille
     
Rajula

        Please find the attached image which demonstrates the same. The left
        terminal is of version 7.0, right one is of 6.0. Can someone help me out
        with this?
        <http://forum.world.st/file/n4960327/Screenshot_from_2017-08-11_00-04-29.png>



        --
        View this message in context: http://forum.world.st/New-line-on-command-line-tp4960327.html
        Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.




    --

      
       

    Guille Polito


    Research Engineer

    French National Center for Scientific Research - http://www.cnrs.fr



    Web: http://guillep.github.io

    Phone: <a href="tel:+33%206%2052%2070%2066%2013" value="+33652706613" target="_blank">+33 06 52 70 66 13
 



View this message in context: Re: New line on command line



--

   

Guille Polito


Research Engineer

French National Center for Scientific Research - http://www.cnrs.fr



Web: http://guillep.github.io

Phone: +33 06 52 70 66 13

Reply | Threaded
Open this post in threaded view
|

Re: New line on command line

Rajula Vineet
Oh ok sure. I will try my best. :)

Rajula
Reply | Threaded
Open this post in threaded view
|

Re: New line on command line

Rajula Vineet
Hey Guille,

I think I found the fix. But I would like to run by you first. I want to get a review before making a PR.

In the method nextPut: in ZnCrProtableWriteStream, when a new line character is sent using 'OSPlatform current lineEnding', there isn`t any statement which satisfies in this nextPut:. So at the end where the character is checked if it`s a new line, when I added a ifFalse statement and added self newline.

Full code is as follows

nextPut: aCharacter

        (String crlf includes: aCharacter )
                ifFalse: [
                        previous ifNotNil: [ self newLine ].
                        ^ stream nextPut: aCharacter ].

        previous = Character cr
                ifTrue: [ self newLine ].
        aCharacter ~= Character lf
                ifTrue: [ previous := aCharacter ]
                ifFalse:[ self newLine ].

The only change is the last line.

Rajula