When using the built-in Debugger, the breakpoints and the current step will be framed looks like this:

My favorite part is, those frames are adaptive to the text when window width changing makes it auto-wrapped to a different shape:

So my question is:
How can I programmly get a frame with this kind of adaptive behavior, as good performance (executing fast) as possible?