Changeset 60c1386
- Timestamp:
- Sep 18, 2010, 5:07:39 PM (14 years ago)
- Branches:
- master, release-1.10, release-1.7, release-1.8, release-1.9
- Children:
- a8186dc
- Parents:
- 2640b63
- git-author:
- David Benjamin <davidben@mit.edu> (08/01/10 16:29:45)
- git-committer:
- David Benjamin <davidben@mit.edu> (09/18/10 17:07:39)
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
owl.h
r9eb38bb r60c1386 394 394 } owl_mainwin; 395 395 396 typedef struct _owl_editwin owl_editwin; 397 typedef struct _owl_editwin_excursion owl_editwin_excursion; 398 396 399 typedef struct _owl_viewwin { 397 400 owl_fmtext fmtext; … … 400 403 int rightshift; 401 404 owl_window *window; 402 gulong sig_redraw_id;403 405 void (*onclose_hook) (struct _owl_viewwin *vwin, void *data); 404 406 void *onclose_hook_data; 407 408 gulong sig_resize_id; 409 owl_window *content; 410 gulong sig_content_redraw_id; 411 owl_window *status; 412 gulong sig_status_redraw_id; 405 413 } owl_viewwin; 406 414 … … 462 470 int repeats; 463 471 } owl_history; 464 465 typedef struct _owl_editwin owl_editwin;466 typedef struct _owl_editwin_excursion owl_editwin_excursion;467 472 468 473 typedef struct _owl_mainpanel { -
viewwin.c
r2640b63 r60c1386 5 5 #define EMPTY_INDICATOR "~" 6 6 7 static void owl_viewwin_redraw(owl_window *w, WINDOW *curswin, void *user_data); 7 static void owl_viewwin_redraw_content(owl_window *w, WINDOW *curswin, void *user_data); 8 static void owl_viewwin_redraw_status(owl_window *w, WINDOW *curswin, void *user_data); 9 static void owl_viewwin_layout(owl_viewwin *v); 8 10 static void owl_viewwin_set_window(owl_viewwin *v, owl_window *w); 9 11 … … 56 58 static void owl_viewwin_set_window(owl_viewwin *v, owl_window *w) 57 59 { 58 v->window = w; 59 if (w) { 60 g_object_ref(v->window); 61 v->sig_redraw_id = g_signal_connect(w, "redraw", G_CALLBACK(owl_viewwin_redraw), v); 62 } 60 v->window = g_object_ref(w); 61 v->content = owl_window_new(v->window); 62 v->status = owl_window_new(v->window); 63 64 v->sig_content_redraw_id = 65 g_signal_connect(v->content, "redraw", G_CALLBACK(owl_viewwin_redraw_content), v); 66 v->sig_status_redraw_id = 67 g_signal_connect(v->status, "redraw", G_CALLBACK(owl_viewwin_redraw_status), v); 68 v->sig_resize_id = 69 g_signal_connect_swapped(v->window, "resized", G_CALLBACK(owl_viewwin_layout), v); 70 owl_viewwin_layout(v); 71 72 owl_window_show(v->content); 73 owl_window_show(v->status); 63 74 } 64 75 … … 68 79 } 69 80 81 static void owl_viewwin_layout(owl_viewwin *v) 82 { 83 int lines, cols; 84 owl_window_get_position(v->window, &lines, &cols, NULL, NULL); 85 owl_window_set_position(v->content, lines - BOTTOM_OFFSET, cols, 0, 0); 86 owl_window_set_position(v->status, BOTTOM_OFFSET, cols, lines - BOTTOM_OFFSET, 0); 87 } 88 70 89 /* regenerate text on the curses window. */ 71 static void owl_viewwin_redraw (owl_window *w, WINDOW *curswin, void *user_data)90 static void owl_viewwin_redraw_content(owl_window *w, WINDOW *curswin, void *user_data) 72 91 { 73 92 owl_fmtext fm1, fm2; … … 77 96 78 97 owl_window_get_position(w, &winlines, &wincols, 0, 0); 79 98 80 99 werase(curswin); 81 100 wmove(curswin, 0, 0); … … 83 102 owl_fmtext_init_null(&fm1); 84 103 owl_fmtext_init_null(&fm2); 85 86 owl_fmtext_truncate_lines(&(v->fmtext), v->topline, winlines -BOTTOM_OFFSET, &fm1);104 105 owl_fmtext_truncate_lines(&(v->fmtext), v->topline, winlines, &fm1); 87 106 owl_fmtext_truncate_cols(&fm1, v->rightshift, wincols-1+v->rightshift, &fm2); 88 107 … … 92 111 y = v->textlines - v->topline; 93 112 wmove(curswin, y, 0); 94 for (; y < winlines -BOTTOM_OFFSET; y++) {113 for (; y < winlines; y++) { 95 114 waddstr(curswin, EMPTY_INDICATOR); 96 115 waddstr(curswin, "\n"); 97 116 } 98 117 99 /* print the message at the bottom */ 100 wmove(curswin, winlines-1, 0); 118 owl_fmtext_cleanup(&fm1); 119 owl_fmtext_cleanup(&fm2); 120 } 121 122 static void owl_viewwin_redraw_status(owl_window *w, WINDOW *curswin, void *user_data) 123 { 124 owl_viewwin *v = user_data; 125 int winlines, wincols; 126 127 owl_window_get_position(v->content, &winlines, &wincols, 0, 0); 128 129 werase(curswin); 130 wmove(curswin, 0, 0); 101 131 wattrset(curswin, A_REVERSE); 102 if (v->textlines - v->topline > winlines -BOTTOM_OFFSET) {132 if (v->textlines - v->topline > winlines) { 103 133 waddstr(curswin, "--More-- (Space to see more, 'q' to quit)"); 104 134 } else { … … 106 136 } 107 137 wattroff(curswin, A_REVERSE); 108 109 owl_fmtext_cleanup(&fm1);110 owl_fmtext_cleanup(&fm2);111 138 } 112 139 … … 122 149 void owl_viewwin_dirty(owl_viewwin *v) 123 150 { 124 if (v->window)125 owl_window_dirty(v->window);151 owl_window_dirty(v->content); 152 owl_window_dirty(v->status); 126 153 } 127 154 128 155 void owl_viewwin_down(owl_viewwin *v, int amount) { 129 156 int winlines; 130 owl_window_get_position(v-> window, &winlines, 0, 0, 0);157 owl_window_get_position(v->content, &winlines, 0, 0, 0); 131 158 /* Don't scroll past the bottom. */ 132 amount = MIN(amount, v->textlines - (v->topline + winlines - BOTTOM_OFFSET));159 amount = MIN(amount, v->textlines - (v->topline + winlines)); 133 160 /* But if we're already past the bottom, don't back up either. */ 134 161 if (amount > 0) { … … 148 175 { 149 176 int winlines; 150 owl_window_get_position(v-> window, &winlines, 0, 0, 0);151 owl_viewwin_down(v, winlines - BOTTOM_OFFSET);177 owl_window_get_position(v->content, &winlines, 0, 0, 0); 178 owl_viewwin_down(v, winlines); 152 179 } 153 180 … … 160 187 { 161 188 int winlines; 162 owl_window_get_position(v-> window, &winlines, 0, 0, 0);163 owl_viewwin_up(v, winlines - BOTTOM_OFFSET);189 owl_window_get_position(v->content, &winlines, 0, 0, 0); 190 owl_viewwin_up(v, winlines); 164 191 } 165 192 … … 192 219 { 193 220 int winlines; 194 owl_window_get_position(v-> window, &winlines, 0, 0, 0);195 v->topline = v->textlines - winlines + BOTTOM_OFFSET;221 owl_window_get_position(v->content, &winlines, 0, 0, 0); 222 v->topline = v->textlines - winlines; 196 223 owl_viewwin_dirty(v); 197 224 } … … 228 255 v->onclose_hook_data = NULL; 229 256 } 230 if (v->window) { 231 g_signal_handler_disconnect(v->window, v->sig_redraw_id); 232 g_object_unref(v->window); 233 v->window = NULL; 234 } 257 /* TODO: This is far too tedious. owl_viewwin should own v->window 258 * and just unlink it in one go. Signals should also go away for 259 * free. */ 260 g_signal_handler_disconnect(v->window, v->sig_resize_id); 261 g_signal_handler_disconnect(v->content, v->sig_content_redraw_id); 262 g_signal_handler_disconnect(v->status, v->sig_status_redraw_id); 263 owl_window_unlink(v->content); 264 owl_window_unlink(v->status); 265 g_object_unref(v->window); 266 g_object_unref(v->content); 267 g_object_unref(v->status); 235 268 owl_fmtext_cleanup(&(v->fmtext)); 236 269 owl_free(v);
Note: See TracChangeset
for help on using the changeset viewer.