elemakil
elemakil

Reputation: 3811

Get absolute position in frame

The way I understand how emacs displays stuff is that essentially everything is text. If you have something in the fringe or linum mode active, essentially your document is pushed a little inwards and something is written in the first few columns.

I'm writing a function for putting some stuff into the head-line and this works nicely, however, I would like the start of the text to be aligned with the start of the document.

Thus I am looking for a way to get the number of columns that sit between the frame border and the start of the actual document.

Let me illustrate using a poorly produced graphic:

DistanceMarker

I want to get the number of columns (or the number of pixels) that make up the distance marker by the ruler just below the line number 10000.

The function which returns this value shall be executed in the functions which create the head-line.

Upvotes: 2

Views: 271

Answers (1)

itsjeyd
itsjeyd

Reputation: 5280

There is a function called window-inside-edges that you can use to determine the offset of the text area ("window body") from the total width and height of the window in columns and lines, respectively.

It returns a list four values; the order is left - top - right - bottom, so to get the value you are interested in for the current window, just do

(car (window-inside-edges))

More information on window coordinates can be found here; this page has information about window sizes, including a nice ASCII representation of window elements.

Upvotes: 3

Related Questions