bug-readline
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

rl_already_prompted changed in version 8.1


From: Laszlo Csirmaz
Subject: rl_already_prompted changed in version 8.1
Date: Sat, 15 Oct 2022 17:28:33 +0200

I used the following yesno() procedure to handle the yes/no answer
from the user after printing some ugly question. This worked as
expected in version 7.0, but in 8.1 it stopped working. Any hints on
how to achieve the same effect?
When using 8.1, the previous output is overwritten at random places
and the cursor is relocated at the end of the supplied (not to be
printed) prompt string.
Laszlo Csirmaz
----------------------------------------------------------
The C routine:
int yesno(int force)
{rl_completion_func_t *ocomp;  int prompted;  char *line; int res=-1;
    ocomp=rl_attempted_completion_function;
    rl_attempted_completion_function=yesno_completion;
    prompted=rl_already_prompted; rl_already_prompted=1;
    while(res<0){
        line=readline("Please enter 'y' or 'n' (y/n)? ");
        if(!line){printf("\n"); continue;}
        if(strlen(line)<5){
           if(line[0]=='y'||line[0]=='Y'){ res=1; }
           else if(line[0]=='n'||line[0]=='N'){ res=0; }
           else if(force==0){
              res=0; printf(" no\n");
           }
        }
        free(line); rl_already_prompted=prompted;
    }
    rl_already_prompted=prompted;
    rl_attempted_completion_function=ocomp;
    return res;
}



reply via email to

[Prev in Thread] Current Thread [Next in Thread]