Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > How do I format outputted text?

Reply
Thread Tools

How do I format outputted text?

 
 
Dan Mariani
Guest
Posts: n/a
 
      08-30-2007

How can I control the format (font size, color and location) for text
that I am out-putting to the screen. For example:

puts ("Ruby is great!")

How can I make this appear in larger font on my screen when I run my
program?

Any help would be GREATLY appreciated!!

dm
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
 
Dan Zwell
Guest
Posts: n/a
 
      08-30-2007
Dan Mariani wrote:
> How can I control the format (font size, color and location) for text
> that I am out-putting to the screen. For example:
>
> puts ("Ruby is great!")
>
> How can I make this appear in larger font on my screen when I run my
> program?
>
> Any help would be GREATLY appreciated!!
>
> dm


What environment are you running the program in? Are you using a GUI
toolkit? Are you just printing to the console? Are you (trying) to get
this functionality in TextMate? What operating system are you using? Do
you need a portable program?

See http://catb.org/~esr/faqs/smart-questions.html

Dan

 
Reply With Quote
 
 
 
 
Morton Goldberg
Guest
Posts: n/a
 
      08-30-2007
On Aug 29, 2007, at 10:06 PM, smc smc wrote:

> fish can't fly but birds can
> birds can't swim but fish can


Therefore, penguins are fish

Regards, Morton

 
Reply With Quote
 
Dan Mariani
Guest
Posts: n/a
 
      08-30-2007
Dan Zwell wrote:
> Dan Mariani wrote:
>> dm

> What environment are you running the program in?

A: I am running the program from the DOS Command Prompt.

Are you using a GUI toolkit?
A: No, I don't even know what one is. I am new to both programming and
Ruby.

Are you just printing to the console?
A: Yes, I am just printing to the console.

Are you (trying) to get this functionality in TextMate?
A: I am not familiar with TextMate.

What operating system are you using?
A: Windows XP

Do you need a portable program?
A: Yes, I would prefer that it be portable.
>
> See http://catb.org/~esr/faqs/smart-questions.html
>
> Dan


Thanks for the help!


--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Dan Zwell
Guest
Posts: n/a
 
      08-30-2007
Dan Mariani wrote:
> Dan Zwell wrote:
>> Dan Mariani wrote:
>>> dm

>> What environment are you running the program in?

> A: I am running the program from the DOS Command Prompt.
>
> Are you using a GUI toolkit?
> A: No, I don't even know what one is. I am new to both programming and
> Ruby.
>
> Are you just printing to the console?
> A: Yes, I am just printing to the console.


When printing to the console, the simplest case is that you add spaces
or newlines.

10.times { puts }
puts (" " * 20) + "This is in the middle of the screen"
10.times { puts }

Being that most text mode programs print one line at a time, there isn't
an easier way. Perhaps you could write a method that printed 30 lines at
a time, if you wanted the illusion of being able to print to various
parts of the screen. A lot of people use simple ideas like printing
blank lines or loud characters to get the eye's attention. You can't
change the font, but there's a lot you can do to effectively
communicate. Some examples:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@@@@@@@@

!!!!!! Are you sure? !!!!!!!!!

================================================== ========================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
================================================== ========================

Started.........

To do more with screen positioning, there is a library called ncurses
that gives you complete flexibility to place anything anywhere on the
screen. This is really the standard for complex console output. The
homepage for ncurses-ruby is here: http://ncurses-ruby.berlios.de/ , and
I saw what looked like a Windows package, but I don't know whether that
means you can install it without cygwin (Linux emulation, basically).
Learning to use this library might be too much to learn at once for a
beginner to programming, but know that this is the most powerful tool
(that can be used with Ruby) for doing layout stuff on the console.

If you will be content with being able to change colors, I would go for
a library called HighLine (http://highline.rubyforge.org/). See the
examples here
http://viewvc.rubyforge.mmmultiworks...?root=highline
for descriptions of how it can be used. You can find documentation from
the first link.

Good luck,
Dan

 
Reply With Quote
 
Bertram Scharpf
Guest
Posts: n/a
 
      08-30-2007

Hi,

Am Donnerstag, 30. Aug 2007, 10:31:29 +0900 schrieb Dan Mariani:
>
> puts ("Ruby is great!")
>
> How can I make this appear in larger font on my screen when I run my
> program?


IO.popen "figlet", "w" do |f| f.puts "Ruby is great!" end

<http://www.google.de/search?q=figlet>

Bertram


--
Bertram Scharpf
Stuttgart, Deutschland/Germany
http://www.bertram-scharpf.de

 
Reply With Quote
 
Jeremy Woertink
Guest
Posts: n/a
 
      08-30-2007
Dan Mariani wrote:
>
> How can I control the format (font size, color and location) for text
> that I am out-putting to the screen. For example:
>
> puts ("Ruby is great!")
>
> How can I make this appear in larger font on my screen when I run my
> program?
>
> Any help would be GREATLY appreciated!!
>
> dm


Doing it in console, you can't format it. There are GUI toolkits like
FXRuby you can checkout or just do a google search for GUI toolkits for
Ruby. If you do Rails development on MacOSX there is a gem that allows
you to have your text in different colors for your log file. Being new
to all this stuff, that may be a bit too much, but just keep it in mind
if you ever get into Rails development, then hop back on here and ask
the question again


~Jeremy
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
Mohit Sindhwani
Guest
Posts: n/a
 
      09-03-2007
Jeremy Woertink wrote:
> Dan Mariani wrote:
>
>> How can I control the format (font size, color and location) for text
>> that I am out-putting to the screen. For example:
>>
>> puts ("Ruby is great!")
>>
>> How can I make this appear in larger font on my screen when I run my
>> program?
>>
>> Any help would be GREATLY appreciated!!
>>
>> dm
>>

>
> Doing it in console, you can't format it. There are GUI toolkits like
> FXRuby you can checkout or just do a google search for GUI toolkits for
> Ruby. If you do Rails development on MacOSX there is a gem that allows
> you to have your text in different colors for your log file. Being new
> to all this stuff, that may be a bit too much, but just keep it in mind
> if you ever get into Rails development, then hop back on here and ask
> the question again
>
>
> ~Jeremy
>


Or you could use WideStudio [1] to make Ruby based executable programs
in a GUI style!

[1] www.widestudio.org

Cheers,
Mohit.
9/3/2007 | 11:33 PM.




 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Money Format + Decimal Place Format shannon Java 1 02-02-2006 03:47 PM
need code to convert float format to internal java float format which is kept in 4 bytes integer Andy Java 7 05-10-2004 09:26 PM
NTFS quick format and normal format Guan Foo Wah MCSE 2 05-08-2004 11:35 PM
Date Format - best way of converting a string into a date format Brian Candy ASP .Net 2 02-18-2004 02:13 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57