tags:

views:

17

answers:

1

Quoted from here:

The standard left-to-right cursor is a mark with right gravity (when you type, the cursor stays on the right side of the text you're typing).

Now I see what's an mark with right gravity.

But I still don't have an idea what's a mark with left gravity like,is there an example of left gravity mark?

+1  A: 

Marks are used as stable pointers into a text buffer. Cursor is one example, but marks are often used for internal (not visible to user) reasons too. Suppose there's a mark pointing in to the middle of the following word (| signifies the mark, not a character in the text):

foo|bar

If we insert text "baz" after "foo" and before "bar" the mark will behave differently depending on the gravity.

For mark with left gravity:

foo|bazbar

With right gravity (like the cursor):

foobaz|bar

A good usecase for left gravity is a mark that points to the beginning of some line of text. With right gravity, text insertion could shift it to somewhere else, with left gravity it will always point to the line beginning (provided that linefeed before is not deleted, of course).

doublep
Does the gravity of mark determin the position of scrollbar?
Gtker
@Runner: I don't understand your question. In general, marks have no representation in user interface except for two special cases: cursor and selection bound.
doublep
@doublep,can you take a look at this post: http://stackoverflow.com/questions/2750729/how-do-i-understand-what-the-following-means
Gtker