teken.c (197520) | teken.c (197522) |
---|---|
1/*- 2 * Copyright (c) 2008-2009 Ed Schouten <ed@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 2008-2009 Ed Schouten <ed@FreeBSD.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/sys/teken/teken.c 197520 2009-09-26 15:03:42Z ed $ | 26 * $FreeBSD: head/sys/teken/teken.c 197522 2009-09-26 15:26:32Z ed $ |
27 */ 28 29#include <sys/cdefs.h> 30#if defined(__FreeBSD__) && defined(_KERNEL) 31#include <sys/param.h> 32#include <sys/lock.h> 33#include <sys/systm.h> 34#define teken_assert(x) MPASS(x) --- 369 unchanged lines hidden (view full) --- 404 /* Also count the last argument. */ 405 t->t_curnum++; 406 } 407 } 408 409 return (0); 410} 411 | 27 */ 28 29#include <sys/cdefs.h> 30#if defined(__FreeBSD__) && defined(_KERNEL) 31#include <sys/param.h> 32#include <sys/lock.h> 33#include <sys/systm.h> 34#define teken_assert(x) MPASS(x) --- 369 unchanged lines hidden (view full) --- 404 /* Also count the last argument. */ 405 t->t_curnum++; 406 } 407 } 408 409 return (0); 410} 411 |
412teken_color_t 413teken_256to8(teken_color_t c) 414{ 415 unsigned int r, g, b; 416 417 if (c < 16) { 418 /* Traditional color indices. */ 419 return (c % 8); 420 } else if (c >= 244) { 421 /* Upper grayscale colors. */ 422 return (TC_WHITE); 423 } else if (c >= 232) { 424 /* Lower grayscale colors. */ 425 return (TC_BLACK); 426 } 427 428 /* Convert to RGB. */ 429 c -= 16; 430 b = c % 6; 431 g = (c / 6) % 6; 432 r = c / 36; 433 434 if (r < g) { 435 /* Possibly green. */ 436 if (g < b) 437 return (TC_BLUE); 438 else if (g > b) 439 return (TC_GREEN); 440 else 441 return (TC_CYAN); 442 } else if (r > g) { 443 /* Possibly red. */ 444 if (r < b) 445 return (TC_BLUE); 446 else if (r > b) 447 return (TC_RED); 448 else 449 return (TC_MAGENTA); 450 } else { 451 /* Possibly brown. */ 452 if (g < b) 453 return (TC_BLUE); 454 else if (g > b) 455 return (TC_BROWN); 456 else if (r < 3) 457 return (TC_BLACK); 458 else 459 return (TC_WHITE); 460 } 461} 462 |
|
412#include "teken_state.h" | 463#include "teken_state.h" |