Register
4coder » Wiki

4coder Wiki

Featured Article: [MODULE] Vertical scope annotation

Description

This module helps to figure out which scope is enclosing the current code line by displaying the line preceding the start of the scope vertically in the margin.

vertical scope annotation screenshot

Version

This was tested with 4coder 4.1.6.

Setup

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 vertical_scope_annotation_draw from the render caller hook (HookID_RenderCaller). By default this is the default_render_buffer function in 4coder_default_hooks.cpp.

If you're using the default hook, you will need to insert the following function prototype above the declaration of default_render_buffer.

1
function void vertical_scope_annotation_draw( Application_Links *app, View_ID view, Buffer_ID buffer, Text_Layout_ID text_layout_id, u32 flags );

You'll also need to either move the declaration of the vertical_scope_annotation_flag_t enum before the declaration of default_render_buffer or hardcoding the values instead of using the enum names. The values are:

1
2
3
4
5
6
vertical_scope_annotation_flag_top_to_bottom = 0;
vertical_scope_annotation_flag_bottom_to_top = 1;
vertical_scope_annotation_flag_highlight = 2;
vertical_scope_annotation_flag_highlight_case_label = 4;
vertical_scope_annotation_flag_no_comment = 8;
vertical_scope_annotation_flag_only_last_case = 16;

If you're using a custom render caller hook, make sure you include the file before the ...