!! !! Module Name : JUSTIFY.TPU !! !! Original Request Number : !! System Designation : !! Module Description : Right justify text. Uses current left and !! : right margins and paragraph settings. !! : Enter JUSTIFY P[ARTIAL] for ragged right !! : margin. Routine will still remove extra !! : spaces and tabs from paragraph. !! : !! Original Programmer : UCS.KAS !! !! Date Approved : 5-AUG-1989 !! !! Files open for Input : !! Files open for Output : !! Modules Referenced : !! procedure eve_justify(;partial) local saved_mark, start_paragraph, stop_paragraph, rm, lm, the_indent, s_result, new_spaces, more, word_end, next_word, word_index; on_error [OTHERWISE]: endon_error; if beginning_of (current_buffer) = end_of (current_buffer) then message("Nothing to justify"); eve$learn_abort; return(FALSE); endif; position (TEXT); saved_mark := mark (NONE); loop position (LINE_BEGIN); exitif mark (NONE) = beginning_of (current_buffer); move_vertical (-1); position (LINE_BEGIN); if eve$paragraph_break then position (LINE_END); move_horizontal (1); exitif 1; endif; endloop; loop exitif (current_character <> " ") and (current_character <> ascii(9)); erase_character(1); endloop; start_paragraph := mark (free_cursor); position (saved_mark); loop position (LINE_BEGIN); exitif mark (NONE) = end_of (current_buffer); exitif eve$paragraph_break; move_vertical (1); endloop; if start_paragraph = mark (NONE) then message("Nothing to justify"); position (saved_mark); eve$learn_abort; return (FALSE); else move_horizontal (-1); stop_paragraph := mark (NONE); position(start_paragraph); loop s_result := search_quietly(span(ascii(9) + " "),forward); exitif s_result = 0; position(s_result); exitif mark(none) > stop_paragraph; erase(s_result); if current_character <> "" then move_horizontal(-1); if index("?.!",current_character) <> 0 then move_horizontal(1); copy_text(" "); else move_horizontal(1); copy_text(" "); endif; endif; endloop; endif; rm := get_info (current_buffer, "right_margin"); if eve$$x_word_wrap_indent {current_buffer} <> tpu$k_unspecified then lm := eve$$x_word_wrap_indent {current_buffer}; else lm := get_info (current_buffer, "left_margin"); endif; if eve$$x_paragraph_indent {current_buffer} <> tpu$k_unspecified then the_indent := eve$$x_paragraph_indent {current_buffer} -lm; else the_indent := get_info (current_buffer, "left_margin") - lm; endif; fill (create_range (start_paragraph, stop_paragraph, NONE), eve$x_fill_separators, lm, rm, the_indent); if (substr(partial,1,1) = "P") or (substr(partial,1,1) = "p") then return endif; position(start_paragraph); loop exitif mark(none) > stop_paragraph; new_spaces := rm - length(current_line) - lm + 1; if mark(none) = start_paragraph then new_spaces := new_spaces - the_indent; endif; if new_spaces > 0 then word_end := create_array; loop next_word := str(eve$current_word); exitif current_character = ""; more := 0; loop exitif word_end{length(next_word) * 100 + more} = tpu$k_unspecified; more := more + 1; endloop; word_end{length(next_word) * 100 + more} := mark(FREE_CURSOR); endloop; exitif mark(free_cursor) >= stop_paragraph; position(line_begin); loop exitif new_spaces = 0; word_index := get_info(word_end,"last"); exitif word_index = tpu$k_unspecified; loop exitif word_index = tpu$k_unspecified; exitif new_spaces = 0; position(word_end{word_index}); copy_text(" "); new_spaces := new_spaces - 1; word_index := get_info(word_end,"previous"); endloop; endloop; endif; position(line_end); move_horizontal(1); endloop; position (stop_paragraph); eve$show_first_line; return (TRUE); endprocedure;