DataMuseum.dk

Presents historical artifacts from the history of:

Bogika Butler

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about Bogika Butler

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download

⟦4f923816d⟧ TextFile

    Length: 8960 (0x2300)
    Types: TextFile
    Names: »TF1B.PAS«

Derivation

└─⟦11e151dc0⟧ Bits:30009789/_.ft.Ibm2.50006589.imd Mogens Pelles Zilog 80,000 / EOS projekt
    └─⟦this⟧ »TF1B.PAS« 
└─⟦514567ecc⟧ Bits:30009789/_.ft.Ibm2.50006603.imd Mogens Pelles Zilog 80,000 / EOS projekt
    └─⟦this⟧ »TF1B.PAS« 
└─⟦59c2ecd8d⟧ Bits:30009789/_.ft.Ibm2.50006600.imd Mogens Pelles Zilog 80,000 / EOS projekt
    └─⟦this⟧ »TF1B.PAS« 

TextFile



(*******************************************************************)
(*                                                                 *)
(*                        MODULE 1B starts                         *)
(*                MODULE 1B is nested within MODULE 1              *)

var
  f_line : f_string;
      (* contains a line being assembled from words *)
  f_line_len : index0;
      (* number of valid characters in f_line *)
  first_word : index0;
      (* index into f_line of the first word *)
  f_line_width : integer;
      (* length in points of the contents of f_line *)
  nr_words : integer;
      (* number of words in f_line *)

(**********************************)
(* local procedures for module 1b *)

procedure make_new_line_ready;
begin
  f_space(left+left_add, f_line, 1);
  f_line_len := 1; first_word := f_line_len+1;
  f_line_width := left+left_add;
  nr_words := 0;
end;

procedure underscore_spaces;
  (* put underscores in spaces between underscored words *)
  var i : index0; j : integer;
begin
  i := first_word;
  for j := 1 to nr_words-1 do begin
    i := f_pos(' ', f_line, i+1, f_line_len);
    f_line(.i.).attr := f_line(.i.).attr + (.underscore.) *
        f_line(.i-1.).attr * f_line(.i+1.).attr;
  end;
end;

(* end of local procedures for module 1b *)
(*****************************************)

procedure init_1b;
begin
  make_new_line_ready;
end;

(* The procedures below are called in the following sequence :
   1. left  or  left_add  changes => changed_1b is called.
   2. Possibly write_in_margin_1b is called.
   3. Possibly indent_1b is called.
   4. A number of times write_word_1b is called.
      Zero times is allowed only in case (2) above.
   5. close_par_1b is called.
   Repeat from (1).                                              *)

procedure changed_1b;
begin
  make_new_line_ready
end;

procedure write_in_margin_1b(var text : f_string;
                             first, last : index0);
  var a : integer;
begin
  f_space(left, f_line, 1);
  f_copy(text, first, last, f_line, 2);
  f_line_len := 1+(last-first+1);
  a := max(0, left+left_add-width(f_line, 1, f_line_len));
  f_space(a, f_line, f_line_len+1); f_line_len := f_line_len+1;
  first_word := f_line_len+1;
  f_line_width := width(f_line, 1, f_line_len);
end;

procedure indent_1b;
begin
  f_line_len := f_line_len+1; first_word := first_word+1;
  f_space(indentation, f_line, f_line_len);
  f_line_width := f_line_width+indentation;
end;

procedure write_word_1b(var word : f_string; first, last : index;
                        var divide_point : integer);

  procedure out_word(div_point : index0; pos : integer;
                     var new_pos : integer);
      (* used when the user divides a word manually *)
    var i : integer;
  begin
    start_special_printing;
    for i := pos downto 1 do move_cursor_left;
    for i := first to div_point do print_attr(word(.i.));
    new_pos := div_point-first+1;
    if div_point >= first then
      if word(.div_point.).ch <> '-' then begin
        print_normal('-'); new_pos := new_pos+1;
      end;
    print_normal(' '); print_normal(' ');
    for i := div_point+1 to last do print_attr(word(.i.));
    print_normal(' '); print_normal(' ');
    print_normal(' '); print_normal(' ');
    for i := 1 to 1+(last-div_point)+4 do move_cursor_left;
    new_pos := new_pos+1;
    stop_special_printing;
  end;

  var i, max_i : index0;
      auto_division : boolean;
      space_left, j, k : integer;
      ch : char;

begin (* write_word_1b *)
  divide_point := -1;
  while width(word, first, last) > right-f_line_width do begin
    (* make a line break *)
    auto_division := not (dividepoint in word(.first.).attr);
    word(.first.).attr := word(.first.).attr+(.dividepoint.);
    if auto_division then
      for i := first to last-1 do
        if word(.i.).ch = '-' then
          word(.i+1.).attr := word(.i+1.).attr+(.dividepoint.);

    (* calculate max_i so that it indicates the rightmost possible
       division point. That is, set max_i to the maximum value
       still satisfying width(word, first, max_i)+ (perhaps the
       width of a hyphen) <= right-f_line_width . max_i will lie
       in the range first-1..last-1 . max_i indicates a division
       point in the sense that the first line should contain
       nothing if max_i=first-1 and otherwise
       word(first...max_i) + (a hyphen if word(max_i) is not
       itself a hyphen)  and that the second line should contain
       word(max_i+1..last) *)
    max_i := first-1;
    repeat
      max_i := max_i+1;
      j := width(word, first, max_i);
      if word(.max_i.).ch <> '-' then
        j := j+hyphen_width(word(.max_i.).attr);
    until j > right-f_line_width; (* max_i will never exceed last *)
    max_i := max_i-1;

    (* calculate i <= max_i indicating an acceptable division point
       in the same way that max_i indicates the rightmost possible
       division point. i will lie in the range first-1..max_i *)
    i := max_i;
    while not (dividepoint in word(.i+1.).attr) do i := i-1;

    (* calculate how much space will be left on the line
       if this division point is used *)
    if i = first-1 then begin
      space_left := right-
        (f_line_width - width(f_line, f_line_len, f_line_len));
    end else begin
      space_left := right-f_line_width - width(word, first, i);
      if word(.i.).ch <> '-' then
        space_left := space_left - hyphen_width(word(.i.).attr);
    end;

    if auto_division
       and (space_left > max_white_space)
       and (max_i >= first)
    then begin
      (* ask the user to divide the word *)
      (* below, i indicates a division point in the same way as above *)
      i := max_i;
      writeln; write('Hvor skal dette ord deles ?  ');
      out_word(i, 0, j);
      repeat
        ch := getkey;
        case ch of
          cursor_left :
            if i >= first then begin
              i := i-1; out_word(i, j, j);
            end;
          cursor_right :
            if i < max_i then begin
              i := i+1; out_word(i, j, j);
            end;
          else
        end;
      until ch = cr;
      writeln;

      (* calculate how much space will be left on the line
         if this division point is used *)
      if i = first-1 then begin
        space_left := right-
          (f_line_width - width(f_line, f_line_len, f_line_len));
      end else begin
        space_left := right-f_line_width - width(word, first, i);
        if word(.i.).ch <> '-' then
          space_left := space_left - hyphen_width(word(.i.).attr);
      end;
      if space_left > max_white_space then
        divide_point := first
      else
        divide_point := i+1;
    end; (* if auto_division and .... *)

    if i <> first-1 then begin
      (* divide the word so that the character in position
         i is the last one on the current line *)
      f_copy(word, first, i, f_line, f_line_len+1);
      f_line_len := f_line_len+(i-first+1);
      f_line_width := f_line_width+width(word, first, i);
      if word(.i.).ch <> '-' then
        add_hyphen(f_line, f_line_len, f_line_width);
      add_space(f_line, f_line_len, f_line_width);
      nr_words := nr_words+1;
      first := i+1;
    end; (* if i <> first-1 *)

    (* remove trailing space : *)
    f_line_width := f_line_width-width(f_line, f_line_len, f_line_len);
    f_line_len := f_line_len-1;
    (* put underscore in spaces between underscored words : *)
    underscore_spaces;

    (* make the right margin straight if so asked *)
    if (nr_words > 1) and straight_margin then
      expand(f_line, f_line_len, (* these are modified *)
        first_word, nr_words, right-f_line_width);

    write_line_2(f_line, f_line_len);
    make_new_line_ready;
    word(.first.).attr := word(.first.).attr-(.dividepoint.);
    if not auto_division then
      word(.first.).attr := word(.first.).attr+(.dividepoint.);
  end; (* while.... (line break) *)
  f_copy(word, first, last, f_line, f_line_len+1);
  f_line_len := f_line_len+(last-first+1);
  f_line_width := f_line_width+width(word, first, last);
  add_space(f_line, f_line_len, f_line_width);
  nr_words := nr_words+1;
end; (* write_word_1b *)

procedure close_par_1b;
begin
  underscore_spaces;
  write_line_2(f_line, f_line_len);
  make_new_line_ready;
end;

procedure terminate_1b;
begin
end;


(*                         MODULE 1B ends                          *)
(*                MODULE 1B was nested within MODULE 1             *)
(*                                                                 *)
(*******************************************************************)
«eof»