window-text-width

window-text-width is a built-in function in `C source code'.

(window-text-width &optional WINDOW PIXELWISE)

Return the width in columns of the text display area of WINDOW.
WINDOW must be a live window and defaults to the selected one.

The returned width does not include dividers, scrollbars, margins,
fringes, nor any partial-width columns at the right of the text
area.

Optional argument PIXELWISE non-nil, means to return the width in
pixels.