Lines Matching +full:num +full:- +full:ob +full:- +full:windows

2  * Copyright (C) 1984-2025  Mark Nudelman
17 #include "windows.h"
85 * win_flush has at least one non-critical issue when an escape sequence
87 * as a temporary measure to reduce likelyhood of encountering end-of-buffer
88 * issues till the SGR parser is replaced, OUTBUF_SIZE is 8K on Windows.
91 static char *ob = obuf; variable
109 #define T_ANSI 1ul /* colors 0-7 */
125 /* returns 0 on success, non-0 on unknown SGR code */
132 case 1: sgr->attr |= A_BOLD; break; in update_sgr()
133 case 22: sgr->attr &= ~A_BOLD; break; in update_sgr()
135 case 3: sgr->attr |= A_ITALIC; break; in update_sgr()
136 case 23: sgr->attr &= ~A_ITALIC; break; in update_sgr()
138 case 4: sgr->attr |= A_UNDERLINE; break; in update_sgr()
139 case 24: sgr->attr &= ~A_UNDERLINE; break; in update_sgr()
141 case 6: /* fast-blink, fallthrough */ in update_sgr()
142 case 5: sgr->attr |= A_BLINK; break; in update_sgr()
143 case 25: sgr->attr &= ~A_BLINK; break; in update_sgr()
145 case 7: sgr->attr |= A_INVERSE; break; in update_sgr()
146 case 27: sgr->attr &= ~A_INVERSE; break; in update_sgr()
148 case 8: sgr->attr |= A_CONCEAL; break; in update_sgr()
149 case 28: sgr->attr &= ~A_CONCEAL; break; in update_sgr()
151 case 39: sgr->fg = C_DEFAULT; break; in update_sgr()
152 case 49: sgr->bg = C_DEFAULT; break; in update_sgr()
156 sgr->fg = C_ANSI(code - 30); in update_sgr()
161 sgr->bg = C_ANSI(code - 40); in update_sgr()
191 int fg, bg, tmp; /* Windows colors */ in set_win_colors()
193 /* Not "SGR mode": apply -D<x> to default fg+bg with one attribute */ in set_win_colors()
194 if (!sgr_mode && sgr->fg == C_DEFAULT && sgr->bg == C_DEFAULT) in set_win_colors()
196 switch (sgr->attr) in set_win_colors()
211 * There's no -Di so italic should not be here, but to in set_win_colors()
212 * preserve legacy behavior, apply -Ds to italic too. in set_win_colors()
220 /* generic application of the SGR state as Windows colors */ in set_win_colors()
222 fg = sgr->fg == C_DEFAULT ? nm_fg_color in set_win_colors()
223 : screen_color[CGET_ANSI(sgr->fg)]; in set_win_colors()
225 bg = sgr->bg == C_DEFAULT ? nm_bg_color in set_win_colors()
226 : screen_color[CGET_ANSI(sgr->bg)]; in set_win_colors()
228 if (sgr->attr & A_BOLD) in set_win_colors()
231 if (sgr->attr & (A_BLINK | A_UNDERLINE)) in set_win_colors()
234 if (sgr->attr & (A_INVERSE | A_ITALIC)) in set_win_colors()
241 if (sgr->attr & A_CONCEAL) in set_win_colors()
259 WIN32textout(obuf, ptr_diff(ob, obuf)); in win_flush()
263 * Digest text, apply embedded SGR sequences as Windows-colors. in win_flush()
264 * By default - when -Da ("SGR mode") is unset - also apply in win_flush()
265 * translation of -D command-line options (at set_win_colors) in win_flush()
276 * to the terminal - which can handle it better than us. in win_flush()
281 * until we know we're in sync again - on a valid reset. in win_flush()
286 (p_next = memchr(p_next, ESC, ob - p_next)) != NULL; ) in win_flush()
289 if (p[1] == '[') /* "ESC-[" sequence */ in win_flush()
309 p += 2; /* Skip the "ESC-[" */ in win_flush()
343 ob = &obuf[slop]; in win_flush()
376 * until we're in-sync again in win_flush()
388 WIN32textout(anchor, ptr_diff(ob, anchor)); in win_flush()
390 ob = obuf; in win_flush()
414 n = ptr_diff(ob, obuf); in flush()
417 ob = obuf; in flush()
430 ob = obuf + n; in flush()
431 *ob = '\0'; in flush()
458 #if 0 /* fake UTF-8 output for testing */ in putchr()
486 if (c == '\n' && is_tty) /* In OS-9, '\n' == 0x0D */ in putchr()
491 * Some versions of flush() write to *ob, so we must flush in putchr()
494 if (ob >= &obuf[sizeof(obuf)-1]) in putchr()
496 *ob++ = c; in putchr()
523 void funcname(type num, char *buf, int radix) \
525 int neg = (num < 0); \
526 char tbuf[INT_STRLEN_BOUND(num)+2]; \
528 if (neg) num = -num; \
529 *--s = '\0'; \
531 *--s = "0123456789ABCDEF"[num % radix]; \
532 } while ((num /= radix) != 0); \
533 if (neg) *--s = '-'; \
542 * Convert a string to an integral type. Return ((type) -1) on overflow. in TYPE_TO_A_FUNC()
551 …it = (c >= '0' && c <= '9') ? c - '0' : (c >= 'a' && c <= 'f') ? c - 'a' + 10 : (c >= 'A' && c <= … in TYPE_TO_A_FUNC()
557 return v ? (type)(-1) : val; \ in TYPE_TO_A_FUNC()
563 if (ebuf != NULL) *ebuf = (char *) cbuf; /*{{const-issue}}*/ \
575 static int funcname(type num, int radix) \
577 char buf[INT_STRLEN_BOUND(num)]; \
578 typetoa(num, buf, radix); \
587 * This function implements printf-like functionality
612 s = parg->p_string;
627 col += iprint_int(parg->p_int, 10);
631 col += iprint_int(parg->p_int, 16);
635 col += iprint_linenum(parg->p_linenum, 10);
639 s = prchar((LWCHAR) parg->p_char);
658 * If some other non-trivial char is pressed, unget it, so it will
723 * time-consuming operation.
758 * and return a single-character response.