Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #3231

Re: Printing PS Data Structures

Newsgroups comp.lang.postscript
Date 2018-01-25 16:20 -0800
References <95a75c45-f12b-43d1-8d6e-f987f58dcddb@googlegroups.com>
Message-ID <d01ed8e3-7376-497b-be8f-8d3241cc0fe9@googlegroups.com> (permalink)
Subject Re: Printing PS Data Structures
From luser droog <luser.droog@gmail.com>

Show all headers | View raw


On Thursday, January 25, 2018 at 5:41:26 PM UTC-6, luser droog wrote:
[snip][...] I think the program can be redesigned
> to be smaller, simpler, and more flexible.
> 
[snip]
> That's a little better, I think. This version traverses
> any compound data structure and prints it ... but all
> on one long line.
> 
> So, all the places where I called `show` need to call
> a new function which decides whether to start a new line
> and if so, then it also figures out appropriate
> indentation, and then calls show.
> 
> And let me do some thinking on this next step before 
> I blog all over myself.... more to follow.


Ok this version minds line lengths and ghostscript shows
me the whole thing on one page. Still not quite achieving
the quality of output from the original, but I ain't done yet....

laptop ~
$ cat printdata.ps
%!

<<
    /type-switch { 1 index type  switch }
    /switch { 2 copy known not { pop /default } if  get exec }
    /+= { dup load 3 2 roll add store }

    /show-object { object-procs type-switch }
    /show-simple { =string cvs show-it ( ) show-it }
    /object-procs <<
                      /default { show-simple }
                      
                      /nametype {
                          dup xcheck not { (/) show-and-update-position } if  % ie. <nobr>
                          show-simple
                      }
                      /arraytype {
                          ([ ) show-it  { show-object } forall  (] ) show-it
                      }
                      /dicttype {
                          (<< ) show-it { exch show-object show-object } forall (>> ) show-it
                      }
                  >>
    /line-position 0
    /max-line-length 80
    /show-and-update-position {
        dup length /line-position +=
        show
    }
    /show-it {
        show-and-update-position
        line-position max-line-length gt {
            next-line
        } if
    }
    /next-line {
        lead neg /Y +=
        x Y moveto
        /line-position 0 store
    }
    /x 30
    /X {max-line-length}
    /Y 600
    /y 30
>> {def} forall


x Y moveto
/Palatino-Roman 10 selectfont /lead 12 def
<<
    /currentpagedevice currentpagedevice
>> show-object

showpage

Back to comp.lang.postscript | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Printing PS Data Structures luser droog <luser.droog@gmail.com> - 2018-01-25 15:41 -0800
  Re: Printing PS Data Structures luser droog <luser.droog@gmail.com> - 2018-01-25 16:20 -0800
    Re: Printing PS Data Structures luser droog <luser.droog@gmail.com> - 2018-01-25 16:54 -0800
      Re: Printing PS Data Structures luser droog <luser.droog@gmail.com> - 2018-02-01 20:11 -0800
      Re: Printing PS Data Structures Martin Leese <please@see.Web.for.e-mail.INVALID> - 2018-02-01 22:57 -0700
        Re: Printing PS Data Structures luser droog <luser.droog@gmail.com> - 2018-02-02 18:24 -0800
          Re: Printing PS Data Structures Martin Leese <please@see.Web.for.e-mail.INVALID> - 2018-02-03 13:54 -0700
  Re: Printing PS Data Structures ken <ken@spamcop.net> - 2018-01-26 17:49 +0000
    Re: Printing PS Data Structures luser droog <luser.droog@gmail.com> - 2018-01-26 14:18 -0800

csiph-web