Gap buffer implementation