- Timestamp:
- Jun 1, 2010, 12:14:11 PM (14 years ago)
- Branches:
- master, release-1.10, release-1.7, release-1.8, release-1.9
- Children:
- e294783
- Parents:
- 84a4aca
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
editwin.c
r4e33cb2 rf6fae8d 28 28 int cursorx; 29 29 int winlines, wincols, fillcol, wrapcol; 30 WINDOW *curswin; 30 owl_window *win; 31 gulong repaint_id; 32 gulong resized_id; 31 33 int style; 32 34 int lock; … … 40 42 }; 41 43 44 static void oe_set_curswin(owl_editwin *e, owl_window *w, int winlines, int wincols); 45 static void oe_redisplay(owl_window *win, WINDOW *curswin, void *user_data); 42 46 static void oe_reframe(owl_editwin *e); 43 47 static void oe_save_excursion(owl_editwin *e, oe_excursion *x); … … 58 62 static char *oe_chunk(owl_editwin *e, int start, int end); 59 63 static void oe_destroy_cbdata(owl_editwin *e); 64 static void oe_dirty(owl_editwin *e); 65 static void oe_window_resized(owl_window *w, owl_editwin *e); 60 66 61 67 #define INCR 4096 … … 73 79 void owl_editwin_delete(owl_editwin *e) 74 80 { 81 if (e->win) { 82 g_signal_handler_disconnect(e->win, e->repaint_id); 83 g_signal_handler_disconnect(e->win, e->resized_id); 84 } 75 85 owl_free(e->buff); 76 86 owl_free(e->killbuf); … … 91 101 } 92 102 e->index = index; 103 oe_dirty(e); 93 104 } 94 105 … … 105 116 106 117 static void _owl_editwin_init(owl_editwin *e, 107 WINDOW *win,108 118 int winlines, 109 119 int wincols, … … 130 140 e->style=OWL_EDITWIN_STYLE_MULTILINE; 131 141 } 132 owl_editwin_set_curswin(e, win, winlines, wincols);133 142 e->lock=0; 134 143 e->dotsend=0; 135 144 e->echochar='\0'; 136 137 if (win) werase(win); 138 } 139 140 owl_editwin *owl_editwin_new(WINDOW *win, int winlines, int wincols, int style, owl_history *hist) 145 } 146 147 owl_editwin *owl_editwin_new(owl_window *win, int winlines, int wincols, int style, owl_history *hist) 141 148 { 142 149 owl_editwin *e = owl_editwin_allocate(); 143 150 144 _owl_editwin_init(e, win, winlines, wincols, style, hist); 151 _owl_editwin_init(e, winlines, wincols, style, hist); 152 oe_set_curswin(e, win, winlines, wincols); 145 153 return e; 146 154 } 147 155 148 void owl_editwin_set_curswin(owl_editwin *e, WINDOW *w, int winlines, int wincols) 149 { 150 e->curswin=w; 156 static void oe_window_resized(owl_window *w, owl_editwin *e) 157 { 158 /* update the sizes */ 159 owl_window_get_position(w, &e->winlines, &e->wincols, NULL, NULL); 160 } 161 162 static void oe_set_curswin(owl_editwin *e, owl_window *w, int winlines, int wincols) 163 { 164 e->win=w; 151 165 e->winlines=winlines; 152 166 e->wincols=wincols; … … 156 170 else 157 171 e->wrapcol = 0; 172 if (e->win) { 173 e->repaint_id = g_signal_connect(w, "redraw", G_CALLBACK(oe_redisplay), e); 174 e->resized_id = g_signal_connect(w, "resized", G_CALLBACK(oe_window_resized), e); 175 owl_window_dirty(e->win); 176 } 158 177 } 159 178 … … 165 184 { 166 185 e->echochar=ch; 167 } 168 169 WINDOW *owl_editwin_get_curswin(owl_editwin *e) 170 { 171 return(e->curswin); 186 oe_dirty(e); 172 187 } 173 188 … … 239 254 e->lock=e->bufflen; 240 255 oe_set_index(e, e->lock); 241 o wl_editwin_redisplay(e);256 oe_dirty(e); 242 257 } 243 258 … … 265 280 266 281 owl_free(e->buff); 267 _owl_editwin_init(e, e-> curswin, e->winlines, e->wincols, e->style, e->hist);282 _owl_editwin_init(e, e->winlines, e->wincols, e->style, e->hist); 268 283 269 284 if (lock > 0) { … … 286 301 { 287 302 e->topindex = -1; 303 oe_dirty(e); 288 304 } 289 305 … … 467 483 468 484 oe_restore_excursion(e, &x); 469 } 470 471 static void oe_addnec(owl_editwin *e, int count) 485 oe_dirty(e); 486 } 487 488 static void oe_addnec(owl_editwin *e, WINDOW *curswin, int count) 472 489 { 473 490 int i; 474 491 475 492 for (i = 0; i < count; i++) 476 waddch( e->curswin, e->echochar);477 } 478 479 static void oe_mvaddnec(owl_editwin *e, int y, int x, int count)480 { 481 wmove( e->curswin, y, x);482 oe_addnec(e, c ount);493 waddch(curswin, e->echochar); 494 } 495 496 static void oe_mvaddnec(owl_editwin *e, WINDOW *curswin, int y, int x, int count) 497 { 498 wmove(curswin, y, x); 499 oe_addnec(e, curswin, count); 483 500 } 484 501 485 502 /* regenerate the text on the curses window */ 486 void owl_editwin_redisplay(owl_editwin *e)503 static void oe_redisplay(owl_window *win, WINDOW *curswin, void *user_data) 487 504 { 488 505 int x = -1, y = -1, t, hard; 489 506 int line, index, lineindex, times = 0; 507 owl_editwin *e = user_data; 490 508 491 509 do { 492 werase( e->curswin);510 werase(curswin); 493 511 494 512 if (e->topindex == -1 || e->index < e->topindex) … … 505 523 if (index - lineindex) { 506 524 if (!e->echochar) 507 mvwaddnstr( e->curswin, line, 0,525 mvwaddnstr(curswin, line, 0, 508 526 e->buff + lineindex, 509 527 index - lineindex); 510 528 else { 511 529 if(lineindex < e->lock) { 512 mvwaddnstr( e->curswin, line, 0,530 mvwaddnstr(curswin, line, 0, 513 531 e->buff + lineindex, 514 532 MIN(index - lineindex, 515 533 e->lock - lineindex)); 516 534 if (e->lock < index) 517 oe_addnec(e, 535 oe_addnec(e, curswin, 518 536 oe_region_width(e, e->lock, index, 519 537 oe_region_width(e, lineindex, e->lock, 0))); 520 538 } else 521 oe_mvaddnec(e, line, 0, oe_region_width(e, lineindex, index, 0));539 oe_mvaddnec(e, curswin, line, 0, oe_region_width(e, lineindex, index, 0)); 522 540 } 523 541 if (!hard) 524 waddch( e->curswin, '\\');542 waddch(curswin, '\\'); 525 543 } 526 544 line++; … … 531 549 } while(x == -1 && times < 3); 532 550 533 wmove( e->curswin, y, x);551 wmove(curswin, y, x); 534 552 e->cursorx = x; 535 owl_global_set_needrefresh(&g);536 553 } 537 554 … … 625 642 if (start <= e->topindex) 626 643 owl_editwin_recenter(e); 644 645 oe_dirty(e); 627 646 628 647 return change; … … 858 877 859 878 e->goal_column = goal_column; 879 oe_dirty(e); 860 880 861 881 return distance; … … 1212 1232 return; 1213 1233 } 1214 owl_editwin_redisplay(e);1215 1234 } 1216 1235 … … 1347 1366 } 1348 1367 1368 static void oe_dirty(owl_editwin *e) 1369 { 1370 if (e->win) owl_window_dirty(e->win); 1371 } 1372 1349 1373 1350 1374
Note: See TracChangeset
for help on using the changeset viewer.