Skip to content

Instantly share code, notes, and snippets.

@pmarin
pmarin / gap.c
Last active September 24, 2020 11:48
Gap buffer implementation by Joseph H. Allen. (found in comp.editors)
/*
One of the simplest and most effecient ways of storing a file in memory is
with a gap buffer. The file is broken into three parts in one big array: The
beginning, the gap and the end. The beginning and end parts are just normal
text stored in an array: if the size of the gap is zero, then the buffer
looks like a file loaded simply into an array. The gap lets you insert and
delete characters without moving any large amount of data. All you have to do
is change the size of the gap. You do have to move the gap if it's not at the
spot you want to insert or delete, however. If you can get away with it, it's
a good idea to always keep the gap at the cursor. (I.E., so moving the cursor
@pmarin
pmarin / debug.tcl
Created May 9, 2020 16:25
Fast OpenMSX reboot
proc chdir {} {
diska .
set ::throttle on
}
proc remove_all_breaks {} {
foreach i [split [debug_list_all_breaks] "\n"] {
if [llength $i] {debug remove_bp [lindex $i 0]}}
}
proc reboot {} {