1 /* manexamp.c -- The examples which appear in the documentation are here. */
3 /* Copyright (C) 1987-2009 Free Software Foundation, Inc.
5 This file is part of the GNU Readline Library (Readline), a library for
6 reading lines of text with interactive input and history editing.
8 Readline is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation, either version 3 of the License, or
11 (at your option) any later version.
13 Readline is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with Readline. If not, see <http://www.gnu.org/licenses/>.
23 #include <readline/readline.h>
25 /* **************************************************************** */
27 /* How to Emulate gets () */
29 /* **************************************************************** */
31 /* A static variable for holding the line. */
32 static char *line_read
= (char *)NULL
;
34 /* Read a string, and return a pointer to it. Returns NULL on EOF. */
38 /* If the buffer has already been allocated, return the memory
43 line_read
= (char *)NULL
;
46 /* Get a line from the user. */
47 line_read
= readline ("");
49 /* If the line has any text in it, save it on the history. */
50 if (line_read
&& *line_read
)
51 add_history (line_read
);
56 /* **************************************************************** */
58 /* Writing a Function to be Called by Readline. */
60 /* **************************************************************** */
62 /* Invert the case of the COUNT following characters. */
63 invert_case_line (count
, key
)
66 register int start
, end
;
78 /* Find the end of the range to modify. */
79 end
= start
+ (count
* direction
);
81 /* Force it to be within range. */
97 /* Tell readline that we are modifying the line, so save the undo
99 rl_modifying (start
, end
);
101 for (; start
!= end
; start
+= direction
)
103 if (_rl_uppercase_p (rl_line_buffer
[start
]))
104 rl_line_buffer
[start
] = _rl_to_lower (rl_line_buffer
[start
]);
105 else if (_rl_lowercase_p (rl_line_buffer
[start
]))
106 rl_line_buffer
[start
] = _rl_to_upper (rl_line_buffer
[start
]);
109 /* Move point to on top of the last character changed. */
110 rl_point
= end
- direction
;
This page took 0.030861 seconds and 4 git commands to generate.