~ubuntu-branches/ubuntu/vivid/inform/vivid

« back to all changes in this revision

Viewing changes to include/center.h

  • Committer: Bazaar Package Importer
  • Author(s): Jan Christoph Nordholz
  • Date: 2008-05-26 22:09:44 UTC
  • mfrom: (2.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080526220944-ba7phz0d1k4vo7wx
Tags: 6.31.1+dfsg-1
* Remove a considerable number of files from the package
  due to unacceptable licensing terms.
* Repair library symlinks.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
!  Center       A handy utility for centering printed text in the lower 
2
 
!               or upper window for Inform 6 by L. Ross Raszewski
3
 
!               (rraszews@skipjack.bleucrab.org)
4
 
! Ever wanted something like a status line centered but not known how to do 
5
 
! it without storing the width of the text somewhere?  I know I have.
6
 
! Yes, I'm sure everyone knows how to _now_, but do you have a library to do 
7
 
! it for you?  Are you a casual programmer who doesn't want to play with 
8
 
! @output_stream?  
9
 
! Center(x);
10
 
! x is either a string, or a routine to print one.  The result is centered 
11
 
! on the current line.  
12
 
! More useful is:
13
 
! CenterU(x,i)
14
 
! x is as above, i is the number of the line IN THE UPPER WINDOW you want to 
15
 
! print to.
16
 
! The catch?  It will only center a number of characters less than your 
17
 
! screen width.  Moreover, if your screen width is greater than 128, you can
18
 
! only center 128 characters.  And I think new lines will make it blow up.
19
 
!
20
 
! Still, it's better than the alternative, innit?
21
 
!
22
 
 
23
 
Array CenterText string 128;
24
 
 
25
 
[ Center instring i;
26
 
  CenterText-->0=128;
27
 
  @output_stream 3 CenterText;
28
 
  if (instring ofclass string)
29
 
  print (string) instring;
30
 
  if (instring ofclass Routine)
31
 
  indirect(instring);
32
 
  @output_stream -3;
33
 
  i=0->33;
34
 
  i=i-CenterText-->0;
35
 
  i=i/2;
36
 
  spaces(i);
37
 
  if (instring ofclass string)
38
 
  print (string) instring;
39
 
  if (instring ofclass Routine)
40
 
  indirect(instring);
41
 
];
42
 
[ CenterU instring j i;
43
 
  CenterText-->0=128;
44
 
  @output_stream 3 CenterText;
45
 
  if (instring ofclass string)
46
 
  print (string) instring;
47
 
  if (instring ofclass Routine)
48
 
  indirect(instring);
49
 
  @output_stream -3;
50
 
  i=0->33;
51
 
  i=i-CenterText-->0;
52
 
  i=i/2;
53
 
  @set_cursor j i;
54
 
  if (instring ofclass string)
55
 
  print (string) instring;
56
 
  if (instring ofclass Routine)
57
 
  indirect(instring);
58
 
];