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
Demo Scene Picture sinwav...
by
Gigatron
[
Today
at 12:48:52 am]
open dialog - default dir...
by
KodeZwerg
[
Today
at 12:34:53 am]
Can function be used for ...
by
jamie
[
Today
at 12:26:42 am]
DbGrid, grid column check...
by
KodeZwerg
[
Today
at 12:08:29 am]
Colore celle StringGrid
by
JuanBell
[April 24, 2024, 10:37:56 pm]
Likely bug
by
440bx
[April 24, 2024, 10:12:59 pm]
Any upgrades to fpWeb pag...
by
verasan
[April 24, 2024, 10:11:46 pm]
Web Applications with Pas...
by
Handoko
[April 24, 2024, 08:56:29 pm]
AI, NLP and CAI: Text Gen...
by
indydev
[April 24, 2024, 08:54:00 pm]
Offical launch of the 1 B...
by
Gustavo 'Gus' Carreno
[April 24, 2024, 08:48:22 pm]
Multidimensional arrays a...
by
KodeZwerg
[April 24, 2024, 08:34:38 pm]
Ho Ho Ho IntraWeb in Laza...
by
Thaddy
[April 24, 2024, 08:31:29 pm]
[SOLVED] System.Now gives...
by
alpine
[April 24, 2024, 08:29:19 pm]
Installing and using Vamp...
by
Odacir
[April 24, 2024, 07:58:22 pm]
Demo Scene Bitmap Font Sc...
by
KodeZwerg
[April 24, 2024, 07:21:14 pm]
what's difference between...
by
ASerge
[April 24, 2024, 07:09:52 pm]
splitting an image
by
KodeZwerg
[April 24, 2024, 07:07:21 pm]
Debugger error
by
bobonwhidbey
[April 24, 2024, 07:03:07 pm]
How to: create DLL file f...
by
paule32
[April 24, 2024, 07:02:31 pm]
Your best UI design - con...
by
circular
[April 24, 2024, 06:48:12 pm]
Converting a string/index...
by
1HuntnMan
[April 24, 2024, 06:35:19 pm]
Drawing grid lines on a t...
by
KodeZwerg
[April 24, 2024, 05:42:19 pm]
Compile/Convert Delphi pr...
by
Martin_fr
[April 24, 2024, 05:29:03 pm]
Lazarus features in a non...
by
Lutz Mändle
[April 24, 2024, 05:26:34 pm]
Lazarus for Windows on aa...
by
msintle
[April 24, 2024, 05:03:57 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Draw ANSI/ASCII art in terminal support and suggestions wanted. (Read 3181 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: 11459
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