! ABEL_CASE.TPU ! ! Table of Contents as of 27-Mar-1988 ! ! Procedure name Page Description ! -------------- ---- ----------- ! ! eve_change_case 1 Change case of character or range ! eve_change_word_case 2 Change case of word ! Page 1 procedure eve_change_case($user_case) ! Change case of character or range ! Changes case of select range if active, or current character. Do not ! move the cursor to the end of line if past end of line (different than ! DEC's) ! ! Parameter: ! $user_case string case to change to ! ! Qualifiers: ! /reset boolean reset select range when done ! ! Source: ! Eve local this_position, ! Marker for current cursor position remove_range, ! Range being removed cc, ! Current character if changing one char user_case; ! Case to change to ! ! Prompt for case if necessary ! if not abl$prompt_word("/lower/upper/invert",$user_case,user_case, "Case (upper, lower, invert) []? ","Aborted...") then return 0; endif; ! this_position := mark (none); ! ! If changing case of a selected range... ! if eve$x_select_position <> 0 then if get_info (eve$x_select_position, "buffer") <> current_buffer then message ("Change_case must be used in the same buffer as Select"); else remove_range := select_range; ! Change_case & Remove in same spot => erase this character if remove_range = 0 then if this_position = end_of (current_buffer) then message ("No case changed"); eve$x_select_position := 0; return; else remove_range := create_range (mark (none), mark (none), none); endif; endif; if user_case = "upper" then change_case(remove_range,upper) endif; if user_case = "lower" then change_case(remove_range,lower) endif; if user_case = "invert" then change_case(remove_range,invert) endif; if abl$q_reset then eve$x_select_position := 0; remove_range := 0; endif; endif; ! ! Changing case of single character ! else cc:=current_character; if cc<>0 then if get_info(current_buffer,"mode")<>overstrike then erase_character(1); endif; if user_case = "upper" then change_case(cc,upper) endif; if user_case = "lower" then change_case(cc,lower) endif; if user_case = "invert" then change_case(cc,invert) endif; copy_text(cc); endif endif; endprocedure; ! Page 2 procedure eve_change_word_case ! Change case of word ($user_case) ! Changes case of the current word. ! ! Parameters: ! $user_case string case to change to ! ! Source: ! Eve local here, ! User's starting position word_range, ! Range for current word word_string, ! String for current word this_mode, ! Current mode for this buffer user_case, ! Case to change to this_buffer, ! Handle on this buffer cc; ! Current character on_error endon_error; ! ! Some init's...move cursor to end of line if beyond ! this_buffer:=current_buffer; if get_info(this_buffer,"character")=eve$x_null then eve_end_of_line; endif; here:=mark(none); ! ! Keep backing up if we're not on a word ! loop cc:=get_info(this_buffer,"character"); exitif mark(none)=beginning_of(this_buffer); if (cc=ascii(32)) or (cc=ascii(9)) or (cc=0) then move_horizontal(-1) else exitif 1 endif; endloop; if current_offset>0 then move_horizontal(-1) endif; ! ! Identify the word and change it's case ! word_range := eve$current_word; word_range:=create_range(beginning_of(word_range),end_of(word_range),underline); position(beginning_of(word_range)); update(current_window); if (word_range <> 0) then ! ! Prompt for case if necessary ! if not abl$prompt_word("/lower/upper/invert/capitalize",$user_case, user_case, "Case (upper, lower, invert, capitalize) []? ","Aborted...") then position(here); return 0; endif; ! ! Remove the old word, change it's case, and put it back in ! word_string := erase_character(length(word_range)); if user_case = "capitalize" then eve$capitalize_string(word_string) else if user_case = "upper" then change_case(word_string,upper) endif; if user_case = "lower" then change_case(word_string,lower) endif; if user_case = "invert" then change_case(word_string,invert) endif; endif; eve$insert_text(word_string); endif; endprocedure;