Changeset c447d9c


Ignore:
Timestamp:
May 29, 2010, 1:14:57 PM (14 years ago)
Author:
David Benjamin <davidben@mit.edu>
Branches:
master, release-1.10, release-1.7, release-1.8, release-1.9
Children:
5f7eadf
Parents:
d3814ff
git-author:
David Benjamin <davidben@mit.edu> (05/27/10 12:08:01)
git-committer:
David Benjamin <davidben@mit.edu> (05/29/10 13:14:57)
Message:
Also drop winlines/wincols from the viewwin struct

Deduplicating data is probably worthwhile, although this doesn't have a
negative diffstat. Maybe the owl_window struct should just be open.
(Then it should maybe return some sort of const owl_window * while we
internally work with a owl_window_private *)
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • owl.h

    rd3814ff rc447d9c  
    403403  int topline;
    404404  int rightshift;
    405   int winlines, wincols;
    406405  owl_window *window;
    407406  void (*onclose_hook) (struct _owl_viewwin *vwin, void *data);
  • viewwin.c

    r68f63a2 rc447d9c  
    5454  if (v->window) {
    5555    owl_window_set_redraw_cb(v->window, 0, 0, 0);
    56     owl_window_set_resize_cb(v->window, 0, 0, 0);
    5756  }
    5857  v->window = w;
    5958  if (w) {
    60     owl_window_get_position(w, &v->winlines, &v->wincols, 0, 0);
    6159    owl_window_set_redraw_cb(w, owl_viewwin_redisplay, v, 0);
    62     owl_window_set_resize_cb(w, owl_viewwin_resize_hook, v, 0);
    6360  }
    6461}
     
    6966}
    7067
    71 void owl_viewwin_resize_hook(owl_window *w, void *user_data)
    72 {
    73   owl_viewwin *v = user_data;
    74   owl_window_get_position(w, &v->winlines, &v->wincols, 0, 0);
    75 }
    76 
    7768/* regenerate text on the curses window. */
    7869void owl_viewwin_redisplay(owl_window *w, WINDOW *curswin, void *user_data)
     
    8071  owl_fmtext fm1, fm2;
    8172  owl_viewwin *v = user_data;
     73  int winlines, wincols;
     74
     75  owl_window_get_position(w, &winlines, &wincols, 0, 0);
    8276 
    8377  werase(curswin);
     
    8781  owl_fmtext_init_null(&fm2);
    8882 
    89   owl_fmtext_truncate_lines(&(v->fmtext), v->topline, v->winlines-BOTTOM_OFFSET, &fm1);
    90   owl_fmtext_truncate_cols(&fm1, v->rightshift, v->wincols-1+v->rightshift, &fm2);
     83  owl_fmtext_truncate_lines(&(v->fmtext), v->topline, winlines-BOTTOM_OFFSET, &fm1);
     84  owl_fmtext_truncate_cols(&fm1, v->rightshift, wincols-1+v->rightshift, &fm2);
    9185
    9286  owl_fmtext_curs_waddstr_without_search(&fm2, curswin);
    9387
    9488  /* print the message at the bottom */
    95   wmove(curswin, v->winlines-1, 0);
     89  wmove(curswin, winlines-1, 0);
    9690  wattrset(curswin, A_REVERSE);
    97   if (v->textlines - v->topline > v->winlines-BOTTOM_OFFSET) {
     91  if (v->textlines - v->topline > winlines-BOTTOM_OFFSET) {
    9892    waddstr(curswin, "--More-- (Space to see more, 'q' to quit)");
    9993  } else {
     
    108102void owl_viewwin_pagedown(owl_viewwin *v)
    109103{
    110   v->topline+=v->winlines - BOTTOM_OFFSET;
    111   if ( (v->topline+v->winlines-BOTTOM_OFFSET) > v->textlines) {
    112     v->topline = v->textlines - v->winlines + BOTTOM_OFFSET;
     104  int winlines;
     105  owl_window_get_position(v->window, &winlines, 0, 0, 0);
     106  v->topline+=winlines - BOTTOM_OFFSET;
     107  if ( (v->topline+winlines-BOTTOM_OFFSET) > v->textlines) {
     108    v->topline = v->textlines - winlines + BOTTOM_OFFSET;
    113109  }
    114110  owl_window_dirty(v->window);
     
    117113void owl_viewwin_linedown(owl_viewwin *v)
    118114{
     115  int winlines;
     116  owl_window_get_position(v->window, &winlines, 0, 0, 0);
    119117  v->topline++;
    120   if ( (v->topline+v->winlines-BOTTOM_OFFSET) > v->textlines) {
    121     v->topline = v->textlines - v->winlines + BOTTOM_OFFSET;
     118  if ( (v->topline+winlines-BOTTOM_OFFSET) > v->textlines) {
     119    v->topline = v->textlines - winlines + BOTTOM_OFFSET;
    122120  }
    123121  owl_window_dirty(v->window);
     
    126124void owl_viewwin_pageup(owl_viewwin *v)
    127125{
    128   v->topline-=v->winlines;
     126  int winlines;
     127  owl_window_get_position(v->window, &winlines, 0, 0, 0);
     128  v->topline-=winlines;
    129129  if (v->topline<0) v->topline=0;
    130130  owl_window_dirty(v->window);
     
    160160void owl_viewwin_bottom(owl_viewwin *v)
    161161{
    162   v->topline = v->textlines - v->winlines + BOTTOM_OFFSET;
     162  int winlines;
     163  owl_window_get_position(v->window, &winlines, 0, 0, 0);
     164  v->topline = v->textlines - winlines + BOTTOM_OFFSET;
    163165  owl_window_dirty(v->window);
    164166}
Note: See TracChangeset for help on using the changeset viewer.