/* readline.h * This is the header file for the Readline module for Tap. */ /* Copyright (C) 1999 Jonathan duSaint * * This file is part of Tap, an interactive program for reading and * writing data to the serial port to facilitate the reverse * engineering of communication protocols. * * Tap is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2, or (at your option) * any later version. * * Tap is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public * License for more details. * * The GNU General Public License is generally kept in a file called * COPYING or LICENSE. If you do not have a copy of the license, write * to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "tap.h" /* extended character codes returned by readchar() */ #define ECQUIT 0x100 /* \n */ #define ECUP 0x101 /* ^P */ #define ECDOWN 0x102 /* ^N */ #define ECLEFT 0x103 /* ^B */ #define ECRIGHT 0x104 /* ^F */ #define ECSTART 0x105 /* ^A */ #define ECEND 0x106 /* ^E */ #define ECDEL 0x107 /* ^D */ #define ECERASE 0x108 /* ^H */ #define ECMARK 0x109 /* ^ */ #define ECKILLR 0x10A /* ^W */ #define ECKILLL 0x10B /* ^K */ #define ECYANK 0x10C /* ^Y */ #define ECTRANS 0x10D /* ^T */ #define ECCLEAR 0x10E /* ^L */ #define ECCOUNT 0x10F /* ^U */ #define ECTAB 0x110 /* \t */ #define ECUNKNOWN 0xFFF /* unrecognized control code */ /* raw character codes */ #define RCUP 0x10 #define RCDOWN 0x0E #define RCLEFT 0x02 #define RCRIGHT 0x06 #define RCSTART 0x01 #define RCEND 0x05 #define RCDEL 0x04 #define RCDELK 0x7F #define RCERASE 0x08 #define RCMARK 0x00 #define RCKILLR 0x17 #define RCKILLL 0x0B #define RCYANK 0x19 #define RCTRANS 0x14 #define RCCLEAR 0x0C #define RCCOUNT 0x15 #define RCTAB '\t' /* arrow key escape sequence */ #define RCESC 0x1B #define EARROW 0x4F #define AUP 0x41 #define ADOWN 0x42 #define ARIGHT 0x43 #define ALEFT 0x44 /* used by do_tab_completion () when creating internal structures */ #define INCR_VALUE 8 /* the default number of entries in the kill ring */ #define DEFAULT_KILL_RING_SIZE 32 /* the minimum amount of padding to use when printing partial matches */ #define PADDING 2 /* used for determing the actual amount of memory used by a line of text */ #define ROUND_UP_SIZE(nom) (((nom + 1) / GROW_SIZE) * GROW_SIZE + GROW_SIZE) /* specifies to delete_char() whether to delete the * character to the left or the right of the point */ enum direction { LEFT, RIGHT }; /* kill ring entries */ struct kill_ring { long length; /* the length of TEXT */ char *text; /* the actual text in the ring */ struct kill_ring *prev; /* the previous entry in the kill ring */ struct kill_ring *next; /* the next entry in the kill ring */ }; /* history list entries */ struct history_node { char *data; /* the actual history entry */ char *saved_data; /* temporary entry used for when an earlier line is being edited */ struct history_node *prev; /* the previous entry in the history list */ struct history_node *next; /* the next entry in the history list */ }; /* global variables */ /* prompt to use */ extern char *prompt; /* the line under construction */ extern char *current_line; /* its actual size */ extern long line_size; /* number of characters active */ extern long chars_in_line; /* where the point is */ extern long current_position; /* for when C- is pressed */ extern long mark_start; /* start position of the cursor */ extern int start_y; /* cursor position after the prompt has been printed */ extern int start_x; /* the last repeat value -- should be 1 unless C-U has just been typed */ extern int repeat_value; /* the kill ring */ extern struct kill_ring *the_kill_ring; /* a zero length string */ extern char zero_length_string[]; /* function prototypes */ /* the main function -- read a line of text */ extern char *readline (char *); /* character functions used by readline () */ extern int readchar (void); extern void dispatch_special (int); /* keystroke functions */ extern void kill_region (void); extern void kill_to_eol (void); extern void insert_char (char); extern void delete_char (enum direction); extern void move_cursor_left (void); extern void move_cursor_right (void); extern void move_cursor_to_start (void); extern void move_cursor_to_end (void); extern void transpose_chars (void); extern void yank_text (void); extern void do_count (void); /* functions for the kill ring */ extern void kill_to_ring (int, int); extern char *get_ring_entry (int); extern void ring_init (void); /* tab completion */ extern void do_tab_completion (void); /* history functions */ extern void add_history(char *); extern char *next_history (void); extern char *prev_history (void);