Movatterモバイル変換


[0]ホーム

URL:


man7.org > Linux >man-pages

Linux/UNIX system programming training


curs_attr(3x) — Linux manual page

NAME |SYNOPSIS |DESCRIPTION |VIDEO ATTRIBUTES |NOTES |HISTORY |EXTENSIONS |PORTABILITY |RETURN VALUE |SEE ALSO |COLOPHON

curs_attr(3X)curs_attr(3X)

NAME        top

attr_get,wattr_get,attr_set,wattr_set,attr_off,wattr_off,attr_on,wattr_on,attroff,wattroff,attron,wattron,attrset,wattrset,chgat,wchgat,mvchgat,mvwchgat,color_set,wcolor_set,standend,wstandend,standout,wstandout-cursescharacter and       window attribute control routines

SYNOPSIS        top

#include <curses.h>int attr_get(attr_t *attrs, short *pair, void *opts);int  wattr_get(WINDOW  *win,  attr_t  *attrs,  short  *pair,  void*opts);int attr_set(attr_tattrs, shortpair, void *opts);int wattr_set(WINDOW *win, attr_tattrs, shortpair, void *opts);int attr_off(attr_tattrs, void *opts);int wattr_off(WINDOW *win, attr_tattrs, void *opts);int attr_on(attr_tattrs, void *opts);int wattr_on(WINDOW *win, attr_tattrs, void *opts);int attroff(intattrs);int wattroff(WINDOW *win, intattrs);int attron(intattrs);int wattron(WINDOW *win, intattrs);int attrset(intattrs);int wattrset(WINDOW *win, intattrs);int chgat(intn, attr_tattr, shortpair, const void *opts);int wchgat(WINDOW *win,intn, attr_tattr, shortpair, const void *opts);int mvchgat(inty, intx,intn, attr_tattr, shortpair, const void *opts);int mvwchgat(WINDOW *win, int y, int x,intn,attr_tattr, shortpair, const void *opts);int color_set(shortpair, void*opts);int wcolor_set(WINDOW *win, shortpair, void*opts);int standend(void);int wstandend(WINDOW *win);int standout(void);int wstandout(WINDOW *win);

DESCRIPTION        top

       These routines manipulate the current attributes of the named win‐       dow, which then apply to all characters that are written into  the       window withwaddch,waddstrandwprintw.  Attributes are a proper‐       ty  of  the  character,  and  move  with the character through any       scrolling and insert/delete line/character operations.  To the ex‐       tent possible, they are displayed as appropriate modifications  to       the graphic rendition of characters put on the screen.       These routines do not affect the attributes used when erasing por‐       tions of the window.  Seecurs_bkgd(3X) for functions which modify       the attributes used for erasing and clearing.       Routines  which  do  not have aWINDOW*parameter apply tostdscr.       For example,attr_setis thestdscrvariant ofwattr_set.Window attributes       There are two sets of functions:       •   functions for manipulating the window attributes and color:wattr_setandwattr_get.       •   functions for manipulating only the window attributes (not           color):wattr_onandwattr_off.       Thewattr_setfunction sets the current attributes of the given       window toattrs, with color specified bypair.       Usewattr_getto retrieve attributes for the given window.       Useattr_onandwattr_onto turn on window attributes, i.e., val‐       ues OR'd together inattr, without affecting other attributes.       Useattr_offandwattr_offto turn off window attributes, again       values OR'd together inattr, without affecting other attributes.Legacy window attributes       The X/Open window attribute routines whichset orget, turnon oroff are extensions of older routines which assume that color pairs       are OR'd into the attribute parameter.  These newer routines use       similar names, because X/Open simply added an underscore (_) for       the newer names.       Theintdatatype used in the legacy routines is treated as if it       is the same size aschtype(used byaddch(3X)).  It holds the com‐       mon video attributes (such as bold, reverse), as well as a few       bits for color.  Those bits correspond to theA_COLORsymbol.  TheCOLOR_PAIRmacro provides a value which can be OR'd into the at‐       tribute parameter.  For example, as long as that value fits into       theA_COLORmask, then these calls produce similar results:           attrset(A_BOLD | COLOR_PAIR(pair));           attr_set(A_BOLD,pair, NULL);       However, if the value does not fit, then theCOLOR_PAIRmacro uses       only the bits that fit.  For example, because in ncursesA_COLOR       has eight (8) bits, thenCOLOR_PAIR(259)is 4 (i.e., 259 is 4 more       than the limit 255).       ThePAIR_NUMBERmacro extracts a pair number from anint(orchtype).  For example, theinput andoutput values in these state‐       ments would be the same:           int value = A_BOLD | COLOR_PAIR(input);           intoutput = PAIR_NUMBER(value);       Theattrsetroutine is a legacy feature predating SVr4 curses but       kept in X/Open Curses for the same reason that SVr4 curses kept       it: compatibility.       The remainingattr* functions operate exactly like the correspond‐       ingattr_* functions, except that they take arguments of typeint       rather thanattr_t.       There is no correspondingattrgetfunction as such in X/Open Curs‐       es, although ncurses providesgetattrs(see curs_legacy(3X)).Change character rendition       The routinechgatchanges the attributes of a given number of       characters starting at the current cursor location ofstdscr.  It       does not update the cursor and does not perform wrapping.  A char‐       acter count of -1 or greater than the remaining window width means       to change attributes all the way to the end of the current line.       Thewchgatfunction generalizes this to any window; themvwchgat       function does a cursor move before acting.       In these functions, the colorpair argument is a color-pair index       (as in the first argument ofinit_pair, seecurs_color(3X)).Change window color       The routinecolor_setsets the current color of the given window       to the foreground/background combination described by the colorpair parameter.Standout       The routinestandoutis the same asattron(A_STANDOUT).  The rou‐       tinestandendis the same asattrset(A_NORMAL)orattrset(0), that       is, it turns off all attributes.       X/Open does not mark these “restricted”, because       •   they have well established legacy use, and       •   there is no ambiguity about the way the attributes might be           combined with a color pair.

VIDEO ATTRIBUTES        top

       The following video attributes, defined in<curses.h>, can be       passed to the routinesattron,attroff, andattrset, or OR'd with       the characters passed toaddch(seecurs_addch(3X)).Name           Description              ─────────────────────────────────────────────────────────────────A_NORMALNormal display (no highlight)A_STANDOUTBest highlighting mode of the terminal.A_UNDERLINEUnderliningA_REVERSEReverse videoA_BLINKBlinkingA_DIMHalf brightA_BOLDExtra bright or boldA_PROTECTProtected modeA_INVISInvisible or blank modeA_ALTCHARSETAlternate character setA_ITALICItalics (non-X/Open extension)A_CHARTEXTBit-mask to extract a characterA_COLORBit-mask to extract a color (legacy routines)       These video attributes are supported byattr_onand related func‐       tions (which also support the attributes recognized byattron,       etc.):Name            Description              ─────────────────────────────────────────WA_HORIZONTALHorizontal highlightWA_LEFTLeft highlightWA_LOWLow highlightWA_RIGHTRight highlightWA_TOPTop highlightWA_VERTICALVertical highlight       The return values of many of these routines are not meaningful       (they are implemented as macro-expanded assignments and simply re‐       turn their argument).  The SVr4 manual page claims (falsely) that       these routines always return1.

NOTES        top

       These functions may be macros:attroff,wattroff,attron,wattron,attrset,wattrset,standendandstandout.       Color pair values can only be OR'd with attributes if the pair       number is less than 256.  The alternate functions such ascol‐or_setcan pass a color pair value directly.  However, ncurses ABI       4 and 5 simply OR this value within the alternate functions.  You       must use ncurses ABI 6 to support more than 256 color pairs.

HISTORY        top

       X/Open Curses is largely based on SVr4 curses, adding support for       “wide-characters” (not specific to Unicode).  Some of the X/Open       differences from SVr4 curses address the way video attributes can       be applied to wide-characters.  But aside from that,attrsetandattr_setare similar.  SVr4 curses provided the basic features for       manipulating video attributes.  However, earlier versions of curs‐       es provided a part of these features.       As seen in 2.8BSD, curses assumed 7-bit characters, using the       eighth bit of a byte to represent thestandout feature (often im‐       plemented as bold and/or reverse video).  The BSD curses library       provided functionsstandoutandstandendwhich were carried along       into X/Open Curses due to their pervasive use in legacy applica‐       tions.       Some terminals in the 1980s could support a variety of video at‐       tributes, although the BSD curses library could do nothing with       those.  System V (1983) provided an improved curses library.  It       defined theA_symbols for use by applications to manipulate the       other attributes.  There are few useful references for the       chronology.       Goodheart's bookUNIX Curses Explained (1991) describes SVr3       (1987), commenting on several functions:       •   theattron,attroff,attrsetfunctions (and most of the func‐           tions found in SVr4 but not in BSD curses) were introduced by           System V,       •   the alternate character set feature withA_ALTCHARSETwas           added in SVr2 and improved in SVr3 (by addingacs_map[]),       •start_colorand related color-functions were introduced by           System V.3.2,       •   pads, soft-keys were added in SVr3, and       Goodheart did not mention the background character or thecchar_t       type.  Those are respectively SVr4 and X/Open features.  He did       mention theA_constants, but did not indicate their values.       Those were not the same in different systems, even for those       marked as System V.       Different Unix systems used different sizes for the bit-fields inchtypeforcharacters andcolors, and took into account the dif‐       ferent integer sizes (32-bit versus 64-bit).       This table showing the number of bits forA_COLORandA_CHARTEXT       was gleaned from the curses header files for various operating       systems and architectures.  The inferred architecture and notes       reflect the format and size of the defined constants as well as       clues such as the alternate character set implementation.  A       32-bit library can be used on a 64-bit system, but not necessarily       the reverse.Year   System        Arch    Color   Char   Notes              ────────────────────────────────────────────────────────────────              1992   Solaris 5.2   32      6       17     SVr4 curses              1992   HPUX 9        32      no      8      SVr2 curses              1992   AIX 3.2       32      no      23     SVr2 curses              1994   OSF/1 r3      32      no      23     SVr2 curses              1995   HP-UX 10.00   32      6       16     SVr3 “curses_colr”              1995   HP-UX 10.00   32      6       8      SVr4, X/Open curses              1995   Solaris 5.4   32/64   7       16     X/Open curses              1996   AIX 4.2       32      7       16     X/Open curses              1996   OSF/1 r4      32      6       16     X/Open curses              1997   HP-UX 11.00   32      6       8      X/Open curses              2000   U/Win         32/64   7/31    16     useschtype       Notes:          Regarding HP-UX,          •   HP-UX 10.20 (1996) added support for 64-bit PA-RISC proces‐              sors in 1996.          •   HP-UX 10.30 (1997) marked “curses_colr” obsolete.  That              version of curses was dropped with HP-UX 11.30 in 2006.          Regarding OSF/1 (and Tru64),          •   These used 64-bit hardware.  Like ncurses, the OSF/1 curses              interface is not customized for 32-bit and 64-bit versions.          •   Unlike other systems which evolved from AT&T code, OSF/1              provided a new implementation for X/Open curses.          Regarding Solaris,          •   The initial release of Solaris was in 1992.          •   Thexpg4 (X/Open) curses was developed by MKS from 1990 to              1995.  Sun's copyright began in 1996.          •   Sun updated the X/Open curses interface after 64-bit sup‐              port was introduced in 1997, but did not modify the SVr4              curses interface.          Regarding U/Win,          •   Development of the curses library began in 1991, stopped in              2000.          •   Color support was added in 1998.          •   The library uses onlychtype(nocchar_t).       Once X/Open curses was adopted in the mid-1990s, the constraint of       a 32-bit interface with many colors and wide-characters forchtype       became a moot point.  Thecchar_tstructure (whose size and mem‐       bers are not specified in X/Open Curses) could be extended as       needed.       Other interfaces are rarely used now:       •   BSD curses was improved slightly in 1993/1994 using Keith           Bostic's modification to make the library 8-bit clean fornvi(1).  He movedstandout attribute to a structure member.           The resulting 4.4BSD curses was replaced by ncurses over the           next ten years.       •   U/Win is rarely used now.

EXTENSIONS        top

       This implementation provides theA_ITALICattribute for terminals       which have theenter_italics_mode(sitm) andexit_italics_mode       (ritm) capabilities.  Italics are not mentioned in X/Open Curses.       Unlike the other video attributes,A_ITALICis unrelated to theset_attributescapabilities.  This implementation makes the as‐       sumption thatexit_attribute_modemay also reset italics.       Each of the functions added by XSI Curses has a parameteropts,       which X/Open Curses still (after more than twenty years) documents       as reserved for future use, saying that it should beNULL.  This       implementation uses that parameter in ABI 6 for the functions       which have a color-pair parameter to supportextended color pairs:       •   For functions which modify the color, e.g.,wattr_setandwat‐tr_on, ifopts is set it is treated as a pointer toint, and           used to set the color pair instead of theshortpair parame‐           ter.       •   For functions which retrieve the color, e.g.,wattr_get, ifopts is set it is treated as a pointer toint, and used to re‐           trieve the color pair as anintvalue, in addition to retriev‐           ing it via the standard pointer toshortparameter.       •   For functions which turn attributes off, e.g.,wattr_off, theopts parameter is ignored except except to check that it isNULL.

PORTABILITY        top

       These functions are supported in the XSI Curses standard, Issue 4.       The standard defined the dedicated type for highlights,attr_t,       which was not defined in SVr4 curses.  The functions takingattr_t       arguments were not supported under SVr4.       Very old versions of this library did not force an update of the       screen when changing the attributes.  Usetouchwinto force the       screen to match the updated attributes.       The XSI Curses standard states that whether the traditional func‐       tionsattron/attroff/attrsetcan manipulate attributes other thanA_BLINK,A_BOLD,A_DIM,A_REVERSE,A_STANDOUT, orA_UNDERLINEis       “unspecified”.  Under this implementation as well as SVr4 curses,       these functions correctly manipulate all other highlights (specif‐       ically,A_ALTCHARSET,A_PROTECT, andA_INVIS).       XSI Curses added these entry points:attr_get,attr_on,attr_off,attr_set,wattr_on,wattr_off,wattr_get,wattr_set       The new functions are intended to work with a new series of high‐       light macros prefixed withWA_.  The older macros have direct       counterparts in the newer set of names:Name            Description              ────────────────────────────────────────────────────────────WA_NORMALNormal display (no highlight)WA_STANDOUTBest highlighting mode of the terminal.WA_UNDERLINEUnderliningWA_REVERSEReverse videoWA_BLINKBlinkingWA_DIMHalf brightWA_BOLDExtra bright or boldWA_ALTCHARSETAlternate character set       XSI curses does not assign values to these symbols, nor does it       state whether or not they are related to the similarly-named       A_NORMAL, etc.:       •   The XSI curses standard specifies that each pair of corre‐           spondingA_andWA_-using functions operates on the same cur‐           rent-highlight information.       •   However, in some implementations, those symbols have unrelated           values.           For example, the Solarisxpg4 (X/Open) curses declaresattr_t           to be an unsigned short integer (16-bits), whilechtypeis a           unsigned integer (32-bits).  TheWA_symbols in this case are           different from theA_symbols because they are used for a           smaller datatype which does not representA_CHARTEXTorA_COL‐OR.           In this implementation (as in many others), the values happen           to be the same because it simplifies copying information be‐           tweenchtypeandcchar_tvariables.       •   Because ncurses'sattr_tcan hold a color pair (in theA_COLOR           field), a call towattr_on,wattr_off, orwattr_setmay alter           the window's color.  If the color pair information in the at‐           tribute parameter is zero, no change is made to the window's           color.           This is consistent with SVr4 curses; X/Open Curses does not           specify this.       The XSI standard extended conformance level adds new highlightsA_HORIZONTAL,A_LEFT,A_LOW,A_RIGHT,A_TOP,A_VERTICAL(and cor‐       respondingWA_macros for each).  As of August 2013, no known ter‐       minal provides these highlights (i.e., via thesgr1capability).

RETURN VALUE        top

       All routines return the integerOKon success, orERRon failure.       X/Open does not define any error conditions.       This implementation       •   returns an error if the window pointer is null.       •   returns an error if the color pair parameter forwcolor_setis           outside the range 0..COLOR_PAIRS-1.       •   does not return an error if either of the parameters ofwat‐tr_getused for retrieving attribute or color-pair values isNULL.       Functions with a “mv” prefix first perform a cursor movement usingwmove, and return an error if the position is outside the window,       or if the window pointer is null.

SEE ALSO        top

curses(3X),curs_addch(3X),curs_addstr(3X),curs_bkgd(3X),curs_printw(3X),curs_variables(3X)

COLOPHON        top

       This page is part of thencurses (new curses) project.  Informa‐       tion about the project can be found at        ⟨https://www.gnu.org/software/ncurses/ncurses.html⟩.  If you have a       bug report for this manual page, send it to       bug-ncurses-request@gnu.org.  This page was obtained from the       project's upstream Git mirror of the CVS repository       ⟨https://github.com/mirror/ncurses.git⟩ on 2025-08-11.  (At that       time, the date of the most recent commit that was found in the       repository was 2023-03-12.)  If you discover any rendering       problems in this HTML version of the page, or you believe there is       a better or more up-to-date source for the page, or you have       corrections or improvements to the information in this COLOPHON       (which isnot part of the original manual page), send a mail to       man-pages@man7.orgcurs_attr(3X)


HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface.

For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere.

Hosting byjambit GmbH.

Cover of TLPI


[8]ページ先頭

©2009-2025 Movatter.jp