ClientUser::Prompt( const StrPtr &, StrBuf &, int, Error * )

Prompt the user and get a response.

Virtual?

Yes

 

Class

ClientUser

 

Arguments

const StrPtr &msg

the message with which to prompt the user

 

StrBuf &rsp

where to put the user’s response

 

int noEcho

specifies whether echo should be turned off at the console

 

Error *e

an Error object

Returns

void

 

Notes

Prompt() is used in the default implementation of HandleError() to prompt the user to correct the error. Prompt() is also used by the interactive resolve routine to prompt for options.

Example

Consider the following user interaction with p4 resolve:

> p4 resolve file.c
c:\depot\file.c - merging //depot/file.c#2,#10
Diff chunks: 0 yours + 1 theirs + 0 both + 0 conflicting
Accept(a) Edit(e) Diff(d) Merge (m) Skip(s) Help(?) [at]: at

In the above example, the "msg" argument to Prompt() is the “Accept…​[at\]:” string. The response, "at", is placed into the "rsp" StrBuf, which is sent to the server and processed as "accept theirs".

To alter the behavior of Prompt(), create a subclass of ClientUser and provide an alternate implementation of Prompt().

For example, suppose that you are writing a GUI application and want each option in the interactive resolve to appear in a dialog box. A function called MyDialog() to create a dialog box containing the text of its argument and a text field, and return a character array with the user’s response, would look like this:

void MyClientUser::Prompt( const StrPtr &msg, StrBuf &buf, \
                           int noEcho, Error *e )
{
    buf.Set( MyDialog( msg.Text() ) );
}