Forum > FV/Textmode IDE
Draw ANSI/ASCII art in terminal support and suggestions wanted.
(1/1)
d-_-b:
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. :o >:(
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---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
marcov:
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.
winni:
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
Navigation
[0] Message Index