4coder»Forums
Luke
2 posts
Yeet Sheet
Edited by Luke on Reason: added link to github
Enjoying 4coder at the moment. Took me a while to get my head around the API but once I did it was pretty nice and easy to use! I've implemented a feature that I've wanted in a text editor for a while and was also inspired by the recent demo from Dion Systems.

The yeet sheet is a buffer you can "yeet" any text into and any edits will be kept in sync. This means you can pull in functions from all over the codebase and have them in a single buffer to edit from. Also not showcased in my is I have recently added yeet sheet snapshots. I have the snapshot save/load buttons bound to F10-F12. So say you've got a few audio related functions in a few files, you can yeet them all into the yeet sheet, save a snapshot of it to slot 1, then clear the yeet sheet, yeet all your various draw functions in there and save that to slot 2 and now you can easily switch between the two cross-cutting categories.



Find it on guthub: https://github.com/perky/4coder_loco
Simon Anciaux
1337 posts
Yeet Sheet
Seems interesting.

I remember that Allen at some point showed a feature where they edited search result (I think) and it modified the code file in sync, but I don't think it ever made it in a release.
Jason
235 posts
Yeet Sheet
Like the concept. Just tried it today. Haven't dabbled too much with it yet. Just noticed 4coder doesn't apply virtual whitespace to the yeeted code. Is there a way to get 4coder to apply virtual whitespace to yeet buffers easily?
Simon Anciaux
1337 posts
Yeet Sheet
I didn't try it, but if you change the name of the yeet buffer from *yeet* to yeet.c (create it with this name), than the begin_buffer hook should set it up as a code buffer. Otherwise you might be able to set it like this (once again I haven't tested it):

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
static Buffer_ID
loco_get_yeet_buffer(Application_Links *app)
{
    String_Const_u8 yeet_name = string_u8_litexpr("*yeet*");
    Buffer_ID yeet_buffer = get_buffer_by_name(app, yeet_name, Access_Always);
    if (!buffer_exists(app, yeet_buffer))
    {
        yeet_buffer = create_buffer(app, yeet_name, BufferCreate_AlwaysNew);
        buffer_set_setting(app, yeet_buffer, BufferSetting_Unimportant, true);

        /* Add this line. */
        buffer_set_layout(app, yeet_buffer, layout_virt_indent_literal_generic);
    }
    return yeet_buffer;
}

This assumes that the begin_buffer hook runs before create_buffer returns which I haven't tested.
Jason
235 posts
Yeet Sheet
Edited by Jason on
Otherwise you might be able to set it like this (once again I haven't tested it):


Yep, I think that did the trick. Thank you for the suggestion.


Edit:

It's not perfect however. I'll have to see if maybe I can it to correctly identify a yeet buffer as a code file (yeet.c).
Simon Anciaux
1337 posts
Yeet Sheet
You can look in the default begin_buffer hook in 4coder_default_hook.cpp to see what else is set on code buffers.
Luke
2 posts
Yeet Sheet
Ah yeah forgot I added a bit to 4coder_fluery_hooks.cpp, just this bit
1
function BUFFER_HOOK_SIG(F4_BeginBuffer)
.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
if(treat_as_code == false)
    {
        if(buffer_name.size > 0)
        {
            if(string_match(buffer_name, string_u8_litexpr("*calc*")))
            {
                treat_as_code = true;
            }
            else if(string_match(buffer_name, string_u8_litexpr("*peek*")))
            {
                treat_as_code = true;
            }
            else if(string_match(buffer_name, string_u8_litexpr("*yeet*")))
            {
                treat_as_code = true;
            }
        }
    }
Jason
235 posts
Yeet Sheet
Got it to work now. Thanks!