003 File Manager
Current Path:
/usr/src/contrib/less
usr
/
src
/
contrib
/
less
/
📁
..
📄
FREEBSD-upgrade
(1.06 KB)
📄
INSTALL
(7.71 KB)
📄
LICENSE
(1.24 KB)
📄
NEWS
(32.19 KB)
📄
README
(10.86 KB)
📄
brac.c
(2.18 KB)
📄
ch.c
(18.37 KB)
📄
charset.c
(17.3 KB)
📄
charset.h
(717 B)
📄
cmd.h
(4.42 KB)
📄
cmdbuf.c
(32.21 KB)
📄
command.c
(36.63 KB)
📄
compose.uni
(10.17 KB)
📄
cvt.c
(2.49 KB)
📄
decode.c
(20.81 KB)
📄
edit.c
(16.68 KB)
📄
filename.c
(19.65 KB)
📄
fmt.uni
(712 B)
📄
forwback.c
(9.77 KB)
📄
funcs.h
(17.56 KB)
📄
help.c
(49.78 KB)
📄
ifile.c
(7.39 KB)
📄
input.c
(8.82 KB)
📄
jump.c
(6.54 KB)
📄
less.h
(12.74 KB)
📄
less.hlp
(12.19 KB)
📄
less.nro
(69.08 KB)
📄
lessecho.c
(4.82 KB)
📄
lessecho.nro
(1.5 KB)
📄
lesskey.c
(17.99 KB)
📄
lesskey.h
(813 B)
📄
lesskey.nro
(9.15 KB)
📄
lglob.h
(2.98 KB)
📄
line.c
(28 KB)
📄
linenum.c
(10.36 KB)
📄
lsystem.c
(7.17 KB)
📄
main.c
(8.07 KB)
📄
mark.c
(8.28 KB)
📄
mkutable
(2.75 KB)
📄
optfunc.c
(13.61 KB)
📄
option.c
(13.89 KB)
📄
option.h
(2 KB)
📄
opttbl.c
(17.14 KB)
📄
os.c
(6.2 KB)
📄
output.c
(13 KB)
📄
pattern.c
(8.55 KB)
📄
pattern.h
(1.54 KB)
📄
pckeys.h
(898 B)
📄
position.c
(5.13 KB)
📄
position.h
(414 B)
📄
prompt.c
(11.98 KB)
📄
regexp.c
(27.74 KB)
📄
regexp.h
(973 B)
📄
screen.c
(53.03 KB)
📄
scrsize.c
(3.06 KB)
📄
search.c
(35.45 KB)
📄
signal.c
(4.63 KB)
📄
tags.c
(15.73 KB)
📄
ttyin.c
(4.12 KB)
📄
ubin.uni
(602 B)
📄
version.c
(46.22 KB)
📄
wide.uni
(3.52 KB)
Editing: ttyin.c
/* * Copyright (C) 1984-2020 Mark Nudelman * * You may distribute under the terms of either the GNU General Public * License or the Less License, as specified in the README file. * * For more information, see the README file. */ /* * Routines dealing with getting input from the keyboard (i.e. from the user). */ #include "less.h" #if OS2 #include "cmd.h" #include "pckeys.h" #endif #if MSDOS_COMPILER==WIN32C #define WIN32_LEAN_AND_MEAN #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x400 #endif #include <windows.h> public DWORD console_mode; public HANDLE tty; #else public int tty; #endif extern int sigs; extern int utf_mode; extern int wheel_lines; /* * Open keyboard for input. */ public void open_getchr(VOID_PARAM) { #if MSDOS_COMPILER==WIN32C /* Need this to let child processes inherit our console handle */ SECURITY_ATTRIBUTES sa; memset(&sa, 0, sizeof(SECURITY_ATTRIBUTES)); sa.nLength = sizeof(SECURITY_ATTRIBUTES); sa.bInheritHandle = TRUE; tty = CreateFile("CONIN$", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, &sa, OPEN_EXISTING, 0L, NULL); GetConsoleMode(tty, &console_mode); /* Make sure we get Ctrl+C events. */ SetConsoleMode(tty, ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT); #else #if MSDOS_COMPILER extern int fd0; /* * Open a new handle to CON: in binary mode * for unbuffered keyboard read. */ fd0 = dup(0); close(0); tty = open("CON", OPEN_READ); #if MSDOS_COMPILER==DJGPPC /* * Setting stdin to binary causes Ctrl-C to not * raise SIGINT. We must undo that side-effect. */ (void) __djgpp_set_ctrl_c(1); #endif #else /* * Try /dev/tty. * If that doesn't work, use file descriptor 2, * which in Unix is usually attached to the screen, * but also usually lets you read from the keyboard. */ #if OS2 /* The __open() system call translates "/dev/tty" to "con". */ tty = __open("/dev/tty", OPEN_READ); #else tty = open("/dev/tty", OPEN_READ); #endif if (tty < 0) tty = 2; #endif #endif } /* * Close the keyboard. */ public void close_getchr(VOID_PARAM) { #if MSDOS_COMPILER==WIN32C SetConsoleMode(tty, console_mode); CloseHandle(tty); #endif } #if MSDOS_COMPILER==WIN32C /* * Close the pipe, restoring the keyboard (CMD resets it, losing the mouse). */ int pclose(f) FILE *f; { int result; result = _pclose(f); SetConsoleMode(tty, ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT); return result; } #endif /* * Get the number of lines to scroll when mouse wheel is moved. */ public int default_wheel_lines(VOID_PARAM) { int lines = 1; #if MSDOS_COMPILER==WIN32C if (SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0, &lines, 0)) { if (lines == WHEEL_PAGESCROLL) lines = 3; } #endif return lines; } /* * Get a character from the keyboard. */ public int getchr(VOID_PARAM) { char c; int result; do { #if MSDOS_COMPILER && MSDOS_COMPILER != DJGPPC /* * In raw read, we don't see ^C so look here for it. */ flush(); #if MSDOS_COMPILER==WIN32C if (ABORT_SIGS()) return (READ_INTR); c = WIN32getch(); #else c = getch(); #endif result = 1; if (c == '\003') return (READ_INTR); #else { unsigned char uc; result = iread(tty, &uc, sizeof(char)); c = (char) uc; } if (result == READ_INTR) return (READ_INTR); if (result < 0) { /* * Don't call error() here, * because error calls getchr! */ quit(QUIT_ERROR); } #endif #if 0 /* allow entering arbitrary hex chars for testing */ /* ctrl-A followed by two hex chars makes a byte */ { static int hex_in = 0; static int hex_value = 0; if (c == CONTROL('A')) { hex_in = 2; result = 0; continue; } if (hex_in > 0) { int v; if (c >= '0' && c <= '9') v = c - '0'; else if (c >= 'a' && c <= 'f') v = c - 'a' + 10; else if (c >= 'A' && c <= 'F') v = c - 'A' + 10; else v = 0; hex_value = (hex_value << 4) | v; if (--hex_in > 0) { result = 0; continue; } c = hex_value; } } #endif /* * Various parts of the program cannot handle * an input character of '\0'. * If a '\0' was actually typed, convert it to '\340' here. */ if (c == '\0') c = '\340'; } while (result != 1); return (c & 0xFF); }
Upload File
Create Folder