The raw bytes streaming from your program's $stdout stream include a
bunch of digits (value 0x30 to 0x39) and the odd "\b" (0x08). It's up
to the terminal/console/etc. that receives them and formats them for
display to interpret the 0x08-bytes the way you intended.
Where are you running said script? (Which operating system, terminal
emulator, etc.?)
···
On 14 September 2012 09:24, Cookie Rubster <lists@ruby-forum.com> wrote:
Hi,
New to Ruby and can't seem to get the \b escape to work. Code:
j=0
while j<10
print rand(1...10)
sleep (0.1)
print "\b"
j+=1
end
Output:
4523175329
- just a series of 10 random numbers on the same line.
Am I missing something, or shouldn't it backspace, and print all the #s
in the first character space?
I'm on a Mac, running Aptana Studio 3. Does that help?
Cheers
Matthew Kerwin wrote in post #1075924:
···
On 14 September 2012 09:24, Cookie Rubster <lists@ruby-forum.com> wrote:
end
Jeff
In short: it depends where you're printing it.
The raw bytes streaming from your program's $stdout stream include a
bunch of digits (value 0x30 to 0x39) and the odd "\b" (0x08). It's up
to the terminal/console/etc. that receives them and formats them for
display to interpret the 0x08-bytes the way you intended.
Where are you running said script? (Which operating system, terminal
emulator, etc.?)
Where are you running said script? (Which operating system, terminal
emulator, etc.?)
Thanks for your reply!
I'm on a Mac, running Aptana Studio 3. Does that help?
I'm afraid it doesn't help me, since I'm not a Mac user. From what I
can see (although it's hard to find any real information) Aptana
Studio seems to use the system's built-in terminal, and while I've
seen some comments on the OSX terminal not handling keyboard
backspace/delete propertly, all the proposed solutions imply that
actually printing a ^H / 0x08 / "\b" should work.
Hopefully someone else can help you.
By the way, your loop works fine in my Linux terminal.
···
On 14 September 2012 09:46, Cookie Rubster <lists@ruby-forum.com> wrote:
Any others that can help with this? I'm running RubyMine on Mac and
experiencing the same thing with the \b not properly backspacing.
All I know is that the terminal emulators built into editors and IDEs
like RubyMine often don't support the full range of interactions
possible in a proper terminal emulator, like Terminal or iTerm2. It's
possible JetBrains just didn't implement output of the backspace
character (ASCII 8); I believe it's very seldom used in actually
programs.
Long story short: Use a real terminal, like Terminal or iTerm2.
···
On Sun, Sep 23, 2012 at 10:26 PM, Jeff L. <lists@ruby-forum.com> wrote:
Thanks!
Brian Candler wrote in post #1076055:
OSX Lion, standard system ruby, running in iTerm2:
Eek - thanks so much for your time, Matthew - appreciate it!
Hopefully someone else can chime in.
Matthew Kerwin wrote in post #1075926:
···
Matthew Kerwin wrote in post #1075924:
In short: it depends where you're printing it.
Where are you running said script? (Which operating system, terminal
emulator, etc.?)
On 14 September 2012 09:46, Cookie Rubster <lists@ruby-forum.com> wrote:
Thanks for your reply!
I'm on a Mac, running Aptana Studio 3. Does that help?
I'm afraid it doesn't help me, since I'm not a Mac user. From what I
can see (although it's hard to find any real information) Aptana
Studio seems to use the system's built-in terminal, and while I've
seen some comments on the OSX terminal not handling keyboard
backspace/delete propertly, all the proposed solutions imply that
actually printing a ^H / 0x08 / "\b" should work.
Hopefully someone else can help you.
By the way, your loop works fine in my Linux terminal.