Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
General
»
Drawing a Box like MC
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
IRC channel
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Send a control name to a ...
by
andyf97
[
Today
at 10:32:15 pm]
MyDbfStudio - New Admin t...
by
wp
[
Today
at 10:28:25 pm]
Synapse for oAuth1 with w...
by
arneolav
[
Today
at 10:23:04 pm]
New wiki guide on how to ...
by
Derz
[
Today
at 10:02:12 pm]
Fullscreen event?
by
Espectr0
[
Today
at 09:40:52 pm]
How to display barcode co...
by
jmpessoa
[
Today
at 09:03:18 pm]
Examples of third-party p...
by
JuhaManninen
[
Today
at 08:42:00 pm]
Setting TStringGrid exten...
by
Blaazen
[
Today
at 08:31:08 pm]
[SOLVED] Font question
by
Pe3s
[
Today
at 08:17:50 pm]
centered text in progress...
by
wp
[
Today
at 08:05:53 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Drawing a Box like MC (Read 368 times)
BSaidus
Sr. Member
Posts: 453
lazarus 1.8.4 Win8.1 / cross FreeBSD
Drawing a Box like MC
«
on:
February 03, 2023, 11:42:49 pm »
Hello.
I'm trying to draw a box like MC(midnight commander) do but, It wont work in windows or FreeBSD.
the box look like.
Code: Pascal
[Select]
[+]
[-]
WriteLn
(
' ┌──────────────────────────────────────────────────────────────────────┐ '
)
;
WriteLn
(
' │ │'
)
;
WriteLn
(
' ├──────────────────────────────────────────────────────────────────────┤'
)
;
WriteLn
(
' │ │'
)
;
WriteLn
(
' │ │'
)
;
WriteLn
(
' │ │'
)
;
WriteLn
(
' │ │'
)
;
WriteLn
(
' │ │'
)
;
WriteLn
(
' │ │'
)
;
WriteLn
(
' ├──────────────────────────────────────────────────────────────────────┤'
)
;
WriteLn
(
' │ │'
)
;
WriteLn
(
' │ │'
)
;
WriteLn
(
' │ │'
)
;
WriteLn
(
' │ │'
)
;
WriteLn
(
' │ │'
)
;
WriteLn
(
' │ │'
)
;
WriteLn
(
' ├──────────────────────────────────────────────────────────────────────┤'
)
;
WriteLn
(
' │ │'
)
;
WriteLn
(
' └──────────────────────────────────────────────────────────────────────┘'
)
;
Caracters are printed using
Code:
[Select]
ALT + CODE // CODE = 185, ....
but the result is some charaters other then wanted.
Any idea about this ??
Thank you
Logged
lazarus 1.8.4 Win8.1 / cross FreeBSD
dhukmucmur vernadh!
Blaazen
Hero Member
Posts: 3162
POKE 54296,15
Re: Drawing a Box like MC
«
Reply #1 on:
February 04, 2023, 12:00:59 am »
If you use Lazarus, try this: menu Edit -> Insert from character map ... and select tab Unicode and item "Box drawing" from the combo below.
It looks fine here, i.e. I got the same characters in writeln('╔═════╗'); and in output.
«
Last Edit: February 04, 2023, 12:03:32 am by Blaazen
»
Logged
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21
Try Eye-Candy Controls:
https://sourceforge.net/projects/eccontrols/files/
Bogen85
Hero Member
Posts: 572
Re: Drawing a Box like MC
«
Reply #2 on:
February 04, 2023, 04:20:44 am »
I asked openAI to write a program for this.
I tweaked the output slightly.
Code: Pascal
[Select]
[+]
[-]
program
TestDrawBookshelf
;
{$mode objfpc}{$H+}
uses
SysUtils
;
const
HORIZONTAL_LINE
:
AnsiString
=
#
$E2
#
$94
#
$80
;
VERTICAL_LINE
:
AnsiString
=
#
$E2
#
$94
#
$82
;
UPPER_LEFT_CORNER
:
AnsiString
=
#
$E2
#
$94
#
$8C
;
LOWER_LEFT_CORNER
:
AnsiString
=
#
$E2
#
$94
#
$94
;
UPPER_RIGHT_CORNER
:
AnsiString
=
#
$E2
#
$94
#
$90
;
LOWER_RIGHT_CORNER
:
AnsiString
=
#
$E2
#
$94
#
$98
;
LEFT_SHELF_INTERSECTION
:
AnsiString
=
#
$E2
#
$94
#
$9C
;
RIGHT_SHELF_INTERSECTION
:
AnsiString
=
#
$E2
#
$94
#
$A4
;
procedure
DrawBookshelf
(
width
:
Integer
;
shelfHeights
:
array
of
Integer
)
;
var
i
,
j
,
k
,
shelfHeight
:
Integer
;
begin
// Draw the top of the bookshelf
Write
(
UPPER_LEFT_CORNER
)
;
for
i
:
=
1
to
width
do
Write
(
HORIZONTAL_LINE
)
;
WriteLn
(
UPPER_RIGHT_CORNER
)
;
// Draw the shelves
for
i
:
=
0
to
High
(
shelfHeights
)
do
begin
shelfHeight
:
=
shelfHeights
[
i
]
;
Write
(
LEFT_SHELF_INTERSECTION
)
;
for
j
:
=
1
to
width
do
Write
(
HORIZONTAL_LINE
)
;
WriteLn
(
RIGHT_SHELF_INTERSECTION
)
;
// Draw the shelf contents
for
j
:
=
1
to
shelfHeight
do
begin
Write
(
VERTICAL_LINE
)
;
for
k
:
=
1
to
width
do
Write
(
' '
)
;
WriteLn
(
VERTICAL_LINE
)
;
end
;
end
;
// Draw the bottom of the bookshelf
Write
(
LOWER_LEFT_CORNER
)
;
for
i
:
=
1
to
width
do
Write
(
HORIZONTAL_LINE
)
;
WriteLn
(
LOWER_RIGHT_CORNER
)
;
end
;
var
width
:
Integer
;
shelfHeights
:
array
of
Integer
;
i
:
Integer
;
begin
// Get the width of the bookshelf
width
:
=
StrToInt
(
ParamStr
(
1
)
)
;
// Get the shelf heights
SetLength
(
shelfHeights
,
ParamCount
-
1
)
;
for
i
:
=
2
to
ParamCount
do
shelfHeights
[
i
-
2
]
:
=
StrToInt
(
ParamStr
(
i
)
)
;
// Draw the bookshelf
DrawBookshelf
(
width
,
shelfHeights
)
;
end
.
The above with
./testdrawbookshelf 40 5 5 0
produces:
Code: Pascal
[Select]
[+]
[-]
┌────────────────────────────────────────┐
├────────────────────────────────────────┤
│ │
│ │
│ │
│ │
│ │
├────────────────────────────────────────┤
│ │
│ │
│ │
│ │
│ │
├────────────────────────────────────────┤
└────────────────────────────────────────┘
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
Drawing a Box like MC
TinyPortal
© 2005-2018