| | 467 | ==== State Vector Diffs ==== |
| | 468 | |
| | 469 | State Vectors can also be sent as a "Diff", which means relative to a state vector sent previously. |
| | 470 | |
| | 471 | For example, if such a diff contains the value "2:3;1:1", this means that the value 3 needs to be added to the processed requests of user 2 of the reference state vector, and 1 to the requests of user 1. |
| | 472 | |
| | 473 | === Operations === |
| | 474 | |
| | 475 | Some fields of the InfText messages use operations to describe a change that has been made to the document. This section defines what operations are allowed. |
| | 476 | |
| | 477 | There are two types of operations. Such operations that modify the document and such that do not. For example, inserting a character into the document does modify it, but moving the cursor of a user does not. If the operation of a request does not modify the document, the request is not recorded into the request log (and cannot be undone). |
| | 478 | |
| | 479 | {{{ |
| | 480 | <insert pos="pos">text</insert> |
| | 481 | <insert-caret pos="pos">text</insert-caret> |
| | 482 | }}} |
| | 483 | |
| | 484 | * pos, Integer: The character offset at which to insert text. |
| | 485 | * text, String: The text to insert. |
| | 486 | |
| | 487 | An operation that inserts new text into the document. The <insert-caret> version additionally places the cursor of the user that made the request behind the inserted text. |
| | 488 | |
| | 489 | {{{ |
| | 490 | <delete pos="pos" len="len" /> |
| | 491 | <delete-caret pos="pos" len="len" /> |
| | 492 | }}} |
| | 493 | |
| | 494 | * pos, Integer: The character offset at which to start deleting characters |
| | 495 | * len, Integer: The number of characters to delete. |
| | 496 | |
| | 497 | Deletes text from the buffer. This operation is only used in <request /> messages. Again, <delete-caret /> additionally places the cursor of the user that made the request to the place where characters have been deleted. |
| | 498 | |
| | 499 | {{{ |
| | 500 | <delete pos="pos"><segment author="user_id">text</segment>[...]</delete> |
| | 501 | }}} |
| | 502 | |
| | 503 | * pos, Integer: The character offset at which to start deleting characters. |
| | 504 | * segments: The text that was deleted, including author information, i.e. which user wrote what text. |
| | 505 | |
| | 506 | Deletes text from the buffer and specifies what text is deleted. This operation is only used in <sync-request /> messages. The synchronization client cannot deduce what text was actually deleted, but must be able to compute the reverse operation in case someone undoes the request. In a normal <request /> message, other users can deduce what text was deleted by having a look at the document and which transformations were required to transform the request to the current state before the operation is actually executed. |
| | 507 | |
| | 508 | {{{ |
| | 509 | <no-op /> |
| | 510 | }}} |
| | 511 | |
| | 512 | Does nothing, and does especially not modify the document (see above). This is used when a user was inactive for some time to report its current state vector to the other users. |
| | 513 | |
| | 514 | {{{ |
| | 515 | <move caret="pos" selection="len" /> |
| | 516 | }}} |
| | 517 | |
| | 518 | * pos, Integer: The character offset to place the cursor to. |
| | 519 | * len, Integer: The length of the selection area, in characters. Negative values mean selection towards the beginning of the document. |
| | 520 | |
| | 521 | Changes the position of the user's cursor position and selection area. This operation does not modify the document. |
| | 522 | |
| | 523 | {{{ |
| | 524 | <undo /> |
| | 525 | <undo-caret /> |
| | 526 | }}} |
| | 527 | |
| | 528 | Undoes the previous request of the user. The <undo-caret /> version also places the user's cursor to the position where the operation was performed. |
| | 529 | |
| | 530 | {{{ |
| | 531 | <redo /> |
| | 532 | <redo-caret /> |
| | 533 | }}} |
| | 534 | |
| | 535 | Redoes the previous request of the user. The <redo-caret /> version also places the user's cursor to the position where the operation was performed. |
| | 536 | |
| 468 | | * caret: The position of the user's cursor, in characters, from the document beginning |
| 469 | | * selection: The number of characters selected, starting at the character caret. Negative means selection towards the beginning of the document. |
| | 542 | * caret, Integer: The position of the user's cursor, in characters, from the document beginning |
| | 543 | * selection, Integer: The number of characters selected, starting at the character caret. Negative means selection towards the beginning of the document. |
| | 544 | * hue, Float: A floating point number between 0.0 (red) and 1.0 (red), specifying the user's color. |
| 509 | | * time, State Vector diff: Describes the document state at which the request was made. |
| 510 | | * operation: The operation performed by the request, see below. |
| 511 | | |
| 512 | | Whenever a user issues a request the <request> message is sent. The user must have joined via the connection the request message comes from. <request> is sent to the whole subscription group. The time sent with this message is not absolute, but relative to the time from the last request of this user. For, example, if time contains the value "2:3;1:1", this means that since the last request of that user, it processed 3 requests from user 2 and one request from user 1. Note that the value for the user itself is therefore always zero, because there cannot be any requests inbetween them. This requires the requests from some user to arrive in-order, but it state vector components from inactive (or users that have left the session) need not to be transmitted all the time. |
| 513 | | |
| 514 | | === Operations === |
| 515 | | |
| 516 | | There are two types of operations. Such operations that modify the document and such that do not. For example, inserting a character into the document does modify it, but moving the cursor of a user does not. If the operation of a request does not modify the document, the request is not recorded in the request log. |
| 517 | | |
| 518 | | The following operations are defined: |
| 519 | | |
| 520 | | {{{ |
| 521 | | <insert pos="pos">text</insert> |
| 522 | | <insert-caret pos="pos">text</insert-caret> |
| 523 | | }}} |
| 524 | | |
| 525 | | * pos, Integer: The character offset at which to insert text. |
| 526 | | * text, String: The text to insert. |
| 527 | | |
| 528 | | An operation that inserts new text into the document. The <insert-caret> version additionally places the cursor of the user that made the request behind the inserted text. |
| 529 | | |
| 530 | | {{{ |
| 531 | | <delete pos="pos" len="len" /> |
| 532 | | <delete-caret pos="pos" len="len" /> |
| 533 | | }}} |
| 534 | | |
| 535 | | * pos, Integer: The character offset at which to start deleting characters |
| 536 | | * len, Integer: The number of characters to delete. |
| 537 | | |
| 538 | | Deletes text from the buffer. This operation is only used in <request> messages. Again, <delete-caret> additionally places the cursor of the user that made the request to the place where characters have been deleted. |
| 539 | | |
| 540 | | {{{ |
| 541 | | <delete pos="pos"><segment author="user_id">text</segment>[...]</delete> |
| 542 | | }}} |
| 543 | | |
| 544 | | * pos, Integer: The character offset at which to start deleting characters. |
| 545 | | * segments: The text that was deleted, including author information, i.e. which user wrote what text. |
| 546 | | |
| 547 | | Deletes text from the buffer and specifies what text is deleted. This operation is only used in <sync-request> messages. The synchronization client cannot deduce what text was actually deleted, but must be able to compute the reverse operation in case someone undoes the request. In a normal <request> message, other users can deduce what text was deleted by having a look at the document and which transformations were required to transform the request to the current state before the operation is actually executed. |
| 548 | | |
| 549 | | {{{ |
| 550 | | <no-op /> |
| 551 | | }}} |
| 552 | | |
| 553 | | Does nothing, and does especially not modify the document (see above). This is used when a user was inactive for some time to report its current state vector to the other users. |
| 554 | | |
| 555 | | {{{ |
| 556 | | <move caret="pos" selection="len" /> |
| 557 | | }}} |
| 558 | | |
| 559 | | * pos, Integer: The character offset to place the cursor to. |
| 560 | | * len, Integer: The length of the selection area, in characters. Negative values mean selection towards the beginning of the document. |
| 561 | | |
| 562 | | Changes the position of the user's cursor position and selection area. This operation does not modify the document. |
| 563 | | |
| 564 | | {{{ |
| 565 | | <undo /> |
| 566 | | <undo-caret /> |
| 567 | | }}} |
| 568 | | |
| 569 | | Undoes the last request of the user. The <undo-caret> version also places the user's cursor to the position where the operation was performed. |
| 570 | | |
| 571 | | {{{ |
| 572 | | <redo /> |
| 573 | | <redo-caret /> |
| 574 | | }}} |
| 575 | | |
| 576 | | Redoes the last request of the user. The <redo-caret> version also places the user's cursor to the position where the operation was performed. |
| | 584 | * time, State Vector Diff: Describes the document state at which the request was made. |
| | 585 | * operation, Operation: The operation performed by the request, see below. |
| | 586 | |
| | 587 | Whenever a user issues a request the <request> message is sent. The user must have joined via the connection the request message comes from. <request> is sent to the whole subscription group. The time is a State Vector Diff, with the previous time sent by that user being the reference state vector. Therefore, it requires the requests from some user to arrive in-order, but state vector components from inactive users (or ones that have left the session) need not to be transmitted all the time. Note that the value for the user itself is therefore always zero, because there cannot be any requests inbetween them. |
| 614 | | r.v() is the state vector at which request r was made. The function associated_request returns request the given request r undoes (which is a DO or REDO request if r is a UNDO request, or an UNDO request if r is a REDO request). In the following diagram DO operations at (0,0), (0,1) and an UNDO operation at (1,1) have been issued. Note that the point (2,0) is reachable by folding from (0,0). The translation path of the blue request from (0,0) to (2,1) shows how it may be used. Although there exists another path in this example where (2,0) does not need to be reachable, the tests described in [svn://svn.0x539.de/infinote/trunk/test/std/test-21.xml test/std/test-21.xml] and [svn://svn.0x539.de/infinote/trunk/test/std/test-46.xml test/std/test-46.xml] fail with the original definition of the Reachable function. |
| | 625 | r.v() is the state vector at which request r was made. The function associated_request returns request the given request r undoes (which is a DO or REDO request if r is a UNDO request, or an UNDO request if r is a REDO request). In the following diagram DO operations at (0,0), (0,1) and an UNDO operation at (1,1) have been issued. Note that the point (2,0) is reachable by folding from (0,0). The translation path of the blue request from (0,0) to (2,1) shows how it may be used. Although there exists another path in this example where (2,0) does not need to be reachable, the tests described in [http://git.0x539.de/?p=infinote.git;a=blob;f=test/session/test-21.xml;hb=master test/std/test-21.xml] and [http://git.0x539.de/?p=infinote.git;a=blob;f=test/session/test-46.xml;hb=master test/std/test-46.xml] fail with the original definition of the Reachable function. |