home *** CD-ROM | disk | FTP | other *** search
/ ADA Programming Guide / ADA Programming Guide.iso / ada_gwu / cursor.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-01-30  |  3.8 KB  |  174 lines

  1. /*
  2.     GWAda Development Environment for 386/486 PCs   
  3.     Copyright (C) 1993, Arthur Vargas Lopes  & Michael Bliss Feldman
  4.                         vlopes@vortex.ufrgs.br mfeldman@seas.gwu.edu
  5.  
  6.     This program is free software; you can redistribute it and/or modify
  7.     it under the terms of the GNU General Public License as published by
  8.     the Free Software Foundation; version 2 of the License.    
  9.  
  10.  
  11.     This program is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14.     GNU General Public License for more details.
  15.  
  16.     You should have received a copy of the GNU General Public License
  17.     along with this program; if not, write to the Free Software
  18.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  19. */
  20.  
  21. /* cursor.c */
  22.  
  23. #include "externs.h"
  24.  
  25.  
  26.  
  27.  
  28. void AVL_UPDATE_CURSOR()
  29. {
  30.     struct rccoord old;
  31.     AVL_EDIT_WINDOW_PTR w;
  32.     if (avl_hscroll_on)
  33.         return;
  34.     w = &avl_windows[avl_window];
  35.     w -> scr_col = AVL_COL() - w -> offset;
  36.     _settextposition(w -> scr_row, w -> scr_col);
  37. }
  38.  
  39.  
  40. void AVL_CURSOR_HOME()
  41. {
  42.     avl_windows[avl_window].txt_col = 0;
  43.     if (avl_windows[avl_window].offset > 0)  {
  44.         avl_windows[avl_window].offset = 0;
  45.         avl_windows[avl_window].txt_col= 0;
  46.         AVL_SCROLL();
  47.         }
  48.     else
  49.         AVL_UPDATE_LINE();
  50. }
  51.  
  52.  
  53.  
  54. void AVL_CURSOR_END()
  55. {
  56.     AVL_EDIT_WINDOW_PTR w;
  57.     short n, i, oldoffset;
  58.     char *d;
  59.     w = &avl_windows[avl_window];
  60.     oldoffset = w -> offset;
  61.     w -> txt_col = strlen (w -> current_line -> line);
  62.     if (w -> txt_col < 0)
  63.         w -> txt_col = 0;
  64.     w -> offset = AVL_OFFSET();
  65.     if (w -> offset != oldoffset)
  66.         AVL_SCROLL();
  67.     else
  68.         AVL_UPDATE_LINE();
  69.     AVL_UPDATE_CURSOR();
  70. }
  71.  
  72. void AVL_CURSOR_PGUP()
  73. {
  74.     int i;
  75.     AVL_EDIT_WINDOW_PTR w;
  76.     w = &avl_windows[avl_window];
  77.     for (i = 1; i < (w -> r2 - w -> r1 + 2); ++i)
  78.         AVL_CURSOR_UP(1);
  79.     AVL_UPDATE_CURSOR();
  80. }
  81.  
  82. void AVL_CURSOR_PGDN()
  83. {
  84.     int i;
  85.     AVL_EDIT_WINDOW_PTR w;
  86.     w = &avl_windows[avl_window];
  87.     for (i = 1; i < (w -> r2 - w -> r1 + 2); ++i)
  88.         AVL_CURSOR_DOWN(1);
  89.     AVL_UPDATE_CURSOR();
  90. }
  91.  
  92. void AVL_CURSOR_LEFT(int no)
  93. {
  94.     AVL_EDIT_WINDOW_PTR w;
  95.     w = &avl_windows[avl_window];
  96.     if (no <= 0) no = 1;
  97.     while ( no-- )  {
  98.         if (w -> txt_col > 0)  {
  99.             w -> txt_col -= 1;
  100.             if (w -> scr_col == 1)  {
  101.                 w -> offset = AVL_OFFSET();
  102.                 AVL_SCROLL();
  103.                 }
  104.             AVL_UPDATE_CURSOR();
  105.             }
  106.         }
  107. }
  108.  
  109. void AVL_CURSOR_RIGHT(int no)
  110. {
  111.     AVL_EDIT_WINDOW_PTR w;
  112.     w = &avl_windows[avl_window];
  113.     if (no <= 0) no = 1;
  114.     while ( no-- )  {
  115.         if ((w -> txt_col) < strlen(w -> current_line -> line))  {
  116.             w -> txt_col += 1;
  117.             if (w -> scr_col >= w -> c2)  {
  118.                 w -> offset = AVL_OFFSET();
  119.                 AVL_SCROLL();
  120.                 }
  121.             AVL_UPDATE_CURSOR();
  122.             }
  123.         }
  124. }
  125.  
  126.  
  127.  
  128. void AVL_CURSOR_UP(int no)
  129. {
  130.     AVL_EDIT_WINDOW_PTR w;
  131.     short att, k;
  132.     att = _settextcursor(0x2000);
  133.     w = &avl_windows[avl_window];
  134.     if (no <= 0) no = 1;
  135.     while (no --)  {
  136.         if (w -> head != w -> current_line -> previous)  {
  137.             w -> current_line = w -> current_line -> previous;
  138.             if (w -> scr_row == 1) {
  139.                 _scrolltextwindow( -1 );
  140.                 AVL_UPDATE_LINE();
  141.                 }
  142.             else {
  143.                 w -> scr_row -= 1;
  144.                 }
  145.             }
  146.         }
  147.     att = _settextcursor(att);
  148.     AVL_UPDATE_CURSOR();
  149. }
  150.  
  151. void AVL_CURSOR_DOWN(int no)
  152. {
  153.     AVL_EDIT_WINDOW_PTR w;
  154.     short att, k;
  155.     att = _settextcursor(0x2000);
  156.     w = &avl_windows[avl_window];
  157.     if (no <= 0) no = 1;
  158.     while ( no-- )  {
  159.         if (w -> head != w -> current_line -> next)  {
  160.             w -> current_line = w -> current_line -> next;
  161.             if (w -> scr_row == (w -> r2 - w -> r1 + 1)) {
  162.                 _scrolltextwindow( 1 );
  163.                 AVL_UPDATE_LINE();
  164.                 }
  165.             else {
  166.                 w -> scr_row += 1;
  167.                 }
  168.             }
  169.         }
  170.     att = _settextcursor(att);
  171.     AVL_UPDATE_CURSOR();
  172. }
  173.  
  174.  
  175.