logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

notcurses_tabbed – tabbed interface widget

Authors

       v3.0.7.

                                                                                             notcurses_tabbed(3)

Description

       An nctabbed is a widget with one area for data display and a bar with names of tabs.  Unless there are no
       tabs, exactly one tab is "selected", and exactly one tab is "leftmost".  The selected tab is the one that
       controls  the  tab content plane.  The leftmost tab is the one of which the header is visible furthest to
       the left.  Any tab can be moved to and from anywhere in the list.  The tabs can be "rotated", which real‐
       ly means the leftmost tab gets shifted.  The widget is drawn only when nctabbed_redraw or  ntabbed_create
       are called.

   LAYOUT
       The  widget has a tab list either on the top or the bottom, 1 row thick.  The tab list contains tab head‐
       ers (i.e.  their names), separated with the separator specified in nctabbed_create or  nctabbed_set_sepa‐rator.   The channels for the selected tab's header, other tab headers and the separator can be set inde‐
       pendently of each other.  The tab separator can be 0-length, or NULL, in which case there is  no  visible
       separator  between  tab headers.  The selected tab can be made sure to be visible when drawn (by changing
       the leftmost tab) by calling the very long-named nctabbed_ensure_selected_header_visible.   The  rest  of
       the widget is an ncplane housing the selected tab content.  (if any)

   THETABCALLBACK
       The  tab  callback  (of  type  tabcb) takes a tab, the tab content plane, and the opaque pointer given to
       nctabbed_add or nctabbed_set_userptr.  It is called when the tab content is supposed to be drawn, that is
       when the whole widget is redrawn.  It should draw the tab content and possibly make other actions, but it
       should not assume anything about the current state of the tab content plane, nor  should  it  modify  the
       widget's or the tab's state.

Name

       notcurses_tabbed – tabbed interface widget

Return Values

nctabbed_create returns the newly created widget, or NULL when the widget failed to be created.  This de‐
       stroys the ncplane given to it even if it fails.

       nctabbed_selected  and  nctabbed_leftmost  return the selected and leftmost tabs, respectively.  If there
       are no tabs, these return NULL.

       nctab_name returns the tab's name.  This is not a copy, and it should not be stored, since  it  is  freed
       when the tab's name is changed or the tab is deleted.

       nctabbed_next, nctabbed_prev and nctabbed_select return the newly selected tab.

       nctabbed_separator  returns the tab separator.  This is not a copy, and it should not be stored, since it
       is freed when the separator is changed or the widget is deleted.

       Functions returning int return -1 on failure.

See Also

notcurses(3), notcurses_channels(3), notcurses_plane(3)

Synopsis

#include<notcurses/notcurses.h>

              #define NCTABBED_OPTION_BOTTOM 0x0001

              struct nctabbed;
              struct ncplane;
              struct nctab;

              typedef struct nctabbed_options {
                uint64_t selchan; // channel for the selected tab header
                uint64_t hdrchan; // channel for unselected tab headers
                uint64_t sepchan; // channel for the tab separator
                const char* separator; // separator string (copied by nctabbed_create())
                uint64_t flags;   // bitmask of NCTABBED_OPTION_*
              } nctabbed_options;

              typedef void (*tabcb)(struct nctab* t, struct ncplane* ncp, void* userptr);

       structnctabbed*nctabbed_create(structncplane*ncp,constnctabbed_options*opts);voidnctabbed_destroy(structnctabbed*nt);voidnctabbed_redraw(structnctabbed*nt);voidnctabbed_ensure_selected_header_visible(structnctabbed*nt);structnctab*nctabbed_selected(structnctabbed*nt);structnctab*nctabbed_leftmost(structnctabbed*nt);intnctabbed_tabcount(structnctabbed*nt);structncplane*nctabbed_plane(structnctabbed*nt);structncplane*nctabbed_content_plane(structnctabbed*nt);tabcbnctab_cb(structnctab*t);constchar*nctab_name(structnctab*t);intnctab_name_width(structnctab*t);void*nctab_userptr(structnctab*t);structnctab*nctab_next(structnctab*t);structnctab*nctab_prev(structnctab*t);structnctab*nctabbed_add(structnctabbed*nt,structnctab*after,structnctab*before,tabcbtcb,constchar*name,void*opaque**);

       intnctabbed_del(structnctabbed*nt,structnctab*t);intnctab_move(structnctabbed*nt,structnctab*t,structnctab*after,structnctab*before);voidnctab_move_right(structnctabbed*nt,structnctab*t);voidnctab_move_left(structnctabbed*nt,structnctab*t);voidnctabbed_rotate(structnctabbed*nt,intamt);structnctab*nctabbed_next(structnctabbed*nt);structnctab*nctabbed_prev(structnctabbed*nt);structnctab*nctabbed_select(structnctabbed*nt,structnctab*t);voidnctabbed_channels(structnctabbed*nt,uint64_t*RESTRICThdrchan,uint64_t*RESTRICTselchan,uint64_t*RESTRICTsepchan);uint64_tnctabbed_hdrchan(structnctabbed*nt);uint64_tnctabbed_selchan(structnctabbed*nt);uint64_tnctabbed_sepchan(structnctabbed*nt);constchar*nctabbed_separator(structnctabbed*nt);intnctabbed_separator_width(structnctabbed*nt);voidnctabbed_set_hdrchan(structnctabbed*nt,uint64_tchan);voidnctabbed_set_selchan(structnctabbed*nt,uint64_tchan);voidnctabbed_set_sepchan(structnctabbed*nt,uint64_tchan);tabcbnctab_set_cb(structnctab*t,tabcbnewcb);intnctab_set_name(structnctab*t,constchar*newname);void*nctab_set_userptr(structnctab*t,void*newopaque);intnctabbed_set_separator(structnctabbed*nt,constchar*separator);

See Also