howl.Chunk

buffer = Buffer {}

before_each ->
  buffer.text = 'Liñe 1 öf text'

.start_pos returns the start_pos passed in constructor

assert.equal 3, Chunk(buffer, 3, 7).start_pos

.end_pos returns the end_pos passed in constructor

assert.equal 7, Chunk(buffer, 3, 7).end_pos

.text returns the text in the range [start_pos..end_pos]

assert.equal 'ñe 1', Chunk(buffer, 3, 6).text

.styling is a table of offsets and styles, { start, "style", end [,..]}

styles = { 1, 'keyword', 3 }
styler.apply buffer, 1, buffer.size, styles
assert.same { 1, 'keyword', 2 }, Chunk(buffer, 2, 2).styles

delete() deletes the chunk

Chunk(buffer, 1, 5)\delete!
assert.equal '1 öf text', buffer.text

tostring(chunk) returns .text

chunk = Chunk(buffer, 3, 6)
assert.equal chunk.text, tostring(chunk)

#chunk returns the length of the chunk

chunk = Chunk(buffer, 3, 6)
assert.equal 4, #chunk

.text = <string>

.text = <string> replaces the chunk with <string>

chunk = Chunk(buffer, 3, 6)
chunk.text = 'feguard'
assert.equal 'Lifeguard öf text', buffer.text

updates .start_pos and .end_pos to reflect the new chunk

chunk = Chunk(buffer, 1, 6)
chunk.text = 'Zen'
assert.equal 3, chunk.end_pos
assert.equal 'Zen', chunk.text