- Timestamp:
- Jul 18, 2010, 4:48:15 PM (13 years ago)
- Branches:
- master, release-1.7, release-1.8, release-1.9
- Children:
- 205e164
- Parents:
- 1cc9b615 (diff), 8bba1ae (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
global.c
refc460e rd296c9a 13 13 #endif 14 14 15 static void _owl_global_init_windows(owl_global *g); 16 15 17 void owl_global_init(owl_global *g) { 16 18 struct hostent *hent; 17 19 char hostname[MAXHOSTNAMELEN]; 18 20 char *cd; 21 22 g_type_init(); 19 23 20 24 gethostname(hostname, MAXHOSTNAMELEN); … … 26 30 } 27 31 32 g->lines=LINES; 33 g->cols=COLS; 34 /* We shouldn't need this if we initialize lines and cols before the first 35 * owl_window_get_screen, but to be safe, we synchronize. */ 36 owl_window_resize(owl_window_get_screen(), g->lines, g->cols); 37 28 38 g->context_stack = NULL; 29 owl_global_push_context(g, OWL_CTX_STARTUP, NULL, NULL );39 owl_global_push_context(g, OWL_CTX_STARTUP, NULL, NULL, NULL); 30 40 31 41 g->curmsg=0; 32 42 g->topmsg=0; 33 43 g->markedmsgid=-1; 34 g->needrefresh=1;35 44 g->startupargs=NULL; 36 45 37 46 owl_variable_dict_setup(&(g->vars)); 38 39 g->lines=LINES;40 g->cols=COLS;41 47 42 48 g->rightshift=0; … … 54 60 g->curmsg_vert_offset=0; 55 61 g->resizepending=0; 56 g->relayoutpending = 0;57 62 g->direction=OWL_DIRECTION_DOWNWARDS; 58 63 g->zaway=0; … … 76 81 g->nextmsgid=0; 77 82 78 _owl_global_setup_windows(g);79 80 83 /* Fill in some variables which don't have constant defaults */ 81 84 /* TODO: come back later and check passwd file first */ … … 89 92 90 93 owl_messagelist_create(&(g->msglist)); 91 owl_mainwin_init(&(g->mw)); 92 owl_popwin_init(&(g->pw));94 95 _owl_global_init_windows(g); 93 96 94 97 g->aim_screenname=NULL; … … 115 118 g->timerlist = NULL; 116 119 g->interrupted = FALSE; 120 } 121 122 static void _owl_global_init_windows(owl_global *g) 123 { 124 /* Create the main window */ 125 owl_mainpanel_init(&(g->mainpanel)); 126 127 /* Create the widgets */ 128 owl_mainwin_init(&(g->mw), g->mainpanel.recwin); 129 owl_popwin_init(&(g->pw)); 130 owl_msgwin_init(&(g->msgwin), g->mainpanel.msgwin); 131 owl_sepbar_init(g->mainpanel.sepwin); 132 133 owl_window_set_default_cursor(g->mainpanel.sepwin); 117 134 118 135 /* set up a pad for input */ … … 121 138 keypad(g->input_pad, 1); 122 139 meta(g->input_pad, 1); 140 } 141 142 void owl_global_sepbar_dirty(owl_global *g) 143 { 144 owl_window_dirty(g->mainpanel.sepwin); 123 145 } 124 146 … … 153 175 } 154 176 155 void _owl_global_setup_windows(owl_global *g) {156 int cols, typwin_lines;157 158 cols=g->cols;159 typwin_lines=owl_global_get_typwin_lines(g);160 161 /* set the new window sizes */162 g->recwinlines=g->lines-(typwin_lines+2);163 if (g->recwinlines<0) {164 /* gotta deal with this */165 g->recwinlines=0;166 }167 168 /* create the new windows */169 _owl_panel_set_window(&g->recpan, newwin(g->recwinlines, cols, 0, 0));170 _owl_panel_set_window(&g->seppan, newwin(1, cols, g->recwinlines, 0));171 _owl_panel_set_window(&g->msgpan, newwin(1, cols, g->recwinlines+1, 0));172 _owl_panel_set_window(&g->typpan, newwin(typwin_lines, cols, g->recwinlines+2, 0));173 174 if (g->tw)175 owl_editwin_set_curswin(g->tw, owl_global_get_curs_typwin(g), typwin_lines, g->cols);176 177 idlok(owl_global_get_curs_typwin(g), FALSE);178 idlok(owl_global_get_curs_recwin(g), FALSE);179 idlok(owl_global_get_curs_sepwin(g), FALSE);180 idlok(owl_global_get_curs_msgwin(g), FALSE);181 182 wmove(owl_global_get_curs_typwin(g), 0, 0);183 }184 185 177 owl_context *owl_global_get_context(owl_global *g) { 186 178 if (!g->context_stack) … … 189 181 } 190 182 191 static void owl_global_lookup_keymap(owl_global *g) { 192 owl_context *c = owl_global_get_context(g); 193 if (!c || !c->keymap) 183 static void owl_global_activate_context(owl_global *g, owl_context *c) { 184 if (!c) 194 185 return; 195 186 196 if (!owl_keyhandler_activate(owl_global_get_keyhandler(g), c->keymap)) { 197 owl_function_error("Unable to activate keymap '%s'", c->keymap); 198 } 199 } 200 201 void owl_global_push_context(owl_global *g, int mode, void *data, const char *keymap) { 187 if (c->keymap) { 188 if (!owl_keyhandler_activate(owl_global_get_keyhandler(g), c->keymap)) { 189 owl_function_error("Unable to activate keymap '%s'", c->keymap); 190 } 191 } 192 owl_window_set_cursor(c->cursor); 193 } 194 195 void owl_global_push_context(owl_global *g, int mode, void *data, const char *keymap, owl_window *cursor) { 202 196 owl_context *c; 203 197 if (!(mode & OWL_CTX_MODE_BITS)) … … 206 200 c->mode = mode; 207 201 c->data = data; 202 c->cursor = cursor ? g_object_ref(cursor) : NULL; 208 203 c->keymap = owl_strdup(keymap); 209 204 g->context_stack = g_list_prepend(g->context_stack, c); 210 owl_global_ lookup_keymap(g);205 owl_global_activate_context(g, owl_global_get_context(g)); 211 206 } 212 207 … … 218 213 g->context_stack = g_list_delete_link(g->context_stack, 219 214 g->context_stack); 215 if (c->cursor) 216 g_object_unref(c->cursor); 220 217 owl_free(c->keymap); 221 218 owl_free(c); 222 owl_global_ lookup_keymap(g);219 owl_global_activate_context(g, owl_global_get_context(g)); 223 220 } 224 221 … … 232 229 233 230 int owl_global_get_recwin_lines(const owl_global *g) { 234 return (g->recwinlines);231 return g->mainpanel.recwinlines; 235 232 } 236 233 … … 298 295 } 299 296 300 /* curses windows */ 301 302 WINDOW *owl_global_get_curs_recwin(const owl_global *g) { 303 return panel_window(g->recpan); 304 } 305 306 WINDOW *owl_global_get_curs_sepwin(const owl_global *g) { 307 return panel_window(g->seppan); 308 } 309 310 WINDOW *owl_global_get_curs_msgwin(const owl_global *g) { 311 return panel_window(g->msgpan); 312 } 313 314 WINDOW *owl_global_get_curs_typwin(const owl_global *g) { 315 return panel_window(g->typpan); 297 /* underlying owl_windows */ 298 299 owl_window *owl_global_get_typwin_window(const owl_global *g) { 300 return g->mainpanel.typwin; 316 301 } 317 302 … … 322 307 } 323 308 324 /* refresh */325 326 int owl_global_is_needrefresh(const owl_global *g) {327 if (g->needrefresh==1) return(1);328 return(0);329 }330 331 void owl_global_set_needrefresh(owl_global *g) {332 g->needrefresh=1;333 }334 335 void owl_global_set_noneedrefresh(owl_global *g) {336 g->needrefresh=0;337 }338 339 309 /* variable dictionary */ 340 310 … … 352 322 353 323 void owl_global_set_rightshift(owl_global *g, int i) { 354 g->rightshift=i; 324 g->rightshift = i; 325 owl_mainwin_redisplay(owl_global_get_mainwin(g)); 355 326 } 356 327 … … 367 338 owl_function_resize_typwin(owl_global_get_typwin_lines(g) + d); 368 339 369 g->tw = owl_editwin_new(owl_global_get_curs_typwin(g), 340 if (g->typwin_erase_id) { 341 g_signal_handler_disconnect(owl_global_get_typwin_window(g), g->typwin_erase_id); 342 g->typwin_erase_id = 0; 343 } 344 345 g->tw = owl_editwin_new(owl_global_get_typwin_window(g), 370 346 owl_global_get_typwin_lines(g), 371 347 g->cols, … … 380 356 owl_function_resize_typwin(owl_global_get_typwin_lines(g) - d); 381 357 382 werase(owl_global_get_curs_typwin(g)); 358 if (!g->typwin_erase_id) { 359 g->typwin_erase_id = 360 g_signal_connect(owl_global_get_typwin_window(g), "redraw", G_CALLBACK(owl_window_erase_cb), NULL); 361 } 362 owl_window_dirty(owl_global_get_typwin_window(g)); 363 383 364 g->tw = NULL; 384 365 } … … 388 369 void owl_global_set_resize_pending(owl_global *g) { 389 370 g->resizepending=1; 390 }391 392 void owl_global_set_relayout_pending(owl_global *g) {393 g->relayoutpending = 1;394 371 } 395 372 … … 471 448 * fail. 472 449 */ 473 static void _owl_global_get_size(int *lines, int *cols) {450 void owl_global_get_terminal_size(int *lines, int *cols) { 474 451 struct winsize size; 475 452 /* get the new size */ … … 488 465 } 489 466 490 void owl_global_ resize(owl_global *g, int x, int y) {491 /* resize the screen. If x or yis 0 use the terminal size */467 void owl_global_check_resize(owl_global *g) { 468 /* resize the screen. If lines or cols is 0 use the terminal size */ 492 469 if (!g->resizepending) return; 493 470 g->resizepending = 0; 494 471 495 _owl_global_get_size(&g->lines, &g->cols); 496 if (x != 0) { 497 g->lines = x; 498 } 499 if (y != 0) { 500 g->cols = y; 501 } 502 503 resizeterm(g->lines, g->cols); 472 owl_global_get_terminal_size(&g->lines, &g->cols); 473 owl_window_resize(owl_window_get_screen(), g->lines, g->cols); 504 474 505 475 owl_function_debugmsg("New size is %i lines, %i cols.", g->lines, g->cols); 506 owl_global_set_relayout_pending(g);507 }508 509 void owl_global_relayout(owl_global *g) {510 owl_popwin *pw;511 owl_viewwin *vw;512 513 if (!g->relayoutpending) return;514 g->relayoutpending = 0;515 516 owl_function_debugmsg("Relayouting...");517 518 /* re-initialize the windows */519 _owl_global_setup_windows(g);520 521 /* in case any styles rely on the current width */522 owl_messagelist_invalidate_formats(owl_global_get_msglist(g));523 524 /* recalculate the topmsg to make sure the current message is on525 * screen */526 owl_function_calculate_topmsg(OWL_DIRECTION_NONE);527 528 /* recreate the popwin */529 pw = owl_global_get_popwin(g);530 if (owl_popwin_is_active(pw)) {531 /*532 * This is somewhat hacky; we probably want a proper windowing layer. We533 * destroy the popwin and recreate it. Then the viewwin is redirected to534 * the new window.535 */536 vw = owl_global_get_viewwin(g);537 owl_popwin_close(pw);538 owl_popwin_up(pw);539 owl_viewwin_set_curswin(vw, owl_popwin_get_curswin(pw),540 owl_popwin_get_lines(pw), owl_popwin_get_cols(pw));541 owl_viewwin_redisplay(vw);542 }543 544 /* refresh stuff */545 g->needrefresh=1;546 owl_mainwin_redisplay(&(g->mw));547 sepbar(NULL);548 if (g->tw)549 owl_editwin_redisplay(g->tw);550 else551 werase(owl_global_get_curs_typwin(g));552 553 owl_function_full_redisplay();554 555 owl_function_makemsg("");556 476 } 557 477 … … 623 543 624 544 void owl_global_set_curmsg_vert_offset(owl_global *g, int i) { 625 g->curmsg_vert_offset =i;545 g->curmsg_vert_offset = i; 626 546 } 627 547
Note: See TracChangeset
for help on using the changeset viewer.