Changeset e5d4294 in mainline for uspace/app/edit/edit.c
- Timestamp:
- 2009-09-16T21:31:46Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 57688fe2
- Parents:
- 8c73012 (diff), 743e17b (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
-
uspace/app/edit/edit.c
r8c73012 re5d4294 72 72 /** Current position of the caret */ 73 73 tag_t caret_pos; 74 75 /** 76 * Ideal column where the caret should try to get. This is used 77 * for maintaining the same column during vertical movement. 78 */ 79 int ideal_column; 74 80 } pane_t; 75 81 … … 130 136 131 137 pane.rows = scr_rows - 1; 138 pane.columns = scr_columns; 132 139 pane.sh_row = 1; 140 pane.sh_column = 1; 133 141 134 142 /* Start with an empty sheet. */ … … 139 147 sheet_get_cell_pt(&doc.sh, &coord, dir_before, &pt); 140 148 sheet_place_tag(&doc.sh, &pt, &pane.caret_pos); 149 pane.ideal_column = coord.column; 141 150 142 151 if (argc == 2) { … … 206 215 case KC_ENTER: 207 216 insert_char('\n'); 208 pane.rflags |= REDRAW_TEXT;209 217 caret_update(); 210 218 break; … … 235 243 case KC_BACKSPACE: 236 244 delete_char_before(); 237 pane.rflags |= REDRAW_TEXT;238 245 caret_update(); 239 246 break; 240 247 case KC_DELETE: 241 248 delete_char_after(); 242 pane.rflags |= REDRAW_TEXT;243 249 caret_update(); 244 250 break; … … 246 252 if (ev->c >= 32 || ev->c == '\t') { 247 253 insert_char(ev->c); 248 pane.rflags |= REDRAW_ROW;249 254 caret_update(); 250 255 } … … 402 407 static void pane_row_range_display(int r0, int r1) 403 408 { 404 int width;405 409 int i, j, fill; 406 410 spt_t rb, re, dep; … … 415 419 console_goto(con, 0, 0); 416 420 for (i = r0; i < r1; ++i) { 417 sheet_get_row_width(&doc.sh, pane.sh_row + i, &width); 418 419 /* Determine row starting point. */ 420 rbc.row = pane.sh_row + i; rbc.column = 1; 421 /* Starting point for row display */ 422 rbc.row = pane.sh_row + i; 423 rbc.column = pane.sh_column; 421 424 sheet_get_cell_pt(&doc.sh, &rbc, dir_before, &rb); 422 425 423 /* Determine row ending point. */ 424 rec.row = pane.sh_row + i; rec.column = width + 1; 426 /* Ending point for row display */ 427 rec.row = pane.sh_row + i; 428 rec.column = pane.sh_column + pane.columns; 425 429 sheet_get_cell_pt(&doc.sh, &rec, dir_before, &re); 426 430 … … 494 498 495 499 spt_get_coord(&caret_pt, &coord); 496 console_goto(con, coord.column - 1, coord.row - pane.sh_row); 500 console_goto(con, coord.column - pane.sh_column, 501 coord.row - pane.sh_row); 497 502 } 498 503 … … 511 516 512 517 (void) sheet_insert(&doc.sh, &pt, dir_before, cbuf); 518 519 pane.rflags |= REDRAW_ROW; 520 if (c == '\n') 521 pane.rflags |= REDRAW_TEXT; 513 522 } 514 523 … … 526 535 527 536 (void) sheet_delete(&doc.sh, &sp, &ep); 537 538 pane.rflags |= REDRAW_ROW; 539 if (coord.column < 1) 540 pane.rflags |= REDRAW_TEXT; 528 541 } 529 542 … … 532 545 { 533 546 spt_t sp, ep; 534 coord_t coord;547 coord_t sc, ec; 535 548 536 549 tag_get_pt(&pane.caret_pos, &sp); 537 spt_get_coord(&sp, &coord); 538 539 sheet_get_cell_pt(&doc.sh, &coord, dir_after, &ep); 550 spt_get_coord(&sp, &sc); 551 552 sheet_get_cell_pt(&doc.sh, &sc, dir_after, &ep); 553 spt_get_coord(&ep, &ec); 540 554 541 555 (void) sheet_delete(&doc.sh, &sp, &ep); 556 557 pane.rflags |= REDRAW_ROW; 558 if (ec.row != sc.row) 559 pane.rflags |= REDRAW_TEXT; 542 560 } 543 561 … … 555 573 spt_get_coord(&pt, &coord); 556 574 557 /* Scroll pane as necessary. */575 /* Scroll pane vertically. */ 558 576 559 577 if (coord.row < pane.sh_row) { … … 561 579 pane.rflags |= REDRAW_TEXT; 562 580 } 581 563 582 if (coord.row > pane.sh_row + pane.rows - 1) { 564 583 pane.sh_row = coord.row - pane.rows + 1; … … 566 585 } 567 586 587 /* Scroll pane horizontally. */ 588 589 if (coord.column < pane.sh_column) { 590 pane.sh_column = coord.column; 591 pane.rflags |= REDRAW_TEXT; 592 } 593 594 if (coord.column > pane.sh_column + pane.columns - 1) { 595 pane.sh_column = coord.column - pane.columns + 1; 596 pane.rflags |= REDRAW_TEXT; 597 } 598 568 599 pane.rflags |= (REDRAW_CARET | REDRAW_STATUS); 569 570 600 } 571 601 … … 582 612 coord_t coord; 583 613 int num_rows; 614 bool pure_vertical; 584 615 585 616 tag_get_pt(&pane.caret_pos, &pt); … … 594 625 if (coord.row > num_rows) coord.row = num_rows; 595 626 } 627 628 /* For purely vertical movement try attaining @c ideal_column. */ 629 pure_vertical = (dcolumn == 0 && align_dir == dir_before); 630 if (pure_vertical) 631 coord.column = pane.ideal_column; 596 632 597 633 /* … … 603 639 sheet_place_tag(&doc.sh, &pt, &pane.caret_pos); 604 640 641 /* For non-vertical movement set the new value for @c ideal_column. */ 642 if (!pure_vertical) { 643 spt_get_coord(&pt, &coord); 644 pane.ideal_column = coord.column; 645 } 646 605 647 caret_update(); 606 648 }
Note:
See TracChangeset
for help on using the changeset viewer.