1 /* manexamp.c -- The examples which appear in the documentation are here. */
4 #include <readline/readline.h>
7 /* **************************************************************** */
9 * How to Emulate
gets () */
11 /* **************************************************************** */
13 /* A static variable for holding the line. */
14 static char *line_read
= (char *)NULL
;
16 /* Read a string, and return a pointer to it. Returns NULL on EOF. */
20 /* If the buffer has already been allocated, return the memory
25 line_read
= (char *)NULL
;
28 /* Get a line from the user. */
29 line_read
= readline ("");
31 /* If the line has any text in it, save it on the history. */
32 if (line_read
&& *line_read
)
33 add_history (line_read
);
38 /* **************************************************************** */
40 /* Writing a Function to be Called by Readline. */
42 /* **************************************************************** */
44 /* Invert the case of the COUNT following characters. */
45 invert_case_line (count
, key
)
48 register int start
, end
;
60 /* Find the end of the range to modify. */
61 end
= start
+ (count
* direction
);
63 /* Force it to be within range. */
79 /* Tell readline that we are modifying the line, so save the undo
81 rl_modifying (start
, end
);
83 for (; start
!= end
; start
+= direction
)
85 if (uppercase_p (rl_line_buffer
[start
]))
86 rl_line_buffer
[start
] = to_lower (rl_line_buffer
[start
]);
87 else if (lowercase_p (rl_line_buffer
[start
]))
88 rl_line_buffer
[start
] = to_upper (rl_line_buffer
[start
]);
91 /* Move point to on top of the last character changed. */
92 rl_point
= end
- direction
;
This page took 0.044017 seconds and 4 git commands to generate.