1 /* manexamp.c -- The examples which appear in the documentation are here. */
3 /* Copyright (C) 1987-2002 Free Software Foundation, Inc.
5 This file is part of the GNU Readline Library, a library for
6 reading lines of text with interactive input and history editing.
8 The GNU Readline Library is free software; you can redistribute it
9 and/or modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2, or
11 (at your option) any later version.
13 The GNU Readline Library is distributed in the hope that it will be
14 useful, but WITHOUT ANY WARRANTY; without even the implied warranty
15 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 The GNU General Public License is often shipped with GNU software, and
19 is generally kept in a file called COPYING or LICENSE. If you do not
20 have a copy of the license, write to the Free Software Foundation,
21 59 Temple Place, Suite 330, Boston, MA 02111 USA. */
24 #include <readline/readline.h>
26 /* **************************************************************** */
28 /* How to Emulate gets () */
30 /* **************************************************************** */
32 /* A static variable for holding the line. */
33 static char *line_read
= (char *)NULL
;
35 /* Read a string, and return a pointer to it. Returns NULL on EOF. */
39 /* If the buffer has already been allocated, return the memory
44 line_read
= (char *)NULL
;
47 /* Get a line from the user. */
48 line_read
= readline ("");
50 /* If the line has any text in it, save it on the history. */
51 if (line_read
&& *line_read
)
52 add_history (line_read
);
57 /* **************************************************************** */
59 /* Writing a Function to be Called by Readline. */
61 /* **************************************************************** */
63 /* Invert the case of the COUNT following characters. */
64 invert_case_line (count
, key
)
67 register int start
, end
;
79 /* Find the end of the range to modify. */
80 end
= start
+ (count
* direction
);
82 /* Force it to be within range. */
98 /* Tell readline that we are modifying the line, so save the undo
100 rl_modifying (start
, end
);
102 for (; start
!= end
; start
+= direction
)
104 if (_rl_uppercase_p (rl_line_buffer
[start
]))
105 rl_line_buffer
[start
] = _rl_to_lower (rl_line_buffer
[start
]);
106 else if (_rl_lowercase_p (rl_line_buffer
[start
]))
107 rl_line_buffer
[start
] = _rl_to_upper (rl_line_buffer
[start
]);
110 /* Move point to on top of the last character changed. */
111 rl_point
= end
- direction
;
This page took 0.033164 seconds and 5 git commands to generate.