API request: sys::StrBuf.remove(Range) #559
brian
30 Apr 2009
Promoted to ticket #559 and assigned to brian
Good idea, I will add removeRange with consistent semantics to sys::List.removeRange.
I am not sure about slice though. If we did it seems like it should return a StrBuf, not a Str. You can always do this if you want a Str:
buf.toStr[3..5]
brian
30 Apr 2009
Ticket resolved in 1.0.42
Added StrBuf.removeRange
KevinKelley
30 Apr 2009
Was wanting to try using StrBuf as a backing model for a textedit, until I noticed there's no good way to remove a chunk from the strbuf.
There's an
insert(int index, Obj x)which presumably does the right thing in growing the buf and copying everything afterindexto the proper spot. But the onlyremovedoes a single character. So to remove ann-character block, you have to call removentimes, meaning everything subsequent toindexgets copiedntimes. Instead of copying it once, to where it should end up.You could do it yourself, with
set(index, char)-- except there's no means of setting the size of the strbuf after you move everything down.sizemaybe should be a field with get/set, like in List, instead of being a method. But the biggest issue is the lack of aremove(range)method.While I'm looking at StrBuf, seems like a
slicemethod that returns a sub-string of the buffer, would be nice too.