Changeset 743e17b in mainline


Ignore:
Timestamp:
2009-09-16T21:25:30Z (15 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
985e26d2, e5d4294
Parents:
884b461
Message:

Try maintaining column during vertical caret movements.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/edit/edit.c

    r884b461 r743e17b  
    7272        /** Current position of the caret */
    7373        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;
    7480} pane_t;
    7581
     
    141147        sheet_get_cell_pt(&doc.sh, &coord, dir_before, &pt);
    142148        sheet_place_tag(&doc.sh, &pt, &pane.caret_pos);
     149        pane.ideal_column = coord.column;
    143150
    144151        if (argc == 2) {
     
    605612        coord_t coord;
    606613        int num_rows;
     614        bool pure_vertical;
    607615
    608616        tag_get_pt(&pane.caret_pos, &pt);
     
    617625                if (coord.row > num_rows) coord.row = num_rows;
    618626        }
     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;
    619632
    620633        /*
     
    626639        sheet_place_tag(&doc.sh, &pt, &pane.caret_pos);
    627640
     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
    628647        caret_update();
    629648}
Note: See TracChangeset for help on using the changeset viewer.