[txmt-dev] Re: Setting the background color of a specific line

Jacob Carlborg doob at me.com
Thu Apr 3 13:30:35 UTC 2014


> A minor change, it should probably be:
>
>      "$TM_MATE" --line 32:3 --mark "error:unexpected identifier"
> /path/to/file
>
> This way we can use the same option for errors, warnings, and set
> bookmarks or search marks from ‘mate’.

Yeah, good point. It should also support passing multiple --mark flags, 
to allow setting multiple marks for a line.

> You mean that the code that segfaults could be your custom paragraph_t
> function? That does sound plausible if you copy/pasted the code from
> layout_t::line_record_for to get the paragraph_t object (since that code
> should work).
>
>> Currently I'm using "iterator_at", but that's probably not right.
>
> The layout_t holds a list (tree) of paragraph_t objects which each
> correspond to a single line in the source buffer.
>
> The paragraph_t has a list of paragraph_t::node_t objects, and
> paragraph_t::iterator_at returns a pointer to the node corresponding to
> a particular offset into the line. The line is broken up into nodes to
> handle things like soft wrap, tabs, or folding markers.
>
> The ct::line_t object held by the paragraph_t::node_t object is a
> shallow wrapper for a CoreText CTLineRef and lazily created (and
> disposed if the source buffer gets updated).
>
> So you do not want to drill all the way down to ct::line_t

I manged to drill down to ct::line_t. I kind of works, but not entirely 
as I want to. As soon as I edit a marked line the background color is 
removed.

> As of such, I do think this actually belongs in buffer_t and then
> layout_t will read the proper attributes from the source buffer (during
> drawing or when constructing/updating the layout).

Probably a better idea. I did had some problem with the drawing, see above.

> But if you want to make it an attribute of the layout_t then it should
> probably be set on paragraph_t and this object will pass it as an
> argument when it calls draw_background on its children.

Ok, I see. Thanks.

-- 
/Jacob Carlborg



More information about the textmate-dev mailing list