Open AlecTroemel opened 12 months ago
I'd be against this approach as this as it sounds very much like a hack IMHO... if we really want to save bookmarks lets define a chunk type of the cartridge for doing so and then persist them properly.
the only downside to storing bookmarks in a chunk type is that the bookmarks are separated from the source. That would complicate any external editor support, but that shouldn't really be the concern of tic80. Plus chunks do seem like the more "conical" way of saving any sort of cart data... Im convinced!
A simple approach would be to simply store the line number of the bookmark, something like this
<BOOKMARKS>
001:10
002:123
the example would result in bookmarks at lines 10
and 123
.
Well tic80 already has code to persist binary chunks to TXT (that it uses for all the other areas of a cartridge inside a TXT file)... so any editor that really wanted to support bookmarks could just read and write that area of the TXT cartridge... I can't imagine it would be encoded all the difficult, perhaps just an array of words?
Thumb up to this conversation ! :+1: Bookmark persistence may be one of the last big misses for me, subjectively.
@joshgoebel I'm still try to wrap my head around chunks so forgive my ignorance :smile:
By "just an array of words", do you mean a list of "binary words"? like 00000110
means "there's a bookmark on line 3"?
Well that's a byte, 8 bits... I meant a word (2 bytes)... which lets you bookmark values between 1-65535... no need to get fancy. So for 20 bookmarks you'd need 20 words or a chunk of 40 bytes...
As far as I can tell Bookmarks within the Code editor are not actually saved to the cart. That means they go away when you reload the cart or restart tic80 in any way.
My suggestion is to save these bookmarks in the source code using a Formfeed Character. I've been experimenting with this within emacs. Some observations/thoughts
Some more details on the formfeed character and "Pages" here --> https://www.gnu.org/software/emacs/manual/html_node/emacs/Pages.html
If this is agreeable to the people here, I'd be happy to try my hand at implementing this!