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
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
Tchart with dual numbers ...
by
wp
[
Today
at 10:48:18 am]
trunk compiler bug for mi...
by
Key-Real
[
Today
at 10:44:52 am]
Generics - correct syntax
by
VisualLab
[
Today
at 10:23:16 am]
match automatic highlight...
by
Чебурашка
[
Today
at 10:07:45 am]
Compile/Convert Delphi pr...
by
TRon
[
Today
at 09:59:52 am]
add new targets to make
by
Key-Real
[
Today
at 09:38:23 am]
Debugger crashes with App...
by
Martin_fr
[
Today
at 09:29:46 am]
Copyrights Q
by
BrassGear
[
Today
at 09:13:14 am]
[SOLVED] how to build the...
by
Key-Real
[
Today
at 09:12:33 am]
Quirky windows
by
tetrastes
[
Today
at 08:59:06 am]
May be useful to somebody
by
Handoko
[
Today
at 07:35:48 am]
How can I draw a rectangl...
by
Handoko
[
Today
at 07:30:55 am]
Draw a line in the Scroll...
by
Handoko
[
Today
at 07:27:54 am]
Offical launch of the 1 B...
by
Handoko
[
Today
at 06:05:11 am]
web development using pas...
by
Nate897
[
Today
at 02:04:05 am]
questionable function def...
by
440bx
[
Today
at 01:35:28 am]
Why isn't TTIRadioGroup's...
by
jamie
[
Today
at 12:13:45 am]
Same project and two Pcs
by
caiov1n1c1us
[
Today
at 12:04:00 am]
v3.99 code completion que...
by
440bx
[April 22, 2024, 11:08:26 pm]
[SOLVED]RichMemo StringRe...
by
KodeZwerg
[April 22, 2024, 08:44:40 pm]
[SOLVED] LAMW/Linux - Ins...
by
Alcatiz
[April 22, 2024, 08:04:06 pm]
[SOLVED] TimeStampToMSecs...
by
korba812
[April 22, 2024, 06:23:33 pm]
Access violation when re-...
by
cdbc
[April 22, 2024, 05:39:59 pm]
FPDebug: Evaluate/Modify ...
by
bpranoto
[April 22, 2024, 03:14:12 pm]
Your best UI design - con...
by
lainz
[April 22, 2024, 02:28:00 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Draw ANSI/ASCII art in terminal support and suggestions wanted. (Read 3179 times)
d-_-b
New Member
Posts: 43
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: 11455
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