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
InstallAware Using Lazaru...
by
TRon
[
Today
at 02:55:41 am]
Generics - correct syntax
by
Blaazen
[
Today
at 01:57:40 am]
Forum slow
by
TRon
[
Today
at 01:16:26 am]
Demoscene The Champs Crac...
by
Gigatron
[
Today
at 01:05:16 am]
How to use the Event Log?
by
n7800
[
Today
at 12:47:25 am]
v3.99 code completion que...
by
440bx
[
Today
at 12:45:55 am]
FpDebug breakpoint on "be...
by
440bx
[
Today
at 12:36:23 am]
Access violation when re-...
by
TRon
[April 19, 2024, 11:44:51 pm]
[solved] how to get class...
by
jamie
[April 19, 2024, 11:34:44 pm]
Lazarus for Windows on aa...
by
Wallaby
[April 19, 2024, 10:52:25 pm]
Poll: Watches and Display...
by
440bx
[April 19, 2024, 07:13:51 pm]
Who is Indy mattias?
by
paweld
[April 19, 2024, 04:17:53 pm]
I just released a commerc...
by
BrassGear
[April 19, 2024, 03:17:28 pm]
Does anyone know why thes...
by
Laksen
[April 19, 2024, 03:04:14 pm]
Database standards OR Am ...
by
gidesa
[April 19, 2024, 02:37:56 pm]
How to: create DLL file f...
by
TRon
[April 19, 2024, 02:26:53 pm]
A fairly simple sound sol...
by
paweld
[April 19, 2024, 01:46:11 pm]
Access violation when ope...
by
Чебурашка
[April 19, 2024, 12:27:34 pm]
Step-into the field sette...
by
Martin_fr
[April 19, 2024, 11:31:48 am]
AI, NLP and CAI: Text Gen...
by
Dzandaa
[April 19, 2024, 11:03:26 am]
dwindows for Android
by
PierceNg
[April 19, 2024, 10:54:44 am]
create system unit from s...
by
Laksen
[April 19, 2024, 10:53:57 am]
[Solved] Find child contr...
by
Joanna
[April 19, 2024, 09:53:43 am]
FpDebug unexpected Assemb...
by
Marc
[April 19, 2024, 08:46:38 am]
Offical launch of the 1 B...
by
Handoko
[April 19, 2024, 07:59:07 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Draw ANSI/ASCII art in terminal support and suggestions wanted. (Read 3163 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: 11453
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