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
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
Good opportunity for a fr...
by
dbannon
[
Today
at 12:41:07 am]
Fedora and libQtxPas
by
dbannon
[
Today
at 12:17:38 am]
Give Pascal a Second Look
by
Bogen85
[
Today
at 12:15:28 am]
Debugging problem (Steppi...
by
Curt Carpenter
[
Today
at 12:14:59 am]
TOpenDialog
by
wp
[November 01, 2024, 11:50:33 pm]
AI usefulness discussion
by
440bx
[November 01, 2024, 11:40:47 pm]
Variant Record Behavior
by
440bx
[November 01, 2024, 11:31:41 pm]
Contest: fastest IsAnagra...
by
Bart
[November 01, 2024, 11:30:11 pm]
Does a procedure in a pro...
by
Joanna from IRC
[November 01, 2024, 11:00:05 pm]
[SOLVED] Could not load S...
by
donaldklopper
[November 01, 2024, 10:45:12 pm]
[Solved] Sqlite Update on...
by
Wilko500
[November 01, 2024, 10:35:17 pm]
Strange bugs with Advance...
by
Warfley
[November 01, 2024, 10:07:57 pm]
Identifiers character set
by
PascalDragon
[November 01, 2024, 10:07:11 pm]
Fpcupdeluxe
by
DonAlfredo
[November 01, 2024, 09:19:07 pm]
LAMW Install not working
by
dseligo
[November 01, 2024, 09:08:29 pm]
Database example without ...
by
Tanto
[November 01, 2024, 08:27:28 pm]
Difference in fpc and laz...
by
HotShoe
[November 01, 2024, 08:20:30 pm]
Defining Table Structures
by
Handoko
[November 01, 2024, 06:35:05 pm]
A request or maybe its al...
by
LV
[November 01, 2024, 03:37:56 pm]
Errors when building FPC ...
by
Aruna
[November 01, 2024, 02:03:30 pm]
WS2812 LED string demo wi...
by
MarkMLl
[November 01, 2024, 12:51:02 pm]
Lazarus Release Candidate...
by
Martin_fr
[November 01, 2024, 12:51:00 pm]
How to implement a divide...
by
silvercoder70
[November 01, 2024, 12:50:37 pm]
MPlayer Component, suitab...
by
neodarkman
[November 01, 2024, 12:48:36 pm]
A simple question for Mac...
by
carl_caulkett
[November 01, 2024, 12:12:04 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Drawing a Box like MC (Read 644 times)
BSaidus
Hero Member
Posts: 575
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: 3241
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: 656
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