comp.lang.ada
 help / color / mirror / Atom feed
* Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?)
@ 2018-08-04  1:37 Hazz
  2018-08-04  1:59 ` Lucretia
                   ` (3 more replies)
  0 siblings, 4 replies; 22+ messages in thread
From: Hazz @ 2018-08-04  1:37 UTC (permalink / raw)


Hello,

I'm pretty new to Ada.

Can we print coloured text to the terminal?

Other languages permit the use of ANSI escape sequences, i.e. in Python (for example) I'd write

    print("\033[93mHowdy!\033[0m")

And "Howdy!" appears in orange on my screen.

How can I do this in Ada? I tried using Ada.Characters.Latin_1 ESC characters, but it just prints plaintext.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?)
  2018-08-04  1:37 Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?) Hazz
@ 2018-08-04  1:59 ` Lucretia
  2018-08-04  2:21 ` Hazz
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 22+ messages in thread
From: Lucretia @ 2018-08-04  1:59 UTC (permalink / raw)


On Saturday, 4 August 2018 02:37:39 UTC+1, Hazz  wrote:
> Hello,
> 
> I'm pretty new to Ada.
> 
> Can we print coloured text to the terminal?
> 
> Other languages permit the use of ANSI escape sequences, i.e. in Python (for example) I'd write
> 
>     print("\033[93mHowdy!\033[0m")
> 
> And "Howdy!" appears in orange on my screen.
> 
> How can I do this in Ada? I tried using Ada.Characters.Latin_1 ESC characters, but it just prints plaintext.

https://github.com/search?utf8=%E2%9C%93&q=ansi++language%3AAda&type=Repositories&ref=advsearch&l=Ada&l=


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?)
  2018-08-04  1:37 Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?) Hazz
  2018-08-04  1:59 ` Lucretia
@ 2018-08-04  2:21 ` Hazz
  2018-08-04  9:07 ` Jeffrey R. Carter
  2018-08-07  0:01 ` Aurele
  3 siblings, 0 replies; 22+ messages in thread
From: Hazz @ 2018-08-04  2:21 UTC (permalink / raw)


I solved it!

Turns out that "\033" is the ACII escape character, not part of the ANSI encoding itself, so I have to modify the code to be:

    Put_Line(ESC + "[93mHowdy!" ESC + "[0m");

And it works!


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?)
  2018-08-04  1:37 Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?) Hazz
  2018-08-04  1:59 ` Lucretia
  2018-08-04  2:21 ` Hazz
@ 2018-08-04  9:07 ` Jeffrey R. Carter
  2018-08-06  6:35   ` briot.emmanuel
  2018-08-07  0:01 ` Aurele
  3 siblings, 1 reply; 22+ messages in thread
From: Jeffrey R. Carter @ 2018-08-04  9:07 UTC (permalink / raw)


On 08/04/2018 03:37 AM, Hazz wrote:
> 
> How can I do this in Ada? I tried using Ada.Characters.Latin_1 ESC characters, but it just prints plaintext.

That should work (and it appears from your later post that it did). You could 
look at pkg PragmARC.ANSI_TTY_Control

https://github.com/jrcarter/PragmARC

It doesn't do colors, since at the time it was developed (c. 1990) colors 
weren't very portable, and this is not used much these days, but it should serve 
as a guide for how to do it.

-- 
Jeff Carter
"The time has come to act, and act fast. I'm leaving."
Blazing Saddles
36

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?)
  2018-08-04  9:07 ` Jeffrey R. Carter
@ 2018-08-06  6:35   ` briot.emmanuel
  2018-08-06 22:15     ` Randy Brukardt
  0 siblings, 1 reply; 22+ messages in thread
From: briot.emmanuel @ 2018-08-06  6:35 UTC (permalink / raw)



You can also take a look at GNATCOLL.terminal, in the GNAT Components Collection. It will do colors either using ansi escape sequences or, on Windows, proper system calls. In terms of portability, better to think early on that not all terminals support escape sequences...

Manu


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?)
  2018-08-06  6:35   ` briot.emmanuel
@ 2018-08-06 22:15     ` Randy Brukardt
  2018-08-07  5:12       ` Per Sandberg
  2018-08-07  8:33       ` Dmitry A. Kazakov
  0 siblings, 2 replies; 22+ messages in thread
From: Randy Brukardt @ 2018-08-06 22:15 UTC (permalink / raw)


<briot.emmanuel@gmail.com> wrote in message 
news:810948b7-1370-4c0d-aaf3-ed66b7dfbba5@googlegroups.com...

>You can also take a look at GNATCOLL.terminal, in the GNAT
>Components Collection. It will do colors either using ansi escape
>sequences or, on Windows, proper system calls. In terms of
>portability, better to think early on that not all terminals support
>escape sequences...

And they don't all support the same escape sequences, either. But most 
important is that Windows almost never supports escape sequences, so any 
code that you want to be reasonably portable has to avoid them. (If you want 
it really portable, that is to work with other Ada compileers, you have to 
avoid GNATCOLL, too, since it is GNAT-specific.)

                                                   Randy.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?)
  2018-08-04  1:37 Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?) Hazz
                   ` (2 preceding siblings ...)
  2018-08-04  9:07 ` Jeffrey R. Carter
@ 2018-08-07  0:01 ` Aurele
  2018-08-12 20:56   ` Matt Borchers
  3 siblings, 1 reply; 22+ messages in thread
From: Aurele @ 2018-08-07  0:01 UTC (permalink / raw)


Windows 10 now inherently supports the almost complete set of ANSI escape sequences. I wrote my own virtual console terminal (all in Ada) and it works great. Here is the Windows documentation link:

https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?)
  2018-08-06 22:15     ` Randy Brukardt
@ 2018-08-07  5:12       ` Per Sandberg
  2018-08-07 22:31         ` Randy Brukardt
  2018-08-07  8:33       ` Dmitry A. Kazakov
  1 sibling, 1 reply; 22+ messages in thread
From: Per Sandberg @ 2018-08-07  5:12 UTC (permalink / raw)




On 08/07/18 00:15, Randy Brukardt wrote:
> <briot.emmanuel@gmail.com> wrote in message
> news:810948b7-1370-4c0d-aaf3-ed66b7dfbba5@googlegroups.com...
> 
>> You can also take a look at GNATCOLL.terminal, in the GNAT
>> Components Collection. It will do colors either using ansi escape
>> sequences or, on Windows, proper system calls. In terms of
>> portability, better to think early on that not all terminals support
>> escape sequences...
> 
> And they don't all support the same escape sequences, either. But most
> important is that Windows almost never supports escape sequences, so any
> code that you want to be reasonably portable has to avoid them. (If you want
> it really portable, that is to work with other Ada compileers, you have to
> avoid GNATCOLL, too, since it is GNAT-specific.)
> 
>                                                     Randy.
> 
> 
> 

Yes these source-code libraries are strongly associated with GNAT, but 
most of the code is compilable with "any" ada-12 compiler without change 
and they are battle proven so whey not use them instead of reinventing 
the wheel.

/P


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?)
  2018-08-06 22:15     ` Randy Brukardt
  2018-08-07  5:12       ` Per Sandberg
@ 2018-08-07  8:33       ` Dmitry A. Kazakov
  2018-08-07 13:59         ` Dan'l Miller
  2018-08-07 22:36         ` Randy Brukardt
  1 sibling, 2 replies; 22+ messages in thread
From: Dmitry A. Kazakov @ 2018-08-07  8:33 UTC (permalink / raw)


On 2018-08-07 00:15, Randy Brukardt wrote:
> <briot.emmanuel@gmail.com> wrote in message
> news:810948b7-1370-4c0d-aaf3-ed66b7dfbba5@googlegroups.com...
> 
>> You can also take a look at GNATCOLL.terminal, in the GNAT
>> Components Collection. It will do colors either using ansi escape
>> sequences or, on Windows, proper system calls. In terms of
>> portability, better to think early on that not all terminals support
>> escape sequences...
> 
> And they don't all support the same escape sequences, either. But most
> important is that Windows almost never supports escape sequences, so any
> code that you want to be reasonably portable has to avoid them.

I didn't test it, because the idea to use character terminal in XXI 
century is beyond silly, but I heard that Windows 10 cmd has them 
enabled. It took less than 3 decades to do, but they finally managed it! 
On older versions ANSI.SYS driver is required.

> (If you want
> it really portable, that is to work with other Ada compileers, you have to
> avoid GNATCOLL, too, since it is GNAT-specific.)

There are lots of GUI frameworks with Ada support for Windows as well as 
raw Windows GDI bindings. No reason to mess with terminal commands.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?)
  2018-08-07  8:33       ` Dmitry A. Kazakov
@ 2018-08-07 13:59         ` Dan'l Miller
  2018-08-07 22:36         ` Randy Brukardt
  1 sibling, 0 replies; 22+ messages in thread
From: Dan'l Miller @ 2018-08-07 13:59 UTC (permalink / raw)


On Tuesday, August 7, 2018 at 3:33:47 AM UTC-5, Dmitry A. Kazakov wrote:
> On 2018-08-07 00:15, Randy Brukardt wrote:
> > Briot Emmanuel wrote in message
> > news:810948b7-1370-4c0d-aaf3-ed66b7dfbba5@googlegroups.com...
> > 
> >> You can also take a look at GNATCOLL.terminal, in the GNAT
> >> Components Collection. It will do colors either using ansi escape
> >> sequences or, on Windows, proper system calls. In terms of
> >> portability, better to think early on that not all terminals support
> >> escape sequences...
> > 
> > And they don't all support the same escape sequences, either. But most
> > important is that Windows almost never supports escape sequences, so any
> > code that you want to be reasonably portable has to avoid them.
> 
> I didn't test it, because the idea to use character terminal in XXI 
> century is beyond silly, …

Conversely, on the major widely-deployed UIs/UXes {X Window, Win32, Windows UWP, Cocoa, Cocoa Touch, Android, Java Swing} the •only• technology in common among all of them is terminfo/termcap-specified POSIX terminals for escape-sequence ChUIs in terminal windows.  Some of us still appreciate the ability to fire up Vi or Emacs in terminfo-/termcap-specified ChUI mode.  Indeed, some of us still appreciate the ability to use old software that isn't forcibly deprecated due to fads & fashions.  (Which is worse?  1. Escape-sequence ChUI still working versus 2. deprecation of Display Postcript of yesteryear or Mir nowadays, as fads & fantasies pass us by. )  And even more to the point, how much churn & vicious not-invented-here/not-in-my-backyard tug-of-war has Gnome and KDE (and Ubuntu's divergent UX/UI strategy du jour) gone through in recent years for no good reason?

the purported replacement for X Window 11:
https://en.wikipedia.org/wiki/Mir_(software)

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?)
  2018-08-07  5:12       ` Per Sandberg
@ 2018-08-07 22:31         ` Randy Brukardt
  2018-08-08  6:39           ` Per Sandberg
  0 siblings, 1 reply; 22+ messages in thread
From: Randy Brukardt @ 2018-08-07 22:31 UTC (permalink / raw)


"Per Sandberg" <per.s.sandberg@bahnhof.se> wrote in message 
news:FS9aD.1212605$Vv2.679376@fx06.am4...
...
> Yes these source-code libraries are strongly associated with GNAT, but 
> most of the code is compilable with "any" ada-12 compiler without change 
> and they are battle proven so whey not use them instead of reinventing the 
> wheel.

(1) There aren't any other full Ada-2012 compilers, so this is an empty 
statement. Portable Ada code has to be in Ada 2005 at most.
(2) Code that is truly portable has to be have been compiled with multiple 
Ada compilers. Every Ada compiler has bugs, and some of those bugs include 
allowing too much. (Experience is that around 20% of new ACATS tests for 
existing features fail on existing compilers; that seems pretty constant 
regardless of whose compiler you are talking about. Errors of omission are 
extremely difficult to detect.)

You can't really know if you've used some feature that isn't supposed to be 
legal until you've at least tried the code on other compilers. You also 
can't easily see if you've unintentionally used compiler-specific stuff. 
Most of the GNAT libraries I've looked at are full of 'Img and 
'Unrestricted_Access and similar non-Ada things.
(3) I personally only care about things that will compile with Janus/Ada 
(90% of what I write starts there), and it is (intentionally) weird enough 
that nothing much will work. For instance, Integer is 16-bit on Janus/Ada, 
and that seems to break about 100% of outside code I try on it.

                                                 Randy.



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?)
  2018-08-07  8:33       ` Dmitry A. Kazakov
  2018-08-07 13:59         ` Dan'l Miller
@ 2018-08-07 22:36         ` Randy Brukardt
  2018-08-09 17:08           ` G. B.
  1 sibling, 1 reply; 22+ messages in thread
From: Randy Brukardt @ 2018-08-07 22:36 UTC (permalink / raw)


"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> wrote in message 
news:pkblh9$b97$1@gioia.aioe.org...
> On 2018-08-07 00:15, Randy Brukardt wrote:
>> <briot.emmanuel@gmail.com> wrote in message
>> news:810948b7-1370-4c0d-aaf3-ed66b7dfbba5@googlegroups.com...
>>
>>> You can also take a look at GNATCOLL.terminal, in the GNAT
>>> Components Collection. It will do colors either using ansi escape
>>> sequences or, on Windows, proper system calls. In terms of
>>> portability, better to think early on that not all terminals support
>>> escape sequences...
>>
>> And they don't all support the same escape sequences, either. But most
>> important is that Windows almost never supports escape sequences, so any
>> code that you want to be reasonably portable has to avoid them.
>
> I didn't test it, because the idea to use character terminal in XXI 
> century is beyond silly, but I heard that Windows 10 cmd has them enabled. 
> It took less than 3 decades to do, but they finally managed it! On older 
> versions ANSI.SYS driver is required.

Really? Why?

ANSI.SYS was depreciated some decades ago; my understanding was that it was 
unsupported on Windows 7 and 8. Going back the dinosaur age makes little 
sense (and causes security issues).

There's really no good reason to use TUIs anyway; either write a proper GUI 
or use a browser for your interface (HTML is no harder to write than escape 
sequences). If that's overkill, then basic Put_Line is enough.

                                                    Randy.




^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?)
  2018-08-07 22:31         ` Randy Brukardt
@ 2018-08-08  6:39           ` Per Sandberg
  2018-08-08 17:59             ` Randy Brukardt
  0 siblings, 1 reply; 22+ messages in thread
From: Per Sandberg @ 2018-08-08  6:39 UTC (permalink / raw)




On 08/08/18 00:31, Randy Brukardt wrote:
> "Per Sandberg" <per.s.sandberg@bahnhof.se> wrote in message
> news:FS9aD.1212605$Vv2.679376@fx06.am4...
> ...
>> Yes these source-code libraries are strongly associated with GNAT, but
>> most of the code is compilable with "any" ada-12 compiler without change
>> and they are battle proven so whey not use them instead of reinventing the
>> wheel.
> 
> (1) There aren't any other full Ada-2012 compilers, so this is an empty
> statement. Portable Ada code has to be in Ada 2005 at most.
> (2) Code that is truly portable has to be have been compiled with multiple
> Ada compilers. Every Ada compiler has bugs, and some of those bugs include
> allowing too much. (Experience is that around 20% of new ACATS tests for
> existing features fail on existing compilers; that seems pretty constant
> regardless of whose compiler you are talking about. Errors of omission are
> extremely difficult to detect.)
> 
> You can't really know if you've used some feature that isn't supposed to be
> legal until you've at least tried the code on other compilers. You also
> can't easily see if you've unintentionally used compiler-specific stuff.
> Most of the GNAT libraries I've looked at are full of 'Img and
> 'Unrestricted_Access and similar non-Ada things.
> (3) I personally only care about things that will compile with Janus/Ada
> (90% of what I write starts there), and it is (intentionally) weird enough
> that nothing much will work. For instance, Integer is 16-bit on Janus/Ada,
> and that seems to break about 100% of outside code I try on it.
> 
>                                                   Randy.
> 
> 
> 
Randy,
I think you put the finger on the problem with time, and that is that 
time implies change. And to require every newly written software to be 
compatible with every previous compiler does not work since that would 
mean freezing time. However to require new compilers to accept old code 
(sometimes with minor modification due to new keywords for example) is 
complete different story.
And time still ticks with the Ada202x reference manual available as draft.

Its exactly the same with C++ where we got C++98, C++03, C++11, C++14, 
C++17, and C++20 lurking in the shadows, where the where the main 
difference compared to Ada is that the pain to throw C++98-code on an 
C++19-compiler is huge whereas the pain to throw Ada83-code to 
Ada12-compiler is fairly negligible.
And to throw C++17 code on an C++03 compiler is completely unthinkable.

/Per


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?)
  2018-08-08  6:39           ` Per Sandberg
@ 2018-08-08 17:59             ` Randy Brukardt
  2018-08-08 18:28               ` Dmitry A. Kazakov
  0 siblings, 1 reply; 22+ messages in thread
From: Randy Brukardt @ 2018-08-08 17:59 UTC (permalink / raw)


"Per Sandberg" <per.s.sandberg@bahnhof.se> wrote in message 
news:LewaD.910619$aC7.586128@fx03.fr7...
...
> I think you put the finger on the problem with time, and that is that time 
> implies change. And to require every newly written software to be 
> compatible with every previous compiler does not work since that would 
> mean freezing time. However to require new compilers to accept old code 
> (sometimes with minor modification due to new keywords for example) is 
> complete different story.

That only makes sense for code that was created to be portable.

That requires that the code was compiled on multiple Ada compilers, lest it 
depend on incorrect implementations of Ada or vendor-specific 
features/interpretations. By definition, that cannot be the case for Ada 
2012 code, since there is no other such compiler. I was only worrying about 
currently supported Ada compilers: ObjectAda (bit of Ada 2012, full Ada 
2005), Apex (full Ada 2005), Irvine (full Ada 2005), and Janus/Ada (little 
bit of everything, not a whole lot of anything :-)

The alternative is to say that every Ada compiler has to clone GNAT, 
including all of its unique (and unimplementable in other technologies) 
features like Unrestricted_Access -- rather than implement the Ada language 
as defined. In that case, there is no real point to even having an Ada 
standard or even other Ada compilers (they could never match up to the 
"original").

That's not my idea of a healthy marketplace where the best 
ideas/implementations have an opportunity to win. Nor is it practical for 
Janus/Ada: for instance, changing the definition of Integer would break 
binary compatibility for all of our customers (Sequential_IO, Direct_IO, 
Stream_IO), which isn't a reasonable thing to do. Code sharing of generics 
is not allowed in such a world (it's incompatible at the margins with GNAT), 
meaning several man-years of re-engineering (and loss of capability, too). 
And so on.

For a substantial portion of Ada users, GNAT lock-in isn't a problem. Then 
use GNATCOLL and lots of other GNAT-specific software. For people that don't 
want to be locked in, care is needed.

                                                 Randy.






^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?)
  2018-08-08 17:59             ` Randy Brukardt
@ 2018-08-08 18:28               ` Dmitry A. Kazakov
  2018-08-08 19:23                 ` Dan'l Miller
  0 siblings, 1 reply; 22+ messages in thread
From: Dmitry A. Kazakov @ 2018-08-08 18:28 UTC (permalink / raw)


On 2018-08-08 19:59, Randy Brukardt wrote:
> "Per Sandberg" <per.s.sandberg@bahnhof.se> wrote in message
> news:LewaD.910619$aC7.586128@fx03.fr7...
> ...
>> I think you put the finger on the problem with time, and that is that time
>> implies change. And to require every newly written software to be
>> compatible with every previous compiler does not work since that would
>> mean freezing time. However to require new compilers to accept old code
>> (sometimes with minor modification due to new keywords for example) is
>> complete different story.
> 
> That only makes sense for code that was created to be portable.
> 
> That requires that the code was compiled on multiple Ada compilers, lest it
> depend on incorrect implementations of Ada or vendor-specific
> features/interpretations. By definition, that cannot be the case for Ada
> 2012 code, since there is no other such compiler. I was only worrying about
> currently supported Ada compilers: ObjectAda (bit of Ada 2012, full Ada
> 2005), Apex (full Ada 2005), Irvine (full Ada 2005), and Janus/Ada (little
> bit of everything, not a whole lot of anything :-)

In this context, what about the move AdaCore made recently with GNAT 
Community 2018? They disabled all older Ada compatibility modes 83, 95, 
2015. Only Ada 2012 is available now.

Any conspiracy theorists here? (:-))

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?)
  2018-08-08 18:28               ` Dmitry A. Kazakov
@ 2018-08-08 19:23                 ` Dan'l Miller
  0 siblings, 0 replies; 22+ messages in thread
From: Dan'l Miller @ 2018-08-08 19:23 UTC (permalink / raw)


On Wednesday, August 8, 2018 at 1:28:55 PM UTC-5, Dmitry A. Kazakov wrote:
> On 2018-08-08 19:59, Randy Brukardt wrote:
> > "Per Sandberg" wrote in message
> > news:LewaD.910619$aC7.586128@fx03.fr7...
> > ...
> >> I think you put the finger on the problem with time, and that is that time
> >> implies change. And to require every newly written software to be
> >> compatible with every previous compiler does not work since that would
> >> mean freezing time. However to require new compilers to accept old code
> >> (sometimes with minor modification due to new keywords for example) is
> >> complete different story.
> > 
> > That only makes sense for code that was created to be portable.
> > 
> > That requires that the code was compiled on multiple Ada compilers, lest it
> > depend on incorrect implementations of Ada or vendor-specific
> > features/interpretations. By definition, that cannot be the case for Ada
> > 2012 code, since there is no other such compiler. I was only worrying about
> > currently supported Ada compilers: ObjectAda (bit of Ada 2012, full Ada
> > 2005), Apex (full Ada 2005), Irvine (full Ada 2005), and Janus/Ada (little
> > bit of everything, not a whole lot of anything :-)
> 
> In this context, what about the move AdaCore made recently with GNAT 
> Community 2018? They disabled all older Ada compatibility modes 83, 95, 
> [2005]. Only Ada 2012 is available now.
> 
> Any conspiracy theorists here? (:-))

Just the usual & customary one, as is their habit:  AdaCore gives away only the single •most-recent• stabilized era of Ada (plus partial support for the next era) for free in each release, converting any prior era of Ada over to paying-customers-only.  It is a way to strongly encourage users of Ada to pay support fees to avoid churn by staying with, say, Ada2005 for many years without any Ada2012 or Ada2020 changes/AIs to existing-feature semantics.

Don't want to pay at all?  Then expect semantic churn as Ada2020 features are added and as AI-reported defects cause even the slight adjustment within Ada83-to-Ada2016-era features post-Ada2012's TC1.  As based on their past behavior, I foresee that AdaCore would likely remove Ada2012 support from some future GPL Community Edition once Ada2020 becomes normative & fully implemented.

To be fair to AdaCore, it does cost a nontrivial amount of effort to maintain Ada83-end-of-era (i.e., Ada87) semantics in isolation from Ada95-end-of-era (i.e., Ada2000) semantics in isolation from Ada2005-end-of-era (i.e., Ada2007) semantics in isolation from Ada2012-end-of-era (i.e., Ada2016) semantics in isolation from current-wavefront Ada2020-evolving semantics.  Changing this without disturbing that at all always costs time, effort, and money, which in turn is passed on as a value-add to the paying customer who dearly values that additional level of loving-touch service.


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?)
  2018-08-07 22:36         ` Randy Brukardt
@ 2018-08-09 17:08           ` G. B.
  0 siblings, 0 replies; 22+ messages in thread
From: G. B. @ 2018-08-09 17:08 UTC (permalink / raw)


Randy Brukardt <randy@rrsoftware.com> wrote:
> 
> Really? Why?
> 
> ANSI.SYS was depreciated some decades ago; my understanding was that it was 
> unsupported on Windows 7 and 8. Going back the dinosaur age makes little 
> sense (and causes security issues).

Not sure if it is related but PowerShell has text I/O functions that can
take an option that affects color.

Also, many GUIs place a rectangle around pieces of text. Does this make
them graphic?


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?)
  2018-08-07  0:01 ` Aurele
@ 2018-08-12 20:56   ` Matt Borchers
  2018-08-13 10:23     ` Aurele Vitali
  0 siblings, 1 reply; 22+ messages in thread
From: Matt Borchers @ 2018-08-12 20:56 UTC (permalink / raw)


On Monday, August 6, 2018 at 8:01:39 PM UTC-4, Aurele Vitali wrote:
> Windows 10 now inherently supports the almost complete set of ANSI escape sequences. I wrote my own virtual console terminal (all in Ada) and it works great. Here is the Windows documentation link:
> 
> https://docs.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences

I have Windows 10 (up-to-date Home edition) and neither the Command Console nor Powershell will recognize the escape sequences.  They are recognized when running the program within GPS.

Is there something special that needs to be enabled to get these to work?

I have a very old Linux console program I'd love to try to resurrect on Windows.

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?)
  2018-08-12 20:56   ` Matt Borchers
@ 2018-08-13 10:23     ` Aurele Vitali
  2018-08-16  9:58       ` alby.gamper
  0 siblings, 1 reply; 22+ messages in thread
From: Aurele Vitali @ 2018-08-13 10:23 UTC (permalink / raw)


As described in the link I previously linked, in order for the new Windows 10 Console to recognize ANSI escape sequences you must first enable the virtual terminal mode by first calling (from within your Ada program) the "SetConsoleMode" API and setting the "ENABLE_VIRTUAL_TERMINAL_PROCESSING" flag.   You can also look at the following link and write your own VT100 emulator...

https://gist.github.com/tomzorz/6142d69852f831fb5393654c90a1f22e
 
I did something more elaborate, but it works fine.

Cheers


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?)
  2018-08-13 10:23     ` Aurele Vitali
@ 2018-08-16  9:58       ` alby.gamper
  2018-08-16 12:29         ` Aurele Vitali
  0 siblings, 1 reply; 22+ messages in thread
From: alby.gamper @ 2018-08-16  9:58 UTC (permalink / raw)


On Monday, August 13, 2018 at 8:23:07 PM UTC+10, Aurele Vitali wrote:
> As described in the link I previously linked, in order for the new Windows 10 Console to recognize ANSI escape sequences you must first enable the virtual terminal mode by first calling (from within your Ada program) the "SetConsoleMode" API and setting the "ENABLE_VIRTUAL_TERMINAL_PROCESSING" flag.   You can also look at the following link and write your own VT100 emulator...
> 
> https://gist.github.com/tomzorz/6142d69852f831fb5393654c90a1f22e
>  
> I did something more elaborate, but it works fine.
> 
> Cheers

Hi Aurele

I have used your C# code sample and converted it to Ada (and using the win32
bindings) and it works/looks fine also.

See https://github.com/Alex-Gamper/Ada-Win32/tree/master/Examples/Vt100

Note: this was coded up as a simple test of the Win32 bindings, which actually
highlighted issues with the conversion of the C/C++ pre-processor macros!
(which have now been resolved on the 'master' branch on GitHub)

Alex


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?)
  2018-08-16  9:58       ` alby.gamper
@ 2018-08-16 12:29         ` Aurele Vitali
  2018-08-16 12:52           ` alby.gamper
  0 siblings, 1 reply; 22+ messages in thread
From: Aurele Vitali @ 2018-08-16 12:29 UTC (permalink / raw)


Very nice Alex, and remember if you prefer a fullscreen mood (just like an actual VT100 terminal), simply insert a "SetConsoleDisplayMode" API call with the "CONSOLE_FULLSCREEN_MODE" flag set.  You might also want to write your own thin Win32 spec. Just include something like this:

function SetConsoleDisplayMode (
                                ConOut_Ref : access System.Address;
                                Flags      : Interfaces.C.unsigned_long;
                                Buffer_Ref : Coord_Ref
                               )
                               return Interfaces.C.int

with Import        => True,
     Convention    => StdCall,
     External_Name => "SetConsoleDisplayMode";

Also,  Windows 10 supports two screen buffers (see Alternate Screen Buffer in my first link): The main buffer has scroll bars,  the other has none.  Have fun!

^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?)
  2018-08-16 12:29         ` Aurele Vitali
@ 2018-08-16 12:52           ` alby.gamper
  0 siblings, 0 replies; 22+ messages in thread
From: alby.gamper @ 2018-08-16 12:52 UTC (permalink / raw)


On Thursday, August 16, 2018 at 10:29:11 PM UTC+10, Aurele Vitali wrote:
> Very nice Alex, and remember if you prefer a fullscreen mood (just like an actual VT100 terminal), simply insert a "SetConsoleDisplayMode" API call with the "CONSOLE_FULLSCREEN_MODE" flag set.  You might also want to write your own thin Win32 spec. Just include something like this:
> 
> function SetConsoleDisplayMode (
>                                 ConOut_Ref : access System.Address;
>                                 Flags      : Interfaces.C.unsigned_long;
>                                 Buffer_Ref : Coord_Ref
>                                )
>                                return Interfaces.C.int
> 
> with Import        => True,
>      Convention    => StdCall,
>      External_Name => "SetConsoleDisplayMode";
> 
> Also,  Windows 10 supports two screen buffers (see Alternate Screen Buffer in my first link): The main buffer has scroll bars,  the other has none.  Have fun!

Thanks Aurele, I hadn't thought of testing against Vt100 full screen mode, and
I will try (time permitting) to update the sample code accordingly

^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2018-08-16 12:52 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-04  1:37 Can Ada print coloured/styled text to the terminal? (ANSI escape sequences?) Hazz
2018-08-04  1:59 ` Lucretia
2018-08-04  2:21 ` Hazz
2018-08-04  9:07 ` Jeffrey R. Carter
2018-08-06  6:35   ` briot.emmanuel
2018-08-06 22:15     ` Randy Brukardt
2018-08-07  5:12       ` Per Sandberg
2018-08-07 22:31         ` Randy Brukardt
2018-08-08  6:39           ` Per Sandberg
2018-08-08 17:59             ` Randy Brukardt
2018-08-08 18:28               ` Dmitry A. Kazakov
2018-08-08 19:23                 ` Dan'l Miller
2018-08-07  8:33       ` Dmitry A. Kazakov
2018-08-07 13:59         ` Dan'l Miller
2018-08-07 22:36         ` Randy Brukardt
2018-08-09 17:08           ` G. B.
2018-08-07  0:01 ` Aurele
2018-08-12 20:56   ` Matt Borchers
2018-08-13 10:23     ` Aurele Vitali
2018-08-16  9:58       ` alby.gamper
2018-08-16 12:29         ` Aurele Vitali
2018-08-16 12:52           ` alby.gamper

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox