1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-18 15:26:23 -05:00

Introduce newmlarg as alternative to mlreply.

Rewrite gotoline accordingly.
This commit is contained in:
Renaud 2015-09-29 10:43:19 +08:00
parent 198980b81f
commit 7f5f0dd7b3
3 changed files with 16 additions and 10 deletions

21
basic.c
View File

@ -90,25 +90,26 @@ int gotoeol(int f, int n)
*
* @n: The specified line position at the current buffer.
*/
int gotoline(int f, int n)
{
int status ;
char arg[ NSTRING] ; /* Buffer to hold argument. */
int gotoline( int f, int n) {
/* Get an argument if one doesnt exist. */
if( f == FALSE) {
status = mlreply( "Line to GOTO: ", arg, sizeof arg) ;
int status ;
char *arg ; /* Buffer to hold argument. */
status = newmlarg( &arg, "Line to GOTO: ", 0) ;
if( status != TRUE) {
mloutstr( "(Aborted)") ;
return status ;
}
n = atoi( arg) ;
free( arg) ;
}
/* Handle the case where the user may be passed something like this:
* em filename +
* In this case we just go to the end of the buffer.
*/
/* Handle the case where the user may be passed something like this:
* em filename +
* In this case we just go to the end of the buffer.
*/
if (n == 0)
return gotoeob(f, n);

View File

@ -146,6 +146,10 @@ int mlreply( const char *prompt, char *buf, int nbuf) {
return nextarg( prompt, buf, nbuf, nlc) ;
}
int newmlarg( char **outbufref, const char *prompt, int size) {
return newnextarg( outbufref, prompt, size, nlc) ;
}
int newmlargt( char **outbufref, const char *prompt, int size) {
return newnextarg( outbufref, prompt, size, metac) ;
}

View File

@ -24,6 +24,7 @@ extern const int nlc ; /* end of input char */
int mlyesno( const char *prompt) ;
int mlreply( const char *prompt, char *buf, int nbuf) ;
int newmlarg( char **outbufref, const char *prompt, int size) ;
int newmlargt( char **outbufref, const char *prompt, int size) ;
int ectoc( int c) ;
fn_t getname( void) ;