Skip to content

Instantly share code, notes, and snippets.

@romgrk
Created August 3, 2021 04:50
Show Gist options
  • Select an option

  • Save romgrk/7e05acf632158d9556a2cee6ed25dec4 to your computer and use it in GitHub Desktop.

Select an option

Save romgrk/7e05acf632158d9556a2cee6ed25dec4 to your computer and use it in GitHub Desktop.
local ffi = require("ffi")
ffi.cdef[[
typedef int handle_T;
typedef long linenr_T; // line number type
typedef int colnr_T;
typedef struct {
linenr_T lnum; /* line number */
colnr_T col; /* column number */
colnr_T coladd;
} pos_T;
struct window_S {
handle_T handle; ///< unique identifier for the window
void *w_buffer; ///< buffer we are a window into (used
///< often, keep it the first item!)
void *w_s; ///< for :ownsyntax
int w_hl_id_normal; ///< 'winhighlight' normal id
int w_hl_attr_normal; ///< 'winhighlight' normal final attrs
int w_hl_ids[51]; ///< 'winhighlight' id
int w_hl_attrs[51]; ///< 'winhighlight' final attrs
int w_hl_needs_update; ///< attrs need to be recalculated
void *w_prev; ///< link to previous window
void *w_next; ///< link to next window
_Bool w_closing; ///< window is being closed, don't let
/// autocommands close it too.
void *w_frame; ///< frame containing this window
pos_T w_cursor; ///< cursor position in buffer
colnr_T w_curswant; ///< Column we want to be at. This is
/// used to try to stay in the same column
/// for up/down cursor motions.
int w_set_curswant; // If set, then update w_curswant the next
// time through cursupdate() to the
// current virtual column
linenr_T w_last_cursorline; ///< where last 'cursorline' was drawn
pos_T w_last_cursormoved; ///< for CursorMoved event
// the next seven are used to update the visual part
char w_old_visual_mode; ///< last known VIsual_mode
linenr_T w_old_cursor_lnum; ///< last known end of visual part
colnr_T w_old_cursor_fcol; ///< first column for block visual part
colnr_T w_old_cursor_lcol; ///< last column for block visual part
linenr_T w_old_visual_lnum; ///< last known start of visual part
colnr_T w_old_visual_col; ///< last known start of visual part
colnr_T w_old_curswant; ///< last known value of Curswant
// 'listchars' characters. Defaults set in set_chars_option().
struct {
int eol;
int ext;
int prec;
int nbsp;
int space;
int tab1; ///< first tab character
int tab2; ///< second tab character
int tab3; ///< third tab character
int lead;
int trail;
int conceal;
} w_p_lcs_chars;
// 'fillchars' characters. Defaults set in set_chars_option().
struct {
int stl;
int stlnc;
int vert;
int fold;
int foldopen; ///< when fold is open
int foldclosed; ///< when fold is closed
int foldsep; ///< continuous fold marker
int diff;
int msgsep;
int eob;
} w_p_fcs_chars;
/*
* "w_topline", "w_leftcol" and "w_skipcol" specify the offsets for
* displaying the buffer.
*/
linenr_T w_topline; /* buffer line number of the line at the
top of the window */
char w_topline_was_set; /* flag set to TRUE when topline is set,
e.g. by winrestview() */
int w_topfill; // number of filler lines above w_topline
int w_old_topfill; // w_topfill at last redraw
_Bool w_botfill; // true when filler lines are actually
// below w_topline (at end of file)
_Bool w_old_botfill; // w_botfill at last redraw
colnr_T w_leftcol; // window column number of the left most
// character in the window; used when
// 'wrap' is off
colnr_T w_skipcol; // starting column when a single line
// doesn't fit in the window
// NOTE: CROPPED FOR BREVITY
};
typedef struct window_S win_T;
extern win_T *curwin;
]]
print(ffi.C.curwin.w_leftcol)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment