Skip to content

Commit

Permalink
implementation for MutableAttributedString->delete()
Browse files Browse the repository at this point in the history
  • Loading branch information
apemsel committed Feb 22, 2016
1 parent 0cc86d3 commit c892a77
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/MutableAttributedString.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,21 @@ public function insert($pos, $string) {
}

public function delete($pos, $length) {
$leftPart = "";
if ($pos > 0) {
$leftPart = substr($this->string, 0, $pos - 1);
}

}

public function replace($pos, $length, $string) {
$rightPart = "";
if ($pos + $length < $this->length) {
$rightPart = substr($this->string, $pos + $length);
}

$this->string = $leftPart.$rightPart;
$this->length -= $length;

foreach ($this->attributes as $attribute => &$map) {
array_splice($map, $pos, $length);
}
}
}

0 comments on commit c892a77

Please sign in to comment.