Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby

How to place characters in the ruby console at specific locations?

Is it possible to place characters on screen at specific locations?

If so, how is this done?

For example, placing a character at the top right of the screen might be done something like this: puts(40,0,"R") Assuming the screen is 40 characters wide, the origin of the coordinate system is at the top left, and the character 'R' is to be placed there.

2 Answers

I'm not sure if Workspaces even allows cursor positioning, but I found this:

http://rosettacode.org/wiki/Terminal_control/Cursor_positioning

It doesn't appear Workspaces has the 'curses' library, though.

Owen Tran
Owen Tran
6,822 Points

string = "R" puts string.rjust(40)

Thanks for your reply. This is one way of getting characters positioned on screen, but it requires the entire screen be reprinted as well. I was looking for a way to position individual characters anywhere on the screen without refreshing/reprinting everything.