summaryrefslogtreecommitdiffstats
path: root/drivers/nfc/nfcmrvl
AgeCommit message (Expand)Author
2019-11-20nfc: Fix Kconfig indentationKrzysztof Kozlowski
2019-10-06nfc: nfcmrvl: fix platform_no_drv_owner.cocci warningYueHaibing
2019-08-05NFC: nfcmrvl: fix gpio-handling regressionJohan Hovold
2019-05-21treewide: Add SPDX license identifier - Makefile/KconfigThomas Gleixner
2018-10-23NFC: nfcmrvl_uart: fix OF child-node lookupJohan Hovold
2018-06-28NFC: nfcmrvl_usb: use irqsave() in USB's complete callbackSebastian Andrzej Siewior
2017-11-21treewide: setup_timer() -> timer_setup() (2 field)Kees Cook
2017-11-06nfc: nfcmrvl: constify i2c_device_idArvind Yadav
2017-11-02License cleanup: add SPDX GPL-2.0 license identifier to files with no licenseGreg Kroah-Hartman
2017-06-18NFC: nfcmrvl: allow gpio 0 for reset signallingJohan Hovold
2017-06-18NFC: nfcmrvl_usb: use interface as phy deviceJohan Hovold
2017-06-18NFC: nfcmrvl_uart: fix device-node leak during probeJohan Hovold
2017-06-18NFC: nfcmrvl: fix firmware-management initialisationJohan Hovold
2017-06-18NFC: nfcmrvl: use nfc-device for firmware downloadJohan Hovold
2017-06-18NFC: nfcmrvl: do not use device-managed resourcesJohan Hovold
2017-06-18NFC: nfcmrvl_uart: add missing tty-device sanity checkJohan Hovold
2017-06-16networking: add and use skb_put_u8()Johannes Berg
2017-06-16networking: make skb_push & __skb_push return void pointersJohannes Berg
2017-06-16networking: make skb_put & friends return void pointersJohannes Berg
2017-06-16networking: introduce and use skb_put_data()Johannes Berg
2017-04-17nfc: fix get_unaligned_...() misusesAl Viro
2017-04-02NFC: nfcmrvl: double free on error pathDan Carpenter
2017-04-01NFC: nfcmrvl: Include unaligned.h instead of access_ok.hTobias Klauser
2017-04-01NFC: nfcmrvl: drop duplicate header gpio.hGeliang Tang
2015-11-05NFC: nfcmrvl: avoid being stuck on FW dnld timeoutVincent Cuissard
2015-11-05NFC: nfcmrvl: remove unneeded CONFIG_OF switchesVincent Cuissard
2015-11-05NFC: nfcmrvl: free reset gpioVincent Cuissard
2015-11-05NFC: nfcmrvl: add a small wait after setting UART breakVincent Cuissard
2015-11-05NFC: nfcmrvl: avoid UART break control during FW downloadVincent Cuissard
2015-11-05NFC: nfcmrvl: fix SPI driver dependenciesArnd Bergmann
2015-10-27NFC: nfcmrvl: update device tree bindings for Marvell NFCVincent Cuissard
2015-10-27NFC: nfcmrvl: add spi driverVincent Cuissard
2015-10-27NFC: nfcmrvl: add i2c driverVincent Cuissard
2015-10-27NFC: nfcmrvl: configure head/tail room values per low level driversVincent Cuissard
2015-10-27NFC: nfcmrvl: add firmware download supportVincent Cuissard
2015-10-27NFC: nfcmrvl: remove unneeded version definesVincent Cuissard
2015-10-19NFC: nfcmrvl: Auto-select core moduleJean Delvare
2015-06-13NFC: nfcmrvl: set PB_BAIL_OUT at setupVincent Cuissard
2015-06-13NFC: nfcmrvl: Allow ISO15693 protocolVincent Cuissard
2015-06-13NFC: nfcmrvl: small fix in USB driverVincent Cuissard
2015-06-11NFC: nfcmrvl: add UART driverVincent Cuissard
2015-06-11NFC: nfcmrvl: add platform_data and DT configurationVincent Cuissard
2015-06-11NFC: nfcmrvl: add chip reset managementVincent Cuissard
2015-06-11NFC: nfcmrvl: update USB device idVincent Cuissard
2015-06-11NFC: nfcmrvl: update nci recv frame APIVincent Cuissard
2015-06-11NFC: nfcmrvl: add support of HCI-based transportVincent Cuissard
2015-06-11NFC: nfcmrvl: remove integration related settingsVincent Cuissard
2015-04-07NFC: logging neateningJoe Perches
2014-01-09NFC: nfcmrvl: Fix possible memory leak issueAmitkumar Karwar
2014-01-07NFC: nfcmrvl: Add setup handlerAmitkumar Karwar
n426'>426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481
/* $Id: status.c,v 1.42 2008-06-27 17:32:24 nicm Exp $ */

/*
 * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include <sys/types.h>

#include <stdarg.h>
#include <string.h>
#include <time.h>

#include "tmux.h"

size_t	status_width(struct winlink *);
char   *status_print(struct session *, struct winlink *, u_char *);

/* Draw status for client on the last lines of given context. */
void
status_redraw(struct client *c)
{
	struct screen_redraw_ctx	ctx;
	struct session		       *s = c->session;
	struct winlink		       *wl;
	char		 		*left, *right, *text, *ptr;
	char				lbuf[BUFSIZ], rbuf[BUFSIZ];
	size_t				llen, rlen, offset, xx, yy;
	size_t				size, start, width;
	u_char		 		attr, colr;
	struct tm		       *tm;
	int				larrow, rarrow;

	if (c->sy == 0 || !options_get_number(&s->options, "status"))
		goto off;
	larrow = rarrow = 0;

	if (clock_gettime(CLOCK_REALTIME, &c->status_timer) != 0)
		fatal("clock_gettime failed");
	colr = options_get_number(&s->options, "status-bg") + 
	    (options_get_number(&s->options, "status-fg") << 4);

	yy = c->sy - 1;
	if (yy == 0)
		goto blank;

	tm = localtime(&(c->status_timer.tv_sec));
	left = options_get_string(&s->options, "status-left");
	strftime(lbuf, sizeof lbuf, left, tm);
	llen = strlen(lbuf);
	right = options_get_string(&s->options, "status-right");
	strftime(rbuf, sizeof rbuf, right, tm);
	rlen = strlen(rbuf);

	/*
	 * Figure out how much space we have for the window list. If there isn't
	 * enough space, just wimp out.
	 */
	xx = 0;
	if (llen != 0)
		xx += llen + 1;
	if (rlen != 0)
		xx += rlen + 1;
	if (c->sx == 0 || c->sx <= xx)
		goto blank;
	xx = c->sx - xx;

	/*
	 * Right. We have xx characters to fill. Find out how much is to go in
	 * them and the offset of the current window (it must be on screen).
	 */
	width = offset = 0;
	RB_FOREACH(wl, winlinks, &s->windows) {
		size = status_width(wl) + 1;
		if (wl == s->curw)
			offset = width;
		width += size;
	}
	start = 0;

	/* If there is enough space for the total width, all is gravy. */
	if (width <= xx)
		goto draw;

	/* Find size of current window text. */
	size = status_width(s->curw);

	/*
	 * If the offset is already on screen, we're good to draw from the
	 * start and just leave off the end.
	 */
	if (offset + size < xx) {
		if (xx > 0) {
			rarrow = 1;
			xx--;
		}

		width = xx;
		goto draw;
	}

	/*
	 * Work out how many characters we need to omit from the start. There
	 * are xx characters to fill, and offset + size must be the last. So,
	 * the start character is offset + size - xx.
	 */
	if (xx > 0) {
		larrow = 1;
		xx--;
	}

	start = offset + size - xx;
 	if (xx > 0 && width > start + xx + 1) { /* + 1, eh? */
 		rarrow = 1;
 		start++;
 		xx--;
 	}
 	width = xx;

draw:
	/* Bail here if anything is too small too. XXX. */
	if (width == 0 || xx == 0)
		goto blank;

 	/* Begin drawing and move to the starting position. */
	screen_redraw_start_client(&ctx, c);
	screen_redraw_set_attributes(&ctx, 0, colr);
	if (llen != 0) {
 		screen_redraw_move_cursor(&ctx, 0, yy);
		screen_redraw_write_string(&ctx, "%s ", lbuf);
		if (larrow)
			ctx.write(ctx.data, TTY_CHARACTER, ' ');
	} else {
		if (larrow)
			screen_redraw_move_cursor(&ctx, 1, yy);
		else
			screen_redraw_move_cursor(&ctx, 0, yy);
	}

	/* Draw each character in succession. */
	offset = 0;
	RB_FOREACH(wl, winlinks, &s->windows) {
		text = status_print(s, wl, &attr);
		screen_redraw_set_attributes(&ctx, attr, colr);

		if (larrow == 1 && offset < start) {
			if (session_alert_has(s, wl, WINDOW_ACTIVITY))
				larrow = -1;
			if (session_alert_has(s, wl, WINDOW_BELL))
				larrow = -1;
		}

 		for (ptr = text; *ptr != '\0'; ptr++) {
			if (offset >= start && offset < start + width)
				ctx.write(ctx.data, TTY_CHARACTER, *ptr);
			offset++;
		}

		if (rarrow == 1 && offset > start + width) {
			if (session_alert_has(s, wl, WINDOW_ACTIVITY))
				rarrow = -1;
			if (session_alert_has(s, wl, WINDOW_BELL))
				rarrow = -1;
		}

		if (offset < start + width) {
			if (offset >= start) {
				screen_redraw_set_attributes(&ctx, 0, colr);
				ctx.write(ctx.data, TTY_CHARACTER, ' ');
			}
			offset++;
		}

		xfree(text);
	}

	/* Fill the remaining space if any. */
	screen_redraw_set_attributes(&ctx, 0, colr);
 	while (offset++ < xx)
		ctx.write(ctx.data, TTY_CHARACTER, ' ');

	/* Draw the last item. */
	if (rlen != 0) {
		screen_redraw_move_cursor(&ctx, c->sx - rlen - 1, yy);
		screen_redraw_write_string(&ctx, " %s", rbuf);
	}

	/* Draw the arrows. */
	if (larrow != 0) {
		if (larrow == -1)
			screen_redraw_set_attributes(&ctx, ATTR_REVERSE, colr);
		else
			screen_redraw_set_attributes(&ctx, 0, colr);
		if (llen != 0)
			screen_redraw_move_cursor(&ctx, llen + 1, yy);
		else
			screen_redraw_move_cursor(&ctx, 0, yy);
 		ctx.write(ctx.data, TTY_CHARACTER, '<');
	}
	if (rarrow != 0) {
		if (rarrow == -1)
			screen_redraw_set_attributes(&ctx, ATTR_REVERSE, colr);
		else
			screen_redraw_set_attributes(&ctx, 0, colr);
		if (rlen != 0)
			screen_redraw_move_cursor