Register
4coder»Forums»How to highlight
Jason
122 posts
How to highlight
9 months, 3 weeks ago Edited by Jason on Feb. 14, 2019, 1:56 a.m. Reason: Initial post
I'm trying to figure out how to get a highlight to show in 4coder. Eventually I want to be able to implement something equivalent to vim's visual mode but to start I'm just trying to figure out how to get a simple highlight showing. Here is my current attempt:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
CUSTOM_COMMAND_SIG(highlight)
{
    View_Summary view = get_active_view(app, AccessProtected);

    int32_t pos1 = view.cursor.pos;

    move_right(app);
    move_right(app);
    move_right(app);
    move_right(app);
    move_right(app);
    move_right(app);
    move_right(app);
    refresh_view(app, &view);

    int32_t pos2 = view.cursor.pos;

    view_set_highlight(app, &view, pos1, pos2, true);
}; 


As I understand it, all space from pos1 to pos2 should be highlighted, but it is not highlighting. What am I missing?
Allen Webster
480 posts / 2 projects

Heyo

How to highlight
9 months, 3 weeks ago
Unfortunately you're using the highlight API which was superseded by the new marker based highlighting system only a couple builds ago. The old API is still present to keep everyone's code building who was relying on it, but it's no longer implemented, and it's going out soon.

You can find an example of how to use markers to create a highlight range in the implementation of isearch.

(This assumes you're on build 4.0.29 or later, 4.0.28 and earlier still supported the highlight API you are using)