comp.lang.ada
 help / color / mirror / Atom feed
* Pretty printing the pretty print.
@ 2013-09-25 10:36 Mike H
  2013-09-25 11:14 ` Georg Bauhaus
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Mike H @ 2013-09-25 10:36 UTC (permalink / raw)


For the first time ever, I have needed to print some code fragments. The 
default print file command in the GNAT studio produced black and white 
plain text. Is there something that will produce a more "illuminated" 
output?

-- 
"Why," said Ford squatting down beside him and shivering, "are you lying face
down in the dust?" "It's a very effective way of being wretched," said Marvin.
Mike ;-(

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

* Re: Pretty printing the pretty print.
  2013-09-25 10:36 Pretty printing the pretty print Mike H
@ 2013-09-25 11:14 ` Georg Bauhaus
  2013-09-25 14:27 ` Britt
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 13+ messages in thread
From: Georg Bauhaus @ 2013-09-25 11:14 UTC (permalink / raw)


On 25.09.13 12:36, Mike H wrote:
> For the first time ever, I have needed to print some code fragments. The default print file command in the GNAT studio produced black and white plain text. Is there something that will produce a more "illuminated" output?
>

Emacs has customizable highlighting; buffers can be printed.

Thomas Wolf's AdaBrowse, if it helps in this case,
http://home.datacomm.ch/t_wolf/tw/ada95/adabrowse/index.html

And, shameless plug:
http://home.arcor.de/bauhaus/Tools/ASnip/

But the latter hasn't been updated for some time...

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

* Re: Pretty printing the pretty print.
  2013-09-25 10:36 Pretty printing the pretty print Mike H
  2013-09-25 11:14 ` Georg Bauhaus
@ 2013-09-25 14:27 ` Britt
  2013-09-25 14:48   ` Mike H
  2013-09-25 14:47 ` Felix Krause
                   ` (2 subsequent siblings)
  4 siblings, 1 reply; 13+ messages in thread
From: Britt @ 2013-09-25 14:27 UTC (permalink / raw)


On Wednesday, September 25, 2013 6:36:52 AM UTC-4, Mike H wrote:
> For the first time ever, I have needed to print some code fragments. The default print file command in the GNAT studio produced black and white plain text. Is there something that will produce a more "illuminated" output?

Which platform? On Linux GPS printes using a2ps. I use the a2ps "--prologue=color" switch to print the color syntax highlighting.

For example, I have the following in my GPS->Preferences->External Command->Print command string:

a2ps --prologue=color --rows=1 --columns=1 --sides=duplex --major=rows --chars-per-line=140 --line-numbers=5

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

* Re: Pretty printing the pretty print.
  2013-09-25 10:36 Pretty printing the pretty print Mike H
  2013-09-25 11:14 ` Georg Bauhaus
  2013-09-25 14:27 ` Britt
@ 2013-09-25 14:47 ` Felix Krause
  2013-09-26 18:38 ` Manuel Gomez
  2013-09-30 12:20 ` Stefan.Lucks
  4 siblings, 0 replies; 13+ messages in thread
From: Felix Krause @ 2013-09-25 14:47 UTC (permalink / raw)


On 2013-09-25 10:36:52 +0000, Mike H said:

> For the first time ever, I have needed to print some code fragments. 
> The default print file command in the GNAT studio produced black and 
> white plain text. Is there something that will produce a more 
> "illuminated" output?

There's also GNU enscript which supports Ada syntax highlighting:

http://www.gnu.org/software/enscript/

-- 
Felix Krause
http://flyx.org/

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

* Re: Pretty printing the pretty print.
  2013-09-25 14:27 ` Britt
@ 2013-09-25 14:48   ` Mike H
  2013-09-25 15:16     ` gautier_niouzes
  2013-09-29 21:38     ` Stephen Leake
  0 siblings, 2 replies; 13+ messages in thread
From: Mike H @ 2013-09-25 14:48 UTC (permalink / raw)


In message <a0ec7acb-416a-4962-b653-dd2adf70dfd6@googlegroups.com>, 
Britt <britt.snodgrass@gmail.com> writes
>Which platform?
Please don't laugh but it is MS Windows XP.

When I last wrote Ada for a living, Ada95 was still the very latest 
thing! Now I am in my 9th decade and dabble for my own amusement.

-- 
Mike
"Homo sum, humani nihil a me alienum puto" =
"I am human, (so) I (should) judge nothing of humanity to be strange."
Publius Terentius (195/185–159 BC)


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

* Re: Pretty printing the pretty print.
  2013-09-25 14:48   ` Mike H
@ 2013-09-25 15:16     ` gautier_niouzes
  2013-09-26  4:30       ` Per Sandberg
  2013-09-27 13:25       ` Mike H
  2013-09-29 21:38     ` Stephen Leake
  1 sibling, 2 replies; 13+ messages in thread
From: gautier_niouzes @ 2013-09-25 15:16 UTC (permalink / raw)


Le mercredi 25 septembre 2013 16:48:04 UTC+2, Mike H a écrit :

> Please don't laugh but it is MS Windows XP.

Then consider: http://notepad-plus-plus.org/
It does a real pretty print - an not only to the printer, but to the clipboard too, so you can paste "pretty-printed" into Word, e-mails. etc.

XP is not a bad vintage at all, should not be laughed at...
_________________________ 
Gautier's Ada programming 
http://sf.net/users/gdemont


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

* Re: Pretty printing the pretty print.
  2013-09-25 15:16     ` gautier_niouzes
@ 2013-09-26  4:30       ` Per Sandberg
  2013-09-27 13:25       ` Mike H
  1 sibling, 0 replies; 13+ messages in thread
From: Per Sandberg @ 2013-09-26  4:30 UTC (permalink / raw)


But there is cygwin !
And if you want all good stuff follow the recipe:
1) Have all your stuff including the compiler o the same "drive".
2) Make the following mounts:
    Windows              Cygwin
    C:\(GNAT|GNATPRPO)   /(GNAT/GNATPRO)
    C:\mydevelroot       /mydevelroot
3) Update ${PATH} to be
    C:\(GNAT|GNATPRPO)\bin;C:\cygwin\bin;.........

And the tools are there.

/Per

On Wed, 25 Sep 2013 08:16:35 -0700 (PDT)
gautier_niouzes@hotmail.com wrote:

> Le mercredi 25 septembre 2013 16:48:04 UTC+2, Mike H a écrit :
> 
> > Please don't laugh but it is MS Windows XP.
> 
> Then consider: http://notepad-plus-plus.org/
> It does a real pretty print - an not only to the printer, but to the
> clipboard too, so you can paste "pretty-printed" into Word, e-mails.
> etc.
> 
> XP is not a bad vintage at all, should not be laughed at...
> _________________________ 
> Gautier's Ada programming 
> http://sf.net/users/gdemont




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

* Re: Pretty printing the pretty print.
  2013-09-25 10:36 Pretty printing the pretty print Mike H
                   ` (2 preceding siblings ...)
  2013-09-25 14:47 ` Felix Krause
@ 2013-09-26 18:38 ` Manuel Gomez
  2013-09-30 12:20 ` Stefan.Lucks
  4 siblings, 0 replies; 13+ messages in thread
From: Manuel Gomez @ 2013-09-26 18:38 UTC (permalink / raw)


El 25/09/13 12:36, Mike H escribió:
 > For the first time ever, I have needed to print some code fragments. The
 > default print file command in the GNAT studio produced black and white
 > plain text. Is there something that will produce a more "illuminated"
 > output?
 >

The Emacs editor has three printing outputs: plain text, rich format and 
b/w rich format. Try using the menu entry File -> Postscript Print 
Buffer, which invokes this Emacs command:

 >
 > ps-print-buffer-with-faces is an interactive compiled Lisp function in
 > `ps-print.el'.
 >
 > It is bound to <menu-bar> <file> <ps-print-buffer-faces>.
 >
 > (ps-print-buffer-with-faces &optional FILENAME)
 >
 > Generate and print a PostScript image of the buffer.
 > Like `ps-print-buffer', but includes font, color, and underline 
information in
 > the generated image.  This command works only if you are using a 
window system,
 > so it has a way to determine color values.

-- 
Manuel

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

* Re: Pretty printing the pretty print.
  2013-09-25 15:16     ` gautier_niouzes
  2013-09-26  4:30       ` Per Sandberg
@ 2013-09-27 13:25       ` Mike H
  2014-01-04 11:13         ` Oliver Kleinke
  1 sibling, 1 reply; 13+ messages in thread
From: Mike H @ 2013-09-27 13:25 UTC (permalink / raw)


In message <da27e87a-7341-4b83-89f7-f017bb74de18@googlegroups.com>, 
gautier_niouzes@hotmail.com writes
>Then consider: http://notepad-plus-plus.org/
>It does a real pretty print
Agreed!

However, I was unable to persuade the site to download a copy onto my 
PC. Not that it mattered because the on-line demonstration allowed me to 
do all that I wanted to do for my immediate purposes. That purpose was 
to print some code fragments in order to explain what is meant, in Ada, 
by array slices, sliding and unbounded declarations.

A C++ man working for a blue-chip organisation, he was impressed and 
also opined that Ada "seems to have a sweet syntax".

During the same conversation he asked me to write some Ada code to 
perform an exercise question he routinely sets when interviewing 
programmer candidates. Thinking on the hoof I wrote some code that in 
hind-sight was not good Ada and certainly not what I would have written 
if I had time to think the matter through. I seemed to fall straight 
into the trap that he had set. But I say "seemed" because as soon as he 
pointed out the error, and we discussed it, it became obvious that the 
trap was a situation that, in Ada, would possibly not have compiled and 
if it had would certainly have had potential for raising a constraint 
error. I refrained from pointing out that it could be argued that it was 
a specification error in that the specification did not admit that the 
difference between two indices is not an index, it is an offset.

-- 
Knowledge is knowing a tomato is a fruit
Wisdom in knowing not to put it in the fruit salad.
Mike


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

* Re: Pretty printing the pretty print.
  2013-09-25 14:48   ` Mike H
  2013-09-25 15:16     ` gautier_niouzes
@ 2013-09-29 21:38     ` Stephen Leake
  1 sibling, 0 replies; 13+ messages in thread
From: Stephen Leake @ 2013-09-29 21:38 UTC (permalink / raw)


Mike H <postmaster@ada-augusta.demon.co.uk> writes:

> In message <a0ec7acb-416a-4962-b653-dd2adf70dfd6@googlegroups.com>,
> Britt <britt.snodgrass@gmail.com> writes
>>Which platform?
> Please don't laugh but it is MS Windows XP.

Install Cygwin, use a2ps, then ps2pdf, then windows print.

-- 
-- Stephe

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

* Re: Pretty printing the pretty print.
  2013-09-25 10:36 Pretty printing the pretty print Mike H
                   ` (3 preceding siblings ...)
  2013-09-26 18:38 ` Manuel Gomez
@ 2013-09-30 12:20 ` Stefan.Lucks
  4 siblings, 0 replies; 13+ messages in thread
From: Stefan.Lucks @ 2013-09-30 12:20 UTC (permalink / raw)


[-- Attachment #1: Type: TEXT/PLAIN, Size: 2523 bytes --]

On Wed, 25 Sep 2013, Mike H wrote:

> For the first time ever, I have needed to print some code fragments. The 
> default print file command in the GNAT studio produced black and white plain 
> text. Is there something that will produce a more "illuminated" output?

If you really need syntax highlighting, rather than reformatting, then
highlight is a really good choice:

    <http://www.andre-simon.de/doku/highlight/en/highlight.html>

The minor issue is that the Ada support of highlight is at the Ada 95 
level -- since then, a few new keywords have been added, we have got the 
precondition-postcondition-type_invariant aspects, ect. I have recently 
revised the language definition to handle Ada 2012, see below.


<revised  "ada.lang" from highlight>


Description="ADA2012"

Keywords={
   { Id=1,
     List={"abort", "else", "new", "return", "abs", "elsif", "not", 
"reverse", "abstract", "end", "null", "accept", "entry", "select", 
"access", "exception", "", "separate", "", "aliased", "exit", "of", "", 
"subtype", "", "all", "or", "", "and", "", "for", "", "others", "tagged", 
"", "array", "function", "out", "task", "", "at", "terminate", "generic", 
"package", "then", "", "begin", "goto", "pragma", "type", "", "body", 
"private", "if", "procedure", "case", "in", "protected", "", "", "until", 
"", "constant", "is", "", "use", "raise", "declare", "", "", "range", 
"when", "", "delay", "limited", "record", "while", "", "delta", "loop", 
"rem", "", "with", "digits", "renames", "do", "mod", "", "requeue", "xor",
"interface", "overriding", "synchronized",
"some"},
   },
   { Id=2,
     List={"pre", "post", "type_invariant",
           "dynamic_predicate", "static_predicate"},
   },
    { Id=4,
      Regex=[[''']],
    },
   { Id=4,
     List={"true", "false"},
   },
    { Id=4,
      Regex=[[ [\w\)]+('\w+) ]],
    }

}

-- Workaround: distinguish string delimiters and event markers
-- (same eymbol: ')

--workaround for special string '''

Strings={
   Delimiter=[["|']],
   Escape = [[ \\[^'] ]]
}

IgnoreCase=true

Comments={
   { Block=false,
     Delimiter= { [[\-\-]] },
   },
}

Operators=[[\(|\)|\[|\]|\{|\}|\,|\;|\:|\&|\<|\>|\!|\=|\/|\*|\%|\+|\-|\.]]

</revised  "ada.lang" from highlight>



------  I  love  the  taste  of  Cryptanalysis  in  the morning!  ------
     <http://www.uni-weimar.de/cms/medien/mediensicherheit/home.html>
--Stefan.Lucks (at) uni-weimar.de, Bauhaus-Universität Weimar, Germany--

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

* Re: Pretty printing the pretty print.
  2013-09-27 13:25       ` Mike H
@ 2014-01-04 11:13         ` Oliver Kleinke
  2014-01-06 16:37           ` Mike H
  0 siblings, 1 reply; 13+ messages in thread
From: Oliver Kleinke @ 2014-01-04 11:13 UTC (permalink / raw)


> A C++ man working for a blue-chip organisation, he was impressed and 
> also opined that Ada "seems to have a sweet syntax".
> 
> During the same conversation he asked me to write some Ada code to 
> perform an exercise question he routinely sets when interviewing 
> programmer candidates. Thinking on the hoof I wrote some code that in 
> hind-sight was not good Ada and certainly not what I would have
> written if I had time to think the matter through. I seemed to fall
> straight into the trap that he had set. But I say "seemed" because as
> soon as he pointed out the error, and we discussed it, it became
> obvious that the trap was a situation that, in Ada, would possibly
> not have compiled and if it had would certainly have had potential
> for raising a constraint error. I refrained from pointing out that it
> could be argued that it was a specification error in that the
> specification did not admit that the difference between two indices
> is not an index, it is an offset.
> 

Do you by chance remember the task?
I coded 4 solutions[1] to the fizzbuzz exercise that is supposedly used
by interviewers a lot.

--
[1] - https://github.com/oliver117/fizzbuzz

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

* Re: Pretty printing the pretty print.
  2014-01-04 11:13         ` Oliver Kleinke
@ 2014-01-06 16:37           ` Mike H
  0 siblings, 0 replies; 13+ messages in thread
From: Mike H @ 2014-01-06 16:37 UTC (permalink / raw)


In message <20140104121332.22310cd2@vostro>, Oliver Kleinke
<oliver.kleinke@c-01a.de> writes
>Do you by chance remember the task?
As far as I remember the original "specification" was a requirement to
split an array at an arbitrary point and re-join the two parts (first
and last) in the reverse order (last then first). Spotting that what was
actually required was a circular shift changed the game somewhat. By
some odd coincidence, before Christmas I stumbled across the following
(see below). It seems to fit the bill. I also seem to remember that
turning it into a generic was not as sweet and clean as I expected.

function Shift_right_circular
     (A      : in Array_type;
      Places : in Natural) return Array_type is

      P : Natural := Places rem A'LENGTH;

      -- Array will be split into two slices (I1 .. I2) & (I3 .. I4) and
      -- re-made as (I3 .. I4) & (I1 .. I2). The values of I2 and I3 are
      -- derived from their position numbers, P2 and P3.
      P1 : Natural := Index_type'POS (A'FIRST); --  position number of
I1
      P2 : Natural := P1 + P - 1;                        --  position
number of I2
      P3 : Natural := P1 + P;                             --  position
number of I3
      --
      -- I1 is A'FIRST
      I2 : Index_type := Index_type'VAL(P2);
      I3 : Index_type := Index_type'VAL(P3);
      -- I4 is A'LAST

begin

      if Places = 0 then
         -- no shifting to be done
         return A;
      else
         return A (I3 .. A'LAST) & A (A'FIRST .. I2);
      end if;

end Shift_right_circular;


-- 
Mike
Swim? Naturally at Severn Vale
<http://www.severnvalesc.org/>

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

end of thread, other threads:[~2014-01-06 16:37 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-25 10:36 Pretty printing the pretty print Mike H
2013-09-25 11:14 ` Georg Bauhaus
2013-09-25 14:27 ` Britt
2013-09-25 14:48   ` Mike H
2013-09-25 15:16     ` gautier_niouzes
2013-09-26  4:30       ` Per Sandberg
2013-09-27 13:25       ` Mike H
2014-01-04 11:13         ` Oliver Kleinke
2014-01-06 16:37           ` Mike H
2013-09-29 21:38     ` Stephen Leake
2013-09-25 14:47 ` Felix Krause
2013-09-26 18:38 ` Manuel Gomez
2013-09-30 12:20 ` Stefan.Lucks

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