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
22 if (line_read
!= (char *)NULL
)
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
);
39 /* **************************************************************** */
41 /* Writing a Function to be Called by Readline. */
43 /* **************************************************************** */
45 /* Invert the case of the COUNT following characters. */
46 invert_case_line (count
, key
)
49 register int start
, end
;
61 /* Find the end of the range to modify. */
62 end
= start
+ (count
* direction
);
64 /* Force it to be within range. */
80 /* Tell readline that we are modifying the line, so save the undo
82 rl_modifying (start
, end
);
84 for (; start
!= end
; start
+= direction
)
86 if (uppercase_p (rl_line_buffer
[start
]))
87 rl_line_buffer
[start
] = to_lower (rl_line_buffer
[start
]);
88 else if (lowercase_p (rl_line_buffer
[start
]))
89 rl_line_buffer
[start
] = to_upper (rl_line_buffer
[start
]);
92 /* Move point to on top of the last character changed. */
93 rl_point
= end
- direction
;
This page took 0.0318 seconds and 5 git commands to generate.