Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Suggestion] Save code editor bookmarks in cart as formfeed character #2272

Open
AlecTroemel opened this issue Aug 20, 2023 · 6 comments
Open

Comments

@AlecTroemel
Copy link
Sponsor Contributor

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

  1. It doesnt break tic80 in any way.. at least not in Janet code
  2. Shows up as a blank character within the code editor
  3. seems like a good easy way for external text editors to also display bookmarks!

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!

@joshgoebel
Copy link
Collaborator

joshgoebel commented Aug 20, 2023

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.

@AlecTroemel
Copy link
Sponsor Contributor Author

AlecTroemel commented Aug 21, 2023

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.

@joshgoebel
Copy link
Collaborator

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?

@Skeptim
Copy link
Contributor

Skeptim commented Aug 24, 2023

Thumb up to this conversation ! 👍 Bookmark persistence may be one of the last big misses for me, subjectively.

@AlecTroemel
Copy link
Sponsor Contributor Author

@joshgoebel I'm still try to wrap my head around chunks so forgive my ignorance 😄

By "just an array of words", do you mean a list of "binary words"? like 00000110 means "there's a bookmark on line 3"?

@joshgoebel
Copy link
Collaborator

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants