home *** CD-ROM | disk | FTP | other *** search
- $MACRO_FILE TEXT;
- {***************************MULTI-EDIT MACRO FILE******************************
-
- CHNGCASE - Changes the case of a line, word, or block
- TEXTSORT - Sorts lines of text
- CENTER - Centers a line
- OPENLN - Insert a blank line while in overwrite mode
- REFORMAT - Reformats a paragraph
- JUSTIFY - Justifies a paragraph
- UNJUSTIF - Unjustifies a paragraph
- RULER - Displays a character ruler at the cursor position
- END_OF_PARAGRAPH - Finds the end of the current paragraph
- NEXT_PARAGRAPH - Finds the beginning of the next paragraph
- MARKPOS - Mark a position using the stack bookmarks
- GOTOMARK - Return to a mark on the stack
- SET_MARK - Mark a position using random marks
- GET_MARK - Return to a random mark
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
-
- $MACRO CHNGCASE TRANS;
- {*******************************MULTI-EDIT MACRO******************************
-
- Name: CHNGCASE
-
- Description: Changes the case of a block of text.
-
- Parameters: /U=1 Uppercase
- =0 Lowercase
- /T=0 Line
- =1 Word
- =2 Block
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
- def_int( jx, tc, ti, casetype, blocktype, tb1, tbs, tb2, tbl1, tbl2, tbc1, tbc2 );
- def_str( tstr );
-
- push_undo;
- refresh := false;
- ti := insert_mode;
- insert_mode := true;
- casetype := parse_int('/U=', mparm_str);
- blocktype := parse_int('/T=', mparm_str);
-
- if blocktype = 0 then
- if casetype then
- put_line( caps(get_line));
- else
- put_line( lower(get_line));
- end;
- end;
- if blocktype = 1 then
- if not(at_eol) and (xpos(cur_char,word_delimits,1) <> 0) then
- word_right;
- else
- if c_col > 1 then
- left;
- if xpos(cur_char,word_delimits,1) then
- right;
- else
- right;
- word_left;
- end;
- end;
- end;
- tc := c_col;
- tstr := get_word(word_delimits);
- if casetype then
- tstr := caps(tstr);
- else
- tstr := lower(tstr);
- end;
-
- goto_col(tc);
- del_chars( svl(tstr) );
- text( tstr );
- end;
- if (block_stat <> 0) and (blocktype = 2) then
- block_end;
- tbl1 := block_line1; tbl2 := block_line2;
- tbc1 := block_col1; tbc2 := block_col2;
- tbs := block_stat;
- mark_pos;
- jx := block_line1;
- while jx <= tbl2 do
- goto_line(jx);
- if tbs = 1 then
- if casetype then
- put_line( caps(get_line));
- else
- put_line( lower(get_line));
- end;
- end;
- if tbs = 2 then
- goto_col(tbc1);
- tstr := copy(get_line, tbc1, tbc2 - tbc1 + 1);
- del_chars( svl(tstr) );
- if casetype then
- tstr := caps(tstr);
- else
- tstr := lower(tstr);
- end;
- text( tstr );
- end;
- if tbs = 3 then
- goto_col(1);
- tb1 := 1;
- tstr := get_line;
- tb2 := svl( tstr );
- if jx = tbl1 then
- goto_col(tbc1);
- tb1 := tbc1;
- end;
- if jx = tbl2 then
- tb2 := tbc2;
- end;
- del_chars( tb2 - tb1 + 1);
- tstr := copy( tstr, tb1, tb2 - tb1 + 1);
- if casetype then
- tstr := caps(tstr);
- else
- tstr := lower(tstr);
- end;
- text(tstr);
- end;
- ++jx;
- down;
- end;
- if tbs = 3 then
- goto_line(tbl1);
- goto_col(tbc1);
- str_block_begin;
- goto_line(tbl2);
- goto_col(tbc2 + 1);
- block_end;
- end;
- goto_mark;
- end;
- insert_mode := ti;
- pop_undo;
- redraw;
- END_MACRO;
-
- $MACRO TEXTSORT TRANS;
- {*******************************MULTI-EDIT MACRO******************************
-
- Name: TextSort
-
- Description: Sorts lines of text.
-
- Parameters: /C=nn Starting column of sort field.
- /L=nn # of characters in sort field.
- /CASE Ignore case of field.
- /D Sort in descending order.
- /B Sort the marked line block.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
-
- Def_Int( IX, SX, SL,SC, NC, C, L, Caps_On, Descending, jx, Sort_Mode, old_block_stat,tw );
- Def_Int( count );
- Def_Str( DP1, DP2, DX1, DX2 );
- def_char( tc, dc );
-
- push_undo;
- tw := wrap_stat;
- wrap_stat := false;
- insert_mode := true;
- refresh := false;
- working;
- sl := C_line;
- Sc := C_Col;
- old_block_stat := 0;
- goto_col(1);
- set_indent_level;
- EOF;
- NC := C_Line;
- TOF;
- sx := 1;
- count := 0;
- Descending := xpos( '/D', MParm_Str, 1 ) <> 0;
- Caps_On := Xpos( '/CASE', MParm_Str, 1 ) <> 0;
- c := parse_int( '/C=', MParm_Str );
- l := parse_int( '/L=', MParm_Str );
- if c = 0 then
- c := 1;
- end;
- if l = 0 then
- l := 254;
- end;
-
- if xpos( '/B', MParm_Str, 1 ) <> 0 then
- if Block_Stat <> 1 THEN
- Make_Message( 'No line block marked.');
- goto exit;
- end;
- old_block_stat := block_stat;
- sx := block_line1;
- nc := block_line2;
- block_off;
- end;
- sl := sx;
-
- sort_mode := ((nc - sx) > 100);
-
- Make_Message( 'Sorting...' );
-
- { We're going to do this with 2 different loops, depending on the
- options, for speed's sake }
-
-
- if sort_mode then
- jx := 0;
- while jx < 254 do
- ++jx;
- set_global_int( char(jx) + 'SORT', sx );
- end;
- end;
-
- If Descending then
- goto DESCEND;
- end;
-
- ASCEND:
- while sx < nc do
- ++sx;
- put_line_num(sx);
- GOTO_LINE(SX);
- dp1 := Get_Line;
- dx1 := (Copy( dp1, c, l ));
- If Caps_On then
- dx1 := caps(dx1);
- end;
- del_line;
- if sort_mode then
- dc := str_char(dx1,1);
- ix := global_int( dc + 'SORT' );
- else
- ix := sl;
- end;
- while ix < sx do
- goto_line(ix);
- dx2 := (Copy( get_line, c, l ));
- If Caps_On then
- dx2 := caps(dx2);
- end;
- If ( dx1 < dx2 ) then
- do_insert2:
- goto_col(1);
- cr;
- up;
- put_line(dp1);
- ++count;
- IF count > 99 THEN
- pop_undo;
- push_undo;
- count := 0;
- END;
- if sort_mode then
- up;
- goto_col(c);
- tc := cur_char;
- if caps_on then
- tc := caps(tc);
- end;
- if tc < dc then
- set_global_int( dc + 'SORT', c_line );
- end;
- end;
- goto ascend;
- END;
- ++ix;
- END;
- down;
- goto do_insert2;
- loopb:
- END;
- goto done;
-
- DESCEND:
- while sx < nc do
- ++sx;
- put_line_num(sx);
- GOTO_LINE(SX);
- dp1 := Get_Line;
- dx1 := (Copy( dp1, c, l ));
- If Caps_On then
- dx1 := caps(dx1);
- end;
- del_line;
- if sort_mode then
- dc := str_char(dx1,1);
- ix := global_int( dc + 'SORT' );
- else
- ix := sl;
- end;
- while ix < sx do
- goto_line(ix);
- dx2 := (Copy( get_line, c, l ));
- If Caps_On then
- dx2 := caps(dx2);
- end;
- If ( dx2 < dx1 ) then
- do_insert3:
- goto_col(1);
- cr;
- up;
- put_line(dp1);
- ++count;
- IF count > 99 THEN
- pop_undo;
- push_undo;
- count := 0;
- END;
- if sort_mode then
- up;
- tc := cur_char;
- if caps_on then
- tc := caps(tc);
- end;
- if tc > dc then
- set_global_int( dc + 'SORT', c_line );
- end;
- end;
- goto descend;
- END;
- ++ix;
- END;
- down;
- goto do_insert3;
- loopc:
- END;
- goto done;
-
- done:
- Make_Message( 'Sorting complete.' );
- exit:
- if sort_mode then
- jx := 0;
- while jx < 254 do
- ++jx;
- set_global_int( char(jx) + 'SORT', 0 );
- end;
- end;
- if old_block_stat > 0 then
- goto_line(sl);
- block_begin;
- goto_line(nc);
- block_end;
- end;
- wrap_stat := tw;
- pop_undo;
- refresh := true;
- goto_line( sl );
- Goto_COL(sc);
- redraw;
- END_MACRO;
-
- $MACRO CENTER TRANS;
- {*******************************************************************************
- MULTI-EDIT MACRO
-
- Name: CENTER
-
- Description: Centers the line the cursor is on between column 1 and the right
- margin.
-
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- *******************************************************************************}
-
- Def_Int(jx);
- Def_Str(tstr);
- refresh := false;
- Goto_Col(1);
- Push_Undo;
- Insert_Mode := True;
- {Delete leading spaces}
- While NOT(At_EOL) and (XPOS(Cur_Char,'|255|9|32',1) <> 0) Do
- Del_Char;
- End;
- {Store line into variable}
- Tstr := Shorten_Str(Get_Line);
- jx := Svl(Tstr);
- If jx > 0 THEN
- jx := (Right_Margin / 2) - (jx / 2);
- {Blank out existing line}
- Put_line('');
- Goto_Col(jx);
- {Put line at new position. Works with tabs as spaces, or tabs.}
- Text(TStr);
- END;
- redraw;
- Pop_Undo;
- END_MACRO;
-
-
- $MACRO OPENLN;
- {*******************************************************************************
- MULTI-EDIT MACRO
-
- Name: openln
-
- Description: Opens a line below the current line, without moving the cursor.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- *******************************************************************************}
-
- def_int( temp_ins );
- push_undo;
- temp_ins := insert_mode;
- insert_mode := true;
- Mark_Pos;
- CR;
- Goto_Mark;
- Make_Message('Line opened.');
- insert_mode := temp_ins;
- pop_undo;
- END_MACRO;
-
- $MACRO REFORMAT TRANS;
- {******************************************************************************
- MULTI-EDIT MACRO
-
- Name: REFORMAT
-
- Description: Reformats the current paragraph from the current cursor position
- down.
- Parameters:
- /RC=n 1 = Restore Cursor position when done
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
- Push_Undo;
- Word_Wrap_Line( TRUE, FALSE );
- Pop_Undo;
- Make_Message('Paragraph reformatted.');
- END_MACRO;
-
- $MACRO JUSTIFY TRANS;
- {******************************************************************************
- MULTI-EDIT MACRO
-
- Name: JUSTIFY
-
- Description: Justifies the current paragraph from the current cursor position
- down.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
- def_int( jx,jy,rr,jk, ti, tw );
-
- push_undo;
- tw := wrap_stat;
- wrap_stat := false;
- ti := insert_mode;
- insert_mode := true;
- refresh := false;
- mark_pos;
- IF Right_Margin > 132 then
- Goto_Mark;
- Make_Message('Right Margin too big.');
- Goto Exit2;
- END;
- Make_Message('Justifying paragraph...');
- Working;
- MAIN_LOOP:
- down;
- goto_col(1);
- if AT_EOL then
- goto EXIT;
- end;
- if Xpos(page_str,get_line,1) then
- goto exit;
- end;
- up;
- M2:
- first_word;
- {remove trailing spaces}
- put_line( Shorten_Str(Get_Line) );
- jx := 0;
-
- {Count existing spaces}
- SPACE_LOOP:
- if cur_char = ' ' then
- jx := jx + 1;
- end;
- right;
- if NOT( AT_EOL ) then
- goto space_loop;
- end;
- eol;
- left;
- jy := Right_Margin - c_col;
- IF (jy <= 0) OR (jX <= 0) then
- goto NEXT_LINE;
- end;
- rr := jx / jy;
- first_word;
- jx := 0;
- jk := 0;
- {Add in extra spaces until desired line length is reached}
- while NOT( AT_EOL ) do
- if cur_char = ' ' then
- jx := jx + 1;
- if jx >= rr then
- if jk < jy then
- jk := jk + 1;
- text(' ');
- right;
- end;
- jx := 0;
- end;
- end;
- right;
- end;
-
- {Repeat until at end of paragraph}
- IF c_col > Right_Margin then
- goto NEXT_LINE;
- END;
- GOTO M2;
- NEXT_LINE:
- down;
- eol;
- if c_col = 1 then
- goto EXIT;
- end;
- if hard_cr <> '' then
- if xpos(hard_cr, get_line, 1) then
- goto EXIT;
- end;
- end;
-
- GOTO MAIN_LOOP;
-
- EXIT:
- goto_mark;
- Make_Message('Paragraph justified.');
- EXIT2:
- refresh := true;
- wrap_stat := tw;
- pop_undo;
- redraw;
- insert_mode := ti;
- END_MACRO;
-
- $MACRO UNJUSTIF TRANS;
- {******************************************************************************
- MULTI-EDIT MACRO
-
- Name: UNJUSTIF
-
- Description: Unjustifies the current paragraph from the current cursor position
- down.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
- def_int( tw );
- push_undo;
- tw := wrap_stat;
- wrap_stat := false;
-
- mark_pos;
- refresh := false;
-
- Make_Message('Unjustifying paragraph...');
- Working;
- main_loop:
- first_word;
- {Check for end of paragraph}
- if AT_EOL then
- goto EXIT;
- END;
- if hard_cr <> '' then
- if xpos(hard_cr, get_line, 1) then
- goto EXIT;
- end;
- end;
- while NOT( AT_EOL ) do
- {Skip over end of sentences, etc.}
- if pos(cur_char,'.!?:') then
- right;
- right;
- end;
- {Otherwise, remove occurances of more than one space}
- if cur_char = ' ' then
- right;
- while cur_char = ' ' do
- del_char;
- end;
- end;
- right;
- end;
- down;
- goto Main_Loop;
- EXIT:
- Make_Message('Paragraph Unjustified...');
- wrap_stat := tw;
- pop_undo;
- refresh := true;
- goto_mark;
- redraw;
-
- END_MACRO;
-
- $MACRO RULER;
- {*******************************MULTI-EDIT MACRO******************************
-
- Name: RULER
-
- Description: Puts up a character ruler at the cursor position.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
-
- def_str( tstr, tstr2 );
- def_int( jx, jy, jl, jk, old_col, t_line, offset, omm, ptr_removed );
- refresh := TRUE;
- if c_row < 3 then
- offset := 1;
- ELSE
- offset := -2;
- END;
- redraw;
- old_col := c_col;
- tstr := '';
- tstr2 := '';
- jx := 0;
- jy := 1;
- jl := 0;
- while jx < 254 do
- tstr := tstr + str(jy);
- ++jx;
- ++jy;
- if jy = 10 THEN
- ++jx;
- jy := 1;
- tstr := tstr + '0';
- ++jl;
- tstr2 := tstr2 + copy('══════════', 1,10 - length(str(jl))) + str(jl);
- END;
- end;
- omm := mouse_mode;
- ptr_removed := FALSE;
- make_message('Use |27|26 arrow keys, <HOME> and <END> to move. Press <ESC> to exit ruler.');
- loop:
- call put_ruler;
- while NOT(check_key) DO
- Mou_Check_Status;
- IF ((Mou_Last_Status AND 1) = 0) THEN
- mouse_mode := omm;
- IF ptr_removed THEN
- --ptr_removed;
- mou_set_pos( wherex, wherey );
- mou_draw_ptr;
- END;
- END;
- END;
- if key1 = 27 then
- goto exit;
- end;
- if key1 = 0 THEN
- if (key2 = 245) OR (key2 = 251) THEN
- goto exit;
- elsif (key2 = 250) THEN
- IF (mou_last_x > win_x1) AND (mou_last_x < win_x2) AND
- (mou_last_y = wherey) THEN
- RM('MouseInWindow');
- IF return_int THEN
- mouse_mode := TRUE;
- mou_reset;
- mou_remove_ptr;
- ++ptr_removed;
- END;
- END;
- elsif (c_col < 2048) and ((key2 = 77) or (key2 = 243)) THEN
- right;
- elsif (c_col > 1) and ((key2 = 75) or (key2 = 242)) THEN
- left;
- elsif key2 = 71 THEN
- goto_col(old_col);
- elsif key2 = 79 THEN
- eol;
- END;
- end;
- goto loop;
-
- put_ruler:
- jy := c_col - (wherex - win_x1);
- jk := 1;
- if old_col <= jy THEN
- jk := jy - old_col + 2;
- END;
- jx := old_col - jy;
- if jx < 1 THEN
- jx := 1;
- end;
-
- jl := win_x2 - (win_x1 + jx);
-
- write( copy(tstr2, jk, jl), win_x1 + jx, wherey + offset, 0, h_color );
- write( copy(tstr, jk, jl), win_x1 + jx, wherey + offset + 1, 0, h_color );
- ret;
-
- no_room:
- Make_Message('No room in window for ruler.');
- goto exit2;
- exit:
- make_message('Ruler done.');
- exit2:
- while ptr_removed > 0 DO
- --ptr_removed;
- mou_set_pos( wherex, wherey );
- mou_draw_ptr;
- END;
- mouse_mode := omm;
- redraw;
- END_MACRO;
-
-
- $MACRO END_OF_PARAGRAPH;
- {*******************************MULTI-EDIT MACRO******************************
-
- Name: END_OF_PARAGRAPH
-
- Description: Finds the end of the current paragraph.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
-
- Refresh := FALSE;
- LOOP:
- IF (copy(get_line, 1, length(page_str)) = page_str) THEN
- goto EXIT;
- END;
- EOL;
- IF (c_col = 1) OR (At_EOF) THEN
- goto EXIT;
- END;
- LEFT;
- IF cur_char = Hard_CR THEN
- goto exit;
- END;
- DOWN;
- GOTO LOOP;
- EXIT:
- END_MACRO;
-
- $MACRO NEXT_PARAGRAPH;
- {*******************************MULTI-EDIT MACRO******************************
-
- Name: NEXT_PARAGRAPH
-
- Description: Finds the beginning of the next paragraph.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
-
- RM( 'End_Of_Paragraph' );
- Refresh := FALSE;
- LOOP:
- DOWN;
- First_Word;
- IF (cur_char = Hard_Cr) OR (At_EOL) OR
- (copy(get_line, 1, length(page_str)) = page_str) THEN
- IF Not(At_EOF) THEN
- Goto LOOP;
- END;
- END;
- END_MACRO;
-
-
- $MACRO MARKPOS;
- {*******************************MULTI-EDIT MACRO******************************
-
- Name: MARKPOS
-
- Description: Just acts as an interface to the macro function MARK_POS.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
-
- mark_pos;
- make_message('Position marked.');
- END_MACRO;
-
- $MACRO GOTOMARK;
- {*******************************MULTI-EDIT MACRO******************************
-
- Name: GOTOMARK
-
- Description: Just acts as an interface to the macro function GOTO_MARK.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
- goto_mark;
- make_message('Position retrieved.');
- END_MACRO;
-
- $MACRO SET_MARK;
- {******************************************************************************
- MULTI-EDIT MACRO
-
- Name: SET_MARK
-
- Description: Uses the new random access marker stack to set 10 markers.
- If SET_MARK is executed without parameters, the user is prompted
- to press a number key (0-9, 0=10) to specify the marker #. If a
- value of 1-10 is passed as a parameter, then the specified mark
- is set without prompting the user.
-
- Parameters: MParm_Str can contain 1-10 to denote going directly to the mark.
- If the entire MParm_Str does not contain numeric characters, this
- option will not work, and the menu will be invoked. Under these
- circumstances, the following parameters are expected:
- /X= The X coordinate for the menu
- /X= The X coordinate for the menu
- /BC= The amount of boxes which need to be killed upon exit
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
-
- def_int( jx, bc );
-
- {If a numeric parameter was passed then use it, and bypass
- the prompting}
- if Val(jx, MParm_Str) = 0 THEN
- if (jx > 0) and (jx < 11) then
- goto do_set;
- end;
- end;
-
- RM('USERIN^XMENU /B=1/L=Select marker # to set/X=' + parse_str('/X=', mparm_str) +
- '/Y=' + parse_str('/Y=', mparm_str) +
- '/M=1 (CU)2 ()3 ()4 ()5 ()6 ()7 ()8 ()9 ()0 ()');
- if return_int <= 0 then
- goto exit;
- end;
- jx := return_int;
- return_int := 100;
- do_set:
- bc := parse_int('/BC=', mparm_str);
- while box_count > bc do
- kill_box;
- end;
- set_mark( jx );
- make_message('Marker #' + str(jx) + ' set.' );
- exit:
- END_MACRO;
-
- $MACRO GET_MARK;
- {******************************************************************************
- MULTI-EDIT MACRO
-
- Name: GET_MARK
-
- Description: Uses the new random access marker stack to retrieve 10 markers.
- If GET_MARK is executed without parameters, the user is prompted
- to press a number key (0-9, 0=10) to specify the marker #. If a
- value of 1-10 is passed as a parameter, then the specified mark
- is retrieved without prompting the user.
-
- Parameters: MParm_Str can contain 1-10 to denote setting that particular mark.
- If the entire MParm_Str does not contain numeric characters, this
- option will not work, and the menu will be invoked. Under these
- circumstances, the following parameters are expected:
- /X= The X coordinate for the menu
- /X= The X coordinate for the menu
- /BC= The amount of boxes which need to be killed upon exit
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
-
- def_int( jx, bc );
-
- {If a numeric parameter was passed then use it, and bypass
- the prompting}
- if Val(jx, MParm_Str) = 0 THEN
- if (jx > 0) and (jx < 11) then
- goto do_get;
- end;
- end;
- RM('USERIN^XMENU /B=1/L=Select marker # to retrieve/X=' + parse_str('/X=', mparm_str) +
- '/Y=' + parse_str('/Y=', mparm_str) +
- '/M=1 (CU)2 ()3 ()4 ()5 ()6 ()7 ()8 ()9 ()0 ()');
- if return_int <= 0 then
- goto exit;
- end;
- jx := return_int;
- return_int := 100;
- do_get:
- bc := parse_int('/BC=', mparm_str);
- while box_count > bc do
- kill_box;
- end;
- get_mark( jx );
- make_message('Marker #' + str(jx) + ' retrieved.' );
- exit:
- END_MACRO;