Register
4coder » Wiki

4coder Wiki

Featured Article: [MODULE] Scope highlight

Description

This module provides scope highlighting by drawing colored lines or blocks aligned to the scope indentation of the scopes surrounding the cursor.

Version

This was tested with 4coder 4.1.6.

Setup

Make sure that use_scope_highlight is set to true in config.4coder.

You need to #include this file in your custom layer (4coder_default_bindings.cpp by default) below the line:

1
#include "4coder_default_include.cpp"

You need to call the function scope_highlight_draw from default_render_buffer in 4coder_default_hooks.cpp instead of draw_scope_highlight. The function has a slightly different signature: it doesn't take colors and color_count as arguments, instead it takes the view id and a boolean to choose between line and block mode.

The call should look like this:

1
scope_highlight_draw( app, buffer, text_layout_id, cursor_pos, view_id, false );

You'll need to insert the following function prototype above the declaration of default_render_buffer:

1
function void scope_highlight_draw( Application_Links *app, Buffer_ID buffer, Text_Layout_ID text_layout_id, i64 pos, View_ID view, b32 block_mode );

Add those lines in your theme file to change the colors.

1
2
scope_highlight_line_cycle = { 0xfff048be, 0xfff07a48, 0xffbef048, 0xff48f07a, 0xff48bef0, 0xff7a48f0 };
scope_highlight_block_cycle = { 0x3ff048be, ...