Skip to content

Propose luavc module to wrap struct vc_data #554

@lneto

Description

@lneto

The current notifier.vterm callback pushes several individual fields from vc_data/vc_state (c, vc_num, x, y, color, intensity,
flags) to give Lua scripts enough context to react to VT events. Every new piece of VT state that becomes interesting forces another
positional argument, and important fields (e.g. vc_cols/vc_rows, needed to size a mirror grid correctly per-VT) still aren't
exposed.

Proposal: introduce a luavc module that wraps struct vc_data as a lunatik pointer object — same pattern as luaskb wraps struct
sk_buff. The notifier callback would receive a single vc userdata instead of a growing list of positional args:

 function callback(event, vc)
     if event ~= vt.WRITE then return notify.DONE end
     local c, x, y     = vc:char(), vc:x(), vc:y()
     local cols, rows  = vc:cols(), vc:rows()
     local color, attr = vc:color(), vc:attrs()
     ...
 end

Design notes:

  • pointer = true: private holds a non-owning struct vc_data *, so release is a no-op. Lifetime is controlled by the VT subsystem.
  • Read-only access at first; write access (vc:set_cursor(x, y), etc.) can come later and only under the right contexts.
  • Registry pattern (luavc_attach/detach) to hand the same userdata into a hardirq callback without reallocating per event.
  • Enables richer VT examples (vtmirror sizing grids from vc_cols, control-sequence-aware tools, VT_UPDATE/VT_RESIZE consumers)
    without growing the vt_handler positional signature any further.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions