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
Using KeyPress event, how...
by
Joanna
[
Today
at 02:15:13 pm]
Project fails on run but ...
by
Thaddy
[
Today
at 02:06:57 pm]
Controlling the behavior ...
by
1HuntnMan
[
Today
at 02:06:52 pm]
a Unit problem?
by
Thaddy
[
Today
at 01:56:12 pm]
Complex package installat...
by
parcel
[
Today
at 01:48:04 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]
JEDI error but unit compi...
by
Roland57
[
Today
at 11:50:11 am]
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]
Zeos components. Had to c...
by
dbannon
[
Today
at 07:26:11 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]
Center Lost Window featur...
by
Tony Stone
[
Today
at 12:06:16 am]
A "leisure" question on W...
by
EventHorizon
[March 27, 2024, 10:18:38 pm]
need advice about the fol...
by
jamie
[March 27, 2024, 09:56:39 pm]
[SOLVED] Completion box s...
by
Martin_fr
[March 27, 2024, 08:44:09 pm]
Dialog ShowModal and an i...
by
d7_2_laz
[March 27, 2024, 08:25:18 pm]
Offical launch of the 1 B...
by
Gustavo 'Gus' Carreno
[March 27, 2024, 07:41:48 pm]
Problem setting length of...
by
Remy Lebeau
[March 27, 2024, 05:41:10 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Drawing a Box like MC (Read 519 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