/* $Id: tty.c,v 1.53 2008-12-06 09:30:25 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 <sys/ioctl.h>
#include <ncurses.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>
#include "tmux.h"
struct tty_term *tty_find_term(char *, int,char **);
void tty_free_term(struct tty_term *);
void tty_fill_acs(struct tty *);
u_char tty_get_acs(struct tty *, u_char);
const char *tty_strip(const char *);
void tty_raw(struct tty *, const char *);
void tty_puts(struct tty *, const char *);
void tty_putc(struct tty *, char);
void tty_reset(struct tty *);
void tty_attributes(struct tty *, const struct grid_cell *);
void tty_attributes_fg(struct tty *, const struct grid_cell *);
void tty_attributes_bg(struct tty *, const struct grid_cell *);
void tty_cmd_cursorup(struct tty *, struct screen *, va_list);
void tty_cmd_cursordown(struct tty *, struct screen *, va_list);
void tty_cmd_cursorright(struct tty *, struct screen *, va_list);
void tty_cmd_cursorleft(struct tty *, struct screen *, va_list);
void tty_cmd_insertcharacter(struct tty *, struct screen *, va_list);
void tty_cmd_deletecharacter(struct tty *, struct screen *, va_list);
void tty_cmd_insertline(struct tty *, struct screen *, va_list);
void tty_cmd_deleteline(struct tty *, struct screen *, va_list);
void tty_cmd_clearline(struct tty *, struct screen *, va_list);
void tty_cmd_clearendofline(struct tty *, struct screen *, va_list);
void tty_cmd_clearstartofline(struct tty *, struct screen *, va_list);
void tty_cmd_cursormove(struct tty *, struct screen *, va_list);
void tty_cmd_cursormode(struct tty *, struct screen *, va_list);
void tty_cmd_reverseindex(struct tty *, struct screen *, va_list);
void tty_cmd_scrollregion(struct tty *, struct screen *, va_list);
void tty_cmd_insertmode(struct tty *, struct screen *, va_list);
void tty_cmd_mousemode(struct tty *, struct screen *, va_list);
void tty_cmd_linefeed(struct tty *, struct screen *, va_list);
void tty_cmd_carriagereturn(struct tty *, struct screen *, va_list);
void tty_cmd_bell(struct tty *, struct screen *, va_list);
void tty_cmd_clearendofscreen(struct tty *, struct screen *, va_list);
void tty_cmd_clearstartofscreen(struct tty *, struct screen *, va_list);
void tty_cmd_clearscreen(struct tty *, struct screen *, va_list);
void tty_cmd_cell(struct tty *, struct screen *, va_list);
void (*tty_cmds[])(struct tty *, struct screen *, va_list) = {
tty_cmd_cursorup,
tty_cmd_cursordown,
tty_cmd_cursorright,
tty_cmd_cursorleft,
tty_cmd_insertcharacter,
tty_cmd_deletecharacter,
tty_cmd_insertline,
tty_cmd_deleteline,
tty_cmd_clearline,
tty_cmd_clearendofline,
tty_cmd_clearstartofline,
tty_cmd_cursormove,
tty_cmd_cursormode,
tty_cmd_reverseindex,
tty_cmd_scrollregion,
tty_cmd_insertmode,
tty_cmd_mousemode,
tty_cmd_linefeed,