有右引力标记的例子吗?

发布于 2024-08-30 15:08:26 字数 301 浏览 1 评论 0 原文

引用自此处

标准的从左到右光标是 用正确的重力进行标记(当您 输入,光标停留在右侧 您正在输入的文本的一侧)。

现在我明白什么是右重力标记了。

但我还是不知道左重力标记是什么样的,有左重力标记的例子吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

来世叙缘 2024-09-06 15:08:26

标记用作文本缓冲区的稳定指针。光标就是一个例子,但标记也经常用于内部(用户不可见)原因。假设有一个标记指向以下单词的中间(| 表示标记,而不是文本中的字符):

foo|bar

如果我们在“foo”之后和“bar”之前插入文本“baz”标记的行为会根据重力而有所不同。

对于左重力标记:

foo|bazbar

使用右重力(如光标):

foobaz|bar

左重力的一个很好的用例是指向某行文本开头的标记。使用右重力时,文本插入可能会将其移动到其他位置,而使用左重力时,文本插入将始终指向行开头(当然,前提是之前的换行符未被删除)。

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).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文