/* $Id: local.c,v 1.19 2007-11-12 20:29:43 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 <curses.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#define TTYDEFCHARS
/* glibc requires unistd.h before termios.h for TTYDEFCHARS. */
#include <unistd.h>
#include <termios.h>
#include <term.h>
#include "tmux.h"
/*
* Functions to translate input and write output to the local client terminal.
* This file should probably be called tty or terminal.c.
*/
int local_cmp(const void *, const void *);
int local_putc(int);
void local_putp(const char *);
void local_attributes(u_char, u_char);
/* Local key types and key codes. */
struct local_key {
const char *name;
char *string;
size_t size;
int code;
};
struct local_key local_keys[] = {
{ "ka1", NULL, 0, KEYC_A1 },
{ "ka3", NULL, 0, KEYC_A3 },
{ "kb2", NULL, 0, KEYC_B2 },
{ "kbeg", NULL, 0, KEYC_BEG },
{ "kcbt", NULL, 0, KEYC_BTAB },
{ "kc1", NULL, 0, KEYC_C1 },
{ "kc3", NULL, 0, KEYC_C3 },
{ "kcan", NULL, 0, KEYC_CANCEL },
{ "ktbc", NULL, 0, KEYC_CATAB },
{ "kclr", NULL, 0, KEYC_CLEAR },
{ "kclo", NULL, 0, KEYC_CLOSE },
{ "kcmd", NULL, 0, KEYC_COMMAND },
{ "kcpy", NULL, 0, KEYC_COPY },
{ "kcrt", NULL, 0, KEYC_CREATE },
{ "kctab", NULL, 0, KEYC_CTAB },
{ "kdch1", NULL, 0, KEYC_DC },
{ "kdl1", NULL, 0, KEYC_DL },
{ "kcud1", NULL, 0, KEYC_DOWN },
{ "krmir", NULL, 0, KEYC_EIC },
{ "kend", NULL, 0, KEYC_END },
{ "kent", NULL, 0, KEYC_ENTER },
{ "kel", NULL, 0, KEYC_EOL },
{ "ked", NULL, 0, KEYC_EOS },
{ "kext", NULL, 0, KEYC_EXIT },
{ "kf0", NULL, 0, KEYC_F0 },
{ "kf1", NULL, 0, KEYC_F1 },
{ "kf10", NULL, 0, KEYC_F10 },
{ "kf11", NULL, 0, KEYC_F11 },
{ "kf12", NULL, 0, KEYC_F12 },
{ "kf13", NULL, 0, KEYC_F13 },
{ "kf14", NULL, 0, KEYC_F14 },
{ "kf15", NULL, 0, KEYC_F15 },
{ "kf16", NULL, 0, KEYC_F16 },
{ "kf17", NULL, 0, KEYC_F17 },
{ "kf18", NULL, 0, KEYC_F18 },
{ "kf19", NULL, 0, KEYC_F19 },
{ "kf2", NULL, 0, KEYC_F2 },
{ "kf20", NULL, 0, KEYC_F20 },
{ "kf21", NULL, 0, KEYC_F21 },
{ "kf22", NULL, 0, KEYC_F22 },
{ "kf23", NULL, 0, KEYC_F23 },
{ "kf24", NULL, 0, KEYC_F24 },
{ "kf25", NULL, 0, KEYC_F25 },
{ "kf26", NULL, 0, KEYC_F26 },
{ "kf27", NULL, 0, KEYC_F27 },
{ "kf28", NULL, 0, KEYC_F28 },
{ "kf29", NULL, 0, KEYC_F29 },
{ "kf3", NULL, 0, KEYC_F3 },
{ "kf30", NULL, 0, KEYC_F30 },
{ "kf31", NULL, 0, KEYC_F31 },
{ "kf32", NULL, 0, KEYC_F32 },
{ "kf33", NULL, 0, KEYC_F33 },
{ "kf34", NULL, 0, KEYC_F34 },
{ "kf35", NULL, 0, KEYC_F35 },
{ "kf36", NULL, 0, KEYC_F36 },
{ "kf37", NULL, 0, KEYC_F37 },
{ "kf38", NULL, 0, KEYC_F38 },
{ "kf39", NULL, 0, KEYC_F39 },
{ "kf4", NULL, 0, KEYC_F4 },
{ "kf40", NULL, 0, KEYC_F40 },
{ "kf41", NULL, 0, KEYC_F41 },
{ "kf42", NULL, 0, KEYC_F42 },
{ "kf43", NULL, 0, KEYC_F43 },
{ "kf44", NULL, 0, KEYC_F44 },
{ "kf45", NULL, 0, KEYC_F45 },
{