123456789101112131415161718192021222324252627282930313233343536373839404142 |
- import gapbuffer
- import strutils
- var buf = "Hello, world!".toGapBuffer()
- proc dumpInfo =
- echo buf.head.join(), "|", buf.tail.join()
- echo buf
- echo()
- dumpInfo()
- buf.move(6)
- dumpInfo()
- buf.delete()
- dumpInfo()
- buf.insert('!')
- dumpInfo()
- buf[buf.pos] = ','
- dumpInfo()
- buf.moveTo(0)
- dumpInfo()
- buf[buf.pos] = 'h'
- dumpInfo()
- buf.moveTo(buf.len - 1)
- dumpInfo()
- buf.insert("abc\ndef\cghi\ljkl\c\lmno")
- var i = 0
- for line in buf.splitLines():
- echo(i, ": ", line.join())
- inc i
- echo()
- buf.insert("\n")
- buf.moveTo(10)
- i = 0
- for line in buf.splitLines():
- echo(i, ": ", line.join())
- inc i
- echo()
|