home *** CD-ROM | disk | FTP | other *** search
- $MACRO_FILE MOUSE;
- {******************************************************************************
- MULTI-EDIT MACRO FILE
-
- Name: MOUSE
-
- Description: Support for the mouse
-
- MOUEVENT - The main mouse event processor
- MOUSE_MOVE - Handles mouse invoked block marking
- MOUSEINWINDOW - Figures out if mouse is clicked inside the window or on scroll bar.
- MOUSEEVENT2 - Runs the proper routines based on MOUSEINWINDOW
- MOUSEFKEY - Process mouse clicks on the FKEY labels
- GOTOSCROLLBAR - Moves to part of file corresponding to scroll bar click
- HANDLESCROLLBAR - Scrolls up or down when mouse is clicked on the arrows
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
-
- $MACRO MOUEVENT FROM EDIT;
- {******************************************************************************
- MULTI-EDIT MACRO
-
- Name: MOUEVENT
-
- Description: Traps all mouse events and determines whether to bring up the
- menu, move the cursor, invoke the function keys, etc.
-
- Parameters:
- /M= If 1, calling of menu and block marking is disabled.
- /S=1 disable resizing of windows, and selecting other windows
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
-
- def_int(jx, twin, in_win, trefresh, tscreen_num, already_in, recent_display_time );
- def_int( t_ofs, new_line, new_col, old_x, old_y, mouevent_mode, nw, no_sizing );
- def_int( x1, x2, y1, y2 );
-
- trefresh := refresh;
- refresh := false;
- mouevent_mode := Parse_Int('/M=', mparm_str);
- IF mouevent_mode = 0 THEN
- IF (mou_last_y = menu_bar_row) THEN
- IF (mou_last_x >= menu_bar_col) AND (mou_last_x < (menu_bar_col + length(menu_bar_str))) THEN
- Push_Key(key1,key2);
- END;
- RM('MEUTIL3^MEMENUS /B=1');
- goto exit;
- ELSIF (menu_bar_row = 0) AND
- ((mou_last_y = message_row) OR (mou_last_y = status_row)) THEN
- RM('MEUTIL3^MEMENUS');
- goto exit;
- END;
- END;
-
- IF (Mou_Last_Y = FKey_Row) AND (Mou_Last_X < 80) THEN
- RM('MouseFkey');
- goto Exit;
- END;
- old_x := Mou_Last_X;
- old_y := Mou_Last_Y;
- recent_display_time := 0;
- twin := cur_window;
- nw := twin;
- tscreen_num := screen_num;
- in_win := 0;
- call check_window;
- already_in := in_win;
- no_sizing := parse_int('/S=', mparm_str);
- IF (in_win = 0) AND NOT(no_sizing) THEN
- jx := window_count + 1;
- WHILE (jx > 1) DO
- --jx;
- switch_window( jx );
- IF (window_attr AND $81) = 0 THEN
- call check_window;
- END;
- END;
- IF in_win THEN
- switch_window( twin );
- refresh := TRUE;
- { REDRAW; }
- switch_window( nw );
- refresh := FALSE;
- goto mouse_in_window;
- END;
- ELSE
- goto mouse_in_window;
- END;
-
- switch_window( twin );
-
- IF (Mou_Last_Y >= min_window_row) AND (Mou_Last_Y <= max_window_row) THEN
- WHILE ((Mou_Last_Status AND 1) <> 0) AND
- ((old_x = Mou_Last_X) OR (old_y = Mou_Last_Y)) DO
- Mou_Check_Status;
- END;
- IF ((Mou_Last_Status AND 1) <> 0) THEN
- x1 := Old_X;
- x2 := Mou_Last_x;
- y1 := Old_Y;
- y2 := Mou_Last_Y;
- jx := 1;
- IF (Mou_Last_Y > Old_Y) THEN
- jx := 3;
- ELSE
- y1 := Mou_Last_Y;
- y2 := Old_Y;
- END;
- IF (Mou_Last_X > Old_X) THEN
- ++jx;
- ELSE
- x1 := Mou_Last_X;
- x2 := Old_X;
- END;
- refresh := FALSE;
- RM('CREATEWINDOW');
- nw := cur_window;
- size_window( x1, y1, x2, y2 );
- RM('WINDOW^MOD_WIN /MM=1/MS=' + str(jx));
- RM('WINDOW^MAKEWIN /NC=1/L=1');
- switch_window(nw);
- END;
- END;
- goto exit;
-
- mouse_in_window:
- IF (Window_Attr AND $40) <> 0 THEN
- IF (mou_last_x = (win_x1 + Length(Truncate_Path(file_name)) + 2)) THEN
- RM('WINDOW^ZOOM');
- ELSIF (Mou_Last_X <= (Win_X1 + 1)) THEN
- goto RUN_WINDOW_MENU;
- ELSE
- goto MOVE_WIN;
- END;
- ELSIF (Mou_Last_Y = win_y1) THEN
- IF NOT( no_sizing ) THEN
- IF (mou_last_x >= (win_x1 + 2)) AND
- (mou_last_x <= (win_x1 + 3 + length(window_name))) THEN
- RUN_WINDOW_MENU:
- refresh := false;
- RM('MEUTIL3^WINDMENU /X=' + str( mou_last_x ) + '/Y=' + str( mou_last_y ) );
- ELSIF (Mou_Last_X <= (win_x1 + 1)) THEN
- RM('WINDOW^MOD_WIN /MM=1/MS=1');
- ELSIF (Mou_Last_X = win_x2) THEN
- RM('WINDOW^MOD_WIN /MM=1/MS=2');
- ELSIF (Mou_Last_X = (win_x2 - 1)) THEN
- RM('WINDOW^ZOOM');
- ELSE
- MOVE_WIN:
- RM('WINDOW^MOD_WIN /MM=1/MS=0');
- END;
- END;
- ELSE
- IF ((Mou_Last_X = win_x1) AND (Mou_Last_Y <= (win_y1 + 1)))
- OR
- ((Mou_Last_Y = win_y1) AND (Mou_Last_X < (win_x1 + 2))) THEN
- IF NOT(no_sizing) THEN
- RM('WINDOW^MOD_WIN /MM=1/MS=1');
- END;
- ELSIF ((Mou_Last_X = win_x2) AND (Mou_Last_Y >= (win_y2)))
- OR
- ((Mou_Last_Y = win_y2) AND (Mou_Last_X >= (win_x2 - 2))) THEN
- IF NOT(no_sizing) THEN
- RM('WINDOW^MOD_WIN /MM=1/MS=4');
- END;
- ELSIF ((Mou_Last_X = win_x1) AND (Mou_Last_Y = (win_y2))) THEN
- IF NOT(no_sizing) THEN
- RM('WINDOW^MOD_WIN /MM=1/MS=3');
- END;
- ELSIF (mou_last_x = win_x2) THEN
- rm('HandleScrollBar');
- ELSE
- RM('MouseInWindow');
- IF return_int THEN
- RM('MOUSE_MOVE /V=1/H=1/B=' + str( mouevent_mode = 0));
- END;
- END;
- END;
- goto exit;
-
- check_window:
- if (mou_last_x >= win_x1) AND (mou_last_x <= win_x2) AND
- (mou_last_y >= win_y1) AND (mou_last_y <= win_y2) AND
- ( last_update_time > recent_display_time ) THEN
- IF (mou_last_y = win_y2) AND NOT(w_bottom_line) THEN
- ret;
- END;
- in_win := 1;
- nw := cur_window;
- recent_display_time := last_update_time;
- END;
- ret;
-
- exit:
- refresh := trefresh;
- END_MACRO;
-
- $MACRO MOUSE_MOVE FROM ALL;
- {******************************************************************************
- MULTI-EDIT MACRO
-
- Name: MOUSE_MOVE
-
- Description: Moves the cursor or starts block marking based on mouse clicks
-
- Parameters:
-
- /V= If 1, enables vertical movement.
- /H= If 1, enables horizontal movement.
- /B= If 1, enables block marking.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
-
- def_int( jx,old_refresh, old_mouse_mode, vertical, horizontal, first );
- def_str( tstr[20] );
- first := 1;
- old_refresh := refresh;
- refresh := true;
- goto_col( c_col );
- vertical := parse_int('/V=', mparm_str);
- horizontal := parse_int('/H=', mparm_str);
- old_mouse_mode := mouse_mode;
- Mou_Check_Status;
- mou_reset;
- mouse_mode := TRUE;
- mou_remove_ptr;
- loop:
- Mou_Check_Status;
- IF ((Mou_Last_Status AND 3) = 0) THEN
- GOTO exit;
- END;
- IF check_key THEN
- IF first THEN
- first := FALSE;
- IF parse_int('/B=',mparm_str) AND (marking) THEN
- jx := block_stat;
- block_end;
- Make_Message('Block marked.');
- set_global_int('@LAST_BLOCK_TYPE', block_stat);
- END;
- IF parse_int('/B=',mparm_str) THEN
- jx := global_int('@LAST_BLOCK_TYPE');
- IF jx = 1 THEN
- block_begin;
- tstr := 'Line';
- ELSIF jx = 2 THEN
- tstr := 'Columnar';
- col_block_begin;
- ELSIF (jx = 3) OR (jx = 0) THEN
- tstr := 'Stream';
- str_block_begin;
- END;
- Make_Message( 'Marking ' + tstr + ' block, release mouse button to end.' );
- END;
- END;
- IF key1 = 0 THEN
- IF vertical and (key2 = 240) THEN
- UP;
- ELSIF vertical and (key2 = 241) THEN
- DOWN;
- ELSIF horizontal and (key2 = 242) THEN
- MS_LEFT;
- ELSIF horizontal and (key2 = 243) THEN
- RIGHT;
- END;
- ELSIF key1 = 27 THEN
- goto exit;
- END;
- END;
- GOTO loop;
-
- exit:
-
- IF NOT(first) AND (parse_int('/B=',mparm_str)) THEN
- block_end;
- Make_message('Block marked. Default mouse marking mode is ' + tstr + '.');
- set_global_int('@LAST_BLOCK_TYPE', block_stat);
- END;
-
- mouse_mode := old_mouse_mode;
- Mou_Set_Pos( wherex, wherey );
- refresh := old_refresh;
- Mou_Draw_Ptr;
- END_MACRO;
-
- $MACRO MOUSEINWINDOW FROM ALL;
- {******************************************************************************
- MULTI-EDIT MACRO
-
- Name: MOUSEINWINDOW
-
- Description: Handles the mouse when clicked inside the window
-
- RETURNS: RETURN_INT = 1 if mouse was inside window,
- RETURN_INT = 0 if mouse was not inside window.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
-
- DEF_INT( new_col, new_line );
-
- IF (mou_last_x > win_x1) AND (mou_last_x < win_x2) AND
- (mou_last_y < win_y2) AND (mou_last_y > win_y1) THEN
- refresh := true;
- goto_v_col( v_col );
- new_col := (v_col - (wherex - win_x1)) + (Mou_Last_X - win_x1);
- new_line := (c_line - c_row) + (Mou_Last_Y - win_y1);
- IF c_line < new_line THEN
- WHILE c_line < new_line DO
- DOWN;
- END;
- ELSE
- WHILE c_line > new_line DO
- UP;
- END;
- END;
- goto_v_col( new_col );
- return_int := 1;
- ELSE
- return_int := 0;
- END;
-
- END_MACRO;
-
- $MACRO MOUSEEVENT2;
- {******************************************************************************
- MULTI-EDIT MACRO
-
- Name: MOUSEEVENT2
-
- Description: Determines whether to move the text cursor or process the scroll
- bar.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
- RM('MouseInWindow');
- IF return_int THEN
- RM('Mouse_Move /V=1/H=1');
- ELSE
- RM('GotoScrollBar');
- END;
- END_MACRO;
-
- $MACRO MOUSEFKEY FROM ALL;
- {******************************************************************************
- MULTI-EDIT MACRO
-
- Name: MOUSEFKEY
-
- Description: Handles mouse clicks on the function key line.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
-
- Def_Int( Shift_Status, key_num, shift_add );
-
- IF Mou_Last_Y = FKey_Row THEN
- R_AX := $0200;
- INTR($16);
- Shift_Status := R_AX AND $0F;
- shift_add := 0;
- if (Mou_Last_X mod 8) = 0 THEN
- goto exit;
- END;
- key_num := (Mou_Last_X / 8) + 1;
- IF (Shift_Status = 0) THEN {Normal}
- Shift_Add := 58;
- ELSIF (Shift_Status = 4) THEN {Ctrl}
- Shift_Add := 93;
- ELSIF (Shift_Status > 0) AND (Shift_Status < 4) THEN {shifted}
- Shift_Add := 83;
- ELSIF (Shift_Status = 8) THEN
- Shift_Add := 103;
- ELSE
- Goto EXIT;
- END;
- Push_Key(0,Shift_Add + Key_Num);
- END;
- EXIT:
- END_MACRO;
-
- $MACRO GOTOSCROLLBAR;
- {******************************************************************************
- MULTI-EDIT MACRO
-
- Name: GOTOSCROLLBAR
-
- Description: Moves to the line in the file corresponding to the scroll bar.
-
- Parameters:
- /L= Overrides the total lines in the file.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
-
- def_int( jz, jx, jy, tr );
- tr := refresh;
- refresh := false;
- jz := parse_int('/L=', mparm_str);
- jx := c_col;
- IF (Mou_Last_X = Win_X2) AND (Mou_Last_Y < (Win_Y2 - 1)) AND
- (Mou_Last_Y > (Win_Y1 + 1)) THEN
- IF (Mou_Last_Y = (Win_Y1 + 2)) THEN
- tof;
- goto_col(jx);
- ELSIF (Mou_Last_Y = (Win_Y2 - 2)) THEN
- eof;
- goto_col(jx);
- ELSE
- IF jz = 0 THEN
- eof;
- jz := c_line;
- goto_col( jx );
- END;
- WHILE (c_row > 1) AND (c_line > 1) DO
- up;
- END;
-
- jy := win_y2 - win_y1 - 1;
- jx := ((jz - jy)) * 1000;
- jx := jx / (jy - 2);
- jy := mou_last_y - (win_y1 + 1);
- jx := jx * jy;
- IF (jx mod 1000 ) <> 0 THEN
- jx := (jx / 1000) + 1;
- ELSE
- jx := jx / 1000;
- END;
-
- goto_line(jx);
- END;
- END;
- refresh := tr;
- return_int := jz;
- END_MACRO;
-
- $MACRO HANDLESCROLLBAR;
- {******************************************************************************
- MULTI-EDIT MACRO
-
- Name: HANDLESCROLLBAR
-
- Description: Scrolls up or down when mouse is clicked or held down on the
- arrows of the scroll bar.
-
-
- Parameters:
- /EOF=1 Limit movement to EOF.
-
- (C) Copyright 1989 by American Cybernetics, Inc.
- ******************************************************************************}
-
- def_int( jx, old_x, old_y, eof_limit, direction_result );
- eof_limit := parse_int('/EOF=', mparm_str );
- old_x := Mou_Last_X;
- old_y := Mou_Last_Y;
- direction_result := 0;
- IF (mou_last_x = win_x2) THEN
- IF (mou_last_y = (win_y2 - 1)) THEN
- refresh := false;
- jx := c_row;
- while c_row < ((win_y2 - win_y1 - 1)) DO
- down;
- END;
- refresh := TRUE;
- scroll_up:
- IF (eof_limit = 0) OR (at_eof = 0) THEN
- down;
- END;
- CALL Mouse_Repeat_Loop;
- IF return_int = 1 THEN
- Goto Scroll_Up;
- END;
- refresh := false;
- while c_row > jx DO
- up;
- END;
- refresh := TRUE;
- direction_result := 1;
- ELSIF (mou_last_y = (win_y1 + 1)) THEN
- refresh := false;
- jx := c_row;
- while c_row > 1 DO
- up;
- END;
- refresh := TRUE;
- scroll_down:
- up;
- CALL Mouse_Repeat_Loop;
- IF return_int = 1 THEN
- Goto Scroll_Down;
- END;
- refresh := false;
- while c_row < jx DO
- down;
- END;
- refresh := TRUE;
- direction_result := 2;
- ELSIF (Mou_Last_y > win_y1) AND (Mou_Last_y < win_y2) THEN
- refresh := TRUE;
- page_loop:
- jx := Mou_Last_Y - Win_Y1 - 1;
- IF jx > cur_scroll_pos THEN
- page_down;
- direction_result := 1;
- ELSIF jx < cur_scroll_pos THEN
- page_up;
- direction_result := 2;
- ELSIF jx = cur_scroll_pos THEN
- goto drag_scroll_pos;
- END;
- CALL Mouse_Repeat_Loop;
- IF return_int = 1 THEN
- Goto page_loop;
- END;
- END;
- END;
- GOTO EXIT;
-
-
- Mouse_Repeat_Loop:
- Mou_Repeat := TRUE;
- du2:
- Mou_Check_Status;
- IF ((Mou_Last_Status AND 1) <> 0) AND (old_x = Mou_Last_X) AND
- (old_y = Mou_Last_Y) THEN
- IF check_Key THEN
- IF (key2 = 250) AND (key1 = 0) THEN
- return_int := 1;
- RET;
- ELSE
- push_key( key1, key2 );
- END;
- ELSE
- GOTO du2;
- END;
- END;
- return_int := 0;
- Mou_Repeat := FALSE;
- RET;
-
- drag_scroll_pos:
- return_int := parse_int('/L=', mparm_str);
- Mou_Set_Limits(win_x2,win_y1 + 2,win_x2, win_y2 - 2);
- Mou_Repeat := FALSE;
- du3:
- Mou_Check_Status;
- IF ((Mou_Last_Status AND 1) <> 0) THEN
- IF old_y <> mou_last_y THEN
- RM('GOTOSCROLLBAR /L=' + str(return_int));
- REFRESH := TRUE;
- update_window;
- END;
- old_y := mou_last_y;
- goto du3;
- END;
- Mou_Set_Limits(1,1,screen_width, screen_length);
- direction_result := 1;
- goto exit;
- exit:
- return_int := direction_result;
- END_MACRO;
-