Changeset 521bc84
- Timestamp:
- Jul 11, 2009, 1:14:34 PM (15 years ago)
- Branches:
- master, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
- Children:
- bab52da
- Parents:
- 6073462
- git-author:
- Karl Ramm <kcr@1ts.org> (06/09/09 20:52:40)
- git-committer:
- Nelson Elhage <nelhage@mit.edu> (07/11/09 13:14:34)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
editwin.c
r6073462 r521bc84 44 44 } 45 45 46 static void oe_set_index(owl_editwin *e, int index) { 47 e->index = index; 48 e->goal_column = -1; 49 } 50 46 51 /* initialize the editwin e. 47 52 * 'win' is an already initialzed curses window that will be used by editwin … … 54 59 e->hist=hist; 55 60 e->allocated=INCR; 56 e->index = 0;61 oe_set_index(e, 0); 57 62 e->goal_column = -1; 58 63 e->topindex=0; … … 170 175 void owl_editwin_set_locktext(owl_editwin *e, char *text) 171 176 { 172 e->index = 0;177 oe_set_index(e, 0); 173 178 owl_editwin_overwrite_string(e, text); 174 179 owl_editwin_overwrite_char(e, '\0'); 175 180 e->lock=strlen(text); 176 e->index = e->lock;181 oe_set_index(e, e->lock); 177 182 owl_editwin_redisplay(e, 0); 178 183 } … … 201 206 e->bufflen=ptr - e->buff; 202 207 e->buff[e->bufflen]='\0'; 203 e->index = 0;208 oe_set_index(e, 0); 204 209 } 205 210 } … … 246 251 if (locktext) owl_free(locktext); 247 252 248 e->index = lock;253 oe_set_index(e, lock); 249 254 } 250 255 … … 274 279 static void oe_restore_excursion(owl_editwin *e, oe_excursion *x) 275 280 { 276 e->index = x->index;281 oe_set_index(e, x->index); 277 282 e->goal_column = x->goal_column; 278 283 e->lock = x->lock; … … 380 385 owl_editwin_point_move(e, -1); 381 386 } 387 388 e->topindex = e->index; 382 389 /* if we overshot, backtrack */ 383 390 for (n = 0; n < (count - goal); n++) 384 e->index = oe_find_display_line(e, NULL, e->index); 385 386 e->topindex = e->index; 391 e->topindex = oe_find_display_line(e, NULL, e->topindex); 387 392 388 393 oe_restore_excursion(e, &x); … … 480 485 if (c != ' ') { 481 486 i = ptr1 - e->buff; 482 e->index = i;487 oe_set_index(e, i); 483 488 _owl_editwin_insert_bytes(e, 1); 484 489 /* _owl_editwin_insert_bytes may move e->buff. */ … … 544 549 545 550 /* advance the cursor */ 546 e->index += len;551 oe_set_index(e, e->index + len); 547 552 } 548 553 … … 596 601 597 602 /* advance the cursor */ 598 e->index += newlen;603 oe_set_index(e, e->index + newlen); 599 604 } 600 605 … … 634 639 if (e->index == e->bufflen) { 635 640 /* point is after last character */ 636 e->index--;641 oe_set_index(e, e->index - 1); 637 642 } 638 643 … … 660 665 strncpy(p3, tmp, p2 - p3); 661 666 owl_free(tmp); 662 e->index = p3 - e->buff;667 oe_set_index(e, p3 - e->buff); 663 668 } 664 669 … … 725 730 p = oe_prev_point(e, p); 726 731 if (p != NULL) { 727 e->index = p - e->buff;732 oe_set_index(e, p - e->buff); 728 733 d++; 729 734 } 730 735 } 731 732 if (delta)733 e->goal_column = -1;734 736 735 737 return delta > 0 ? d : -d; … … 980 982 void owl_editwin_move_to_end(owl_editwin *e) 981 983 { 982 e->index = e->bufflen;984 oe_set_index(e, e->bufflen); 983 985 } 984 986 985 987 void owl_editwin_move_to_top(owl_editwin *e) 986 988 { 987 e->index = e->lock;989 oe_set_index(e, e->lock); 988 990 } 989 991 … … 1003 1005 if ( (i<=e->lock) || 1004 1006 ((e->buff[i]=='\n') && (e->buff[i-1]=='\n'))) { 1005 e->index = i + 1;1007 oe_set_index(i + 1); 1006 1008 break; 1007 1009 } … … 1029 1031 /* we may have added a character. */ 1030 1032 if (i < save) save += e->bufflen - len; 1031 e->index = i;1033 oe_set_index(i); 1032 1034 } 1033 1035
Note: See TracChangeset
for help on using the changeset viewer.