terminal.c (157195) | terminal.c (165675) |
---|---|
1/* $FreeBSD: head/contrib/libreadline/terminal.c 157195 2006-03-27 23:53:05Z ache $ */ | 1/* $FreeBSD: head/contrib/libreadline/terminal.c 165675 2006-12-31 09:22:31Z ache $ */ |
2/* terminal.c -- controlling the terminal with termcap. */ 3 | 2/* terminal.c -- controlling the terminal with termcap. */ 3 |
4/* Copyright (C) 1996-2005 Free Software Foundation, Inc. | 4/* Copyright (C) 1996-2006 Free Software Foundation, Inc. |
5 6 This file is part of the GNU Readline Library, a library for 7 reading lines of text with interactive input and history editing. 8 9 The GNU Readline Library is free software; you can redistribute it 10 and/or modify it under the terms of the GNU General Public License 11 as published by the Free Software Foundation; either version 2, or 12 (at your option) any later version. --- 49 unchanged lines hidden (view full) --- 62/* Some standard library routines. */ 63#include "readline.h" 64#include "history.h" 65 66#include "rlprivate.h" 67#include "rlshell.h" 68#include "xmalloc.h" 69 | 5 6 This file is part of the GNU Readline Library, a library for 7 reading lines of text with interactive input and history editing. 8 9 The GNU Readline Library is free software; you can redistribute it 10 and/or modify it under the terms of the GNU General Public License 11 as published by the Free Software Foundation; either version 2, or 12 (at your option) any later version. --- 49 unchanged lines hidden (view full) --- 62/* Some standard library routines. */ 63#include "readline.h" 64#include "history.h" 65 66#include "rlprivate.h" 67#include "rlshell.h" 68#include "xmalloc.h" 69 |
70#if defined (__MINGW32__) 71# include <windows.h> 72# include <wincon.h> 73 74static void _win_get_screensize PARAMS((int *, int *)); 75#endif 76 77#if defined (__EMX__) 78static void _emx_get_screensize PARAMS((int *, int *)); 79#endif 80 |
|
70#define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay) 71#define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc) 72 | 81#define CUSTOM_REDISPLAY_FUNC() (rl_redisplay_function != rl_redisplay) 82#define CUSTOM_INPUT_FUNC() (rl_getc_function != rl_getc) 83 |
73int rl_prefer_env_winsize; | 84/* If the calling application sets this to a non-zero value, readline will 85 use the $LINES and $COLUMNS environment variables to set its idea of the 86 window size before interrogating the kernel. */ 87int rl_prefer_env_winsize = 0; |
74 75/* **************************************************************** */ 76/* */ 77/* Terminal and Termcap */ 78/* */ 79/* **************************************************************** */ 80 81static char *term_buffer = (char *)NULL; --- 25 unchanged lines hidden (view full) --- 107char *_rl_term_ic; 108char *_rl_term_ip; 109char *_rl_term_IC; 110 111/* How to delete characters. */ 112char *_rl_term_dc; 113char *_rl_term_DC; 114 | 88 89/* **************************************************************** */ 90/* */ 91/* Terminal and Termcap */ 92/* */ 93/* **************************************************************** */ 94 95static char *term_buffer = (char *)NULL; --- 25 unchanged lines hidden (view full) --- 121char *_rl_term_ic; 122char *_rl_term_ip; 123char *_rl_term_IC; 124 125/* How to delete characters. */ 126char *_rl_term_dc; 127char *_rl_term_DC; 128 |
115#if defined (HACK_TERMCAP_MOTION) | |
116char *_rl_term_forward_char; | 129char *_rl_term_forward_char; |
117#endif /* HACK_TERMCAP_MOTION */ | |
118 119/* How to go up a line. */ 120char *_rl_term_up; 121 122/* A visible bell; char if the terminal can be made to flash the screen. */ 123static char *_rl_visible_bell; 124 125/* Non-zero means the terminal can auto-wrap lines. */ --- 54 unchanged lines hidden (view full) --- 180 181 if (swp) 182 *swp = sz[0]; 183 if (shp) 184 *shp = sz[1]; 185} 186#endif 187 | 130 131/* How to go up a line. */ 132char *_rl_term_up; 133 134/* A visible bell; char if the terminal can be made to flash the screen. */ 135static char *_rl_visible_bell; 136 137/* Non-zero means the terminal can auto-wrap lines. */ --- 54 unchanged lines hidden (view full) --- 192 193 if (swp) 194 *swp = sz[0]; 195 if (shp) 196 *shp = sz[1]; 197} 198#endif 199 |
200#if defined (__MINGW32__) 201static void 202_win_get_screensize (swp, shp) 203 int *swp, *shp; 204{ 205 HANDLE hConOut; 206 CONSOLE_SCREEN_BUFFER_INFO scr; 207 208 hConOut = GetStdHandle (STD_OUTPUT_HANDLE); 209 if (hConOut != INVALID_HANDLE_VALUE) 210 { 211 if (GetConsoleScreenBufferInfo (hConOut, &scr)) 212 { 213 *swp = scr.dwSize.X; 214 *shp = scr.srWindow.Bottom - scr.srWindow.Top + 1; 215 } 216 } 217} 218#endif 219 |
|
188/* Get readline's idea of the screen size. TTY is a file descriptor open 189 to the terminal. If IGNORE_ENV is true, we do not pay attention to the 190 values of $LINES and $COLUMNS. The tests for TERM_STRING_BUFFER being 191 non-null serve to check whether or not we have initialized termcap. */ 192void 193_rl_get_screen_size (tty, ignore_env) 194 int tty, ignore_env; 195{ --- 8 unchanged lines hidden (view full) --- 204 if (ioctl (tty, TIOCGWINSZ, &window_size) == 0) 205 { 206 wc = (int) window_size.ws_col; 207 wr = (int) window_size.ws_row; 208 } 209#endif /* TIOCGWINSZ */ 210 211#if defined (__EMX__) | 220/* Get readline's idea of the screen size. TTY is a file descriptor open 221 to the terminal. If IGNORE_ENV is true, we do not pay attention to the 222 values of $LINES and $COLUMNS. The tests for TERM_STRING_BUFFER being 223 non-null serve to check whether or not we have initialized termcap. */ 224void 225_rl_get_screen_size (tty, ignore_env) 226 int tty, ignore_env; 227{ --- 8 unchanged lines hidden (view full) --- 236 if (ioctl (tty, TIOCGWINSZ, &window_size) == 0) 237 { 238 wc = (int) window_size.ws_col; 239 wr = (int) window_size.ws_row; 240 } 241#endif /* TIOCGWINSZ */ 242 243#if defined (__EMX__) |
212 _emx_get_screensize (&_rl_screenwidth, &_rl_screenheight); | 244 _emx_get_screensize (&wc, &wr); 245#elif defined (__MINGW32__) 246 _win_get_screensize (&wc, &wr); |
213#endif 214 215 if (ignore_env || rl_prefer_env_winsize == 0) 216 { 217 _rl_screenwidth = wc; 218 _rl_screenheight = wr; 219 } 220 else --- 133 unchanged lines hidden (view full) --- 354 { "kh", &_rl_term_kh }, /* home */ 355 { "kl", &_rl_term_kl }, 356 { "kr", &_rl_term_kr }, 357 { "ks", &_rl_term_ks }, /* start keypad mode */ 358 { "ku", &_rl_term_ku }, 359 { "le", &_rl_term_backspace }, 360 { "mm", &_rl_term_mm }, 361 { "mo", &_rl_term_mo }, | 247#endif 248 249 if (ignore_env || rl_prefer_env_winsize == 0) 250 { 251 _rl_screenwidth = wc; 252 _rl_screenheight = wr; 253 } 254 else --- 133 unchanged lines hidden (view full) --- 388 { "kh", &_rl_term_kh }, /* home */ 389 { "kl", &_rl_term_kl }, 390 { "kr", &_rl_term_kr }, 391 { "ks", &_rl_term_ks }, /* start keypad mode */ 392 { "ku", &_rl_term_ku }, 393 { "le", &_rl_term_backspace }, 394 { "mm", &_rl_term_mm }, 395 { "mo", &_rl_term_mo }, |
362#if defined (HACK_TERMCAP_MOTION) | |
363 { "nd", &_rl_term_forward_char }, | 396 { "nd", &_rl_term_forward_char }, |
364#endif | |
365 { "pc", &_rl_term_pc }, 366 { "up", &_rl_term_up }, 367 { "vb", &_rl_visible_bell }, 368 { "vs", &_rl_term_vs }, 369 { "ve", &_rl_term_ve }, 370}; 371 372#define NUM_TC_STRINGS (sizeof (tc_strings) / sizeof (struct _tc_string)) --- 80 unchanged lines hidden (view full) --- 453 _rl_term_cr = "\r"; 454 _rl_term_im = _rl_term_ei = _rl_term_ic = _rl_term_IC = (char *)NULL; 455 _rl_term_up = _rl_term_dc = _rl_term_DC = _rl_visible_bell = (char *)NULL; 456 _rl_term_ku = _rl_term_kd = _rl_term_kl = _rl_term_kr = (char *)NULL; 457 _rl_term_kh = _rl_term_kH = _rl_term_kI = _rl_term_kD = (char *)NULL; 458 _rl_term_ks = _rl_term_ke = _rl_term_at7 = (char *)NULL; 459 _rl_term_mm = _rl_term_mo = (char *)NULL; 460 _rl_term_ve = _rl_term_vs = (char *)NULL; | 397 { "pc", &_rl_term_pc }, 398 { "up", &_rl_term_up }, 399 { "vb", &_rl_visible_bell }, 400 { "vs", &_rl_term_vs }, 401 { "ve", &_rl_term_ve }, 402}; 403 404#define NUM_TC_STRINGS (sizeof (tc_strings) / sizeof (struct _tc_string)) --- 80 unchanged lines hidden (view full) --- 485 _rl_term_cr = "\r"; 486 _rl_term_im = _rl_term_ei = _rl_term_ic = _rl_term_IC = (char *)NULL; 487 _rl_term_up = _rl_term_dc = _rl_term_DC = _rl_visible_bell = (char *)NULL; 488 _rl_term_ku = _rl_term_kd = _rl_term_kl = _rl_term_kr = (char *)NULL; 489 _rl_term_kh = _rl_term_kH = _rl_term_kI = _rl_term_kD = (char *)NULL; 490 _rl_term_ks = _rl_term_ke = _rl_term_at7 = (char *)NULL; 491 _rl_term_mm = _rl_term_mo = (char *)NULL; 492 _rl_term_ve = _rl_term_vs = (char *)NULL; |
461#if defined (HACK_TERMCAP_MOTION) 462 term_forward_char = (char *)NULL; 463#endif | 493 _rl_term_forward_char = (char *)NULL; |
464 _rl_terminal_can_insert = term_has_meta = 0; 465 466 /* Reasonable defaults for tgoto(). Readline currently only uses 467 tgoto if _rl_term_IC or _rl_term_DC is defined, but just in case we 468 change that later... */ 469 PC = '\0'; 470 BC = _rl_term_backspace = "\b"; 471 UP = _rl_term_up; --- 231 unchanged lines hidden --- | 494 _rl_terminal_can_insert = term_has_meta = 0; 495 496 /* Reasonable defaults for tgoto(). Readline currently only uses 497 tgoto if _rl_term_IC or _rl_term_DC is defined, but just in case we 498 change that later... */ 499 PC = '\0'; 500 BC = _rl_term_backspace = "\b"; 501 UP = _rl_term_up; --- 231 unchanged lines hidden --- |