[txmt-dev] Re: Setting the background color of a specific line
Allan Odgaard
mailinglist at textmate.org
Thu Apr 3 09:41:24 UTC 2014
On 2 Apr 2014, at 1:39, Jacob Carlborg wrote:
>> "$TM_MATE" --line 32:3 --error "unexpected identifier" /path/to/file
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’.
> […] I've added a method to layout_t where I'm trying to get the
> row/paragraph_t which contains the line I'm interested in. I've used
> the same code as "layout_t::line_record_for" [1] to get a row, but as
> soon as I access the row I get a segmentation fault.
>
> Hmm, the problem might also be in paragraph_t when I'm trying to find
> the node which matches the line I'm interested in.
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
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).
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.
More information about the textmate-dev
mailing list