- Timestamp:
- May 29, 2010, 1:14:57 PM (14 years ago)
- Branches:
- master, release-1.10, release-1.7, release-1.8, release-1.9
- Children:
- 1383b58
- Parents:
- 7c8811c
- git-author:
- David Benjamin <davidben@mit.edu> (05/27/10 02:49:57)
- git-committer:
- David Benjamin <davidben@mit.edu> (05/29/10 13:14:57)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
viewwin.c
rfe4c786 r68f63a2 7 7 * window that will be used by viewwin 8 8 */ 9 void owl_viewwin_init_text(owl_viewwin *v, WINDOW *win, int winlines, int wincols, const char *text)9 void owl_viewwin_init_text(owl_viewwin *v, owl_window *win, const char *text) 10 10 { 11 11 owl_fmtext_init_null(&(v->fmtext)); … … 19 19 v->topline=0; 20 20 v->rightshift=0; 21 v->winlines=winlines;22 v->wincols=wincols;23 v->curswin=win;24 21 v->onclose_hook = NULL; 22 23 owl_viewwin_set_window(v, win); 25 24 } 26 25 … … 28 27 owl_fmtext_append_normal(&(v->fmtext), text); 29 28 v->textlines=owl_fmtext_num_lines(&(v->fmtext)); 29 owl_window_dirty(v->window); 30 30 } 31 31 … … 33 33 * window that will be used by viewwin 34 34 */ 35 void owl_viewwin_init_fmtext(owl_viewwin *v, WINDOW *win, int winlines, int wincols, const owl_fmtext *fmtext)35 void owl_viewwin_init_fmtext(owl_viewwin *v, owl_window *win, const owl_fmtext *fmtext) 36 36 { 37 37 char *text; … … 46 46 v->topline=0; 47 47 v->rightshift=0; 48 v->winlines=winlines; 49 v->wincols=wincols; 50 v->curswin=win; 48 49 owl_viewwin_set_window(v, win); 51 50 } 52 51 53 void owl_viewwin_set_ curswin(owl_viewwin *v, WINDOW *w, int winlines, int wincols)52 void owl_viewwin_set_window(owl_viewwin *v, owl_window *w) 54 53 { 55 v->curswin=w; 56 v->winlines=winlines; 57 v->wincols=wincols; 54 if (v->window) { 55 owl_window_set_redraw_cb(v->window, 0, 0, 0); 56 owl_window_set_resize_cb(v->window, 0, 0, 0); 57 } 58 v->window = w; 59 if (w) { 60 owl_window_get_position(w, &v->winlines, &v->wincols, 0, 0); 61 owl_window_set_redraw_cb(w, owl_viewwin_redisplay, v, 0); 62 owl_window_set_resize_cb(w, owl_viewwin_resize_hook, v, 0); 63 } 58 64 } 59 65 … … 63 69 } 64 70 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 65 77 /* regenerate text on the curses window. */ 66 void owl_viewwin_redisplay(owl_ viewwin *v)78 void owl_viewwin_redisplay(owl_window *w, WINDOW *curswin, void *user_data) 67 79 { 68 80 owl_fmtext fm1, fm2; 69 70 /* avoid segfault when screen too small to create curswin */ 71 if (v->curswin == NULL) 72 return; 81 owl_viewwin *v = user_data; 73 82 74 werase( v->curswin);75 wmove( v->curswin, 0, 0);83 werase(curswin); 84 wmove(curswin, 0, 0); 76 85 77 86 owl_fmtext_init_null(&fm1); … … 81 90 owl_fmtext_truncate_cols(&fm1, v->rightshift, v->wincols-1+v->rightshift, &fm2); 82 91 83 owl_fmtext_curs_waddstr_without_search(&fm2, v->curswin);92 owl_fmtext_curs_waddstr_without_search(&fm2, curswin); 84 93 85 94 /* print the message at the bottom */ 86 wmove( v->curswin, v->winlines-1, 0);87 wattrset( v->curswin, A_REVERSE);95 wmove(curswin, v->winlines-1, 0); 96 wattrset(curswin, A_REVERSE); 88 97 if (v->textlines - v->topline > v->winlines-BOTTOM_OFFSET) { 89 waddstr( v->curswin, "--More-- (Space to see more, 'q' to quit)");98 waddstr(curswin, "--More-- (Space to see more, 'q' to quit)"); 90 99 } else { 91 waddstr( v->curswin, "--End-- (Press 'q' to quit)");100 waddstr(curswin, "--End-- (Press 'q' to quit)"); 92 101 } 93 wattroff( v->curswin, A_REVERSE);102 wattroff(curswin, A_REVERSE); 94 103 95 104 owl_fmtext_cleanup(&fm1); … … 103 112 v->topline = v->textlines - v->winlines + BOTTOM_OFFSET; 104 113 } 114 owl_window_dirty(v->window); 105 115 } 106 116 … … 111 121 v->topline = v->textlines - v->winlines + BOTTOM_OFFSET; 112 122 } 123 owl_window_dirty(v->window); 113 124 } 114 125 … … 117 128 v->topline-=v->winlines; 118 129 if (v->topline<0) v->topline=0; 130 owl_window_dirty(v->window); 119 131 } 120 132 … … 123 135 v->topline--; 124 136 if (v->topline<0) v->topline=0; 137 owl_window_dirty(v->window); 125 138 } 126 139 … … 128 141 { 129 142 v->rightshift+=n; 143 owl_window_dirty(v->window); 130 144 } 131 145 … … 134 148 v->rightshift-=n; 135 149 if (v->rightshift<0) v->rightshift=0; 150 owl_window_dirty(v->window); 136 151 } 137 152 … … 140 155 v->topline=0; 141 156 v->rightshift=0; 157 owl_window_dirty(v->window); 142 158 } 143 159 … … 145 161 { 146 162 v->topline = v->textlines - v->winlines + BOTTOM_OFFSET; 163 owl_window_dirty(v->window); 147 164 } 148 165
Note: See TracChangeset
for help on using the changeset viewer.