/[hurd]/hurd/libcons/vcons-scrollback.c
ViewVC logotype

Diff of /hurd/libcons/vcons-scrollback.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by marcus, Mon Sep 9 22:04:25 2002 UTC revision 1.2 by marcus, Fri Sep 13 23:40:10 2002 UTC
# Line 24  Line 24 
24    
25  #include "cons.h"  #include "cons.h"
26    
27  /* Scroll back into the history of VCONS by DELTA lines.  */  /* Non-locking version of cons_vcons_scrollback.  Does also not update
28       the display.  */
29  int  int
30  cons_vcons_scrollback (vcons_t vcons, int delta)  _cons_vcons_scrollback (vcons_t vcons, cons_scroll_t type, float value)
31  {  {
32    int scrolling;    int scrolling;
33    uint32_t new_scr;    uint32_t new_scr;
34    
35    mutex_lock (&vcons->lock);    switch (type)
   if (delta > 0 || vcons->scrolling > (uint32_t) (-delta))  
36      {      {
37        new_scr = vcons->scrolling + delta;      case CONS_SCROLL_DELTA_LINES:
38        if (new_scr > vcons->state.screen.scr_lines)        scrolling = vcons->scrolling + ((uint32_t) value);
39          new_scr = vcons->state.screen.scr_lines;        break;
40        case CONS_SCROLL_DELTA_SCREENS:
41          scrolling = vcons->scrolling
42            + ((uint32_t) (value * vcons->state.screen.height));
43          break;
44        case CONS_SCROLL_ABSOLUTE_LINE:
45          scrolling = (uint32_t) value;
46          break;
47        case CONS_SCROLL_ABSOLUTE_PERCENTAGE:
48          scrolling = (uint32_t) (value * vcons->state.screen.scr_lines);
49          break;
50        default:
51          return 0;
52      }      }
53    else  
54      if (scrolling < 0)
55      new_scr = 0;      new_scr = 0;
56      else if (scrolling > vcons->state.screen.scr_lines)
57        new_scr = vcons->state.screen.scr_lines;
58      else
59        new_scr = scrolling;
60    
61    if (new_scr == vcons->scrolling)    if (new_scr == vcons->scrolling)
62      {      return 0;
63        mutex_unlock (&vcons->lock);  
       return 0;  
     }  
     
64    scrolling = vcons->scrolling - new_scr;    scrolling = vcons->scrolling - new_scr;
65    {    {
66      uint32_t new_cur_line;      uint32_t new_cur_line;
# Line 114  cons_vcons_scrollback (vcons_t vcons, in Line 128  cons_vcons_scrollback (vcons_t vcons, in
128        cons_vcons_set_cursor_status (vcons, CONS_CURSOR_INVISIBLE);        cons_vcons_set_cursor_status (vcons, CONS_CURSOR_INVISIBLE);
129    }    }
130    
   cons_vcons_update (vcons);  
131    vcons->scrolling -= scrolling;    vcons->scrolling -= scrolling;
   mutex_unlock (&vcons->lock);  
132    
133    return -scrolling;    return -scrolling;
134  }  }
135    
136    /* Scroll back into the history of VCONS.  If TYPE is
137       CONS_SCROLL_DELTA_LINES, scroll up or down by VALUE lines.  If TYPE
138       is CONS_SCROLL_DELTA_SCREENS, scroll up or down by VALUE multiples
139       of a screen height.  If TYPE is CONS_SCROLL_ABSOLUTE_LINE, scroll to
140       line VALUE (where 0 is the lowest line).  If TYPE is
141       CONS_SCROLL_ABSOLUTE_PERCENTAGE, scroll to the position determined
142       by VALUE, where 0 is the bottom and 1 is the top.
143    
144       The function returns the number of lines actually scrolled up or
145       down.  */
146    int
147    cons_vcons_scrollback (vcons_t vcons, cons_scroll_t type, float value)
148    {
149      int ret;
150    
151      mutex_lock (&vcons->lock);
152      ret = _cons_vcons_scrollback (vcons, type, value);
153      cons_vcons_update (vcons);
154      mutex_unlock (&vcons->lock);
155      return ret;
156    }
157    

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26