1
0
mirror of https://github.com/rfivet/uemacs.git synced 2024-12-17 23:06:25 -05:00

Merge common code for setting prompt of search and incremental search.

This commit is contained in:
Renaud 2015-03-26 10:15:50 +08:00
parent ac267617ae
commit 247fcfdfb8
3 changed files with 13 additions and 11 deletions

View File

@ -209,7 +209,7 @@ static int isearch(int f, int n)
start_over: start_over:
/* ask the user for the text of a pattern */ /* ask the user for the text of a pattern */
col = promptpattern( "I-Search") ; /* Prompt, remember the col */ col = promptpattern( "ISearch") ; /* Prompt, remember the col */
cpos = 0; /* Start afresh */ cpos = 0; /* Start afresh */
status = TRUE; /* Assume everything's cool */ status = TRUE; /* Assume everything's cool */
@ -432,11 +432,7 @@ static int promptpattern(char *prompt)
{ {
char tpat[NPAT + 20]; char tpat[NPAT + 20];
strncpy( tpat, prompt, 8) ; /* copy prompt to output string */ setprompt( tpat, NPAT / 2, prompt, pat) ;
tpat[ 8] = '\0' ; /* only one pattern "I-Search" */
strcat(tpat, " ("); /* build new prompt string */
expandp(pat, &tpat[strlen(tpat)], NPAT / 2); /* add old pattern */
strcat(tpat, ")<Meta>: ");
/* check to see if we are executing a command line */ /* check to see if we are executing a command line */
if (!clexec) { if (!clexec) {

View File

@ -682,6 +682,14 @@ int eq(unsigned char bc, unsigned char pc)
return bc == pc; return bc == pc;
} }
void setprompt( char *tpat, unsigned tpat_size, char *prompt, char *apat) {
strncpy( tpat, prompt, 14) ; /* copy prompt to output string */
tpat[ 14] = '\0' ; /* longest prompt is "Reverse Search" */
strcat( tpat, " (") ; /* build new prompt string */
expandp( apat, &tpat[ strlen( tpat)], tpat_size) ; /* add old pattern */
strcat( tpat, ")<Meta>: ") ;
}
/* /*
* readpattern -- Read a pattern. Stash it in apat. If it is the * readpattern -- Read a pattern. Stash it in apat. If it is the
* search string, create the reverse pattern and the magic * search string, create the reverse pattern and the magic
@ -698,11 +706,7 @@ static int readpattern(char *prompt, char *apat, int srch)
int status; int status;
char tpat[NPAT + 20]; char tpat[NPAT + 20];
strncpy( tpat, prompt, 14) ; /* copy prompt to output string */ setprompt( tpat, NPAT / 2, prompt, apat) ;
tpat[ 14] = '\0' ; /* longest prompt is "Reverse Search" */
strcat(tpat, " ("); /* build new prompt string */
expandp(&apat[0], &tpat[strlen(tpat)], NPAT / 2); /* add old pattern */
strcat(tpat, ")<Meta>: ");
/* Read a pattern. Either we get one, /* Read a pattern. Either we get one,
* or we just get the META charater, and use the previous pattern. * or we just get the META charater, and use the previous pattern.

View File

@ -39,6 +39,8 @@ int delins( int dlength, char *instr, int use_meta) ;
int expandp( char *srcstr, char *deststr, int maxlength) ; int expandp( char *srcstr, char *deststr, int maxlength) ;
int boundry( struct line *curline, int curoff, int dir) ; int boundry( struct line *curline, int curoff, int dir) ;
void setprompt( char *tpat, unsigned tpat_size, char *prompt, char *apat) ;
#if MAGIC #if MAGIC
void mcclear( void) ; void mcclear( void) ;
void rmcclear( void) ; void rmcclear( void) ;