File: Funcs

package info (click to toggle)
tkcdlayout 0.2-1
  • links: PTS
  • area: main
  • in suites: slink
  • size: 120 kB
  • ctags: 2
  • sloc: sh: 437; makefile: 34
file content (168 lines) | stat: -rw-r--r-- 4,586 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#!/bin/sh
# Functions used by tkcdlayout

function GetFiles {
 # List files ($maxdepth levels from $cddir - directories only if $dironly=yes)

 if [ -z "$exclude" ]; then exclude="%@%"; fi

 if [ -z "$cddir" ]; then rm -f $lines; else

   (cd $cddir &&
    ( 
      maxdepthOPT=
      typeOPT=
      if [ "x$dironly" = "xyes" ]; then
        typeOPT="-type d"
      fi
      if [ -n "$maxdepth" ]; then
        maxdepthOPT="-maxdepth $maxdepth"
      fi
      find . $maxdepthOPT $typeOPT
    ) | sed -e 's,^./,,' -e 's,_,\\\\_,g' |  \
      grep -v $exclude | grep -v '^.$' | sort ) > $lines
 fi
} 

function DoLayout {
   cat $libdir/CD.latex.begin.$page ${mid} $libdir/CD.latex.end >${lay}/${cdn}.latex &&
   cd ${lay} &&
   latex ${cdn}.latex &&
   dvips ${cdn}.dvi -t a4 -t landscape -o &&
   gv -seascape -media A4 ${cdn}.ps 
}

function Title {
   if [ -n "$Title" ]; then
     if [ -l "$Title" -gt 29 ];then
	if [ -l "$Title" -gt 40 ];then
	    echo "\put(3241,-126){\makebox(0,0)[b]{\Large{$Title}}}" >${mid}
	else
	  echo "\put(3241,-126){\makebox(0,0)[b]{\huge{$Title}}}" >${mid}
	fi
     else
        echo "\put(3241,-126){\makebox(0,0)[b]{\smash{\SetFigFont{34}{40.8}{rm}$Title}}}" >${mid}
     fi
   fi
}

function BigTitle {
   if [ -n "$Title" ]; then
      if [ -l "$Title" -gt 14 ];then
        if [ -l "$Title" -gt 17 ];then
         if [ -l "$Title" -gt 23 ]; then
           if [ -l "$Title" -gt 36 ]; then # tested with 64
             echo "\put(3500,-1726){\makebox(0,0)[b]{\textbf{$Title}}}"  >${mid}
           else # Between 24 and 50 chars => LARGE without scalebox
             echo "\put(3500,-1726){\makebox(0,0)[b]{\LARGE{\textbf{$Title}}}}"  >${mid}
           fi
         else # Between 18 and 23 chars => Large
          echo "\put(3241,-1726){\makebox(0,0)[b]{\scalebox{2}{\large{\textbf{$Title}}}}}"  >${mid}
         fi
        else # Between 14 and 17 chars => LARGE
          echo "\put(3300,-1726){\makebox(0,0)[b]{\scalebox{2}{\LARGE{\textbf{$Title}}}}}"  >${mid}
        fi
      else # Few chars => VERY big
        echo "\put(3241,-1726){\makebox(0,0)[b]{\scalebox{2}{\huge{\textbf{$Title}}}}}"  >${mid}
      fi
   fi
}

function Subtitle {
     if [ -n "$subtitle" ]; then
      if [ -l "$subtitle" -gt 20 ];then
        if [ -l "$subtTitle" -gt 41 ];then
         echo "\put(2000,-3346){\makebox(0,0)[lb]{\smash{$subtitle}}}" >>${mid}
        else
         echo "\put(2566,-3346){\makebox(0,0)[lb]{\smash{\large{$subtitle}}}}" >>${mid}
        fi
      else
       echo "\put(2566,-3346){\makebox(0,0)[lb]{\smash{\SetFigFont{20}{24.0}{rm}$subtitle}}}" >>${mid}
      fi
     fi 
}

function MoveTitle { 
# This function moves up the title, because we need some more space below it
    cat ${mid} | sed -e 's/-126/224/' >/tmp/tmpxxxx
    mv -f /tmp/tmpxxxx ${mid}
}

function WriteLines {
# This function reads lines from $lines and writes them, formatted, to 
#    $mid
  # x values (for each page)
  x1=900
  x2=7000
  
  [ -n "$lines" -a -f "$lines" ] || exit 1;
  
  # Number of lines
  nbl=$(cat $lines | wc -l)
   
  
  if [ $nbl -lt 13 ]; then     # very short ( < 13 )
    y=1400
    interv=270
    font="\SetFigFont{14}{16.8}{rm}" ; pf=""

  elif [ $nbl -lt 16 ]; then     # between 13 and 16
    y=646
    interv=270
    font="\SetFigFont{14}{16.8}{rm}" ; pf=""

  elif [ $nbl -lt 20 ]; then     # between 16 and 20
    y=646
    interv=200
    font="" ; pf=""

  elif [ $nbl -lt 26 ]; then   # between 20 and 26
    y=646
    interv=200
    font="" ; pf=""
    if [ $nbl -gt 21 ]; then y=106 ; MoveTitle; fi

  elif [ $nbl -lt 51 ]; then   # between 26 and 51
    y=376
    interv=200
    font=

  else                         # very long ( > 51 )
    MoveTitle
    y=106
    interv=175
    font="\small{"
    pf="}"
  fi
  
  x=$x1        # First page
  cat $lines | while read a; do
    echo "\put($x,-$y){\makebox(0,0)[lb]{\smash{$font$a$pf}}}" >>${mid}
    y=$[$y+$interv]
    if [ $y -gt 4950 ]; then   # Next page
      y=$[106-3*$interv]
      x=$x2    # Second page
    fi
  done
}

function Warning {  
# This function warns the user if $mid exists and if Warn is set to yes
  if [ -f ${mid} -a "x$Warn" != "xno" ]; then
    echo -n "Warning : ${mid} exists ! Do you want to erase it [y/n] :"
    read answ
    if [ "$answ" = "y" ]; then
	rm -f ${mid}
    else
    exit 1;
    fi
  fi
}

function BackBorders {
# This function draws the vertical titles on the back page
   if [ -n "$Title" ]; then
     echo "\put(270,-4750){\myrotatel{$Title}}" >>${mid}
     echo "\put(7140,380){\myrotater{$Title}}" >>${mid}
   fi
}