inch.c revision 1.10
11.10Sjdc/* $NetBSD: inch.c,v 1.10 2009/10/06 20:03:27 jdc Exp $ */ 21.2Sblymn 31.2Sblymn/*- 41.2Sblymn * Copyright (c) 1999 The NetBSD Foundation, Inc. 51.2Sblymn * All rights reserved. 61.2Sblymn * 71.2Sblymn * This code is derived from software contributed to The NetBSD Foundation 81.2Sblymn * by Julian Coleman. 91.2Sblymn * 101.2Sblymn * Redistribution and use in source and binary forms, with or without 111.2Sblymn * modification, are permitted provided that the following conditions 121.2Sblymn * are met: 131.2Sblymn * 1. Redistributions of source code must retain the above copyright 141.2Sblymn * notice, this list of conditions and the following disclaimer. 151.2Sblymn * 2. Redistributions in binary form must reproduce the above copyright 161.2Sblymn * notice, this list of conditions and the following disclaimer in the 171.2Sblymn * documentation and/or other materials provided with the distribution. 181.2Sblymn * 191.2Sblymn * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201.2Sblymn * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211.2Sblymn * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221.2Sblymn * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231.2Sblymn * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241.2Sblymn * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251.2Sblymn * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261.2Sblymn * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271.2Sblymn * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281.2Sblymn * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291.2Sblymn * POSSIBILITY OF SUCH DAMAGE. 301.2Sblymn */ 311.4Sblymn 321.4Sblymn#include <sys/cdefs.h> 331.4Sblymn#ifndef lint 341.10Sjdc__RCSID("$NetBSD: inch.c,v 1.10 2009/10/06 20:03:27 jdc Exp $"); 351.4Sblymn#endif /* not lint */ 361.2Sblymn 371.2Sblymn#include "curses.h" 381.2Sblymn#include "curses_private.h" 391.2Sblymn 401.3Sblymn#ifndef _CURSES_USE_MACROS 411.3Sblymn 421.3Sblymn/* 431.3Sblymn * inch -- 441.3Sblymn * Return character at cursor position from stdscr. 451.3Sblymn */ 461.3Sblymnchtype 471.3Sblymninch(void) 481.3Sblymn{ 491.3Sblymn return winch(stdscr); 501.3Sblymn} 511.3Sblymn 521.3Sblymn/* 531.3Sblymn * mvinch -- 541.3Sblymn * Return character at position (y, x) from stdscr. 551.3Sblymn */ 561.3Sblymnchtype 571.3Sblymnmvinch(int y, int x) 581.3Sblymn{ 591.3Sblymn return mvwinch(stdscr, y, x); 601.3Sblymn} 611.3Sblymn 621.3Sblymn/* 631.3Sblymn * mvwinch -- 641.3Sblymn * Return character at position (y, x) from the given window. 651.3Sblymn */ 661.3Sblymnchtype 671.3Sblymnmvwinch(WINDOW *win, int y, int x) 681.3Sblymn{ 691.3Sblymn if (wmove(win, y, x) == ERR) 701.3Sblymn return ERR; 711.5Sblymn 721.3Sblymn return winch(win); 731.3Sblymn} 741.3Sblymn 751.3Sblymn#endif 761.3Sblymn 771.2Sblymn/* 781.2Sblymn * winch -- 791.2Sblymn * Return character at cursor position. 801.2Sblymn */ 811.2Sblymnchtype 821.3Sblymnwinch(WINDOW *win) 831.2Sblymn{ 841.10Sjdc chtype ch; 851.10Sjdc attr_t attr; 861.2Sblymn 871.10Sjdc ch = (chtype) ((win)->alines[(win)->cury]->line[(win)->curx].ch & 881.10Sjdc __CHARTEXT); 891.10Sjdc attr = (attr_t) ((win)->alines[(win)->cury]->line[(win)->curx].attr & 901.10Sjdc __ATTRIBUTES); 911.10Sjdc if (__using_color && ((attr & __COLOR) == __default_color)) 921.10Sjdc attr &= ~__default_color; 931.10Sjdc return (ch | attr); 941.2Sblymn} 95