!++ ! FILENAME: MARGINS.TPU ! FUNCTION: This file contains procedures which facilitate the setting of ! the margins within a buffer. ! AUTHOR: Steven K. Shapiro, (C) Copyright SKS Enterprises, Austin TX. ! All Rights Reserved. ! ! The format, structure and contents of this file are the sole ! property of Steven K. Shapiro and are copyrighted to SKS ! Enterprises, Austin Texas. ! ! The information may be freely distributed, used and modified ! provided that the information in this header block is not ! changed, altered, disturbed or modified in any way. ! ! DATE: 25-AUG-1987 Original. ! HISTORY: current. ! CONTENTS: ! eve_default_margins ! eve_mail_margins ! eve_notes_margins ! eve_rno_margins ! eve_for_margins ! eve_slm_here ! eve_srm_here ! eve_width ! eve_toggle_width ! eve_user_set_margins ( the_buffer, the_left, the_right ) ! eve_user_strip_margins ( the_range ) ! !23456789A123456789B123456789C123456789D123456789E123456789F123456789G123456789H !-- !*----------------------------------------------------------------------------*! ! The procedure evedt_user_set_margins uses array variables to store the ! margins. Since array elements can be accessed using either braces or ! parentheses, array variables can be used as if they were procedure calls. ! The following statements explicitly declare these variables. variable user_left_margin; variable user_right_margin; !*----------------------------------------------------------------------------*! procedure margins_module_ident local file_date, module_vers; file_date := "-<( 9-DEC-1988 13:14:08.13 )>-"; module_vers := substr(file_date,5,2) + substr(file_date,8,3) + substr(file_date,14,2) + substr(file_date,17,5) ; return module_vers; endprocedure; !*----------------------------------------------------------------------------*! constant eve$x_largest_right_margin := 983; !*----------------------------------------------------------------------------*! ! procedure eve_default_margins ! ! Sets the margins in the current buffer to the default margins ! (left margin = 1 ! right margin = the width of the screen - 1). set (MARGINS,current_buffer, 1, get_info(current_window,'width')-1); eve$update_status_lines; message ('left margin = ' + str(get_info(current_buffer,'left_margin')) + ', right margin = ' + str(get_info(current_buffer,'right_margin'))); endprocedure; procedure eve_mail_margins ! ! Sets the margins in the current buffer to the margins used in creating ! a file in MAIL. set (MARGINS,current_buffer, 5, 75); cursor_horizontal(-current_offset+4); eve$update_status_lines; message ('left margin = ' + str(get_info(current_buffer,'left_margin')) + ', right margin = ' + str(get_info(current_buffer,'right_margin'))); endprocedure; procedure eve_notes_margins ! ! Sets the margins in the current buffer to the margins used in creating ! a file in VAX Notes. set (MARGINS,current_buffer, 5,70 ); cursor_horizontal(-current_offset+4); eve$update_status_lines; message ('left margin = ' + str(get_info(current_buffer,'left_margin')) + ', right margin = ' + str(get_info(current_buffer,'right_margin'))); endprocedure; procedure eve_rno_margins ! ! Procedure called by tpu$local_init to set margins for a file of type ".RNO". ! Can also be called from the command line. set (margins,current_buffer,1,67); eve$update_status_lines; message ('left margin = ' + str(get_info(current_buffer,'left_margin')) + ', right margin = ' + str(get_info(current_buffer,'right_margin'))); endprocedure; procedure eve_for_margins ! ! Procedure called by tpu$local_init to set margins for a file of type ".FOR". ! Can also be called from the command line. set (margins,current_buffer,7,80); cursor_horizontal(-current_offset+6); eve$update_status_lines; message ('left margin = ' + str(get_info(current_buffer,'left_margin')) + ', right margin = ' + str(get_info(current_buffer,'right_margin'))); endprocedure; procedure eve_slm_here local new_left_margin, ! Left margin to set to: current column current_right_margin; ! Right margin for current buffer current_right_margin := get_info (current_buffer, "right_margin"); new_left_margin := get_info (current_window, "current_column"); if new_left_margin >= current_right_margin then message ("Left margin must be left of right margin, " + fao ("currently at column !SL", current_right_margin)); else set (margins, current_buffer, new_left_margin, current_right_margin); eve$update_status_lines; message ('left margin = ' + str(get_info(current_buffer,'left_margin')) + ', right margin = ' + str(get_info(current_buffer,'right_margin'))); endif; endprocedure; procedure eve_srm_here local new_right_margin, ! Right margin to set to: current column current_left_margin; ! Left margin for current buffer current_left_margin := get_info (current_buffer, "left_margin"); new_right_margin := get_info (current_window, "current_column"); if new_right_margin <= current_left_margin then message ("Right margin must be right of left margin, " + fao ("currently at !SL", current_left_margin)); else set (margins, current_buffer, current_left_margin, new_right_margin); eve$update_status_lines; message ('left margin = ' + str(get_info(current_buffer,'left_margin')) + ', right margin = ' + str(get_info(current_buffer,'right_margin'))); endif; endprocedure; !*----------------------------------------------------------------------------*! procedure eve_width ! ! This file contains a command procedure which provides the capability to ! toggle the width of all windows displayed on the current screen between ! 80 character width and 132 character width. ! local window_width, the_window; if (get_info(current_window,'width')=132) then window_width := 80; else window_width := 132; endif; the_window := get_info(window, 'first'); loop exitif (the_window = 0); set (width, the_window, window_width); the_window := get_info(window, 'next'); endloop; endprocedure !*----------------------------------------------------------------------------*! procedure eve_toggle_width local scr_width, cur_right_margin, width_val, tis_mapped, bis_mapped; tis_mapped := get_info(ruler_w_t,"visible"); bis_mapped := get_info(ruler_w_b,"visible"); ! message("top mapped = "+str(tis_mapped)+" bot mapped = "+str(bis_mapped)); scr_width := get_info(current_window,'width'); if scr_width = 80 then width_val := 132; cur_right_margin := 131; else width_val := 80; cur_right_margin := 79 endif; set(width,current_window,width_val); set(margins,current_buffer,1,cur_right_margin); set(width,message_window,width_val); set(width,eve$command_window,width_val); if edt$x_wrap_position <> 0 then edt$x_wrap_position := width_val-2; endif; if tis_mapped = 1 then set(width,ruler_w_t,width_val); endif; if bis_mapped = 1 then set(width,ruler_w_b,width_val); endif; eve$update_status_lines; endprocedure; !*----------------------------------------------------------------------------*! ! ! This procedure associates user-specified margin values with the current ! buffer by storing the values in arrays. This prevents the user-specified ! values from creating "hard" margin settings. Instead, the left margin is set ! in Column 1. ! ! This procedure takes three parameters. The first parameter is the buffer with ! which you want to associate the specified margin values. The second and third ! parameters are integers obtained from the user specifying the left and right ! margin settings. ! procedure eve_user_set_margins ( the_buffer, the_left, the_right ) on_error [OTHERWISE]: endon_error; IF get_info(the_buffer, "type") <> BUFFER THEN message(TPU$_INVPARAM,0,1,"", str(get_info(the_buffer, "type")), "", "BUFFER"); learn_abort; return (FALSE); ENDIF; IF get_info (the_left, "type") <> INTEGER THEN message(TPU$_INVPARAM,0,2,"", str(get_info(the_left, "type")), "", "INTEGER"); learn_abort; return (FALSE); ENDIF; IF get_info (the_right, "type") <> INTEGER THEN message(TPU$_INVPARAM,0,3,"", str(get_info(the_right, "type")), "", "INTEGER"); learn_abort; return (FALSE); ENDIF; IF get_info(user_left_margin, "type") <> ARRAY THEN user_left_margin := create_array; ENDIF; IF get_info(user_right_margin, "type") <> ARRAY THEN user_right_margin := create_array; ENDIF; user_left_margin {the_buffer} := the_left; user_right_margin {the_buffer} := the_right; endprocedure; !*----------------------------------------------------------------------------*! ! ! This procedure sets the left margin at column 1 of all the lines in a ! specified range. Padding spaces are inserted to preserve the screen appearance ! of the text. This procedure may be required by rectangular cut & paste as well ! as the fill procedure. ! ! The parameter specifies the text that is to be modified. The range must start ! at the beginning of a line. ! ! The procedure uses POSITION(LINE_BEGIN) after each MOVE_VERTICAL(1) to ensure ! that the editing point is at the beginning of the line. procedure eve_user_strip_margins ( the_range ) local the_start, the_end, here, the_offset, target_range, saved_left_margin, saved_mark, saved_mode; on_error [TPU$_ENDOFBUF]: set (saved_mode, current_buffer); set (left_margin, current_buffer, saved_left_margin); eve$update_status_lines; position (saved_mark); return; [OTHERWISE]: IF saved_mode = OVERSTRIKE THEN SET (OVERSTRIKE, current_buffer); ENDIF; IF saved_mark <> TPU$K_UNSPECIFIED THEN POSITION (saved_mark); ENDIF; endon_error; saved_mark := mark (FREE_CURSOR); if (the_range = 0) or (the_range = "") then target_range := select_range; else target_range := the_range; endif; start_mark := beginning_of (target_range); the_end := end_of (target_range); position (start_mark); saved_left_margin := get_info(current_buffer, "left_margin"); IF saved_left_margin > 1 THEN set (LEFT_MARGIN, current_buffer, 1); ENDIF; saved_mode := get_info(current_buffer, "mode"); set (INSERT, current_buffer); loop position (line_begin); here := mark(none); exitif not get_info(here, "within_range", target_range); the_offset := get_info(here, "left_margin"); IF the_offset > 1 THEN IF here <> beginning_of (current_buffer) THEN append_line; split_line; ELSE split_line; append_line; ENDIF; copy_text(fao ("!#* ", the_offset - 1)); ENDIF; move_vertical(1); endloop; set (saved_mode, current_buffer); set (left_margin, current_buffer, saved_left_margin); eve$update_status_lines; position (saved_mark); endprocedure;