New line on command line
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? <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.
Hi Rajula On Sat, Aug 12, 2017 at 12:56 AM, Rajula Vineet <Vineet.Reddy@iiitb.org> 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* <http://www.cnrs.fr> *Web:* *http://guillep.github.io* <http://guillep.github.io> *Phone: *+33 06 52 70 66 13
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 -- View this message in context: http://forum.world.st/New-line-on-command-line-tp4960327p4960423.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
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 <Vineet.Reddy@iiitb.org> 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
Phone: +33 06 52 70 66 13 <+33%206%2052%2070%2066%2013>
------------------------------ View this message in context: Re: New line on command line <http://forum.world.st/New-line-on-command-line-tp4960327p4960423.html>
Sent from the Pharo Smalltalk Developers mailing list archive <http://forum.world.st/Pharo-Smalltalk-Developers-f1294837.html> at Nabble.com.
-- Guille Polito Research Engineer French National Center for Scientific Research - *http://www.cnrs.fr* <http://www.cnrs.fr> *Web:* *http://guillep.github.io* <http://guillep.github.io> *Phone: *+33 06 52 70 66 13
Oh ok sure. I will try my best. :) Rajula -- View this message in context: http://forum.world.st/New-line-on-command-line-tp4960327p4961307.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
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 -- View this message in context: http://forum.world.st/New-line-on-command-line-tp4960327p4961385.html Sent from the Pharo Smalltalk Developers mailing list archive at Nabble.com.
participants (2)
-
Guillermo Polito -
Rajula Vineet