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
Dynarray initialization p...
by
Martok
[
Today
at 05:39:03 pm]
Project fails on run but ...
by
dseligo
[
Today
at 05:30:42 pm]
how to change the color f...
by
Handoko
[
Today
at 05:14:06 pm]
JEDI error but unit compi...
by
bobonwhidbey
[
Today
at 05:03:48 pm]
Zeos components. Had to c...
by
Fantablup
[
Today
at 04:17:13 pm]
[SOLVED] Completion box s...
by
furious programming
[
Today
at 04:12:26 pm]
[LAMW] How to create a ca...
by
af0815
[
Today
at 03:48:16 pm]
Complex package installat...
by
wp
[
Today
at 03:38:16 pm]
A "leisure" question on W...
by
gidesa
[
Today
at 03:17:10 pm]
Curling Pythagoras Tree: ...
by
AlexTP
[
Today
at 03:07:53 pm]
[SOLVED] Combined pointer...
by
CM630
[
Today
at 02:48:41 pm]
Controlling the behavior ...
by
rvk
[
Today
at 02:35:41 pm]
Using KeyPress event, how...
by
Zvoni
[
Today
at 02:24:42 pm]
a Unit problem?
by
Thaddy
[
Today
at 01:56:12 pm]
Understanding and adjusti...
by
ArchChem
[
Today
at 12:58:12 pm]
Any upgrades to fpWeb pag...
by
marcov
[
Today
at 12:50:25 pm]
Help needed with Cairo / ...
by
Roland57
[
Today
at 12:25:16 pm]
Configure JCF messages
by
DomingoGP
[
Today
at 11:26:55 am]
IDE instability on Raspbe...
by
rvk
[
Today
at 10:37:14 am]
Boleeman's projects are p...
by
AlexTP
[
Today
at 10:18:04 am]
Your best UI design - con...
by
circular
[
Today
at 09:36:11 am]
ZeosDBO and querys using ...
by
Zvoni
[
Today
at 09:27:17 am]
STARS with line border st...
by
Boleeman
[
Today
at 09:13:29 am]
A button require administ...
by
Fibonacci
[
Today
at 05:57:21 am]
How to detect one externa...
by
d2010
[
Today
at 12:24:32 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Drawing a Box like MC (Read 520 times)
BSaidus
Hero Member
Posts: 540
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: 3237
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: 595
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