home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / ME494-6.ZIP / MOUSE.SRC < prev    next >
Encoding:
Text File  |  1990-06-05  |  14.5 KB  |  566 lines

  1. $MACRO_FILE MOUSE;
  2. {******************************************************************************
  3.                                                         MULTI-EDIT MACRO FILE
  4.  
  5. Name: MOUSE
  6.  
  7. Description:    Support for the mouse
  8.  
  9. MOUEVENT                - The main mouse event processor
  10. MOUSE_MOVE            - Handles mouse invoked block marking
  11. MOUSEINWINDOW        - Figures out if mouse is clicked inside the window or on scroll bar.
  12. MOUSEEVENT2            - Runs the proper routines based on MOUSEINWINDOW
  13. MOUSEFKEY                - Process mouse clicks on the FKEY labels
  14. GOTOSCROLLBAR        - Moves to part of file corresponding to scroll bar click
  15. HANDLESCROLLBAR - Scrolls up or down when mouse is clicked on the arrows
  16.  
  17.                              (C) Copyright 1989 by American Cybernetics, Inc.
  18. ******************************************************************************}
  19.  
  20. $MACRO MOUEVENT FROM EDIT;
  21. {******************************************************************************
  22.                                                                 MULTI-EDIT MACRO
  23.  
  24. Name: MOUEVENT
  25.  
  26. Description:    Traps all mouse events and determines whether to bring up the
  27.                             menu, move the cursor, invoke the function keys, etc.
  28.  
  29. Parameters:
  30.                             /M= If 1, calling of menu and block marking is disabled.
  31.                             /S=1 disable resizing of windows, and selecting other windows
  32.  
  33.                              (C) Copyright 1989 by American Cybernetics, Inc.
  34. ******************************************************************************}
  35.  
  36.     def_int(jx, twin, in_win, trefresh, tscreen_num, already_in, recent_display_time );
  37.     def_int( t_ofs, new_line, new_col, old_x, old_y, mouevent_mode, nw, no_sizing );
  38.     def_int( x1, x2, y1, y2 );
  39.  
  40.     trefresh := refresh;
  41.     refresh := false;
  42.     mouevent_mode := Parse_Int('/M=', mparm_str);
  43.     IF mouevent_mode = 0 THEN
  44.         IF (mou_last_y = menu_bar_row) THEN
  45.             IF (mou_last_x >= menu_bar_col) AND (mou_last_x < (menu_bar_col + length(menu_bar_str))) THEN
  46.                 Push_Key(key1,key2);
  47.             END;
  48.             RM('MEUTIL3^MEMENUS /B=1');
  49.             goto exit;
  50.         ELSIF (menu_bar_row = 0) AND
  51.             ((mou_last_y = message_row) OR (mou_last_y = status_row)) THEN
  52.             RM('MEUTIL3^MEMENUS');
  53.             goto exit;
  54.         END;
  55.     END;
  56.  
  57.     IF (Mou_Last_Y = FKey_Row) AND (Mou_Last_X < 80) THEN
  58.         RM('MouseFkey');
  59.         goto Exit;
  60.     END;
  61.     old_x := Mou_Last_X;
  62.     old_y := Mou_Last_Y;
  63.     recent_display_time := 0;
  64.     twin := cur_window;
  65.     nw := twin;
  66.     tscreen_num := screen_num;
  67.     in_win := 0;
  68.     call check_window;
  69.     already_in := in_win;
  70.     no_sizing := parse_int('/S=', mparm_str);
  71.     IF (in_win = 0) AND NOT(no_sizing) THEN
  72.         jx := window_count + 1;
  73.         WHILE (jx > 1) DO
  74.             --jx;
  75.             switch_window( jx );
  76.             IF (window_attr AND $81) = 0 THEN
  77.                 call check_window;
  78.             END;
  79.         END;
  80.         IF in_win THEN
  81.             switch_window( twin );
  82.             refresh := TRUE;
  83.         {    REDRAW; }
  84.             switch_window( nw );
  85.             refresh := FALSE;
  86.             goto mouse_in_window;
  87.         END;
  88.     ELSE
  89.         goto mouse_in_window;
  90.     END;
  91.  
  92.     switch_window( twin );
  93.  
  94.     IF (Mou_Last_Y >= min_window_row) AND (Mou_Last_Y <= max_window_row) THEN
  95.         WHILE ((Mou_Last_Status AND 1) <> 0) AND
  96.             ((old_x = Mou_Last_X) OR (old_y = Mou_Last_Y)) DO
  97.             Mou_Check_Status;
  98.         END;
  99.         IF ((Mou_Last_Status AND 1) <> 0) THEN
  100.             x1 := Old_X;
  101.             x2 := Mou_Last_x;
  102.             y1 := Old_Y;
  103.             y2 := Mou_Last_Y;
  104.             jx := 1;
  105.             IF (Mou_Last_Y > Old_Y) THEN
  106.                 jx := 3;
  107.             ELSE
  108.                 y1 := Mou_Last_Y;
  109.                 y2 := Old_Y;
  110.             END;
  111.             IF (Mou_Last_X > Old_X) THEN
  112.                 ++jx;
  113.             ELSE
  114.                 x1 := Mou_Last_X;
  115.                 x2 := Old_X;
  116.             END;
  117.             refresh := FALSE;
  118.             RM('CREATEWINDOW');
  119.             nw := cur_window;
  120.             size_window( x1, y1, x2, y2 );
  121.         RM('WINDOW^MOD_WIN /MM=1/MS=' + str(jx));
  122.             RM('WINDOW^MAKEWIN /NC=1/L=1');
  123.             switch_window(nw);
  124.         END;
  125.     END;
  126.     goto exit;
  127.  
  128. mouse_in_window:
  129.     IF (Window_Attr AND $40) <> 0 THEN
  130.         IF (mou_last_x = (win_x1 + Length(Truncate_Path(file_name)) + 2)) THEN
  131.       RM('WINDOW^ZOOM');
  132.         ELSIF (Mou_Last_X <= (Win_X1 + 1)) THEN
  133.             goto RUN_WINDOW_MENU;
  134.         ELSE
  135.             goto MOVE_WIN;
  136.         END;
  137.     ELSIF (Mou_Last_Y = win_y1) THEN
  138.         IF NOT( no_sizing ) THEN
  139.             IF (mou_last_x >= (win_x1 + 2)) AND
  140.                     (mou_last_x <= (win_x1 + 3 + length(window_name))) THEN
  141.         RUN_WINDOW_MENU:
  142.                 refresh := false;
  143.                 RM('MEUTIL3^WINDMENU /X=' + str( mou_last_x ) + '/Y=' + str( mou_last_y ) );
  144.             ELSIF (Mou_Last_X <= (win_x1 + 1)) THEN
  145.                 RM('WINDOW^MOD_WIN /MM=1/MS=1');
  146.             ELSIF (Mou_Last_X = win_x2) THEN
  147.                 RM('WINDOW^MOD_WIN /MM=1/MS=2');
  148.         ELSIF (Mou_Last_X = (win_x2 - 1)) THEN
  149.           RM('WINDOW^ZOOM');
  150.             ELSE
  151.         MOVE_WIN:
  152.                 RM('WINDOW^MOD_WIN /MM=1/MS=0');
  153.             END;
  154.         END;
  155.     ELSE
  156.     IF ((Mou_Last_X = win_x1) AND (Mou_Last_Y <= (win_y1 + 1)))
  157.             OR
  158.          ((Mou_Last_Y = win_y1) AND (Mou_Last_X < (win_x1 + 2))) THEN
  159.             IF NOT(no_sizing) THEN
  160.           RM('WINDOW^MOD_WIN /MM=1/MS=1');
  161.             END;
  162.     ELSIF ((Mou_Last_X = win_x2) AND (Mou_Last_Y >= (win_y2)))
  163.         OR
  164.       ((Mou_Last_Y = win_y2) AND (Mou_Last_X >= (win_x2 - 2))) THEN
  165.             IF NOT(no_sizing) THEN
  166.         RM('WINDOW^MOD_WIN /MM=1/MS=4');
  167.             END;
  168.     ELSIF ((Mou_Last_X = win_x1) AND (Mou_Last_Y = (win_y2))) THEN
  169.             IF NOT(no_sizing) THEN
  170.           RM('WINDOW^MOD_WIN /MM=1/MS=3');
  171.             END;
  172.     ELSIF (mou_last_x = win_x2) THEN
  173.       rm('HandleScrollBar');
  174.     ELSE
  175.       RM('MouseInWindow');
  176.       IF return_int THEN
  177.         RM('MOUSE_MOVE /V=1/H=1/B=' + str( mouevent_mode = 0));
  178.       END;
  179.     END;
  180.   END;
  181.     goto exit;
  182.  
  183. check_window:
  184.     if (mou_last_x >= win_x1) AND (mou_last_x <= win_x2) AND
  185.          (mou_last_y >= win_y1) AND (mou_last_y <= win_y2) AND
  186.             ( last_update_time > recent_display_time ) THEN
  187.         IF (mou_last_y = win_y2) AND NOT(w_bottom_line) THEN
  188.             ret;
  189.         END;
  190.         in_win := 1;
  191.         nw := cur_window;
  192.         recent_display_time := last_update_time;
  193.     END;
  194.     ret;
  195.  
  196. exit:
  197.     refresh := trefresh;
  198. END_MACRO;
  199.  
  200. $MACRO MOUSE_MOVE FROM ALL;
  201. {******************************************************************************
  202.                                                                 MULTI-EDIT MACRO
  203.  
  204. Name: MOUSE_MOVE
  205.  
  206. Description:    Moves the cursor or starts block marking based on mouse clicks
  207.  
  208. Parameters:
  209.  
  210.                             /V= If 1, enables vertical movement.
  211.                             /H= If 1, enables horizontal movement.
  212.                             /B= If 1, enables block marking.
  213.  
  214.                              (C) Copyright 1989 by American Cybernetics, Inc.
  215. ******************************************************************************}
  216.  
  217.     def_int( jx,old_refresh, old_mouse_mode, vertical, horizontal, first  );
  218.     def_str( tstr[20] );
  219.     first := 1;
  220.     old_refresh := refresh;
  221.     refresh := true;
  222.     goto_col( c_col );
  223.     vertical := parse_int('/V=', mparm_str);
  224.     horizontal := parse_int('/H=', mparm_str);
  225.     old_mouse_mode := mouse_mode;
  226.     Mou_Check_Status;
  227.     mou_reset;
  228.     mouse_mode := TRUE;
  229.     mou_remove_ptr;
  230. loop:
  231.     Mou_Check_Status;
  232.     IF ((Mou_Last_Status AND 3) = 0) THEN
  233.         GOTO exit;
  234.     END;
  235.     IF check_key THEN
  236.         IF first THEN
  237.             first := FALSE;
  238.             IF parse_int('/B=',mparm_str) AND (marking) THEN
  239.                 jx := block_stat;
  240.                 block_end;
  241.                 Make_Message('Block marked.');
  242.                 set_global_int('@LAST_BLOCK_TYPE', block_stat);
  243.             END;
  244.             IF parse_int('/B=',mparm_str) THEN
  245.                 jx := global_int('@LAST_BLOCK_TYPE');
  246.                 IF jx = 1 THEN
  247.                     block_begin;
  248.                     tstr := 'Line';
  249.                 ELSIF jx = 2 THEN
  250.                     tstr := 'Columnar';
  251.                     col_block_begin;
  252.                 ELSIF (jx = 3) OR (jx = 0) THEN
  253.                     tstr := 'Stream';
  254.                     str_block_begin;
  255.                 END;
  256.                 Make_Message( 'Marking ' + tstr + ' block, release mouse button to end.' );
  257.             END;
  258.         END;
  259.         IF key1 = 0 THEN
  260.             IF vertical and (key2 = 240) THEN
  261.                 UP;
  262.             ELSIF vertical and (key2 = 241) THEN
  263.                 DOWN;
  264.             ELSIF horizontal and (key2 = 242) THEN
  265.                 MS_LEFT;
  266.             ELSIF horizontal and (key2 = 243) THEN
  267.                 RIGHT;
  268.             END;
  269.         ELSIF key1 = 27 THEN
  270.             goto exit;
  271.         END;
  272.     END;
  273.     GOTO loop;
  274.  
  275. exit:
  276.  
  277.     IF NOT(first) AND (parse_int('/B=',mparm_str)) THEN
  278.         block_end;
  279.         Make_message('Block marked.  Default mouse marking mode is ' + tstr + '.');
  280.     set_global_int('@LAST_BLOCK_TYPE', block_stat);
  281.     END;
  282.  
  283.     mouse_mode := old_mouse_mode;
  284.     Mou_Set_Pos( wherex, wherey );
  285.     refresh := old_refresh;
  286.     Mou_Draw_Ptr;
  287. END_MACRO;
  288.  
  289. $MACRO MOUSEINWINDOW FROM ALL;
  290. {******************************************************************************
  291.                                                                 MULTI-EDIT MACRO
  292.  
  293. Name: MOUSEINWINDOW
  294.  
  295. Description:    Handles the mouse when clicked inside the window
  296.  
  297. RETURNS:    RETURN_INT = 1 if mouse was inside window,
  298.             RETURN_INT = 0 if mouse was not inside window.
  299.  
  300.                              (C) Copyright 1989 by American Cybernetics, Inc.
  301. ******************************************************************************}
  302.  
  303.     DEF_INT( new_col, new_line );
  304.  
  305.     IF (mou_last_x > win_x1) AND (mou_last_x < win_x2) AND
  306.                 (mou_last_y < win_y2) AND (mou_last_y > win_y1) THEN
  307.         refresh := true;
  308.         goto_v_col( v_col );
  309.         new_col := (v_col - (wherex - win_x1)) + (Mou_Last_X - win_x1);
  310.         new_line := (c_line - c_row) + (Mou_Last_Y - win_y1);
  311.         IF c_line < new_line THEN
  312.             WHILE c_line < new_line DO
  313.                 DOWN;
  314.             END;
  315.         ELSE
  316.             WHILE c_line > new_line DO
  317.                 UP;
  318.             END;
  319.         END;
  320.         goto_v_col( new_col );
  321.         return_int := 1;
  322.     ELSE
  323.         return_int := 0;
  324.     END;
  325.  
  326. END_MACRO;
  327.  
  328. $MACRO MOUSEEVENT2;
  329. {******************************************************************************
  330.                                                                 MULTI-EDIT MACRO
  331.  
  332. Name: MOUSEEVENT2
  333.  
  334. Description:    Determines whether to move the text cursor or process the scroll
  335.                             bar.
  336.  
  337.                              (C) Copyright 1989 by American Cybernetics, Inc.
  338. ******************************************************************************}
  339.     RM('MouseInWindow');
  340.     IF return_int THEN
  341.         RM('Mouse_Move /V=1/H=1');
  342.     ELSE
  343.         RM('GotoScrollBar');
  344.     END;
  345. END_MACRO;
  346.  
  347. $MACRO MOUSEFKEY FROM ALL;
  348. {******************************************************************************
  349.                                                                 MULTI-EDIT MACRO
  350.  
  351. Name: MOUSEFKEY
  352.  
  353. Description:    Handles mouse clicks on the function key line.
  354.  
  355.                              (C) Copyright 1989 by American Cybernetics, Inc.
  356. ******************************************************************************}
  357.  
  358.     Def_Int( Shift_Status, key_num, shift_add );
  359.  
  360.     IF Mou_Last_Y = FKey_Row THEN
  361.         R_AX := $0200;
  362.         INTR($16);
  363.         Shift_Status := R_AX AND $0F;
  364.         shift_add := 0;
  365.         if (Mou_Last_X mod 8) = 0 THEN
  366.             goto exit;
  367.         END;
  368.         key_num := (Mou_Last_X / 8) + 1;
  369.         IF (Shift_Status = 0) THEN {Normal}
  370.             Shift_Add := 58;
  371.         ELSIF (Shift_Status = 4) THEN {Ctrl}
  372.             Shift_Add := 93;
  373.         ELSIF (Shift_Status > 0) AND (Shift_Status < 4) THEN {shifted}
  374.             Shift_Add := 83;
  375.         ELSIF (Shift_Status = 8) THEN
  376.             Shift_Add := 103;
  377.         ELSE
  378.             Goto EXIT;
  379.         END;
  380.         Push_Key(0,Shift_Add + Key_Num);
  381.     END;
  382. EXIT:
  383. END_MACRO;
  384.  
  385. $MACRO GOTOSCROLLBAR;
  386. {******************************************************************************
  387.                                                                 MULTI-EDIT MACRO
  388.  
  389. Name: GOTOSCROLLBAR
  390.  
  391. Description:    Moves to the line in the file corresponding to the scroll bar.
  392.  
  393. Parameters:
  394.                             /L=    Overrides the total lines in the file.
  395.  
  396.                              (C) Copyright 1989 by American Cybernetics, Inc.
  397. ******************************************************************************}
  398.  
  399.     def_int( jz, jx, jy, tr );
  400.     tr := refresh;
  401.     refresh := false;
  402.     jz := parse_int('/L=', mparm_str);
  403.     jx := c_col;
  404.     IF (Mou_Last_X = Win_X2) AND (Mou_Last_Y < (Win_Y2 - 1)) AND
  405.          (Mou_Last_Y > (Win_Y1 + 1)) THEN
  406.         IF (Mou_Last_Y = (Win_Y1 + 2)) THEN
  407.             tof;
  408.             goto_col(jx);
  409.         ELSIF (Mou_Last_Y = (Win_Y2 - 2)) THEN
  410.             eof;
  411.             goto_col(jx);
  412.         ELSE
  413.             IF jz = 0 THEN
  414.                 eof;
  415.                 jz := c_line;
  416.                 goto_col( jx );
  417.             END;
  418.             WHILE (c_row > 1) AND (c_line > 1) DO
  419.                 up;
  420.             END;
  421.  
  422.             jy := win_y2 - win_y1 - 1;
  423.             jx := ((jz - jy)) * 1000;
  424.             jx := jx / (jy - 2);
  425.             jy := mou_last_y - (win_y1 + 1);
  426.             jx := jx * jy;
  427.             IF (jx mod 1000 ) <> 0 THEN
  428.                 jx := (jx / 1000) + 1;
  429.             ELSE
  430.                 jx := jx / 1000;
  431.             END;
  432.  
  433.             goto_line(jx);
  434.         END;
  435.     END;
  436.     refresh := tr;
  437.     return_int := jz;
  438. END_MACRO;
  439.  
  440. $MACRO HANDLESCROLLBAR;
  441. {******************************************************************************
  442.                                                                 MULTI-EDIT MACRO
  443.  
  444. Name: HANDLESCROLLBAR
  445.  
  446. Description:    Scrolls up or down when mouse is clicked or held down on the
  447.                             arrows of the scroll bar.
  448.  
  449.  
  450. Parameters:
  451.         /EOF=1        Limit movement to EOF.
  452.  
  453.                              (C) Copyright 1989 by American Cybernetics, Inc.
  454. ******************************************************************************}
  455.  
  456.     def_int( jx, old_x, old_y, eof_limit, direction_result );
  457.     eof_limit := parse_int('/EOF=', mparm_str );
  458.     old_x := Mou_Last_X;
  459.     old_y := Mou_Last_Y;
  460.     direction_result := 0;
  461.     IF (mou_last_x = win_x2) THEN
  462.         IF (mou_last_y = (win_y2 - 1)) THEN
  463.                 refresh := false;
  464.                 jx := c_row;
  465.                 while c_row < ((win_y2 - win_y1 - 1)) DO
  466.                     down;
  467.                 END;
  468.                 refresh := TRUE;
  469.             scroll_up:
  470.                 IF (eof_limit = 0) OR (at_eof = 0) THEN
  471.                     down;
  472.                 END;
  473.                 CALL Mouse_Repeat_Loop;
  474.                 IF return_int = 1 THEN
  475.                     Goto Scroll_Up;
  476.                 END;
  477.                 refresh := false;
  478.                 while c_row > jx DO
  479.                     up;
  480.                 END;
  481.                 refresh := TRUE;
  482.                 direction_result := 1;
  483.         ELSIF (mou_last_y = (win_y1 + 1)) THEN
  484.                 refresh := false;
  485.                 jx := c_row;
  486.                 while c_row > 1 DO
  487.                     up;
  488.                 END;
  489.                 refresh := TRUE;
  490.             scroll_down:
  491.                 up;
  492.                 CALL Mouse_Repeat_Loop;
  493.                 IF return_int = 1 THEN
  494.                     Goto Scroll_Down;
  495.                 END;
  496.                 refresh := false;
  497.                 while c_row < jx DO
  498.                     down;
  499.                 END;
  500.                 refresh := TRUE;
  501.                 direction_result := 2;
  502.         ELSIF (Mou_Last_y > win_y1) AND (Mou_Last_y < win_y2) THEN
  503.                 refresh := TRUE;
  504.             page_loop:
  505.                 jx := Mou_Last_Y - Win_Y1 - 1;
  506.                 IF jx > cur_scroll_pos THEN
  507.                     page_down;
  508.                     direction_result := 1;
  509.                 ELSIF jx < cur_scroll_pos THEN
  510.                     page_up;
  511.                     direction_result := 2;
  512.                 ELSIF jx = cur_scroll_pos THEN
  513.                     goto drag_scroll_pos;
  514.                 END;
  515.                 CALL Mouse_Repeat_Loop;
  516.                 IF return_int = 1 THEN
  517.                     Goto page_loop;
  518.                 END;
  519.         END;
  520.     END;
  521.     GOTO EXIT;
  522.  
  523.  
  524. Mouse_Repeat_Loop:
  525.         Mou_Repeat := TRUE;
  526.         du2:
  527.             Mou_Check_Status;
  528.             IF ((Mou_Last_Status AND 1) <> 0) AND (old_x = Mou_Last_X) AND
  529.                 (old_y = Mou_Last_Y) THEN
  530.                 IF check_Key THEN
  531.                     IF (key2 = 250) AND (key1 = 0) THEN
  532.                         return_int := 1;
  533.                         RET;
  534.                     ELSE
  535.                         push_key( key1, key2 );
  536.                     END;
  537.                 ELSE
  538.                     GOTO du2;
  539.                 END;
  540.             END;
  541.         return_int := 0;
  542.         Mou_Repeat := FALSE;
  543.         RET;
  544.  
  545. drag_scroll_pos:
  546.         return_int := parse_int('/L=', mparm_str);
  547.     Mou_Set_Limits(win_x2,win_y1 + 2,win_x2, win_y2 - 2);
  548.         Mou_Repeat := FALSE;
  549.         du3:
  550.       Mou_Check_Status;
  551.             IF ((Mou_Last_Status AND 1) <> 0) THEN
  552.                 IF old_y <> mou_last_y THEN
  553.                     RM('GOTOSCROLLBAR /L=' + str(return_int));
  554.                     REFRESH := TRUE;
  555.                     update_window;
  556.                 END;
  557.                 old_y := mou_last_y;
  558.                 goto du3;
  559.             END;
  560.         Mou_Set_Limits(1,1,screen_width, screen_length);
  561.         direction_result := 1;
  562.         goto exit;
  563. exit:
  564.      return_int := direction_result;
  565. END_MACRO;
  566.