[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Is there a way to clear the contents of a terminal?

John Maclean

1/4/2006 6:49:00 AM

Hi Chaps,

MATLAB uses cls, in a bash shell I'd use clear. Is there a way to clear the contents of a terminal -safely-?

--
John Maclean
MSc (DIC)
07739 171 531



13 Answers

Gene Tani

1/4/2006 8:03:00 AM

0


John Maclean wrote:
> Hi Chaps,
>
> MATLAB uses cls, in a bash shell I'd use clear. Is there a way to clear the contents of a terminal -safely-?
>
> --
> John Maclean
> MSc (DIC)
> 07739 171 531

Control-L

John Maclean

1/4/2006 9:07:00 AM

0

I should've made myself clearer. Is there a way to do this via a ruby command?

On Wed, 4 Jan 2006 17:07:58 +0900
"Gene Tani" <gene.tani@gmail.com> wrote:

>
> John Maclean wrote:
> > Hi Chaps,
> >
> > MATLAB uses cls, in a bash shell I'd use clear. Is there a way to clear the contents of a terminal -safely-?
> >
> > --
> > John Maclean
> > MSc (DIC)
> > 07739 171 531
>
> Control-L
>
>
>
>


--
John Maclean
MSc (DIC)
07739 171 531



Ross Bamford

1/4/2006 10:02:00 AM

0

On Wed, 04 Jan 2006 06:49:14 -0000, John Maclean <info@jayeola.org> wrote:

> Hi Chaps,
>
> MATLAB uses cls, in a bash shell I'd use clear. Is there a way to clear
> the contents of a terminal -safely-?
>

Safe, sure, reliable, probably not. But on most 'modern' systems I guess
this should work:

puts "\e[2J"

--
Ross Bamford - rosco@roscopeco.remove.co.uk

Ross Bamford

1/4/2006 10:06:00 AM

0

On Wed, 04 Jan 2006 10:01:56 -0000, Ross Bamford
<rosco@roscopeco.remove.co.uk> wrote:

> On Wed, 04 Jan 2006 06:49:14 -0000, John Maclean <info@jayeola.org>
> wrote:
>
>> Hi Chaps,
>>
>> MATLAB uses cls, in a bash shell I'd use clear. Is there a way to clear
>> the contents of a terminal -safely-?
>>
>
> Safe, sure, reliable, probably not. But on most 'modern' systems I guess
> this should work:
>
> puts "\e[2J"
>

or "\e[2J\e[0;0H" to home the cursor too.

--
Ross Bamford - rosco@roscopeco.remove.co.uk

Steve Litt

1/4/2006 2:08:00 PM

0

On Wednesday 04 January 2006 01:49 am, John Maclean wrote:
> Hi Chaps,
>
> MATLAB uses cls, in a bash shell I'd use clear. Is there a way to clear the
> contents of a terminal -safely-?

In the UMENU program, I do this:

puts "\n" * 24

Crude, but effective, and has the advantage of being totally portable -- even
on an ancient teletype terminal. If you use different terminal resolutions,
then it would be

print "\n" * lines_per_screen

SteveT


Steve Litt
http://www.troublesh...
slitt@troubleshooters.com


Steve Litt

1/4/2006 3:01:00 PM

0

On Wednesday 04 January 2006 09:10 am, Steve Litt wrote:
> On Wednesday 04 January 2006 04:07 am, John Maclean wrote:
> > I should've made myself clearer. Is there a way to do this via a ruby
> > command?
>
> print 12.to_s

Dooohhhhh. This would have printed "12". What I needed some sort of equivalent
of Pascal chr().

SteveT

Steve Litt
http://www.troublesh...
slitt@troubleshooters.com


James Gray

1/4/2006 3:04:00 PM

0

On Jan 4, 2006, at 9:00 AM, Steve Litt wrote:

> On Wednesday 04 January 2006 09:10 am, Steve Litt wrote:
>> On Wednesday 04 January 2006 04:07 am, John Maclean wrote:
>>> I should've made myself clearer. Is there a way to do this via a
>>> ruby
>>> command?
>>
>> print 12.to_s
>
> Dooohhhhh. This would have printed "12". What I needed some sort of
> equivalent
> of Pascal chr().

12.chr ?

James Edward Gray II


Tim Hunter

1/4/2006 3:07:00 PM

0

Steve Litt wrote:
>
> Dooohhhhh. This would have printed "12". What I needed some sort of equivalent
> of Pascal chr().
>
Something like this?

rb$ ri Integer.chr
------------------------------------------------------------ Integer#chr
int.chr => string
------------------------------------------------------------------------
Returns a string containing the ASCII character represented by the
receiver's value.

65.chr #=> "A"
?a.chr #=> "a"
230.chr #=> "\346"

Ross Bamford

1/4/2006 5:39:00 PM

0

On Wed, 04 Jan 2006 15:00:45 -0000, Steve Litt <slitt@earthlink.net> wrote:

> On Wednesday 04 January 2006 09:10 am, Steve Litt wrote:
>> On Wednesday 04 January 2006 04:07 am, John Maclean wrote:
>> > I should've made myself clearer. Is there a way to do this via a ruby
>> > command?
>>
>> print 12.to_s
>
> Dooohhhhh. This would have printed "12". What I needed some sort of
> equivalent
> of Pascal chr().
>

IIRC ASCII 0x0C is form-feed, right. Doesn't Ruby support "\f"? (seems to).
But I don't think it'll clear the terminal, will it?

--
Ross Bamford - rosco@roscopeco.remove.co.uk

James Gray

1/4/2006 5:51:00 PM

0

On Jan 4, 2006, at 11:47 AM, Ross Bamford wrote:

> On Wed, 04 Jan 2006 15:00:45 -0000, Steve Litt
> <slitt@earthlink.net> wrote:
>
>> On Wednesday 04 January 2006 09:10 am, Steve Litt wrote:
>>> On Wednesday 04 January 2006 04:07 am, John Maclean wrote:
>>> > I should've made myself clearer. Is there a way to do this via
>>> a ruby
>>> > command?
>>>
>>> print 12.to_s
>>
>> Dooohhhhh. This would have printed "12". What I needed some sort
>> of equivalent
>> of Pascal chr().
>>
>
> IIRC ASCII 0x0C is form-feed, right. Doesn't Ruby support "\f"?
> (seems to).
> But I don't think it'll clear the terminal, will it?

Correct on all accounts. :)

James Edward Gray II