blob: 5a4cd69012cba94417cd1244c4b50eb50a469580 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
|
/* 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 /* ^<spc> */
#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-<spc> 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);
|