void SplitAddAttr (Collection* C, const char* Combined, const char* Name) /* Split a combined name/value pair and add it as an attribute to C. Some * attributes may not need a name. If the name is missing, use Name. If * Name is NULL, terminate with an error. */ { /* Name and value are separated by an equal sign */ const char* Pos = strchr (Combined, '='); if (Pos == 0) { /* Combined is actually a value */ if (Name == 0) { Error ("Command line attribute `%s' doesn't contain a name", Combined); } AddAttr (C, Name, Combined); } else { /* Must split name and value */ StrBuf N = AUTO_STRBUF_INITIALIZER; SB_CopyBuf (&N, Combined, Pos - Combined); SB_Terminate (&N); /* Add the attribute */ AddAttr (C, SB_GetConstBuf (&N), Pos+1); /* Release memory */ SB_Done (&N); } }
NCURSES_SP_NAME(slk_attron) (NCURSES_SP_DCLx const chtype attr) { T((T_CALLED("slk_attron(%p,%s)"), (void *) SP_PARM, _traceattr(attr))); if (SP_PARM != 0 && SP_PARM->_slk != 0) { TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP_PARM->_slk->attr)))); AddAttr(SP_PARM->_slk->attr, attr); if ((attr & A_COLOR) != 0) { SetPair(SP_PARM->_slk->attr, PAIR_NUMBER(attr)); } TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP_PARM->_slk->attr)))); returnCode(OK); } else returnCode(ERR); }
slk_attron(const chtype attr) { T((T_CALLED("slk_attron(%s)"), _traceattr(attr))); if (SP != 0 && SP->_slk != 0) { TR(TRACE_ATTRS, ("... current %s", _tracech_t(CHREF(SP->_slk->attr)))); AddAttr(SP->_slk->attr, attr); if ((attr & A_COLOR) != 0) { SetPair(SP->_slk->attr, PAIR_NUMBER(attr)); } TR(TRACE_ATTRS, ("new attribute is %s", _tracech_t(CHREF(SP->_slk->attr)))); returnCode(OK); } else returnCode(ERR); }
static NCURSES_INLINE NCURSES_CH_T render_char(WINDOW *win, NCURSES_CH_T ch) /* compute a rendition of the given char correct for the current context */ { attr_t a = WINDOW_ATTRS(win); int pair = GetPair(ch); if (ISBLANK(ch) && AttrOf(ch) == A_NORMAL && pair == 0) { /* color/pair in attrs has precedence over bkgrnd */ ch = win->_nc_bkgd; SetAttr(ch, a | AttrOf(win->_nc_bkgd)); if ((pair = GET_WINDOW_PAIR(win)) == 0) pair = GetPair(win->_nc_bkgd); SetPair(ch, pair); } else { /* color in attrs has precedence over bkgrnd */ a |= AttrOf(win->_nc_bkgd) & COLOR_MASK(a); /* color in ch has precedence */ if (pair == 0) { if ((pair = GET_WINDOW_PAIR(win)) == 0) pair = GetPair(win->_nc_bkgd); } #if 0 if (pair > 255) { NCURSES_CH_T fixme = ch; SetPair(fixme, pair); } #endif AddAttr(ch, (a & COLOR_MASK(AttrOf(ch)))); SetPair(ch, pair); } TR(TRACE_VIRTPUT, ("render_char bkg %s (%d), attrs %s (%d) -> ch %s (%d)", _tracech_t2(1, CHREF(win->_nc_bkgd)), GetPair(win->_nc_bkgd), _traceattr(WINDOW_ATTRS(win)), GET_WINDOW_PAIR(win), _tracech_t2(3, CHREF(ch)), GetPair(ch))); return (ch); }
void nsFrameUtil::Tag::ReadAttrs(FILE* aFile) { for (;;) { if (!EatWS(aFile)) { break; } int c = getc(aFile); if (c < 0) break; if (c == '/') { if (!EatWS(aFile)) { return; } if (Expect(aFile, '>')) { type = openClose; break; } } else if (c == '>') { break; } ungetc(c, aFile); char* attr = ReadIdent(aFile); if ((nsnull == attr) || !EatWS(aFile)) { break; } char* value = nsnull; if (Expect(aFile, '=')) { value = ReadString(aFile); if (nsnull == value) { delete [] attr; break; } } AddAttr(attr, value); } }
static NCURSES_INLINE int wadd_wch_nosync(WINDOW *win, cchar_t ch) /* the workhorse function -- add a character to the given window */ { NCURSES_SIZE_T x, y; wchar_t *s; int tabsize = 8; #if USE_REENTRANT SCREEN *sp = _nc_screen_of(win); #endif /* * If we are using the alternate character set, forget about locale. * Otherwise, if the locale claims the code is printable, treat it that * way. */ if ((AttrOf(ch) & A_ALTCHARSET) || iswprint((wint_t) CharOf(ch))) return wadd_wch_literal(win, ch); /* * Handle carriage control and other codes that are not printable, or are * known to expand to more than one character according to unctrl(). */ x = win->_curx; y = win->_cury; switch (CharOf(ch)) { case '\t': #if USE_REENTRANT tabsize = *ptrTabsize(sp); #else tabsize = TABSIZE; #endif x = (NCURSES_SIZE_T) (x + (tabsize - (x % tabsize))); /* * Space-fill the tab on the bottom line so that we'll get the * "correct" cursor position. */ if ((!win->_scroll && (y == win->_regbottom)) || (x <= win->_maxx)) { cchar_t blank = blankchar; AddAttr(blank, AttrOf(ch)); while (win->_curx < x) { if (wadd_wch_literal(win, blank) == ERR) return (ERR); } break; } else { wclrtoeol(win); win->_flags |= _WRAPPED; if (newline_forces_scroll(win, &y)) { x = win->_maxx; if (win->_scroll) { scroll(win); x = 0; } } else { x = 0; } } break; case '\n': wclrtoeol(win); if (newline_forces_scroll(win, &y)) { if (win->_scroll) scroll(win); else return (ERR); } /* FALLTHRU */ case '\r': x = 0; win->_flags &= ~_WRAPPED; break; case '\b': if (x == 0) return (OK); x--; win->_flags &= ~_WRAPPED; break; default: if ((s = wunctrl(&ch)) != 0) { while (*s) { cchar_t sch; SetChar(sch, *s++, AttrOf(ch)); if_EXT_COLORS(SetPair(sch, GetPair(ch))); if (wadd_wch_literal(win, sch) == ERR) return ERR; } return OK; } return ERR; } win->_curx = x; win->_cury = y; return OK; }
static void UnusedAttr (Declaration* D) /* Parse the "unused" attribute */ { /* Add the noreturn attribute */ AddAttr (D, NewDeclAttr (atUnused)); }
static void NoReturnAttr (Declaration* D) /* Parse the "noreturn" attribute */ { /* Add the noreturn attribute */ AddAttr (D, NewDeclAttr (atNoReturn)); }
static void RangeSection (void) /* Parse a range section */ { static const IdentTok RangeDefs[] = { { "COMMENT", INFOTOK_COMMENT }, { "END", INFOTOK_END }, { "NAME", INFOTOK_NAME }, { "START", INFOTOK_START }, { "TYPE", INFOTOK_TYPE }, }; static const IdentTok TypeDefs[] = { { "ADDRTABLE", INFOTOK_ADDRTAB }, { "BYTETABLE", INFOTOK_BYTETAB }, { "CODE", INFOTOK_CODE }, { "DBYTETABLE", INFOTOK_DBYTETAB }, { "DWORDTABLE", INFOTOK_DWORDTAB }, { "RTSTABLE", INFOTOK_RTSTAB }, { "SKIP", INFOTOK_SKIP }, { "TEXTTABLE", INFOTOK_TEXTTAB }, { "WORDTABLE", INFOTOK_WORDTAB }, }; /* Which values did we get? */ enum { tNone = 0x00, tStart = 0x01, tEnd = 0x02, tType = 0x04, tName = 0x08, tComment= 0x10, tNeeded = (tStart | tEnd | tType) }; unsigned Attributes = tNone; /* Locals - initialize to avoid gcc warnings */ unsigned Start = 0; unsigned End = 0; unsigned char Type = 0; char* Name = 0; char* Comment = 0; unsigned MemberSize = 0; /* Skip the token */ InfoNextTok (); /* Expect the opening curly brace */ InfoConsumeLCurly (); /* Look for section tokens */ while (InfoTok != INFOTOK_RCURLY) { /* Convert to special token */ InfoSpecialToken (RangeDefs, ENTRY_COUNT (RangeDefs), "Range attribute"); /* Look at the token */ switch (InfoTok) { case INFOTOK_COMMENT: AddAttr ("COMMENT", &Attributes, tComment); InfoNextTok (); InfoAssureStr (); if (InfoSVal[0] == '\0') { InfoError ("Comment may not be empty"); } Comment = xstrdup (InfoSVal); Attributes |= tComment; InfoNextTok (); break; case INFOTOK_END: AddAttr ("END", &Attributes, tEnd); InfoNextTok (); InfoAssureInt (); InfoRangeCheck (0x0000, 0xFFFF); End = InfoIVal; InfoNextTok (); break; case INFOTOK_NAME: AddAttr ("NAME", &Attributes, tName); InfoNextTok (); InfoAssureStr (); if (InfoSVal[0] == '\0') { InfoError ("Name may not be empty"); } Name = xstrdup (InfoSVal); Attributes |= tName; InfoNextTok (); break; case INFOTOK_START: AddAttr ("START", &Attributes, tStart); InfoNextTok (); InfoAssureInt (); InfoRangeCheck (0x0000, 0xFFFF); Start = InfoIVal; InfoNextTok (); break; case INFOTOK_TYPE: AddAttr ("TYPE", &Attributes, tType); InfoNextTok (); InfoSpecialToken (TypeDefs, ENTRY_COUNT (TypeDefs), "TYPE"); switch (InfoTok) { case INFOTOK_ADDRTAB: Type = atAddrTab; MemberSize = 2; break; case INFOTOK_BYTETAB: Type = atByteTab; MemberSize = 1; break; case INFOTOK_CODE: Type = atCode; MemberSize = 1; break; case INFOTOK_DBYTETAB: Type = atDByteTab; MemberSize = 2; break; case INFOTOK_DWORDTAB: Type = atDWordTab; MemberSize = 4; break; case INFOTOK_RTSTAB: Type = atRtsTab; MemberSize = 2; break; case INFOTOK_SKIP: Type = atSkip; MemberSize = 1; break; case INFOTOK_TEXTTAB: Type = atTextTab; MemberSize = 1; break; case INFOTOK_WORDTAB: Type = atWordTab; MemberSize = 2; break; } InfoNextTok (); break; default: Internal ("Unexpected token: %u", InfoTok); } /* Directive is followed by a semicolon */ InfoConsumeSemi (); } /* Did we get all required values? */ if ((Attributes & tNeeded) != tNeeded) { InfoError ("Required values missing from this section"); } /* Start must be less than end */ if (Start > End) { InfoError ("Start value must not be greater than end value"); } /* Check the granularity */ if (((End - Start + 1) % MemberSize) != 0) { InfoError ("Type of range needs a granularity of %u", MemberSize); } /* Set the range */ MarkRange (Start, End, Type); /* Do we have a label? */ if (Attributes & tName) { /* Define a label for the table */ AddExtLabel (Start, Name); /* Set the comment if we have one */ if (Comment) { SetComment (Start, Comment); } /* Delete name and comment */ xfree (Name); xfree (Comment); } /* Consume the closing brace */ InfoConsumeRCurly (); }