Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Free Pascal
»
FV/Textmode IDE
(Moderators:
FPK
,
Tomas Hajny
) »
Draw ANSI/ASCII art in terminal support and suggestions wanted.
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
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Frustrating Error When us...
by
jamie
[
Today
at 03:05:27 am]
StrMath.pas a String Numb...
by
srvaldez
[
Today
at 03:03:50 am]
Published sets in FPC are...
by
Fred vS
[
Today
at 02:58:25 am]
Debian removes FPC/Lazaru...
by
robert rozee
[
Today
at 02:51:03 am]
'Rounding' to (say) 5 DP
by
LV
[February 17, 2026, 11:51:29 pm]
Is it possible to create ...
by
LeP
[February 17, 2026, 11:20:42 pm]
Status of FPC 3.4.0 or FP...
by
PascalDragon
[February 17, 2026, 09:25:01 pm]
lazarus project
by
dseligo
[February 17, 2026, 09:17:17 pm]
MVP made easier.
by
cdbc
[February 17, 2026, 09:16:07 pm]
A diary project with SQLi...
by
cdbc
[February 17, 2026, 09:03:25 pm]
[ANN] fpGUI Toolkit v2.0....
by
PascalDragon
[February 17, 2026, 08:49:17 pm]
Form has no Taskbar entry...
by
n7800
[February 17, 2026, 07:48:59 pm]
DCPcrypt v2.0.6 — Cryptog...
by
Ten_Mile_Hike
[February 17, 2026, 07:40:22 pm]
[SOLVED] Lazarus recompil...
by
creaothceann
[February 17, 2026, 07:37:12 pm]
4.4 messed with the proje...
by
QEnnay
[February 17, 2026, 07:26:00 pm]
Anyone else getting a tro...
by
dseligo
[February 17, 2026, 07:24:37 pm]
Duplicated icon in the Wi...
by
n7800
[February 17, 2026, 06:11:54 pm]
[AGGPas] Difference betwe...
by
cdbc
[February 17, 2026, 05:02:28 pm]
[SOLVED] Statically linki...
by
marcov
[February 17, 2026, 04:56:09 pm]
pas2js WebAssembly SQLite...
by
PierceNg
[February 17, 2026, 03:32:46 pm]
My AGGPas examples
by
Roland57
[February 17, 2026, 02:10:03 pm]
Datatype of Fields in sql...
by
Dzandaa
[February 17, 2026, 01:46:59 pm]
TurboBird IBX
by
valdir.marcos
[February 17, 2026, 10:38:16 am]
Delphi Magazine issues 1-...
by
valdir.marcos
[February 17, 2026, 10:37:33 am]
We are starting to use La...
by
dbannon
[February 17, 2026, 06:25:04 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Draw ANSI/ASCII art in terminal support and suggestions wanted. (Read 4019 times)
d-_-b
New Member
Posts: 48
Draw ANSI/ASCII art in terminal support and suggestions wanted.
«
on:
April 18, 2020, 09:06:33 pm »
Hi,
I hope someone can point me to some general pascal libraries to draw ascii art border like in this examples i found on the forum?
I also tested the Unicode support on windows 10 using dos, ubuntu wsl console, and mobaxterm.
Unfortunately only mobaxterm is rendering correctly.
Code: Pascal
[Select]
[+]
[-]
program
project1
;
{$mode objfpc}{$H+}
{$APPTYPE CONSOLE}
uses
{$IFDEF WINDOWS}
Windows
,
{for setconsoleoutputcp}
{$ENDIF}
Classes
;
const
// ANSI table drawing chars
tdTopLeft
=
#27
'(0l'
#27
'(B'
;
// ┌
tdTopCenter
=
#27
'(0w'
#27
'(B'
;
// ┬
tdTopRight
=
#27
'(0k'
#27
'(B'
;
// ┐
tdMidLeft
=
#27
'(0t'
#27
'(B'
;
// ├
tdMidCenter
=
#27
'(0n'
#27
'(B'
;
// ┼
tdMidRight
=
#27
'(0u'
#27
'(B'
;
// ┤
tdBottomLeft
=
#27
'(0m'
#27
'(B'
;
// └
tdBottomCenter
=
#27
'(0v'
#27
'(B'
;
// ┴
tdBottomRight
=
#27
'(0j'
#27
'(B'
;
// ┘
tdHorzLine
=
#27
'(0q'
#27
'(B'
;
// ─
tdVertLine
=
#27
'(0x'
#27
'(B'
;
// │
var
i
:
byte
;
s
:
string
;
ch
:
Char
;
begin
{$IFDEF WINDOWS}
SetConsoleOutputCP
(
CP_UTF8
)
;
{$ENDIF}
// thanks wp, https://f...content-available-to-author-only...l.org/index.php/topic,36945.msg246843.html#msg246843
WriteLn
(
'┌──────────────────────┐'
)
;
WriteLn
(
'│ Text in a box │'
)
;
WriteLn
(
'╘══════════════════════╛'
)
;
WriteLn
;
i
:
=
0
;
for
ch
:
=
#32
to
#255
do
begin
Write
(
ch
,
' '
)
;
inc
(
i
)
;
if
i
mod
16
=
0
then
WriteLn
;
end
;
WriteLn
;
WriteLn
(
' 1 '
)
;
WriteLn
(
' ⌠ '
)
;
WriteLn
(
' │ 2 x dx = 1'
)
;
WriteLn
(
' ⌡ '
)
;
WriteLn
(
' 0 '
)
;
WriteLn
;
WriteLn
(
' __'
)
;
WriteLn
(
'√ 2 = '
,
sqrt
(
2
)
)
;
WriteLn
;
// thanks wp, https://f...content-available-to-author-only...l.org/index.php/topic,38910.msg265726.html#msg265726
// Use Unicode range "Box Drawing" in Lazarus' character map
WriteLn
(
'┏━━┓ ┏━━┓'
)
;
WriteLn
(
'┛ ┗━━┛ ┗'
)
;
WriteLn
;
// Thanks Mr Bee aka @pak_lebah, from ansicrt.pas unit
for
i
:
=
1
to
10
do
s
:
=
s
+
tdHorzLine
;
WriteLn
(
tdTopLeft
+
s
+
tdTopRight
)
;
ReadLn
;
end
.
~
Code In Online Pascal Compiler
Logged
Code: Pascal
[Select]
[+]
[-]
mov ax
,
0013h
int 10h
Denthor thanks for the vga programming tutorials
|
Download all tutorials
marcov
Administrator
Hero Member
Posts: 12656
FPC developer.
Re: Draw ANSI/ASCII art in terminal support and suggestions wanted.
«
Reply #1 on:
April 18, 2020, 09:47:23 pm »
Ansi escape sequences are not very portable, nor universal. Sometimes they need addtional drivers or configuration for emulation purposes.
Here on windows everything but the last for loop seems to be ok.
Logged
winni
Hero Member
Posts: 3197
Re: Draw ANSI/ASCII art in terminal support and suggestions wanted.
«
Reply #2 on:
April 18, 2020, 10:17:04 pm »
Hi!
You are playing around with code from the 80s.
Nearly all terminals use Unicode and not the IBM 8 Bit with the semi graphik frames - like Turbo Pascal did.
For example:
╔
is UTF8 Codepoint U2554
The codeblock in the UTF table is called
Box Drawing
and is from
U2500 .. U257F
Have a look at the UTF8 table:
https://www.utf8-chartable.de/unicode-utf8-table.pl
Winni
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Free Pascal
»
FV/Textmode IDE
(Moderators:
FPK
,
Tomas Hajny
) »
Draw ANSI/ASCII art in terminal support and suggestions wanted.
TinyPortal
© 2005-2018