SPAN_POINT_MARK和SPAN_MARK_POINT之间的区别是什么? [英] What is the difference between SPAN_POINT_MARK and SPAN_MARK_POINT?

查看:732
本文介绍了SPAN_POINT_MARK和SPAN_MARK_POINT之间的区别是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读上的文档的跨越式/ Spannable 类项目那我的工作。我一直困惑的定义,包含跨度的使用标记 POINT

A 标记似乎在文档中定义为连接到人物的位置,而 POINT 是定义为粘的字符。因此,一个标记在文本更改不会移动和 POINT 将与它粘字移到当文字被更改。

这些定义似乎表明,标记的代名词的代名词 EXCLUSIVE

不过,这是不是这样既不 SPAN_MARK_MARK SPAN_POINT_POINT 的代名词无论是 SPAN_INCLUSIVE_INCLUSIVE SPAN_EXCLUSIVE_EXCLUSIVE 。事实上, SPAN_INCLUSIVE_INCLUSIVE 是一样的 SPAN_MARK_POINT SPAN_POINT_MARK 是一样的 SPAN_EXCLUSIVE_EXCLUSIVE

我的问题如下:

  1. 为什么 SPAN_POINT_MARK 等同于 SPAN_EXCLUSIVE_EXCLUSIVE ?为什么是 SPAN_MARK_POINT 等同于 SPAN_INCLUSIVE_INCLUSIVE

  2. 为什么不 SPAN_MARK_MARK SPAN_POINT_POINT 等同于 SPAN_INCLUSIVE_INCLUSIVE SPAN_EXCLUSIVE_EXCLUSIVE 分别?

  3. 什么是标记 POINT 的真正定义,这种用法?

解决方案

我想解释一下MARK VS点是由重新presenting他们作为方括号中的任何补偿,他们在一定范围的文本存在的方式。该方向的括号内是指向显示字符的标记或点连接即可。

所以换一个角度,你可以使用开放式支架 - 它连接到它后面的字符。而对于一个标记,你可以使用右括号 - 它安装在字preceding它

让我们来看看每种类型的一些例子:

SPAN_MARK_MARK

插入在一个长度为0的范围的偏移量:这些标记保持固定。

前:LOREM]存有悲坐。
后:LOREM] 插入存有悲坐。

插入在非0长度的跨度的开始:插入的文本被包括在跨度的范围内。

前:LOREM]存有]悲坐。
后:LOREM] 插入存有]悲坐。

插入在非0长度的跨度的末尾:插入的文本被排除在跨度的范围内。

前:LOREM]存有]悲坐。
后:LOREM]存有] 插入悲坐。

您可以从最近的两个例子,为什么 SPAN_MARK_MARK 标志的代名词 SPAN_INCLUSIVE_EXCLUSIVE 标志见。文本在跨度的开始插入被包括在范围内,而在文本插到底的除外。

SPAN_POINT_POINT

插入在一个长度为0的范围的偏移量:这些点推进。

前:LOREM [存有悲坐。
后:LOREM 插入 [存有悲坐。

插入在非0长度的跨度的开始:插入的文本被排除在跨度的范围内。

前:LOREM [存有[悲坐。
后:LOREM 插入 [存有[悲坐。

插入在非0长度的跨度的末尾:插入的文本被包括在跨度的范围内。

前:LOREM [存有[悲坐。
后:LOREM [存有插入 [悲坐。

同样,你可以从最近的两个例子看出为什么 SPAN_POINT_POINT 标志的代名词 SPAN_EXCLUSIVE_INCLUSIVE 标志。文本在跨度的开始插入被排除在范围内,而在文本插到底被包括

SPAN_MARK_POINT

插入在跨度的开始:插入的文本被包括在范围内。

前:LOREM]存有[悲坐。
后:LOREM] 插入存有[悲坐。

在插入跨度的末尾:插入的文本仍包含在范围内。

前:LOREM]存有[悲坐。
后:LOREM]存有插入 [悲坐。

因此​​它具有同义词 SPAN_INCLUSIVE_INCLUSIVE - 插入的文本总是包含在跨度范围

SPAN_POINT_MARK

在插入跨度的开始:插入的文本被排除在范围内。

前:LOREM [存有]悲坐。
后:LOREM 插入 [存有]悲坐。

在插入跨度的末尾:插入的文本仍然被排除在范围内。

前:LOREM [存有]悲坐。
后:LOREM [存有] 插入悲坐。

因此​​它具有同义词 SPAN_EXCLUSIVE_EXCLUSIVE - 插入文本始终排除在跨度范围

我觉得文档通过将一些同义词的定义混淆的东西。例如,描述当 SPAN_MARK_MARK ,他们只定义其使用在一个长度为0跨度方面。然后定义时 SPAN_INCLUSIVE_EXCLUSIVE (其是同义词),他们只限定其在非0长度的跨度而言用法。我认为这将是一个更加清晰,如果他们说了前面,他们是同义词,并且有由这两个术语共享一个单一的定义。

I have been reading up on the docs for the Spanned/Spannable class for a project that I am working on. I have been puzzled by the definition and usage of the spans that contain MARK and POINT.

A MARK seems to be defined in the Doc as "attached" to a character's location while a POINT is defined as being "glued" to a character. Thus a MARK won't move when text is changed and a POINT will move with the character it was "glued" to when text is changed.

These definitions seem to show that MARK is synonymous with INCLUSIVE and that POINT is synonymous with EXCLUSIVE.

However, this is not the case as neither SPAN_MARK_MARK nor SPAN_POINT_POINT are synonymous with either SPAN_INCLUSIVE_INCLUSIVEor SPAN_EXCLUSIVE_EXCLUSIVE. In fact, SPAN_INCLUSIVE_INCLUSIVE is the same as SPAN_MARK_POINT and SPAN_POINT_MARK is the same as SPAN_EXCLUSIVE_EXCLUSIVE.

My questions are as follows

  1. Why is SPAN_POINT_MARK synonymous with SPAN_EXCLUSIVE_EXCLUSIVE? and why is SPAN_MARK_POINT synonymous with SPAN_INCLUSIVE_INCLUSIVE?

  2. Why aren't SPAN_MARK_MARK and SPAN_POINT_POINT synonymous with SPAN_INCLUSIVE_INCLUSIVEand SPAN_EXCLUSIVE_EXCLUSIVE respectively?

  3. What are the true definitions of MARK and POINT in this usage?

解决方案

The way I like to explain MARK vs POINT is by representing them as square brackets at whatever offset they exist in a range of text. The direction the bracket is pointing shows the character that the mark or point is "attached" to.

So for a POINT, you would use the open bracket - it's attached to the character following it. And for a MARK, you would use the close bracket - it's attached to the character preceding it.

Let's look at some examples of each type:

SPAN_MARK_MARK

Inserting at the offset of a 0-length span: The marks remain fixed.

Before: Lorem ]]ipsum dolor sit.
After:  Lorem ]]INSERTipsum dolor sit.

Inserting at the start of a non-0-length span: The inserted text is included in the range of the span.

Before: Lorem ]ipsum] dolor sit.
After:  Lorem ]INSERTipsum] dolor sit.

Inserting at the end of a non-0-length span: The inserted text is excluded from the range of the span.

Before: Lorem ]ipsum] dolor sit.
After:  Lorem ]ipsum]INSERT dolor sit.

You can see from the last two examples, why the SPAN_MARK_MARK flag is synonymous with the SPAN_INCLUSIVE_EXCLUSIVE flag. Text inserted at the start of the span is included in the range, while text inserted at the end is excluded.

SPAN_POINT_POINT

Inserting at the offset of a 0-length span: The points are pushed forward.

Before: Lorem [[ipsum dolor sit.
After:  Lorem INSERT[[ipsum dolor sit.

Inserting at the start of a non-0-length span: The inserted text is excluded from the range of the span.

Before: Lorem [ipsum[ dolor sit.
After:  Lorem INSERT[ipsum[ dolor sit.

Inserting at the end of a non-0-length span: The inserted text is included in the range of the span.

Before: Lorem [ipsum[ dolor sit.
After:  Lorem [ipsumINSERT[ dolor sit.

Again you can see from the last two examples why the SPAN_POINT_POINT flag is synonymous with the SPAN_EXCLUSIVE_INCLUSIVE flag. Text inserted at the start of the span is excluded from the range, while text inserted at the end is included.

SPAN_MARK_POINT

Inserting at the start of the span: The inserted text is included in the range.

Before: Lorem ]ipsum[ dolor sit.
After:  Lorem ]INSERTipsum[ dolor sit.

Inserting at the end of the span: The inserted text is still included in the range.

Before: Lorem ]ipsum[ dolor sit.
After:  Lorem ]ipsumINSERT[ dolor sit.

And thus it has the synonym SPAN_INCLUSIVE_INCLUSIVE - the inserted text is always included in the range of the span.

SPAN_POINT_MARK

Inserting at the start of the span: The inserted text is excluded from the range.

Before: Lorem [ipsum] dolor sit.
After:  Lorem INSERT[ipsum] dolor sit.

Inserting at the end of the span: The inserted text is still excluded from the range.

Before: Lorem [ipsum] dolor sit.
After:  Lorem [ipsum]INSERT dolor sit.

And thus it has the synonym SPAN_EXCLUSIVE_EXCLUSIVE - the inserted text is always excluded from the range of the span.

I think the documentation confuses things by splitting the definitions of some of the synonyms. For example, when describing SPAN_MARK_MARK, they only define its usage in terms of a 0-length span. Then when defining SPAN_INCLUSIVE_EXCLUSIVE (which is a synonym) they only define its usage in terms of non-0-length spans. I think it would have been a lot clearer if they stated up front that they were synonyms, and had a single definition shared by both terms.

这篇关于SPAN_POINT_MARK和SPAN_MARK_POINT之间的区别是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆