Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Draw a box in unix

Status
Not open for further replies.

kaisalhassani

Programmer
Sep 2, 2007
8
GB
Hi

I have a function to draw a box in UNIX shell but I would like to draw a baox with a solid line.
What is the ANSI escape sequence to draw a solid lines.

My scripts is

function draw_box
{
tput clear
echo "\033[4;2H +---------------------------------------------------------------
-----------+"
cnt=5
while [[ $cnt != 24 ]]
do
echo "\033[$cnt;2H |
|"
(( cnt += 1 ))
done
echo "\033[28;2H +--------------------------------------------------------------
------------+"
}
draw_box
Exit

The output is:-


+-----------+
| |
| |
| |
+-----------+
 
this table and this table show the ANSI set. It took me 30 seconds to find it using Google.

Please try Google first.

Ceci n'est pas une signature
Columb Healy
 
Some terminals such as the VT220 have an alternate character set for drawing lines. You can use the tput smacs command to output the escape sequence for entering this mode, and tput rmacs to exit this mode. When you echo characters such as a-z in alternative character set mode you get the line-drawing characters.

Here are some examples, I'm not sure how well these will come out on this web page:

[tt]??????
? ?
??????
??????
?????°±???????????????????
abcdefghijklmnopqrstuvwxyz[/tt]

Unfortunately this has only worked reliably for me using TERM=vt220. The terminfo database for xterms doesn't seem to include this smacs/rmacs capability, even though echoing the correct escape sequences does result in line-drawing characters on some emulators such as PuTTY.

See man terminfo for information about alternate character sets.

Annihilannic.
 
Didn't you ask the same question 3 days ago?

Mike

"Whenever I dwell for any length of time on my own shortcomings, they gradually begin to seem mild, harmless, rather engaging little things, not at all like the staring defects in other people's characters."
 
What is this obsession with box-drawing?

I want to be good, is that not enough?
 
I like boxes.

Having a box gives me a place to think.

(as to which is inside and which is outside, that's completely relative)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top