Changes in uspace/app/edit/edit.c [743e17b:3052ff4] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/edit/edit.c
r743e17b r3052ff4 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 used77 * for maintaining the same column during vertical movement.78 */79 int ideal_column;80 74 } pane_t; 81 75 … … 94 88 static pane_t pane; 95 89 96 static i nt scr_rows, scr_columns;90 static ipcarg_t scr_rows, scr_columns; 97 91 98 92 #define ROW_BUF_SIZE 4096 … … 136 130 137 131 pane.rows = scr_rows - 1; 138 pane.columns = scr_columns;139 132 pane.sh_row = 1; 140 pane.sh_column = 1;141 133 142 134 /* Start with an empty sheet. */ … … 147 139 sheet_get_cell_pt(&doc.sh, &coord, dir_before, &pt); 148 140 sheet_place_tag(&doc.sh, &pt, &pane.caret_pos); 149 pane.ideal_column = coord.column;150 141 151 142 if (argc == 2) { … … 215 206 case KC_ENTER: 216 207 insert_char('\n'); 208 pane.rflags |= REDRAW_TEXT; 217 209 caret_update(); 218 210 break; … … 243 235 case KC_BACKSPACE: 244 236 delete_char_before(); 237 pane.rflags |= REDRAW_TEXT; 245 238 caret_update(); 246 239 break; 247 240 case KC_DELETE: 248 241 delete_char_after(); 242 pane.rflags |= REDRAW_TEXT; 249 243 caret_update(); 250 244 break; … … 252 246 if (ev->c >= 32 || ev->c == '\t') { 253 247 insert_char(ev->c); 248 pane.rflags |= REDRAW_ROW; 254 249 caret_update(); 255 250 } … … 367 362 { 368 363 int sh_rows, rows; 369 int i, j; 364 int i; 365 unsigned j; 370 366 371 367 sheet_get_num_rows(&doc.sh, &sh_rows); … … 407 403 static void pane_row_range_display(int r0, int r1) 408 404 { 405 int width; 409 406 int i, j, fill; 410 407 spt_t rb, re, dep; … … 419 416 console_goto(con, 0, 0); 420 417 for (i = r0; i < r1; ++i) { 421 /* Starting point for row display */ 422 rbc.row = pane.sh_row + i; 423 rbc.column = pane.sh_column; 418 sheet_get_row_width(&doc.sh, pane.sh_row + i, &width); 419 420 /* Determine row starting point. */ 421 rbc.row = pane.sh_row + i; rbc.column = 1; 424 422 sheet_get_cell_pt(&doc.sh, &rbc, dir_before, &rb); 425 423 426 /* Ending point for row display */ 427 rec.row = pane.sh_row + i; 428 rec.column = pane.sh_column + pane.columns; 424 /* Determine row ending point. */ 425 rec.row = pane.sh_row + i; rec.column = width + 1; 429 426 sheet_get_cell_pt(&doc.sh, &rec, dir_before, &re); 430 427 … … 455 452 /* Fill until the end of display area. */ 456 453 457 if (str_length(row_buf) < (unsigned)scr_columns)454 if (str_length(row_buf) < scr_columns) 458 455 fill = scr_columns - str_length(row_buf); 459 456 else … … 498 495 499 496 spt_get_coord(&caret_pt, &coord); 500 console_goto(con, coord.column - pane.sh_column, 501 coord.row - pane.sh_row); 497 console_goto(con, coord.column - 1, coord.row - pane.sh_row); 502 498 } 503 499 … … 516 512 517 513 (void) sheet_insert(&doc.sh, &pt, dir_before, cbuf); 518 519 pane.rflags |= REDRAW_ROW;520 if (c == '\n')521 pane.rflags |= REDRAW_TEXT;522 514 } 523 515 … … 535 527 536 528 (void) sheet_delete(&doc.sh, &sp, &ep); 537 538 pane.rflags |= REDRAW_ROW;539 if (coord.column < 1)540 pane.rflags |= REDRAW_TEXT;541 529 } 542 530 … … 545 533 { 546 534 spt_t sp, ep; 547 coord_t sc, ec;535 coord_t coord; 548 536 549 537 tag_get_pt(&pane.caret_pos, &sp); 550 spt_get_coord(&sp, &sc); 551 552 sheet_get_cell_pt(&doc.sh, &sc, dir_after, &ep); 553 spt_get_coord(&ep, &ec); 538 spt_get_coord(&sp, &coord); 539 540 sheet_get_cell_pt(&doc.sh, &coord, dir_after, &ep); 554 541 555 542 (void) sheet_delete(&doc.sh, &sp, &ep); 556 557 pane.rflags |= REDRAW_ROW;558 if (ec.row != sc.row)559 pane.rflags |= REDRAW_TEXT;560 543 } 561 544 … … 573 556 spt_get_coord(&pt, &coord); 574 557 575 /* Scroll pane vertically. */558 /* Scroll pane as necessary. */ 576 559 577 560 if (coord.row < pane.sh_row) { … … 579 562 pane.rflags |= REDRAW_TEXT; 580 563 } 581 582 564 if (coord.row > pane.sh_row + pane.rows - 1) { 583 565 pane.sh_row = coord.row - pane.rows + 1; … … 585 567 } 586 568 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 599 569 pane.rflags |= (REDRAW_CARET | REDRAW_STATUS); 570 600 571 } 601 572 … … 612 583 coord_t coord; 613 584 int num_rows; 614 bool pure_vertical;615 585 616 586 tag_get_pt(&pane.caret_pos, &pt); … … 625 595 if (coord.row > num_rows) coord.row = num_rows; 626 596 } 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;632 597 633 598 /* … … 639 604 sheet_place_tag(&doc.sh, &pt, &pane.caret_pos); 640 605 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 647 606 caret_update(); 648 607 }
Note:
See TracChangeset
for help on using the changeset viewer.