Skip to content

Commit

Permalink
Add text model operations
Browse files Browse the repository at this point in the history
Affects: #48
Affects: #14
  • Loading branch information
io7m committed Dec 13, 2023
1 parent 4d15bfb commit 49b6cbb
Show file tree
Hide file tree
Showing 8 changed files with 433 additions and 79 deletions.
Expand Up @@ -61,4 +61,13 @@ public SyTextID next()
{
return new SyTextID(this.value.add(BigInteger.ONE));
}

/**
* @return The previous text ID
*/

public SyTextID previous()
{
return new SyTextID(this.value.subtract(BigInteger.ONE));
}
}
Expand Up @@ -45,4 +45,22 @@ public record SyTextLinePositioned(
Objects.requireNonNull(textLineNumber, "textLineNumber");
Objects.requireNonNull(textLine, "textLine");
}

/**
* @return The text direction
*/

public SyTextDirection textDirection()
{
return this.textLine.textAsWrapped().direction();
}

/**
* @return The text
*/

public String text()
{
return this.textLine.textAsWrapped().value();
}
}
Expand Up @@ -22,6 +22,7 @@

import java.util.Optional;
import java.util.SortedMap;
import java.util.stream.Stream;

/**
* A readable multi-line text model.
Expand Down Expand Up @@ -84,4 +85,10 @@ Optional<SyTextLocationType> inspectAt(

Optional<SyTextLinePositioned> lineAt(
SyTextLineNumber line);

/**
* @return A lazy stream of the current lines
*/

Stream<SyTextLinePositioned> lines();
}
Expand Up @@ -60,6 +60,26 @@ void textSectionReplace(
SyTextID textID,
SyText text);

/**
* Insert a text section before the given text ID.
*
* @param textID The text ID
* @param text The new text section
*/

void textSectionInsert(
SyTextID textID,
SyText text);

/**
* Delete a text section with the given ID.
*
* @param textID The text ID
*/

void textSectionDelete(
SyTextID textID);

/**
* Append a section of text at the end of the model.
*
Expand Down

0 comments on commit 49b6cbb

Please sign in to comment.